#include <stdio.h>
#include <stdint.h>

#define CHECK(call)                                                            \
{                                                                              \
    const cudaError_t error = call;                                            \
    if (error != cudaSuccess)                                                  \
    {                                                                          \
        fprintf(stderr, "Error: %s:%d, ", __FILE__, __LINE__);                 \
        fprintf(stderr, "code: %d, reason: %s\n", error,                       \
                cudaGetErrorString(error));                                    \
        exit(1);                                                               \
    }                                                                          \
}

struct GpuTimer
{
    cudaEvent_t start;
    cudaEvent_t stop;

    GpuTimer()
    {
        cudaEventCreate(&start);
        cudaEventCreate(&stop);
    }

    ~GpuTimer()
    {
        cudaEventDestroy(start);
        cudaEventDestroy(stop);
    }

    void Start()
    {
        cudaEventRecord(start, 0);
    }

    void Stop()
    {
        cudaEventRecord(stop, 0);
    }

    float Elapsed()
    {
        float elapsed;
        cudaEventSynchronize(stop);
        cudaEventElapsedTime(&elapsed, start, stop);
        return elapsed;
    }
};

bool checkCorrect(int * out, int * correctOut, int n)
{
    for (int i = 0; i < n; i++)
        if (out[i] != correctOut[i]) {
            printf("%d\n", i);
            printf("%d >< %d\n", out[i], correctOut[i]);
            return false;
        }
    return true;
}

bool checkCorrectInt32(uint32_t * out, uint32_t * correctOut, int n)
{
    for (int i = 0; i < n; i++)
        if (out[i] != correctOut[i]) {
            printf("%d\n", i);
            printf("%d >< %d\n", out[i], correctOut[i]);
            return false;
        }
    return true;
}

// Sequential Radix Sort
void sortByHost(const uint32_t * in, uint32_t * out, int n)
{
	GpuTimer timer; 
    timer.Start();

    int nBits = 4; // Assume: nBits in {1, 2, 4, 8, 16, 32}
    int nBins = 1 << nBits; // 2^nBits

    int * hist = (int *)malloc(nBins * sizeof(int));
    int * histScan = (int *)malloc(nBins * sizeof(int));

    uint32_t * src = (uint32_t *)malloc(n * sizeof(uint32_t));
    memcpy(src, in, n * sizeof(uint32_t));
    uint32_t * dst = out;

    for (int bit = 0; bit < sizeof(uint32_t) * 8; bit += nBits)
    {
    	// Compute histogram
    	memset(hist, 0, nBins * sizeof(int));
    	for (int i = 0; i < n; i++)
    	{
    		int bin = (src[i] >> bit) & (nBins - 1);
    		hist[bin]++;
    	}

    	// Scan histogram (exclusively)
    	memset(histScan, 0, nBins * sizeof(int));
    	for (int bin = 1; bin < nBins; bin++)
    		histScan[bin] = histScan[bin - 1] + hist[bin - 1];

    	// Scatter
    	for (int i = 0; i < n; i++)
    	{
    		int bin = (src[i] >> bit) & (nBins - 1);
    		dst[histScan[bin]] = src[i];
    		histScan[bin]++;
    	}

    	// Swap src and dst
    	uint32_t * temp = src;
    	src = dst;
    	dst = temp;
    }

    // Copy result from src to out
    memcpy(out, src, n * sizeof(uint32_t));

	timer.Stop();
    printf("Time of sortByHost: %.3f ms\n\n", timer.Elapsed());
}

__global__ void computeHist(uint32_t * in, int n, int * hist, int nBins, int bit)
{
    int idx = blockDim.x * blockIdx.x + threadIdx.x;
    if (idx < n) {
        int bin = (in[idx] >> bit) & (nBins - 1);
        int histIdx = blockIdx.x * nBins + bin;
        atomicAdd(&hist[histIdx], 1);

        //__syncthreads();

        // if (threadIdx.x == 0) {
        //     int baseHistIdx = blockIdx.x * nBins;
        //     int prevBin = hist[baseHistIdx];
        //     int curScan = 0;
        //     hist[baseHistIdx] = curScan;
        //     for (int i = 1; i < nBins; i++) {
        //         curScan += prevBin;
        //         prevBin = hist[baseHistIdx + i];
        //         hist[baseHistIdx + i] = curScan;
        //     }
        // }
    }
}

// Compute hist by device
void computeHistByDevice(uint32_t * in, int n, int * hist, int nBins, int bit, int blkSize) 
{
    // Allocate device memories
    uint32_t *d_in;
    int *d_hist;
    int numBlks = (n - 1) / blkSize + 1;
    CHECK(cudaMalloc(&d_in, sizeof(uint32_t) * n));
    CHECK(cudaMalloc(&d_hist, sizeof(int) * nBins * numBlks));
    
    // Copy data to device memories
    CHECK(cudaMemcpy(d_in, in, sizeof(uint32_t) * n, cudaMemcpyHostToDevice));

    // Call kernel to scan within each block's input data
    computeHist<<<numBlks, blkSize>>>(d_in, n, d_hist, nBins, bit);
    cudaDeviceSynchronize();
    CHECK(cudaGetLastError());

    // Copy result from device memories
    CHECK(cudaMemcpy(hist, d_hist, sizeof(int) * nBins * numBlks, cudaMemcpyDeviceToHost));
        
    // Free device memories
    CHECK(cudaFree(d_in));
    CHECK(cudaFree(d_hist));
}

__global__ void scatter(uint32_t * in, uint32_t * out, int n, int * histScan, int nBins, int bit)
{
    int idx = blockIdx.x * blockDim.x;
    if (threadIdx.x == 0) {
        for (int i = 0; i < blockDim.x; i++){
            if (idx + i < n) {
                int bin = (in[idx + i] >> bit) & (nBins - 1);
                int histIdx = blockIdx.x * nBins + bin;
                out[histScan[histIdx]] = in[idx + i];
                histScan[histIdx]++;
            }
        }
    }
}

void scatterByDevice(uint32_t * in, uint32_t * out, int n, int * histScan, int nBins, int bit, int blkSize)
{
    // Allocate device memories
    uint32_t *d_in, *d_out;
    int *d_histScan;
    int numBlks = (n - 1) / blkSize + 1;
    CHECK(cudaMalloc(&d_in, sizeof(uint32_t) * n));
    CHECK(cudaMalloc(&d_histScan, sizeof(int) * nBins * numBlks));
    CHECK(cudaMalloc(&d_out, sizeof(uint32_t) * n));

    // Copy data to device memories
    CHECK(cudaMemcpy(d_in, in, sizeof(uint32_t) * n, cudaMemcpyHostToDevice));
    CHECK(cudaMemcpy(d_histScan, histScan, sizeof(int) * nBins * numBlks, cudaMemcpyHostToDevice));

    // Call kernel to scan within each block's input data
    scatter<<<numBlks, blkSize>>>(d_in, d_out, n, d_histScan, nBins, bit);
    cudaDeviceSynchronize();
    CHECK(cudaGetLastError());

    // Copy result from device memories
    CHECK(cudaMemcpy(out, d_out, sizeof(uint32_t) * n, cudaMemcpyDeviceToHost));
        
    // Free device memories
    CHECK(cudaFree(d_in));
    CHECK(cudaFree(d_histScan));
    CHECK(cudaFree(d_out));
}

// Parallel Radix Sort with k bit
void sortByDeviceLv1(const uint32_t * in, uint32_t * out, int n, int blkSize)
{
	GpuTimer timer; 
    timer.Start();

    int nBits = 4; // Assume: nBits in {1, 2, 4, 8, 16, 32}
    int nBins = 1 << nBits; // 2^nBits

    int numBlks = (n - 1) / blkSize + 1;

    int * hist = (int *)malloc(nBins * numBlks * sizeof(int));
    int * histScan = (int *)malloc(nBins * numBlks * sizeof(int));

    uint32_t * src = (uint32_t *)malloc(n * sizeof(uint32_t));
    memcpy(src, in, n * sizeof(uint32_t));
    uint32_t * dst = out;

    for (int bit = 0; bit < sizeof(uint32_t) * 8; bit += nBits)
    {
    	// Compute histogram
    	memset(hist, 0, nBins * numBlks * sizeof(int));
        computeHistByDevice(src, n, hist, nBins, bit, blkSize);

        int curScan = 0;
        for (int binIdx = 0; binIdx < nBins; binIdx++) {
            for (int blkIdx = 0; blkIdx < numBlks; blkIdx++) {
                int histIdx = blkIdx * nBins + binIdx;
                histScan[histIdx] = curScan;
                curScan += hist[histIdx];
            }
        };

    	// Scatter
    	scatterByDevice(src, dst, n, histScan, nBins, bit, blkSize);

    	// Swap src and dst
    	uint32_t * temp = src;
    	src = dst;
    	dst = temp;
    }

    // Copy result from src to out
    memcpy(out, src, n * sizeof(uint32_t));
    
    timer.Stop();
    printf("Time of sortByDevice: %.3f ms\n\n", timer.Elapsed());
}

void printDeviceInfo()
{
    cudaDeviceProp devProv;
    CHECK(cudaGetDeviceProperties(&devProv, 0));
    printf("**********GPU info**********\n");
    printf("Name: %s\n", devProv.name);
    printf("Compute capability: %d.%d\n", devProv.major, devProv.minor);
    printf("Num SMs: %d\n", devProv.multiProcessorCount);
    printf("Max num threads per SM: %d\n", devProv.maxThreadsPerMultiProcessor); 
    printf("Max num warps per SM: %d\n", devProv.maxThreadsPerMultiProcessor / devProv.warpSize);
    printf("GMEM: %zu byte\n", devProv.totalGlobalMem);
    printf("SMEM per SM: %zu byte\n", devProv.sharedMemPerMultiprocessor);
    printf("SMEM per block: %zu byte\n", devProv.sharedMemPerBlock);
    printf("****************************\n\n");
}

int main(int argc, char ** argv)
{
    // PRINT OUT DEVICE INFO
    printDeviceInfo();

    // SET UP INPUT SIZE
    int n = (1 << 24) + 1;
    printf("Input size: %d\n\n", n);

    // ALLOCATE MEMORIES
    size_t bytes = n * sizeof(uint32_t);
    uint32_t * in = (uint32_t *)malloc(bytes);
    uint32_t * out = (uint32_t *)malloc(bytes); // Device result
    uint32_t * correctOut = (uint32_t *)malloc(bytes); // Host result

    // SET UP INPUT DATA
    for (int i = 0; i < n; i++)
        in[i] = rand();

    // DETERMINE BLOCK SIZE
    int blockSize = 512; // Default 
    if (argc == 2)
        blockSize = atoi(argv[1]);

    // SORT BY HOST
    sortByHost(in, correctOut, n);
    
    // SORT BY DEVICE
    sortByDeviceLv1(in, out, n, blockSize);
    if (checkCorrectInt32(out, correctOut, n) == false)
    	printf("sortByDevice is INCORRECT!\n\n");;

    // FREE MEMORIES
    free(in);
    free(out);
    free(correctOut);
    
    return EXIT_SUCCESS;
}
	.file	"tmpxft_0024f5cd_00000000-6_final_v01.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2046:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2046:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.section	.text._ZN8GpuTimerD2Ev,"axG",@progbits,_ZN8GpuTimerD5Ev,comdat
	.align 2
	.weak	_ZN8GpuTimerD2Ev
	.type	_ZN8GpuTimerD2Ev, @function
_ZN8GpuTimerD2Ev:
.LFB2031:
	.cfi_startproc
	.cfi_personality 0x9b,DW.ref.__gxx_personality_v0
	.cfi_lsda 0x1b,.LLSDA2031
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	movq	%rdi, %rbx
	movq	(%rdi), %rdi
	call	cudaEventDestroy@PLT
	movq	8(%rbx), %rdi
	call	cudaEventDestroy@PLT
	popq	%rbx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2031:
	.globl	__gxx_personality_v0
	.section	.gcc_except_table._ZN8GpuTimerD2Ev,"aG",@progbits,_ZN8GpuTimerD5Ev,comdat
.LLSDA2031:
	.byte	0xff
	.byte	0xff
	.byte	0x1
	.uleb128 .LLSDACSE2031-.LLSDACSB2031
.LLSDACSB2031:
.LLSDACSE2031:
	.section	.text._ZN8GpuTimerD2Ev,"axG",@progbits,_ZN8GpuTimerD5Ev,comdat
	.size	_ZN8GpuTimerD2Ev, .-_ZN8GpuTimerD2Ev
	.weak	_ZN8GpuTimerD1Ev
	.set	_ZN8GpuTimerD1Ev,_ZN8GpuTimerD2Ev
	.section	.text._ZN8GpuTimer7ElapsedEv,"axG",@progbits,_ZN8GpuTimer7ElapsedEv,comdat
	.align 2
	.weak	_ZN8GpuTimer7ElapsedEv
	.type	_ZN8GpuTimer7ElapsedEv, @function
_ZN8GpuTimer7ElapsedEv:
.LFB2035:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	movq	%rdi, %rbx
	subq	$16, %rsp
	.cfi_def_cfa_offset 32
	movq	8(%rdi), %rdi
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	call	cudaEventSynchronize@PLT
	movq	8(%rbx), %rdx
	movq	(%rbx), %rsi
	leaq	4(%rsp), %rdi
	call	cudaEventElapsedTime@PLT
	movss	4(%rsp), %xmm0
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	je	.L5
	call	__stack_chk_fail@PLT
.L5:
	addq	$16, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2035:
	.size	_ZN8GpuTimer7ElapsedEv, .-_ZN8GpuTimer7ElapsedEv
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d\n"
.LC1:
	.string	"%d >< %d\n"
	.text
	.globl	_Z12checkCorrectPiS_i
	.type	_Z12checkCorrectPiS_i, @function
_Z12checkCorrectPiS_i:
.LFB2036:
	.cfi_startproc
	endbr64
	movl	%edx, %eax
	xorl	%edx, %edx
	cmpl	%eax, %edx
	jl	.L17
	movb	$1, %al
	ret
.L17:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	pushq	%rcx
	.cfi_def_cfa_offset 32
.L12:
	movq	%rsi, %rbp
	movq	%rdi, %rbx
	addq	$4, %rsi
	addq	$4, %rdi
	movl	0(%rbp), %ecx
	cmpl	%ecx, (%rbx)
	je	.L10
	leaq	.LC0(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	0(%rbp), %ecx
	movl	(%rbx), %edx
	movl	$2, %edi
	leaq	.LC1(%rip), %rsi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	xorl	%eax, %eax
	jmp	.L8
.L10:
	incl	%edx
	cmpl	%eax, %edx
	jl	.L12
	movb	$1, %al
.L8:
	popq	%rsi
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2036:
	.size	_Z12checkCorrectPiS_i, .-_Z12checkCorrectPiS_i
	.globl	_Z17checkCorrectInt32PjS_i
	.type	_Z17checkCorrectInt32PjS_i, @function
_Z17checkCorrectInt32PjS_i:
.LFB2037:
	.cfi_startproc
	endbr64
	movl	%edx, %eax
	xorl	%edx, %edx
	cmpl	%eax, %edx
	jl	.L27
	movb	$1, %al
	ret
.L27:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	pushq	%rcx
	.cfi_def_cfa_offset 32
.L22:
	movq	%rsi, %rbp
	movq	%rdi, %rbx
	addq	$4, %rsi
	addq	$4, %rdi
	movl	0(%rbp), %ecx
	cmpl	%ecx, (%rbx)
	je	.L20
	leaq	.LC0(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	0(%rbp), %ecx
	movl	(%rbx), %edx
	movl	$2, %edi
	leaq	.LC1(%rip), %rsi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	xorl	%eax, %eax
	jmp	.L18
.L20:
	incl	%edx
	cmpl	%eax, %edx
	jl	.L22
	movb	$1, %al
.L18:
	popq	%rsi
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2037:
	.size	_Z17checkCorrectInt32PjS_i, .-_Z17checkCorrectInt32PjS_i
	.section	.rodata.str1.1
.LC2:
	.string	"Time of sortByHost: %.3f ms\n\n"
	.text
	.globl	_Z10sortByHostPKjPji
	.type	_Z10sortByHostPKjPji, @function
_Z10sortByHostPKjPji:
.LFB2038:
	.cfi_startproc
	.cfi_personality 0x9b,DW.ref.__gxx_personality_v0
	.cfi_lsda 0x1b,.LLSDA2038
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movq	%rdi, %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movl	%edx, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movq	%rsi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movq	%rax, %rdi
	movq	%rax, 8(%rsp)
.LEHB0:
	call	cudaEventCreate@PLT
	leaq	32(%rsp), %rdi
	call	cudaEventCreate@PLT
.LEHE0:
	movq	24(%rsp), %rdi
	xorl	%esi, %esi
.LEHB1:
	call	cudaEventRecord@PLT
	movl	$64, %edi
	movslq	%r13d, %rbx
	call	malloc@PLT
	salq	$2, %rbx
	movl	$64, %edi
	movq	%rax, %rbp
	call	malloc@PLT
	movq	%rbx, %rdi
	movq	%rax, %r14
	call	malloc@PLT
	movq	%r15, %rsi
	movq	%rbx, %rcx
	movq	%rbx, %rdx
	movq	%rax, %rdi
	call	__memcpy_chk@PLT
	movq	%r12, %rsi
	xorl	%r10d, %r10d
	movq	%rax, %r9
	xorl	%eax, %eax
.L34:
	movl	$16, %ecx
	movq	%rbp, %rdi
	rep stosl
	xorl	%edi, %edi
.L29:
	cmpl	%edi, %r13d
	jle	.L43
	movl	(%r9,%rdi,4), %edx
	movl	%r10d, %ecx
	incq	%rdi
	shrl	%cl, %edx
	andl	$15, %edx
	incl	0(%rbp,%rdx,4)
	jmp	.L29
.L43:
	movl	$16, %ecx
	movq	%r14, %rdi
	xorl	%edx, %edx
	rep stosl
.L31:
	movl	0(%rbp,%rdx), %ecx
	addl	(%r14,%rdx), %ecx
	movl	%ecx, 4(%r14,%rdx)
	addq	$4, %rdx
	cmpq	$60, %rdx
	jne	.L31
	xorl	%edx, %edx
.L32:
	cmpl	%edx, %r13d
	jle	.L44
	movl	(%r9,%rdx,4), %edi
	movl	%r10d, %ecx
	incq	%rdx
	movl	%edi, %r8d
	shrl	%cl, %r8d
	movl	%r8d, %ecx
	andl	$15, %ecx
	leaq	(%r14,%rcx,4), %r11
	movslq	(%r11), %r15
	movq	%r15, %rcx
	movl	%edi, (%rsi,%r15,4)
	incl	%ecx
	movl	%ecx, (%r11)
	jmp	.L32
.L44:
	addl	$4, %r10d
	cmpl	$32, %r10d
	je	.L45
	xchgq	%rsi, %r9
	jmp	.L34
.L45:
	movq	%r12, %rdi
	movq	%rbx, %rcx
	rep movsb
	movq	32(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	8(%rsp), %rdi
	call	_ZN8GpuTimer7ElapsedEv
	leaq	.LC2(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	cvtss2sd	%xmm0, %xmm0
	call	__printf_chk@PLT
.LEHE1:
	movq	8(%rsp), %rdi
	call	_ZN8GpuTimerD1Ev
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	je	.L37
	jmp	.L41
.L39:
	endbr64
	movq	%rax, %rbx
.L35:
	movq	8(%rsp), %rdi
	call	_ZN8GpuTimerD1Ev
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L41
	movq	%rbx, %rdi
.LEHB2:
	call	_Unwind_Resume@PLT
.LEHE2:
.L41:
	call	__stack_chk_fail@PLT
.L37:
	addq	$56, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2038:
	.section	.gcc_except_table,"a",@progbits
.LLSDA2038:
	.byte	0xff
	.byte	0xff
	.byte	0x1
	.uleb128 .LLSDACSE2038-.LLSDACSB2038
.LLSDACSB2038:
	.uleb128 .LEHB0-.LFB2038
	.uleb128 .LEHE0-.LEHB0
	.uleb128 0
	.uleb128 0
	.uleb128 .LEHB1-.LFB2038
	.uleb128 .LEHE1-.LEHB1
	.uleb128 .L39-.LFB2038
	.uleb128 0
	.uleb128 .LEHB2-.LFB2038
	.uleb128 .LEHE2-.LEHB2
	.uleb128 0
	.uleb128 0
.LLSDACSE2038:
	.text
	.size	_Z10sortByHostPKjPji, .-_Z10sortByHostPKjPji
	.section	.rodata.str1.1
.LC3:
	.string	"/home/ubuntu/Datasets/stackv2/train-structured/TruongNgocTai/GPU_finalProject/master/final_v01.cu"
.LC4:
	.string	"Error: %s:%d, "
.LC5:
	.string	"code: %d, reason: %s\n"
.LC6:
	.string	"**********GPU info**********\n"
.LC7:
	.string	"Name: %s\n"
.LC8:
	.string	"Compute capability: %d.%d\n"
.LC9:
	.string	"Num SMs: %d\n"
.LC10:
	.string	"Max num threads per SM: %d\n"
.LC11:
	.string	"Max num warps per SM: %d\n"
.LC12:
	.string	"GMEM: %zu byte\n"
.LC13:
	.string	"SMEM per SM: %zu byte\n"
.LC14:
	.string	"SMEM per block: %zu byte\n"
.LC15:
	.string	"****************************\n\n"
	.text
	.globl	_Z15printDeviceInfov
	.type	_Z15printDeviceInfov, @function
_Z15printDeviceInfov:
.LFB2042:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	xorl	%esi, %esi
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	subq	$1048, %rsp
	.cfi_def_cfa_offset 1072
	movq	%fs:40, %rax
	movq	%rax, 1032(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rbp
	movq	%rbp, %rdi
	call	cudaGetDeviceProperties_v2@PLT
	testl	%eax, %eax
	je	.L47
	movq	stderr(%rip), %rdi
	movl	%eax, %ebx
	xorl	%eax, %eax
	movl	$271, %r8d
	leaq	.LC3(%rip), %rcx
	leaq	.LC4(%rip), %rdx
	movl	$2, %esi
	call	__fprintf_chk@PLT
	movl	%ebx, %edi
	call	cudaGetErrorString@PLT
	movq	stderr(%rip), %rdi
	movl	%ebx, %ecx
	leaq	.LC5(%rip), %rdx
	movq	%rax, %r8
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	movl	$1, %edi
	call	exit@PLT
.L47:
	leaq	.LC6(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	%rbp, %rdx
	movl	$2, %edi
	xorl	%eax, %eax
	leaq	.LC7(%rip), %rsi
	call	__printf_chk@PLT
	movl	364(%rsp), %ecx
	movl	$2, %edi
	xorl	%eax, %eax
	movl	360(%rsp), %edx
	leaq	.LC8(%rip), %rsi
	call	__printf_chk@PLT
	movl	388(%rsp), %edx
	leaq	.LC9(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	movl	624(%rsp), %edx
	leaq	.LC10(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	movl	624(%rsp), %eax
	movl	$2, %edi
	leaq	.LC11(%rip), %rsi
	cltd
	idivl	308(%rsp)
	movl	%eax, %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	288(%rsp), %rdx
	leaq	.LC12(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	movq	640(%rsp), %rdx
	leaq	.LC13(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	movq	296(%rsp), %rdx
	leaq	.LC14(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	xorl	%eax, %eax
	movl	$2, %edi
	leaq	.LC15(%rip), %rsi
	call	__printf_chk@PLT
	movq	1032(%rsp), %rax
	subq	%fs:40, %rax
	je	.L48
	call	__stack_chk_fail@PLT
.L48:
	addq	$1048, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2042:
	.size	_Z15printDeviceInfov, .-_Z15printDeviceInfov
	.globl	_Z36__device_stub__Z11computeHistPjiPiiiPjiPiii
	.type	_Z36__device_stub__Z11computeHistPjiPiiiPjiPiii, @function
_Z36__device_stub__Z11computeHistPjiPiiiPjiPiii:
.LFB2068:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdi, 24(%rsp)
	leaq	48(%rsp), %rdi
	movl	%esi, 20(%rsp)
	leaq	60(%rsp), %rsi
	movq	%rdx, 8(%rsp)
	leaq	32(%rsp), %rdx
	movl	%ecx, 16(%rsp)
	leaq	40(%rsp), %rcx
	movl	%r8d, 4(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 56(%rsp)
	movq	%rax, 96(%rsp)
	leaq	20(%rsp), %rax
	movq	%rax, 104(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 128(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 48(%rsp)
	movq	%rax, 60(%rsp)
	movl	$1, 68(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L50
	pushq	40(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z11computeHistPjiPiii(%rip), %rdi
	pushq	40(%rsp)
	.cfi_def_cfa_offset 176
	movq	76(%rsp), %rcx
	movl	84(%rsp), %r8d
	movq	64(%rsp), %rsi
	movl	72(%rsp), %edx
	leaq	112(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 168
	popq	%rdx
	.cfi_def_cfa_offset 160
.L50:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L52
	call	__stack_chk_fail@PLT
.L52:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2068:
	.size	_Z36__device_stub__Z11computeHistPjiPiiiPjiPiii, .-_Z36__device_stub__Z11computeHistPjiPiiiPjiPiii
	.globl	_Z11computeHistPjiPiii
	.type	_Z11computeHistPjiPiii, @function
_Z11computeHistPjiPiii:
.LFB2069:
	.cfi_startproc
	endbr64
	jmp	_Z36__device_stub__Z11computeHistPjiPiiiPjiPiii
	.cfi_endproc
.LFE2069:
	.size	_Z11computeHistPjiPiii, .-_Z11computeHistPjiPiii
	.globl	_Z19computeHistByDevicePjiPiiii
	.type	_Z19computeHistByDevicePjiPiiii, @function
_Z19computeHistByDevicePjiPiiii:
.LFB2039:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	%r8d, %r15d
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movl	%ecx, %r14d
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movl	%r9d, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movl	%esi, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$88, %rsp
	.cfi_def_cfa_offset 144
	movq	%rdi, 16(%rsp)
	leaq	32(%rsp), %rdi
	movq	%rdx, 24(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 72(%rsp)
	xorl	%eax, %eax
	leal	-1(%rsi), %eax
	cltd
	idivl	%r9d
	leal	1(%rax), %ebx
	movslq	%esi, %rax
	salq	$2, %rax
	movq	%rax, %rsi
	movq	%rax, (%rsp)
	call	cudaMalloc@PLT
	testl	%eax, %eax
	je	.L56
	movl	%eax, %r13d
	movl	$157, %r8d
	jmp	.L66
.L56:
	movslq	%ebx, %rdx
	movslq	%r14d, %rax
	leaq	40(%rsp), %rdi
	imulq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rsi
	movq	%rax, 8(%rsp)
	call	cudaMalloc@PLT
	movl	%eax, %r13d
	testl	%eax, %eax
	je	.L57
	movl	$158, %r8d
.L66:
	movq	stderr(%rip), %rdi
	leaq	.LC3(%rip), %rcx
	leaq	.LC4(%rip), %rdx
	xorl	%eax, %eax
	movl	$2, %esi
	call	__fprintf_chk@PLT
	movl	%r13d, %edi
	call	cudaGetErrorString@PLT
	movl	%r13d, %ecx
	movq	%rax, %r8
.L67:
	movq	stderr(%rip), %rdi
	leaq	.LC5(%rip), %rdx
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	movl	$1, %edi
	call	exit@PLT
.L57:
	movq	(%rsp), %rdx
	movq	16(%rsp), %rsi
	movl	$1, %ecx
	movq	32(%rsp), %rdi
	call	cudaMemcpy@PLT
	movl	$161, %r8d
	movl	%eax, %r13d
	testl	%eax, %eax
	jne	.L66
	movabsq	$4294967297, %rax
	movl	%r12d, 60(%rsp)
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movq	%rax, 64(%rsp)
	movl	68(%rsp), %ecx
	movq	%rax, 52(%rsp)
	movq	60(%rsp), %rdx
	movl	%ebx, 48(%rsp)
	movl	56(%rsp), %esi
	movq	48(%rsp), %rdi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L59
	movq	40(%rsp), %rdx
	movq	32(%rsp), %rdi
	movl	%r15d, %r8d
	movl	%r14d, %ecx
	movl	%ebp, %esi
	call	_Z36__device_stub__Z11computeHistPjiPiiiPjiPiii
.L59:
	call	cudaDeviceSynchronize@PLT
	call	cudaGetLastError@PLT
	movl	$166, %r8d
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	.L68
	movq	8(%rsp), %rdx
	movq	40(%rsp), %rsi
	movl	$2, %ecx
	movq	24(%rsp), %rdi
	call	cudaMemcpy@PLT
	movl	$169, %r8d
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	.L68
	movq	32(%rsp), %rdi
	call	cudaFree@PLT
	movl	$172, %r8d
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	.L68
	movq	40(%rsp), %rdi
	call	cudaFree@PLT
	movl	%eax, %ebx
	testl	%eax, %eax
	je	.L55
	movl	$173, %r8d
.L68:
	movq	stderr(%rip), %rdi
	leaq	.LC3(%rip), %rcx
	leaq	.LC4(%rip), %rdx
	xorl	%eax, %eax
	movl	$2, %esi
	call	__fprintf_chk@PLT
	movl	%ebx, %edi
	call	cudaGetErrorString@PLT
	movl	%ebx, %ecx
	movq	%rax, %r8
	jmp	.L67
.L55:
	movq	72(%rsp), %rax
	subq	%fs:40, %rax
	je	.L64
	call	__stack_chk_fail@PLT
.L64:
	addq	$88, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2039:
	.size	_Z19computeHistByDevicePjiPiiii, .-_Z19computeHistByDevicePjiPiiii
	.globl	_Z33__device_stub__Z7scatterPjS_iPiiiPjS_iPiii
	.type	_Z33__device_stub__Z7scatterPjS_iPiiiPjS_iPiii, @function
_Z33__device_stub__Z7scatterPjS_iPiiiPjS_iPiii:
.LFB2070:
	.cfi_startproc
	endbr64
	subq	$184, %rsp
	.cfi_def_cfa_offset 192
	movq	%rdi, 40(%rsp)
	leaq	72(%rsp), %rdi
	movq	%rsi, 32(%rsp)
	leaq	84(%rsp), %rsi
	movl	%edx, 28(%rsp)
	leaq	56(%rsp), %rdx
	movq	%rcx, 16(%rsp)
	leaq	64(%rsp), %rcx
	movl	%r8d, 24(%rsp)
	movl	%r9d, 12(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 168(%rsp)
	xorl	%eax, %eax
	leaq	40(%rsp), %rax
	movl	$1, 80(%rsp)
	movq	%rax, 120(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 128(%rsp)
	leaq	28(%rsp), %rax
	movq	%rax, 136(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 144(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 152(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 160(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 72(%rsp)
	movq	%rax, 84(%rsp)
	movl	$1, 92(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L69
	pushq	64(%rsp)
	.cfi_def_cfa_offset 200
	leaq	_Z7scatterPjS_iPiii(%rip), %rdi
	pushq	64(%rsp)
	.cfi_def_cfa_offset 208
	movq	100(%rsp), %rcx
	movl	108(%rsp), %r8d
	movq	88(%rsp), %rsi
	movl	96(%rsp), %edx
	leaq	136(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 200
	popq	%rdx
	.cfi_def_cfa_offset 192
.L69:
	movq	168(%rsp), %rax
	subq	%fs:40, %rax
	je	.L71
	call	__stack_chk_fail@PLT
.L71:
	addq	$184, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2070:
	.size	_Z33__device_stub__Z7scatterPjS_iPiiiPjS_iPiii, .-_Z33__device_stub__Z7scatterPjS_iPiiiPjS_iPiii
	.globl	_Z7scatterPjS_iPiii
	.type	_Z7scatterPjS_iPiii, @function
_Z7scatterPjS_iPiii:
.LFB2071:
	.cfi_startproc
	endbr64
	jmp	_Z33__device_stub__Z7scatterPjS_iPiiiPjS_iPiii
	.cfi_endproc
.LFE2071:
	.size	_Z7scatterPjS_iPiii, .-_Z7scatterPjS_iPiii
	.globl	_Z15scatterByDevicePjS_iPiiii
	.type	_Z15scatterByDevicePjS_iPiiii, @function
_Z15scatterByDevicePjS_iPiiii:
.LFB2040:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movq	%rdi, %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movl	%r9d, %r14d
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movl	%r8d, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movl	%edx, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$104, %rsp
	.cfi_def_cfa_offset 160
	movq	%rsi, 16(%rsp)
	leaq	40(%rsp), %rdi
	movq	%rcx, 24(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	xorl	%eax, %eax
	leal	-1(%rdx), %eax
	cltd
	idivl	160(%rsp)
	leal	1(%rax), %ebx
	movslq	%ebp, %rax
	salq	$2, %rax
	movq	%rax, %rsi
	movq	%rax, (%rsp)
	call	cudaMalloc@PLT
	testl	%eax, %eax
	je	.L75
	movl	%eax, %r12d
	movl	$197, %r8d
	jmp	.L88
.L75:
	movslq	%ebx, %rdx
	movslq	%r13d, %rax
	leaq	56(%rsp), %rdi
	imulq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rsi
	movq	%rax, 8(%rsp)
	call	cudaMalloc@PLT
	movl	%eax, %r12d
	testl	%eax, %eax
	je	.L76
	movl	$198, %r8d
.L88:
	movq	stderr(%rip), %rdi
	leaq	.LC3(%rip), %rcx
	leaq	.LC4(%rip), %rdx
	xorl	%eax, %eax
	movl	$2, %esi
	call	__fprintf_chk@PLT
	movl	%r12d, %edi
	call	cudaGetErrorString@PLT
	movl	%r12d, %ecx
	movq	%rax, %r8
.L89:
	movq	stderr(%rip), %rdi
	leaq	.LC5(%rip), %rdx
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	movl	$1, %edi
	call	exit@PLT
.L76:
	movq	(%rsp), %rsi
	leaq	48(%rsp), %rdi
	call	cudaMalloc@PLT
	movl	$199, %r8d
	movl	%eax, %r12d
	testl	%eax, %eax
	jne	.L88
	movq	(%rsp), %rdx
	movq	40(%rsp), %rdi
	movl	$1, %ecx
	movq	%r15, %rsi
	call	cudaMemcpy@PLT
	movl	$202, %r8d
	movl	%eax, %r12d
	testl	%eax, %eax
	jne	.L88
	movq	8(%rsp), %rdx
	movq	24(%rsp), %rsi
	movl	$1, %ecx
	movq	56(%rsp), %rdi
	call	cudaMemcpy@PLT
	movl	$203, %r8d
	movl	%eax, %r12d
	testl	%eax, %eax
	jne	.L88
	movl	160(%rsp), %eax
	movl	%ebx, 64(%rsp)
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	%eax, 76(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 80(%rsp)
	movl	84(%rsp), %ecx
	movq	%rax, 68(%rsp)
	movq	76(%rsp), %rdx
	movq	64(%rsp), %rdi
	movl	72(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L80
	movq	56(%rsp), %rcx
	movq	48(%rsp), %rsi
	movl	%r14d, %r9d
	movl	%r13d, %r8d
	movq	40(%rsp), %rdi
	movl	%ebp, %edx
	call	_Z33__device_stub__Z7scatterPjS_iPiiiPjS_iPiii
.L80:
	call	cudaDeviceSynchronize@PLT
	call	cudaGetLastError@PLT
	movl	$208, %r8d
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	.L90
	movq	(%rsp), %rdx
	movq	48(%rsp), %rsi
	movl	$2, %ecx
	movq	16(%rsp), %rdi
	call	cudaMemcpy@PLT
	movl	$211, %r8d
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	.L90
	movq	40(%rsp), %rdi
	call	cudaFree@PLT
	movl	$214, %r8d
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	.L90
	movq	56(%rsp), %rdi
	call	cudaFree@PLT
	movl	$215, %r8d
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	.L90
	movq	48(%rsp), %rdi
	call	cudaFree@PLT
	movl	%eax, %ebx
	testl	%eax, %eax
	je	.L74
	movl	$216, %r8d
.L90:
	movq	stderr(%rip), %rdi
	leaq	.LC3(%rip), %rcx
	leaq	.LC4(%rip), %rdx
	xorl	%eax, %eax
	movl	$2, %esi
	call	__fprintf_chk@PLT
	movl	%ebx, %edi
	call	cudaGetErrorString@PLT
	movl	%ebx, %ecx
	movq	%rax, %r8
	jmp	.L89
.L74:
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	je	.L86
	call	__stack_chk_fail@PLT
.L86:
	addq	$104, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2040:
	.size	_Z15scatterByDevicePjS_iPiiii, .-_Z15scatterByDevicePjS_iPiiii
	.section	.rodata.str1.1
.LC16:
	.string	"Time of sortByDevice: %.3f ms\n\n"
	.text
	.globl	_Z15sortByDeviceLv1PKjPjii
	.type	_Z15sortByDeviceLv1PKjPjii, @function
_Z15sortByDeviceLv1PKjPjii:
.LFB2041:
	.cfi_startproc
	.cfi_personality 0x9b,DW.ref.__gxx_personality_v0
	.cfi_lsda 0x1b,.LLSDA2041
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	movq	%rdi, %r14
	leaq	-72(%rbp), %rdi
	pushq	%r13
	.cfi_offset 13, -40
	movl	%ecx, %r13d
	pushq	%r12
	.cfi_offset 12, -48
	movl	%edx, %r12d
	pushq	%rbx
	subq	$88, %rsp
	.cfi_offset 3, -56
	movq	%rsi, -128(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
.LEHB3:
	call	cudaEventCreate@PLT
	leaq	-64(%rbp), %rdi
	call	cudaEventCreate@PLT
.LEHE3:
	movq	-72(%rbp), %rdi
	xorl	%esi, %esi
.LEHB4:
	call	cudaEventRecord@PLT
	leal	-1(%r12), %eax
	cltd
	idivl	%r13d
	incl	%eax
	movl	%eax, -116(%rbp)
	sall	$4, %eax
	cltq
	salq	$2, %rax
	movq	%rax, %rdi
	movq	%rax, -88(%rbp)
	call	malloc@PLT
	movq	-88(%rbp), %rdi
	movq	%rax, -112(%rbp)
	call	malloc@PLT
	movq	%rax, %r15
	movslq	%r12d, %rax
	salq	$2, %rax
	movq	%rax, %rdi
	movq	%rax, -96(%rbp)
	call	malloc@PLT
	movq	-96(%rbp), %rcx
	movq	%r14, %rsi
	xorl	%r14d, %r14d
	movq	%rax, %rdi
	movq	%rax, %rbx
	movq	%rcx, %rdx
	call	__memcpy_chk@PLT
	movq	-128(%rbp), %rax
	movq	%rax, -104(%rbp)
.L96:
	movq	-88(%rbp), %rcx
	movq	-112(%rbp), %rdi
	xorl	%esi, %esi
	movq	%rcx, %rdx
	call	__memset_chk@PLT
	movq	-112(%rbp), %rdx
	movl	%r13d, %r9d
	movl	%r14d, %r8d
	movl	$16, %ecx
	movl	%r12d, %esi
	movq	%rbx, %rdi
	call	_Z19computeHistByDevicePjiPiiii
	xorl	%edx, %edx
	xorl	%esi, %esi
.L92:
	leaq	0(,%rdx,4), %rax
	xorl	%ecx, %ecx
.L95:
	movl	-116(%rbp), %edi
	cmpl	%edi, %ecx
	jge	.L106
	movq	-112(%rbp), %rdi
	movl	%esi, (%r15,%rax)
	incl	%ecx
	addl	(%rdi,%rax), %esi
	addq	$64, %rax
	jmp	.L95
.L106:
	incq	%rdx
	cmpq	$16, %rdx
	jne	.L92
	pushq	%rcx
	movq	-104(%rbp), %rsi
	movl	%r14d, %r9d
	movl	$16, %r8d
	pushq	%r13
	movq	%r15, %rcx
	movl	%r12d, %edx
	movq	%rbx, %rdi
	.cfi_escape 0x2e,0x10
	call	_Z15scatterByDevicePjS_iPiiii
	addl	$4, %r14d
	popq	%rax
	popq	%rdx
	cmpl	$32, %r14d
	je	.L107
	movq	%rbx, %rax
	movq	-104(%rbp), %rbx
	movq	%rax, -104(%rbp)
	jmp	.L96
.L107:
	movq	-128(%rbp), %rdi
	movq	-104(%rbp), %rsi
	movq	-96(%rbp), %rcx
	rep movsb
	movq	-64(%rbp), %rdi
	xorl	%esi, %esi
	.cfi_escape 0x2e,0
	call	cudaEventRecord@PLT
	leaq	-72(%rbp), %rbx
	movq	%rbx, %rdi
	call	_ZN8GpuTimer7ElapsedEv
	leaq	.LC16(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	cvtss2sd	%xmm0, %xmm0
	call	__printf_chk@PLT
.LEHE4:
	movq	%rbx, %rdi
	call	_ZN8GpuTimerD1Ev
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	je	.L99
	jmp	.L104
.L102:
	endbr64
	movq	%rax, %rbx
.L97:
	leaq	-72(%rbp), %rdi
	call	_ZN8GpuTimerD1Ev
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	jne	.L104
	movq	%rbx, %rdi
.LEHB5:
	call	_Unwind_Resume@PLT
.LEHE5:
.L104:
	call	__stack_chk_fail@PLT
.L99:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2041:
	.section	.gcc_except_table
.LLSDA2041:
	.byte	0xff
	.byte	0xff
	.byte	0x1
	.uleb128 .LLSDACSE2041-.LLSDACSB2041
.LLSDACSB2041:
	.uleb128 .LEHB3-.LFB2041
	.uleb128 .LEHE3-.LEHB3
	.uleb128 0
	.uleb128 0
	.uleb128 .LEHB4-.LFB2041
	.uleb128 .LEHE4-.LEHB4
	.uleb128 .L102-.LFB2041
	.uleb128 0
	.uleb128 .LEHB5-.LFB2041
	.uleb128 .LEHE5-.LEHB5
	.uleb128 0
	.uleb128 0
.LLSDACSE2041:
	.text
	.size	_Z15sortByDeviceLv1PKjPjii, .-_Z15sortByDeviceLv1PKjPjii
	.section	.rodata.str1.1
.LC17:
	.string	"Input size: %d\n\n"
.LC18:
	.string	"sortByDevice is INCORRECT!\n\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2043:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	%edi, %r15d
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movq	%rsi, %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	xorl	%r13d, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	pushq	%rcx
	.cfi_def_cfa_offset 64
	call	_Z15printDeviceInfov
	movl	$16777217, %edx
	leaq	.LC17(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	movl	$67108868, %edi
	call	malloc@PLT
	movl	$67108868, %edi
	movq	%rax, %rbx
	call	malloc@PLT
	movl	$67108868, %edi
	movq	%rax, %r12
	call	malloc@PLT
	movq	%rax, %rbp
.L109:
	call	rand@PLT
	movl	%eax, (%rbx,%r13,4)
	incq	%r13
	cmpq	$16777217, %r13
	jne	.L109
	movl	$512, %r13d
	cmpl	$2, %r15d
	jne	.L110
	movq	8(%r14), %rdi
	call	atoi@PLT
	movl	%eax, %r13d
.L110:
	movl	$16777217, %edx
	movq	%rbp, %rsi
	movq	%rbx, %rdi
	call	_Z10sortByHostPKjPji
	movl	$16777217, %edx
	movq	%r12, %rsi
	movq	%rbx, %rdi
	movl	%r13d, %ecx
	call	_Z15sortByDeviceLv1PKjPjii
	movl	$16777217, %edx
	movq	%rbp, %rsi
	movq	%r12, %rdi
	call	_Z17checkCorrectInt32PjS_i
	testb	%al, %al
	jne	.L111
	leaq	.LC18(%rip), %rsi
	movl	$2, %edi
	call	__printf_chk@PLT
.L111:
	movq	%rbx, %rdi
	call	free@PLT
	movq	%r12, %rdi
	call	free@PLT
	movq	%rbp, %rdi
	call	free@PLT
	popq	%rdx
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2043:
	.size	main, .-main
	.section	.rodata.str1.1
.LC19:
	.string	"_Z7scatterPjS_iPiii"
.LC20:
	.string	"_Z11computeHistPjiPiii"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2073:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	pushq	$0
	.cfi_def_cfa_offset 24
	xorl	%r9d, %r9d
	orl	$-1, %r8d
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC19(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z7scatterPjS_iPiii(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r9d, %r9d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC20(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z11computeHistPjiPiii(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 40
	pushq	$0
	.cfi_def_cfa_offset 48
	call	__cudaRegisterFunction@PLT
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE2073:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.hidden	DW.ref.__gxx_personality_v0
	.weak	DW.ref.__gxx_personality_v0
	.section	.data.rel.local.DW.ref.__gxx_personality_v0,"awG",@progbits,DW.ref.__gxx_personality_v0,comdat
	.align 8
	.type	DW.ref.__gxx_personality_v0, @object
	.size	DW.ref.__gxx_personality_v0, 8
DW.ref.__gxx_personality_v0:
	.quad	__gxx_personality_v0
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:


#include <hip/hip_runtime.h>
#include <stdio.h>
#include <stdint.h>

#define CHECK(call)                                                            \
{                                                                              \
    const hipError_t error = call;                                            \
    if (error != hipSuccess)                                                  \
    {                                                                          \
        fprintf(stderr, "Error: %s:%d, ", __FILE__, __LINE__);                 \
        fprintf(stderr, "code: %d, reason: %s\n", error,                       \
                hipGetErrorString(error));                                    \
        exit(1);                                                               \
    }                                                                          \
}

struct GpuTimer
{
    hipEvent_t start;
    hipEvent_t stop;

    GpuTimer()
    {
        hipEventCreate(&start);
        hipEventCreate(&stop);
    }

    ~GpuTimer()
    {
        hipEventDestroy(start);
        hipEventDestroy(stop);
    }

    void Start()
    {
        hipEventRecord(start, 0);
    }

    void Stop()
    {
        hipEventRecord(stop, 0);
    }

    float Elapsed()
    {
        float elapsed;
        hipEventSynchronize(stop);
        hipEventElapsedTime(&elapsed, start, stop);
        return elapsed;
    }
};

bool checkCorrect(int * out, int * correctOut, int n)
{
    for (int i = 0; i < n; i++)
        if (out[i] != correctOut[i]) {
            printf("%d\n", i);
            printf("%d >< %d\n", out[i], correctOut[i]);
            return false;
        }
    return true;
}

bool checkCorrectInt32(uint32_t * out, uint32_t * correctOut, int n)
{
    for (int i = 0; i < n; i++)
        if (out[i] != correctOut[i]) {
            printf("%d\n", i);
            printf("%d >< %d\n", out[i], correctOut[i]);
            return false;
        }
    return true;
}

// Sequential Radix Sort
void sortByHost(const uint32_t * in, uint32_t * out, int n)
{
	GpuTimer timer; 
    timer.Start();

    int nBits = 4; // Assume: nBits in {1, 2, 4, 8, 16, 32}
    int nBins = 1 << nBits; // 2^nBits

    int * hist = (int *)malloc(nBins * sizeof(int));
    int * histScan = (int *)malloc(nBins * sizeof(int));

    uint32_t * src = (uint32_t *)malloc(n * sizeof(uint32_t));
    memcpy(src, in, n * sizeof(uint32_t));
    uint32_t * dst = out;

    for (int bit = 0; bit < sizeof(uint32_t) * 8; bit += nBits)
    {
    	// Compute histogram
    	memset(hist, 0, nBins * sizeof(int));
    	for (int i = 0; i < n; i++)
    	{
    		int bin = (src[i] >> bit) & (nBins - 1);
    		hist[bin]++;
    	}

    	// Scan histogram (exclusively)
    	memset(histScan, 0, nBins * sizeof(int));
    	for (int bin = 1; bin < nBins; bin++)
    		histScan[bin] = histScan[bin - 1] + hist[bin - 1];

    	// Scatter
    	for (int i = 0; i < n; i++)
    	{
    		int bin = (src[i] >> bit) & (nBins - 1);
    		dst[histScan[bin]] = src[i];
    		histScan[bin]++;
    	}

    	// Swap src and dst
    	uint32_t * temp = src;
    	src = dst;
    	dst = temp;
    }

    // Copy result from src to out
    memcpy(out, src, n * sizeof(uint32_t));

	timer.Stop();
    printf("Time of sortByHost: %.3f ms\n\n", timer.Elapsed());
}

__global__ void computeHist(uint32_t * in, int n, int * hist, int nBins, int bit)
{
    int idx = blockDim.x * blockIdx.x + threadIdx.x;
    if (idx < n) {
        int bin = (in[idx] >> bit) & (nBins - 1);
        int histIdx = blockIdx.x * nBins + bin;
        atomicAdd(&hist[histIdx], 1);

        //__syncthreads();

        // if (threadIdx.x == 0) {
        //     int baseHistIdx = blockIdx.x * nBins;
        //     int prevBin = hist[baseHistIdx];
        //     int curScan = 0;
        //     hist[baseHistIdx] = curScan;
        //     for (int i = 1; i < nBins; i++) {
        //         curScan += prevBin;
        //         prevBin = hist[baseHistIdx + i];
        //         hist[baseHistIdx + i] = curScan;
        //     }
        // }
    }
}

// Compute hist by device
void computeHistByDevice(uint32_t * in, int n, int * hist, int nBins, int bit, int blkSize) 
{
    // Allocate device memories
    uint32_t *d_in;
    int *d_hist;
    int numBlks = (n - 1) / blkSize + 1;
    CHECK(hipMalloc(&d_in, sizeof(uint32_t) * n));
    CHECK(hipMalloc(&d_hist, sizeof(int) * nBins * numBlks));
    
    // Copy data to device memories
    CHECK(hipMemcpy(d_in, in, sizeof(uint32_t) * n, hipMemcpyHostToDevice));

    // Call kernel to scan within each block's input data
    computeHist<<<numBlks, blkSize>>>(d_in, n, d_hist, nBins, bit);
    hipDeviceSynchronize();
    CHECK(hipGetLastError());

    // Copy result from device memories
    CHECK(hipMemcpy(hist, d_hist, sizeof(int) * nBins * numBlks, hipMemcpyDeviceToHost));
        
    // Free device memories
    CHECK(hipFree(d_in));
    CHECK(hipFree(d_hist));
}

__global__ void scatter(uint32_t * in, uint32_t * out, int n, int * histScan, int nBins, int bit)
{
    int idx = blockIdx.x * blockDim.x;
    if (threadIdx.x == 0) {
        for (int i = 0; i < blockDim.x; i++){
            if (idx + i < n) {
                int bin = (in[idx + i] >> bit) & (nBins - 1);
                int histIdx = blockIdx.x * nBins + bin;
                out[histScan[histIdx]] = in[idx + i];
                histScan[histIdx]++;
            }
        }
    }
}

void scatterByDevice(uint32_t * in, uint32_t * out, int n, int * histScan, int nBins, int bit, int blkSize)
{
    // Allocate device memories
    uint32_t *d_in, *d_out;
    int *d_histScan;
    int numBlks = (n - 1) / blkSize + 1;
    CHECK(hipMalloc(&d_in, sizeof(uint32_t) * n));
    CHECK(hipMalloc(&d_histScan, sizeof(int) * nBins * numBlks));
    CHECK(hipMalloc(&d_out, sizeof(uint32_t) * n));

    // Copy data to device memories
    CHECK(hipMemcpy(d_in, in, sizeof(uint32_t) * n, hipMemcpyHostToDevice));
    CHECK(hipMemcpy(d_histScan, histScan, sizeof(int) * nBins * numBlks, hipMemcpyHostToDevice));

    // Call kernel to scan within each block's input data
    scatter<<<numBlks, blkSize>>>(d_in, d_out, n, d_histScan, nBins, bit);
    hipDeviceSynchronize();
    CHECK(hipGetLastError());

    // Copy result from device memories
    CHECK(hipMemcpy(out, d_out, sizeof(uint32_t) * n, hipMemcpyDeviceToHost));
        
    // Free device memories
    CHECK(hipFree(d_in));
    CHECK(hipFree(d_histScan));
    CHECK(hipFree(d_out));
}

// Parallel Radix Sort with k bit
void sortByDeviceLv1(const uint32_t * in, uint32_t * out, int n, int blkSize)
{
	GpuTimer timer; 
    timer.Start();

    int nBits = 4; // Assume: nBits in {1, 2, 4, 8, 16, 32}
    int nBins = 1 << nBits; // 2^nBits

    int numBlks = (n - 1) / blkSize + 1;

    int * hist = (int *)malloc(nBins * numBlks * sizeof(int));
    int * histScan = (int *)malloc(nBins * numBlks * sizeof(int));

    uint32_t * src = (uint32_t *)malloc(n * sizeof(uint32_t));
    memcpy(src, in, n * sizeof(uint32_t));
    uint32_t * dst = out;

    for (int bit = 0; bit < sizeof(uint32_t) * 8; bit += nBits)
    {
    	// Compute histogram
    	memset(hist, 0, nBins * numBlks * sizeof(int));
        computeHistByDevice(src, n, hist, nBins, bit, blkSize);

        int curScan = 0;
        for (int binIdx = 0; binIdx < nBins; binIdx++) {
            for (int blkIdx = 0; blkIdx < numBlks; blkIdx++) {
                int histIdx = blkIdx * nBins + binIdx;
                histScan[histIdx] = curScan;
                curScan += hist[histIdx];
            }
        };

    	// Scatter
    	scatterByDevice(src, dst, n, histScan, nBins, bit, blkSize);

    	// Swap src and dst
    	uint32_t * temp = src;
    	src = dst;
    	dst = temp;
    }

    // Copy result from src to out
    memcpy(out, src, n * sizeof(uint32_t));
    
    timer.Stop();
    printf("Time of sortByDevice: %.3f ms\n\n", timer.Elapsed());
}

void printDeviceInfo()
{
    hipDeviceProp_t devProv;
    CHECK(hipGetDeviceProperties(&devProv, 0));
    printf("**********GPU info**********\n");
    printf("Name: %s\n", devProv.name);
    printf("Compute capability: %d.%d\n", devProv.major, devProv.minor);
    printf("Num SMs: %d\n", devProv.multiProcessorCount);
    printf("Max num threads per SM: %d\n", devProv.maxThreadsPerMultiProcessor); 
    printf("Max num warps per SM: %d\n", devProv.maxThreadsPerMultiProcessor / devProv.warpSize);
    printf("GMEM: %zu byte\n", devProv.totalGlobalMem);
    printf("SMEM per SM: %zu byte\n", devProv.sharedMemPerMultiprocessor);
    printf("SMEM per block: %zu byte\n", devProv.sharedMemPerBlock);
    printf("****************************\n\n");
}

int main(int argc, char ** argv)
{
    // PRINT OUT DEVICE INFO
    printDeviceInfo();

    // SET UP INPUT SIZE
    int n = (1 << 24) + 1;
    printf("Input size: %d\n\n", n);

    // ALLOCATE MEMORIES
    size_t bytes = n * sizeof(uint32_t);
    uint32_t * in = (uint32_t *)malloc(bytes);
    uint32_t * out = (uint32_t *)malloc(bytes); // Device result
    uint32_t * correctOut = (uint32_t *)malloc(bytes); // Host result

    // SET UP INPUT DATA
    for (int i = 0; i < n; i++)
        in[i] = rand();

    // DETERMINE BLOCK SIZE
    int blockSize = 512; // Default 
    if (argc == 2)
        blockSize = atoi(argv[1]);

    // SORT BY HOST
    sortByHost(in, correctOut, n);
    
    // SORT BY DEVICE
    sortByDeviceLv1(in, out, n, blockSize);
    if (checkCorrectInt32(out, correctOut, n) == false)
    	printf("sortByDevice is INCORRECT!\n\n");;

    // FREE MEMORIES
    free(in);
    free(out);
    free(correctOut);
    
    return EXIT_SUCCESS;
}
	.text
	.file	"final_v01.hip"
	.globl	_Z12checkCorrectPiS_i           # -- Begin function _Z12checkCorrectPiS_i
	.type	_Z12checkCorrectPiS_i,@function
_Z12checkCorrectPiS_i:                  # @_Z12checkCorrectPiS_i
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r12
	.cfi_def_cfa_offset 32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	pushq	%rax
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -40
	.cfi_offset %r12, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	testl	%edx, %edx
	jle	.LBB0_1
# %bb.2:                                # %.lr.ph.preheader
	movq	%rsi, %rbx
	movq	%rdi, %r14
	movl	(%rdi), %eax
	cmpl	(%rsi), %eax
	jne	.LBB0_3
# %bb.7:                                # %.lr.ph41.preheader
	movl	%edx, %eax
	movl	$1, %ecx
.LBB0_8:                                # %.lr.ph41
                                        # =>This Inner Loop Header: Depth=1
	cmpq	%rcx, %rax
	je	.LBB0_9
# %bb.4:                                # %.lr.ph
                                        #   in Loop: Header=BB0_8 Depth=1
	movl	(%r14,%rcx,4), %edx
	leaq	1(%rcx), %r12
	cmpl	(%rbx,%rcx,4), %edx
	movq	%r12, %rcx
	je	.LBB0_8
# %bb.5:                                # %.lr.ph._crit_edge.loopexit
	decq	%r12
	cmpq	%rax, %r12
	setae	%r15b
	jmp	.LBB0_6
.LBB0_1:
	movb	$1, %r15b
	jmp	.LBB0_10
.LBB0_3:
	xorl	%r12d, %r12d
	xorl	%r15d, %r15d
.LBB0_6:                                # %.lr.ph._crit_edge
	movl	$.L.str, %edi
	movl	%r12d, %esi
	xorl	%eax, %eax
	callq	printf
	movl	(%r14,%r12,4), %esi
	movl	(%rbx,%r12,4), %edx
	movl	$.L.str.1, %edi
	xorl	%eax, %eax
	callq	printf
	jmp	.LBB0_10
.LBB0_9:                                # %.loopexit.loopexit
	setbe	%r15b
.LBB0_10:                               # %.loopexit
	movl	%r15d, %eax
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_Z12checkCorrectPiS_i, .Lfunc_end0-_Z12checkCorrectPiS_i
	.cfi_endproc
                                        # -- End function
	.globl	_Z17checkCorrectInt32PjS_i      # -- Begin function _Z17checkCorrectInt32PjS_i
	.type	_Z17checkCorrectInt32PjS_i,@function
_Z17checkCorrectInt32PjS_i:             # @_Z17checkCorrectInt32PjS_i
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r12
	.cfi_def_cfa_offset 32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	pushq	%rax
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -40
	.cfi_offset %r12, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	testl	%edx, %edx
	jle	.LBB1_1
# %bb.2:                                # %.lr.ph.preheader
	movq	%rsi, %rbx
	movq	%rdi, %r14
	movl	(%rdi), %eax
	cmpl	(%rsi), %eax
	jne	.LBB1_3
# %bb.7:                                # %.lr.ph41.preheader
	movl	%edx, %eax
	movl	$1, %ecx
.LBB1_8:                                # %.lr.ph41
                                        # =>This Inner Loop Header: Depth=1
	cmpq	%rcx, %rax
	je	.LBB1_9
# %bb.4:                                # %.lr.ph
                                        #   in Loop: Header=BB1_8 Depth=1
	movl	(%r14,%rcx,4), %edx
	leaq	1(%rcx), %r12
	cmpl	(%rbx,%rcx,4), %edx
	movq	%r12, %rcx
	je	.LBB1_8
# %bb.5:                                # %.lr.ph._crit_edge.loopexit
	decq	%r12
	cmpq	%rax, %r12
	setae	%r15b
	jmp	.LBB1_6
.LBB1_1:
	movb	$1, %r15b
	jmp	.LBB1_10
.LBB1_3:
	xorl	%r12d, %r12d
	xorl	%r15d, %r15d
.LBB1_6:                                # %.lr.ph._crit_edge
	movl	$.L.str, %edi
	movl	%r12d, %esi
	xorl	%eax, %eax
	callq	printf
	movl	(%r14,%r12,4), %esi
	movl	(%rbx,%r12,4), %edx
	movl	$.L.str.1, %edi
	xorl	%eax, %eax
	callq	printf
	jmp	.LBB1_10
.LBB1_9:                                # %.loopexit.loopexit
	setbe	%r15b
.LBB1_10:                               # %.loopexit
	movl	%r15d, %eax
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end1:
	.size	_Z17checkCorrectInt32PjS_i, .Lfunc_end1-_Z17checkCorrectInt32PjS_i
	.cfi_endproc
                                        # -- End function
	.globl	_Z10sortByHostPKjPji            # -- Begin function _Z10sortByHostPKjPji
	.type	_Z10sortByHostPKjPji,@function
_Z10sortByHostPKjPji:                   # @_Z10sortByHostPKjPji
.Lfunc_begin0:
	.cfi_startproc
	.cfi_personality 3, __gxx_personality_v0
	.cfi_lsda 3, .Lexception0
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%edx, %ebp
	movq	%rsi, 48(%rsp)                  # 8-byte Spill
	movq	%rdi, 8(%rsp)                   # 8-byte Spill
	leaq	16(%rsp), %rdi
	callq	hipEventCreate
	leaq	24(%rsp), %r14
	movq	%r14, %rdi
	callq	hipEventCreate
	movq	-8(%r14), %rdi
.Ltmp0:
	xorl	%r14d, %r14d
	xorl	%esi, %esi
	callq	hipEventRecord
.Ltmp1:
# %bb.1:                                # %_ZN8GpuTimer5StartEv.exit
	movl	$64, %edi
	callq	malloc
	movq	%rax, %r15
	movl	$64, %edi
	callq	malloc
	movq	%rax, %r13
	movslq	%ebp, %rax
	movq	%rax, 40(%rsp)                  # 8-byte Spill
	leaq	(,%rax,4), %rbx
	movq	%rbx, %rdi
	callq	malloc
	movq	%rax, %r12
	movq	%rax, %rdi
	movq	8(%rsp), %rsi                   # 8-byte Reload
	movq	%rbx, 8(%rsp)                   # 8-byte Spill
	movq	%rbx, %rdx
	callq	memcpy@PLT
	movl	40(%rsp), %eax                  # 4-byte Reload
	xorps	%xmm0, %xmm0
	movq	48(%rsp), %rdi                  # 8-byte Reload
	movq	%rdi, %rdx
.LBB2_2:                                # =>This Loop Header: Depth=1
                                        #     Child Loop BB2_4 Depth 2
                                        #     Child Loop BB2_6 Depth 2
                                        #     Child Loop BB2_9 Depth 2
	movq	%rdx, %rsi
	movq	%r12, %rdx
	movups	%xmm0, 48(%r15)
	movups	%xmm0, 32(%r15)
	movups	%xmm0, 16(%r15)
	movups	%xmm0, (%r15)
	testl	%ebp, %ebp
	jle	.LBB2_5
# %bb.3:                                # %.lr.ph.preheader
                                        #   in Loop: Header=BB2_2 Depth=1
	xorl	%r9d, %r9d
.LBB2_4:                                # %.lr.ph
                                        #   Parent Loop BB2_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	(%rdx,%r9,4), %r8d
	movl	%r14d, %ecx
	shrl	%cl, %r8d
	andl	$15, %r8d
	incl	(%r15,%r8,4)
	incq	%r9
	cmpq	%r9, %rax
	jne	.LBB2_4
.LBB2_5:                                # %._crit_edge
                                        #   in Loop: Header=BB2_2 Depth=1
	movups	%xmm0, 48(%r13)
	movups	%xmm0, 32(%r13)
	movups	%xmm0, 16(%r13)
	movups	%xmm0, (%r13)
	xorl	%ecx, %ecx
	xorl	%r8d, %r8d
.LBB2_6:                                #   Parent Loop BB2_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	addl	(%r15,%rcx,4), %r8d
	movl	%r8d, 4(%r13,%rcx,4)
	incq	%rcx
	cmpq	$15, %rcx
	jne	.LBB2_6
# %bb.7:                                # %.preheader
                                        #   in Loop: Header=BB2_2 Depth=1
	testl	%ebp, %ebp
	jle	.LBB2_10
# %bb.8:                                # %.lr.ph67.preheader
                                        #   in Loop: Header=BB2_2 Depth=1
	xorl	%r10d, %r10d
.LBB2_9:                                # %.lr.ph67
                                        #   Parent Loop BB2_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	(%rdx,%r10,4), %r8d
	movl	%r8d, %r9d
	movl	%r14d, %ecx
	shrl	%cl, %r9d
	andl	$15, %r9d
	movslq	(%r13,%r9,4), %rcx
	movl	%r8d, (%rsi,%rcx,4)
	incl	(%r13,%r9,4)
	incq	%r10
	cmpq	%r10, %rax
	jne	.LBB2_9
.LBB2_10:                               # %._crit_edge68
                                        #   in Loop: Header=BB2_2 Depth=1
	leal	4(%r14), %ecx
	movq	%rsi, %r12
	cmpl	$28, %r14d
	movl	%ecx, %r14d
	jb	.LBB2_2
# %bb.11:
	movq	8(%rsp), %rdx                   # 8-byte Reload
	callq	memcpy@PLT
	movq	24(%rsp), %rdi
.Ltmp3:
	xorl	%esi, %esi
	callq	hipEventRecord
.Ltmp4:
# %bb.12:                               # %_ZN8GpuTimer4StopEv.exit
	movq	24(%rsp), %rdi
.Ltmp5:
	callq	hipEventSynchronize
.Ltmp6:
# %bb.13:                               # %.noexc
	movq	16(%rsp), %rsi
	movq	24(%rsp), %rdx
.Ltmp7:
	leaq	36(%rsp), %rdi
	callq	hipEventElapsedTime
.Ltmp8:
# %bb.14:
	xorps	%xmm0, %xmm0
	cvtss2sd	36(%rsp), %xmm0
	movl	$.L.str.2, %edi
	movb	$1, %al
	callq	printf
	leaq	16(%rsp), %rdi
	callq	_ZN8GpuTimerD2Ev
	addq	$56, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.LBB2_17:
	.cfi_def_cfa_offset 112
.Ltmp2:
	jmp	.LBB2_16
.LBB2_15:
.Ltmp9:
.LBB2_16:
	movq	%rax, %rbx
	leaq	16(%rsp), %rdi
	callq	_ZN8GpuTimerD2Ev
	movq	%rbx, %rdi
	callq	_Unwind_Resume@PLT
.Lfunc_end2:
	.size	_Z10sortByHostPKjPji, .Lfunc_end2-_Z10sortByHostPKjPji
	.cfi_endproc
	.section	.gcc_except_table,"a",@progbits
	.p2align	2, 0x0
GCC_except_table2:
.Lexception0:
	.byte	255                             # @LPStart Encoding = omit
	.byte	255                             # @TType Encoding = omit
	.byte	1                               # Call site Encoding = uleb128
	.uleb128 .Lcst_end0-.Lcst_begin0
.Lcst_begin0:
	.uleb128 .Lfunc_begin0-.Lfunc_begin0    # >> Call Site 1 <<
	.uleb128 .Ltmp0-.Lfunc_begin0           #   Call between .Lfunc_begin0 and .Ltmp0
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp0-.Lfunc_begin0           # >> Call Site 2 <<
	.uleb128 .Ltmp1-.Ltmp0                  #   Call between .Ltmp0 and .Ltmp1
	.uleb128 .Ltmp2-.Lfunc_begin0           #     jumps to .Ltmp2
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp1-.Lfunc_begin0           # >> Call Site 3 <<
	.uleb128 .Ltmp3-.Ltmp1                  #   Call between .Ltmp1 and .Ltmp3
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp3-.Lfunc_begin0           # >> Call Site 4 <<
	.uleb128 .Ltmp8-.Ltmp3                  #   Call between .Ltmp3 and .Ltmp8
	.uleb128 .Ltmp9-.Lfunc_begin0           #     jumps to .Ltmp9
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp8-.Lfunc_begin0           # >> Call Site 5 <<
	.uleb128 .Lfunc_end2-.Ltmp8             #   Call between .Ltmp8 and .Lfunc_end2
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
.Lcst_end0:
	.p2align	2, 0x0
                                        # -- End function
	.section	.text._ZN8GpuTimerD2Ev,"axG",@progbits,_ZN8GpuTimerD2Ev,comdat
	.weak	_ZN8GpuTimerD2Ev                # -- Begin function _ZN8GpuTimerD2Ev
	.p2align	1, 0x90
	.type	_ZN8GpuTimerD2Ev,@function
_ZN8GpuTimerD2Ev:                       # @_ZN8GpuTimerD2Ev
.Lfunc_begin1:
	.cfi_startproc
	.cfi_personality 3, __gxx_personality_v0
	.cfi_lsda 3, .Lexception1
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset %rbx, -16
	movq	%rdi, %rbx
	movq	(%rdi), %rdi
.Ltmp10:
	callq	hipEventDestroy
.Ltmp11:
# %bb.1:
	movq	8(%rbx), %rdi
.Ltmp12:
	callq	hipEventDestroy
.Ltmp13:
# %bb.2:
	popq	%rbx
	.cfi_def_cfa_offset 8
	retq
.LBB3_3:
	.cfi_def_cfa_offset 16
.Ltmp14:
	movq	%rax, %rdi
	callq	__clang_call_terminate
.Lfunc_end3:
	.size	_ZN8GpuTimerD2Ev, .Lfunc_end3-_ZN8GpuTimerD2Ev
	.cfi_endproc
	.section	.gcc_except_table._ZN8GpuTimerD2Ev,"aG",@progbits,_ZN8GpuTimerD2Ev,comdat
	.p2align	2, 0x0
GCC_except_table3:
.Lexception1:
	.byte	255                             # @LPStart Encoding = omit
	.byte	3                               # @TType Encoding = udata4
	.uleb128 .Lttbase0-.Lttbaseref0
.Lttbaseref0:
	.byte	1                               # Call site Encoding = uleb128
	.uleb128 .Lcst_end1-.Lcst_begin1
.Lcst_begin1:
	.uleb128 .Ltmp10-.Lfunc_begin1          # >> Call Site 1 <<
	.uleb128 .Ltmp13-.Ltmp10                #   Call between .Ltmp10 and .Ltmp13
	.uleb128 .Ltmp14-.Lfunc_begin1          #     jumps to .Ltmp14
	.byte	1                               #   On action: 1
.Lcst_end1:
	.byte	1                               # >> Action Record 1 <<
                                        #   Catch TypeInfo 1
	.byte	0                               #   No further actions
	.p2align	2, 0x0
                                        # >> Catch TypeInfos <<
	.long	0                               # TypeInfo 1
.Lttbase0:
	.p2align	2, 0x0
                                        # -- End function
	.text
	.globl	_Z26__device_stub__computeHistPjiPiii # -- Begin function _Z26__device_stub__computeHistPjiPiii
	.type	_Z26__device_stub__computeHistPjiPiii,@function
_Z26__device_stub__computeHistPjiPiii:  # @_Z26__device_stub__computeHistPjiPiii
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$128, %rsp
	.cfi_def_cfa_offset 176
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	12(%rsp), %rdi
	movl	%esi, (%rdi)
	leaq	32(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	8(%rsp), %rdx
	movl	%ecx, (%rdx)
	leaq	4(%rsp), %rcx
	movl	%r8d, (%rcx)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	movq	%rcx, 32(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	24(%rsp), %r12
	leaq	16(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z11computeHistPjiPiii, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$144, %rsp
	.cfi_adjust_cfa_offset -144
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end4:
	.size	_Z26__device_stub__computeHistPjiPiii, .Lfunc_end4-_Z26__device_stub__computeHistPjiPiii
	.cfi_endproc
                                        # -- End function
	.globl	_Z19computeHistByDevicePjiPiiii # -- Begin function _Z19computeHistByDevicePjiPiiii
	.type	_Z19computeHistByDevicePjiPiiii,@function
_Z19computeHistByDevicePjiPiiii:        # @_Z19computeHistByDevicePjiPiiii
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%r9d, %r13d
	movl	%r8d, 20(%rsp)                  # 4-byte Spill
	movl	%ecx, %ebx
	movq	%rdx, 24(%rsp)                  # 8-byte Spill
	movl	%esi, %r15d
	movq	%rdi, 32(%rsp)                  # 8-byte Spill
	leal	-1(%r15), %eax
	cltd
	idivl	%r9d
	movl	%eax, %ebp
	movslq	%esi, %r14
	shlq	$2, %r14
	leaq	8(%rsp), %rdi
	movq	%r14, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB5_1
# %bb.2:
	incl	%ebp
	movl	%ebx, 16(%rsp)                  # 4-byte Spill
	movslq	%ebx, %rax
	movslq	%ebp, %r12
	imulq	%rax, %r12
	shlq	$2, %r12
	movq	%rsp, %rdi
	movq	%r12, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB5_3
# %bb.6:
	movq	8(%rsp), %rdi
	movq	32(%rsp), %rsi                  # 8-byte Reload
	movq	%r14, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB5_7
# %bb.8:
	movl	%ebp, %edi
	btsq	$32, %rdi
	movl	%r13d, %edx
	btsq	$32, %rdx
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB5_10
# %bb.9:
	movq	8(%rsp), %rdi
	movq	(%rsp), %rdx
	movl	%r15d, %esi
	movl	16(%rsp), %ecx                  # 4-byte Reload
	movl	20(%rsp), %r8d                  # 4-byte Reload
	callq	_Z26__device_stub__computeHistPjiPiii
.LBB5_10:
	callq	hipDeviceSynchronize
	callq	hipGetLastError
	testl	%eax, %eax
	jne	.LBB5_11
# %bb.12:
	movq	(%rsp), %rsi
	movq	24(%rsp), %rdi                  # 8-byte Reload
	movq	%r12, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB5_13
# %bb.14:
	movq	8(%rsp), %rdi
	callq	hipFree
	testl	%eax, %eax
	jne	.LBB5_15
# %bb.16:
	movq	(%rsp), %rdi
	callq	hipFree
	testl	%eax, %eax
	jne	.LBB5_17
# %bb.18:
	addq	$40, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.LBB5_1:
	.cfi_def_cfa_offset 96
	movl	%eax, %r12d
	movq	stderr(%rip), %rdi
	movl	$.L.str.3, %esi
	movl	$.L.str.4, %edx
	movl	$159, %ecx
	xorl	%eax, %eax
	callq	fprintf
	movq	stderr(%rip), %rbx
	movl	%r12d, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movq	%rbx, %rdi
	movl	%r12d, %edx
	jmp	.LBB5_5
.LBB5_3:
	movl	%eax, %ebx
	movq	stderr(%rip), %rdi
	movl	$.L.str.3, %esi
	movl	$.L.str.4, %edx
	movl	$160, %ecx
	jmp	.LBB5_4
.LBB5_7:
	movl	%eax, %ebx
	movq	stderr(%rip), %rdi
	movl	$.L.str.3, %esi
	movl	$.L.str.4, %edx
	movl	$163, %ecx
	jmp	.LBB5_4
.LBB5_11:
	movl	%eax, %ebx
	movq	stderr(%rip), %rdi
	movl	$.L.str.3, %esi
	movl	$.L.str.4, %edx
	movl	$168, %ecx
	jmp	.LBB5_4
.LBB5_13:
	movl	%eax, %ebx
	movq	stderr(%rip), %rdi
	movl	$.L.str.3, %esi
	movl	$.L.str.4, %edx
	movl	$171, %ecx
	jmp	.LBB5_4
.LBB5_15:
	movl	%eax, %ebx
	movq	stderr(%rip), %rdi
	movl	$.L.str.3, %esi
	movl	$.L.str.4, %edx
	movl	$174, %ecx
	jmp	.LBB5_4
.LBB5_17:
	movl	%eax, %ebx
	movq	stderr(%rip), %rdi
	movl	$.L.str.3, %esi
	movl	$.L.str.4, %edx
	movl	$175, %ecx
.LBB5_4:
	xorl	%eax, %eax
	callq	fprintf
	movq	stderr(%rip), %r14
	movl	%ebx, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movq	%r14, %rdi
	movl	%ebx, %edx
.LBB5_5:
	movq	%rax, %rcx
	xorl	%eax, %eax
	callq	fprintf
	movl	$1, %edi
	callq	exit
.Lfunc_end5:
	.size	_Z19computeHistByDevicePjiPiiii, .Lfunc_end5-_Z19computeHistByDevicePjiPiiii
	.cfi_endproc
                                        # -- End function
	.globl	_Z22__device_stub__scatterPjS_iPiii # -- Begin function _Z22__device_stub__scatterPjS_iPiii
	.type	_Z22__device_stub__scatterPjS_iPiii,@function
_Z22__device_stub__scatterPjS_iPiii:    # @_Z22__device_stub__scatterPjS_iPiii
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$144, %rsp
	.cfi_def_cfa_offset 192
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	56(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	48(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	20(%rsp), %rsi
	movl	%edx, (%rsi)
	leaq	40(%rsp), %rdx
	movq	%rcx, (%rdx)
	leaq	16(%rsp), %rcx
	movl	%r8d, (%rcx)
	leaq	12(%rsp), %r8
	movl	%r9d, (%r8)
	leaq	96(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	movq	%rcx, 32(%rbx)
	movq	%r8, 40(%rbx)
	leaq	80(%rsp), %r14
	leaq	64(%rsp), %r15
	leaq	32(%rsp), %r12
	leaq	24(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z7scatterPjS_iPiii, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$160, %rsp
	.cfi_adjust_cfa_offset -160
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end6:
	.size	_Z22__device_stub__scatterPjS_iPiii, .Lfunc_end6-_Z22__device_stub__scatterPjS_iPiii
	.cfi_endproc
                                        # -- End function
	.globl	_Z15scatterByDevicePjS_iPiiii   # -- Begin function _Z15scatterByDevicePjS_iPiiii
	.type	_Z15scatterByDevicePjS_iPiiii,@function
_Z15scatterByDevicePjS_iPiiii:          # @_Z15scatterByDevicePjS_iPiiii
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%r9d, 28(%rsp)                  # 4-byte Spill
	movl	%r8d, %ebp
	movq	%rcx, 48(%rsp)                  # 8-byte Spill
	movl	%edx, %ecx
	movq	%rsi, 40(%rsp)                  # 8-byte Spill
	movq	%rdi, %rbx
	leal	-1(%rcx), %eax
	cltd
	idivl	112(%rsp)
	movl	%eax, %r13d
	movq	%rcx, 32(%rsp)                  # 8-byte Spill
	movslq	%ecx, %r14
	shlq	$2, %r14
	leaq	16(%rsp), %rdi
	movq	%r14, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB7_1
# %bb.2:
	incl	%r13d
	movl	%ebp, %r12d
	movslq	%ebp, %rax
	movslq	%r13d, %r15
	imulq	%rax, %r15
	shlq	$2, %r15
	movq	%rsp, %rdi
	movq	%r15, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB7_3
# %bb.6:
	leaq	8(%rsp), %rdi
	movq	%r14, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB7_7
# %bb.8:
	movq	16(%rsp), %rdi
	movq	%rbx, %rsi
	movq	%r14, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB7_9
# %bb.11:
	movq	(%rsp), %rdi
	movq	48(%rsp), %rsi                  # 8-byte Reload
	movq	%r15, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB7_12
# %bb.13:
	movl	%r13d, %edi
	btsq	$32, %rdi
	movl	112(%rsp), %edx
	btsq	$32, %rdx
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB7_15
# %bb.14:
	movq	16(%rsp), %rdi
	movq	8(%rsp), %rsi
	movq	(%rsp), %rcx
	movq	32(%rsp), %rdx                  # 8-byte Reload
                                        # kill: def $edx killed $edx killed $rdx
	movl	%r12d, %r8d
	movl	28(%rsp), %r9d                  # 4-byte Reload
	callq	_Z22__device_stub__scatterPjS_iPiii
.LBB7_15:
	callq	hipDeviceSynchronize
	callq	hipGetLastError
	testl	%eax, %eax
	jne	.LBB7_16
# %bb.17:
	movq	8(%rsp), %rsi
	movq	40(%rsp), %rdi                  # 8-byte Reload
	movq	%r14, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB7_18
# %bb.19:
	movq	16(%rsp), %rdi
	callq	hipFree
	testl	%eax, %eax
	jne	.LBB7_20
# %bb.21:
	movq	(%rsp), %rdi
	callq	hipFree
	testl	%eax, %eax
	jne	.LBB7_22
# %bb.23:
	movq	8(%rsp), %rdi
	callq	hipFree
	testl	%eax, %eax
	jne	.LBB7_24
# %bb.25:
	addq	$56, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.LBB7_1:
	.cfi_def_cfa_offset 112
	movl	%eax, %r15d
	movq	stderr(%rip), %rdi
	movl	$.L.str.3, %esi
	movl	$.L.str.4, %edx
	movl	$199, %ecx
	xorl	%eax, %eax
	callq	fprintf
	movq	stderr(%rip), %rbx
	movl	%r15d, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movq	%rbx, %rdi
	movl	%r15d, %edx
	jmp	.LBB7_5
.LBB7_3:
	movl	%eax, %ebp
	movq	stderr(%rip), %rdi
	movl	$.L.str.3, %esi
	movl	$.L.str.4, %edx
	movl	$200, %ecx
	jmp	.LBB7_4
.LBB7_7:
	movl	%eax, %ebp
	movq	stderr(%rip), %rdi
	movl	$.L.str.3, %esi
	movl	$.L.str.4, %edx
	movl	$201, %ecx
.LBB7_4:
	xorl	%eax, %eax
	callq	fprintf
	movq	stderr(%rip), %rbx
	movl	%ebp, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movq	%rbx, %rdi
	movl	%ebp, %edx
	jmp	.LBB7_5
.LBB7_9:
	movl	%eax, %ebx
	movq	stderr(%rip), %rdi
	movl	$.L.str.3, %esi
	movl	$.L.str.4, %edx
	movl	$204, %ecx
	jmp	.LBB7_10
.LBB7_12:
	movl	%eax, %ebx
	movq	stderr(%rip), %rdi
	movl	$.L.str.3, %esi
	movl	$.L.str.4, %edx
	movl	$205, %ecx
	jmp	.LBB7_10
.LBB7_16:
	movl	%eax, %ebx
	movq	stderr(%rip), %rdi
	movl	$.L.str.3, %esi
	movl	$.L.str.4, %edx
	movl	$210, %ecx
	jmp	.LBB7_10
.LBB7_18:
	movl	%eax, %ebx
	movq	stderr(%rip), %rdi
	movl	$.L.str.3, %esi
	movl	$.L.str.4, %edx
	movl	$213, %ecx
	jmp	.LBB7_10
.LBB7_20:
	movl	%eax, %ebx
	movq	stderr(%rip), %rdi
	movl	$.L.str.3, %esi
	movl	$.L.str.4, %edx
	movl	$216, %ecx
	jmp	.LBB7_10
.LBB7_22:
	movl	%eax, %ebx
	movq	stderr(%rip), %rdi
	movl	$.L.str.3, %esi
	movl	$.L.str.4, %edx
	movl	$217, %ecx
	jmp	.LBB7_10
.LBB7_24:
	movl	%eax, %ebx
	movq	stderr(%rip), %rdi
	movl	$.L.str.3, %esi
	movl	$.L.str.4, %edx
	movl	$218, %ecx
.LBB7_10:
	xorl	%eax, %eax
	callq	fprintf
	movq	stderr(%rip), %r14
	movl	%ebx, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movq	%r14, %rdi
	movl	%ebx, %edx
.LBB7_5:
	movq	%rax, %rcx
	xorl	%eax, %eax
	callq	fprintf
	movl	$1, %edi
	callq	exit
.Lfunc_end7:
	.size	_Z15scatterByDevicePjS_iPiiii, .Lfunc_end7-_Z15scatterByDevicePjS_iPiiii
	.cfi_endproc
                                        # -- End function
	.globl	_Z15sortByDeviceLv1PKjPjii      # -- Begin function _Z15sortByDeviceLv1PKjPjii
	.type	_Z15sortByDeviceLv1PKjPjii,@function
_Z15sortByDeviceLv1PKjPjii:             # @_Z15sortByDeviceLv1PKjPjii
.Lfunc_begin2:
	.cfi_startproc
	.cfi_personality 3, __gxx_personality_v0
	.cfi_lsda 3, .Lexception2
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$88, %rsp
	.cfi_def_cfa_offset 144
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%ecx, %ebp
	movl	%edx, %r12d
	movq	%rsi, %r14
	movq	%rdi, 24(%rsp)                  # 8-byte Spill
	leaq	32(%rsp), %rdi
	callq	hipEventCreate
	leaq	40(%rsp), %rbx
	movq	%rbx, %rdi
	callq	hipEventCreate
	movq	-8(%rbx), %rdi
.Ltmp15:
	xorl	%r15d, %r15d
	xorl	%esi, %esi
	callq	hipEventRecord
.Ltmp16:
# %bb.1:                                # %_ZN8GpuTimer5StartEv.exit
	leal	-1(%r12), %eax
	cltd
	movl	%ebp, 20(%rsp)                  # 4-byte Spill
	idivl	%ebp
	movq	%r12, %rbp
	movl	%eax, %r12d
	shll	$4, %eax
	addl	$16, %eax
	movslq	%eax, %r13
	shlq	$2, %r13
	movq	%r13, %rdi
	callq	malloc
	movq	%rax, %rbx
	movq	%r13, 80(%rsp)                  # 8-byte Spill
	movq	%r13, %rdi
	callq	malloc
	movq	%rax, 56(%rsp)                  # 8-byte Spill
	movq	%rbp, 64(%rsp)                  # 8-byte Spill
	movslq	%ebp, %r13
	shlq	$2, %r13
	movq	%r13, %rdi
	callq	malloc
	movq	%rax, %rbp
	movq	%rax, %rdi
	movq	24(%rsp), %rsi                  # 8-byte Reload
	movq	%r13, 72(%rsp)                  # 8-byte Spill
	movq	%r13, %rdx
	callq	memcpy@PLT
	leal	1(%r12), %r13d
	shlq	$6, %r13
	movq	%r14, 24(%rsp)                  # 8-byte Spill
	movq	%r14, %rax
.LBB8_2:                                # =>This Loop Header: Depth=1
                                        #     Child Loop BB8_4 Depth 2
                                        #       Child Loop BB8_6 Depth 3
	movq	%rax, %r14
	movq	%rbx, %rdi
	xorl	%esi, %esi
	movq	80(%rsp), %rdx                  # 8-byte Reload
	callq	memset@PLT
.Ltmp18:
	movq	%rbp, %rdi
	movq	64(%rsp), %rsi                  # 8-byte Reload
                                        # kill: def $esi killed $esi killed $rsi
	movq	%rbx, %rdx
	movl	$16, %ecx
	movl	%r15d, %r8d
	movl	20(%rsp), %r9d                  # 4-byte Reload
	callq	_Z19computeHistByDevicePjiPiiii
.Ltmp19:
# %bb.3:                                # %.preheader.preheader
                                        #   in Loop: Header=BB8_2 Depth=1
	xorl	%eax, %eax
	movq	56(%rsp), %rcx                  # 8-byte Reload
	movq	%rbx, %rdx
	xorl	%esi, %esi
.LBB8_4:                                # %.preheader
                                        #   Parent Loop BB8_2 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB8_6 Depth 3
	testl	%r12d, %r12d
	js	.LBB8_7
# %bb.5:                                # %.lr.ph.preheader
                                        #   in Loop: Header=BB8_4 Depth=2
	xorl	%edi, %edi
.LBB8_6:                                # %.lr.ph
                                        #   Parent Loop BB8_2 Depth=1
                                        #     Parent Loop BB8_4 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movl	%esi, (%rcx,%rdi)
	addl	(%rdx,%rdi), %esi
	addq	$64, %rdi
	cmpq	%rdi, %r13
	jne	.LBB8_6
.LBB8_7:                                # %._crit_edge
                                        #   in Loop: Header=BB8_4 Depth=2
	incq	%rax
	addq	$4, %rdx
	addq	$4, %rcx
	cmpq	$16, %rax
	jne	.LBB8_4
# %bb.8:                                #   in Loop: Header=BB8_2 Depth=1
.Ltmp21:
	movl	20(%rsp), %eax                  # 4-byte Reload
	movl	%eax, (%rsp)
	movq	%rbp, %rdi
	movq	%r14, %rsi
	movq	64(%rsp), %rdx                  # 8-byte Reload
                                        # kill: def $edx killed $edx killed $rdx
	movq	56(%rsp), %rcx                  # 8-byte Reload
	movl	$16, %r8d
	movl	%r15d, %r9d
	callq	_Z15scatterByDevicePjS_iPiiii
.Ltmp22:
# %bb.9:                                #   in Loop: Header=BB8_2 Depth=1
	leal	4(%r15), %ecx
	movq	%rbp, %rax
	movq	%r14, %rbp
	cmpl	$28, %r15d
	movl	%ecx, %r15d
	jb	.LBB8_2
# %bb.10:
	movq	24(%rsp), %rdi                  # 8-byte Reload
	movq	%r14, %rsi
	movq	72(%rsp), %rdx                  # 8-byte Reload
	callq	memcpy@PLT
	movq	40(%rsp), %rdi
.Ltmp24:
	xorl	%esi, %esi
	callq	hipEventRecord
.Ltmp25:
# %bb.11:                               # %_ZN8GpuTimer4StopEv.exit
	movq	40(%rsp), %rdi
.Ltmp26:
	callq	hipEventSynchronize
.Ltmp27:
# %bb.12:                               # %.noexc
	movq	32(%rsp), %rsi
	movq	40(%rsp), %rdx
.Ltmp28:
	leaq	52(%rsp), %rdi
	callq	hipEventElapsedTime
.Ltmp29:
# %bb.13:
	cvtss2sd	52(%rsp), %xmm0
	movl	$.L.str.6, %edi
	movb	$1, %al
	callq	printf
	leaq	32(%rsp), %rdi
	callq	_ZN8GpuTimerD2Ev
	addq	$88, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.LBB8_16:
	.cfi_def_cfa_offset 144
.Ltmp17:
	jmp	.LBB8_15
.LBB8_14:
.Ltmp30:
	jmp	.LBB8_15
.LBB8_17:
.Ltmp23:
	jmp	.LBB8_15
.LBB8_18:
.Ltmp20:
.LBB8_15:
	movq	%rax, %rbx
	leaq	32(%rsp), %rdi
	callq	_ZN8GpuTimerD2Ev
	movq	%rbx, %rdi
	callq	_Unwind_Resume@PLT
.Lfunc_end8:
	.size	_Z15sortByDeviceLv1PKjPjii, .Lfunc_end8-_Z15sortByDeviceLv1PKjPjii
	.cfi_endproc
	.section	.gcc_except_table,"a",@progbits
	.p2align	2, 0x0
GCC_except_table8:
.Lexception2:
	.byte	255                             # @LPStart Encoding = omit
	.byte	255                             # @TType Encoding = omit
	.byte	1                               # Call site Encoding = uleb128
	.uleb128 .Lcst_end2-.Lcst_begin2
.Lcst_begin2:
	.uleb128 .Lfunc_begin2-.Lfunc_begin2    # >> Call Site 1 <<
	.uleb128 .Ltmp15-.Lfunc_begin2          #   Call between .Lfunc_begin2 and .Ltmp15
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp15-.Lfunc_begin2          # >> Call Site 2 <<
	.uleb128 .Ltmp16-.Ltmp15                #   Call between .Ltmp15 and .Ltmp16
	.uleb128 .Ltmp17-.Lfunc_begin2          #     jumps to .Ltmp17
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp16-.Lfunc_begin2          # >> Call Site 3 <<
	.uleb128 .Ltmp18-.Ltmp16                #   Call between .Ltmp16 and .Ltmp18
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp18-.Lfunc_begin2          # >> Call Site 4 <<
	.uleb128 .Ltmp19-.Ltmp18                #   Call between .Ltmp18 and .Ltmp19
	.uleb128 .Ltmp20-.Lfunc_begin2          #     jumps to .Ltmp20
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp21-.Lfunc_begin2          # >> Call Site 5 <<
	.uleb128 .Ltmp22-.Ltmp21                #   Call between .Ltmp21 and .Ltmp22
	.uleb128 .Ltmp23-.Lfunc_begin2          #     jumps to .Ltmp23
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp22-.Lfunc_begin2          # >> Call Site 6 <<
	.uleb128 .Ltmp24-.Ltmp22                #   Call between .Ltmp22 and .Ltmp24
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp24-.Lfunc_begin2          # >> Call Site 7 <<
	.uleb128 .Ltmp29-.Ltmp24                #   Call between .Ltmp24 and .Ltmp29
	.uleb128 .Ltmp30-.Lfunc_begin2          #     jumps to .Ltmp30
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp29-.Lfunc_begin2          # >> Call Site 8 <<
	.uleb128 .Lfunc_end8-.Ltmp29            #   Call between .Ltmp29 and .Lfunc_end8
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
.Lcst_end2:
	.p2align	2, 0x0
                                        # -- End function
	.text
	.globl	_Z15printDeviceInfov            # -- Begin function _Z15printDeviceInfov
	.type	_Z15printDeviceInfov,@function
_Z15printDeviceInfov:                   # @_Z15printDeviceInfov
	.cfi_startproc
# %bb.0:
	pushq	%r14
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	subq	$1480, %rsp                     # imm = 0x5C8
	.cfi_def_cfa_offset 1504
	.cfi_offset %rbx, -24
	.cfi_offset %r14, -16
	leaq	8(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipGetDevicePropertiesR0600
	testl	%eax, %eax
	jne	.LBB9_2
# %bb.1:
	movl	$.Lstr, %edi
	callq	puts@PLT
	leaq	8(%rsp), %rbx
	movl	$.L.str.8, %edi
	movq	%rbx, %rsi
	xorl	%eax, %eax
	callq	printf
	movl	360(%rbx), %esi
	movl	364(%rbx), %edx
	movl	$.L.str.9, %edi
	xorl	%eax, %eax
	callq	printf
	movl	388(%rbx), %esi
	movl	$.L.str.10, %edi
	xorl	%eax, %eax
	callq	printf
	movl	624(%rbx), %esi
	movl	$.L.str.11, %edi
	xorl	%eax, %eax
	callq	printf
	movl	624(%rbx), %eax
	cltd
	idivl	308(%rbx)
	movl	$.L.str.12, %edi
	movl	%eax, %esi
	xorl	%eax, %eax
	callq	printf
	movq	288(%rbx), %rsi
	movl	$.L.str.13, %edi
	xorl	%eax, %eax
	callq	printf
	movq	640(%rbx), %rsi
	movl	$.L.str.14, %edi
	xorl	%eax, %eax
	callq	printf
	movq	296(%rbx), %rsi
	movl	$.L.str.15, %edi
	xorl	%eax, %eax
	callq	printf
	movl	$.Lstr.1, %edi
	callq	puts@PLT
	addq	$1480, %rsp                     # imm = 0x5C8
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	retq
.LBB9_2:
	.cfi_def_cfa_offset 1504
	movl	%eax, %ebx
	movq	stderr(%rip), %rdi
	movl	$.L.str.3, %esi
	movl	$.L.str.4, %edx
	movl	$273, %ecx                      # imm = 0x111
	xorl	%eax, %eax
	callq	fprintf
	movq	stderr(%rip), %r14
	movl	%ebx, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movq	%r14, %rdi
	movl	%ebx, %edx
	movq	%rax, %rcx
	xorl	%eax, %eax
	callq	fprintf
	movl	$1, %edi
	callq	exit
.Lfunc_end9:
	.size	_Z15printDeviceInfov, .Lfunc_end9-_Z15printDeviceInfov
	.cfi_endproc
                                        # -- End function
	.globl	main                            # -- Begin function main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	pushq	%rax
	.cfi_def_cfa_offset 64
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rsi, %r12
	movl	%edi, %ebp
	callq	_Z15printDeviceInfov
	xorl	%r13d, %r13d
	movl	$.L.str.17, %edi
	movl	$16777217, %esi                 # imm = 0x1000001
	xorl	%eax, %eax
	callq	printf
	movl	$67108868, %edi                 # imm = 0x4000004
	callq	malloc
	movq	%rax, %rbx
	movl	$67108868, %edi                 # imm = 0x4000004
	callq	malloc
	movq	%rax, %r14
	movl	$67108868, %edi                 # imm = 0x4000004
	callq	malloc
	movq	%rax, %r15
.LBB10_1:                               # =>This Inner Loop Header: Depth=1
	callq	rand
	movl	%eax, (%rbx,%r13,4)
	incq	%r13
	cmpq	$16777217, %r13                 # imm = 0x1000001
	jne	.LBB10_1
# %bb.2:
	movl	$512, %r13d                     # imm = 0x200
	cmpl	$2, %ebp
	jne	.LBB10_4
# %bb.3:
	movq	8(%r12), %rdi
	callq	atoi
	movl	%eax, %r13d
.LBB10_4:
	movq	%rbx, %rdi
	movq	%r15, %rsi
	movl	$16777217, %edx                 # imm = 0x1000001
	callq	_Z10sortByHostPKjPji
	movq	%rbx, %rdi
	movq	%r14, %rsi
	movl	$16777217, %edx                 # imm = 0x1000001
	movl	%r13d, %ecx
	callq	_Z15sortByDeviceLv1PKjPjii
	movq	%r14, %rdi
	movq	%r15, %rsi
	movl	$16777217, %edx                 # imm = 0x1000001
	callq	_Z17checkCorrectInt32PjS_i
	testb	%al, %al
	jne	.LBB10_6
# %bb.5:
	movl	$.Lstr.2, %edi
	callq	puts@PLT
.LBB10_6:
	movq	%rbx, %rdi
	callq	free
	movq	%r14, %rdi
	callq	free
	movq	%r15, %rdi
	callq	free
	xorl	%eax, %eax
	addq	$8, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end10:
	.size	main, .Lfunc_end10-main
	.cfi_endproc
                                        # -- End function
	.section	.text.__clang_call_terminate,"axG",@progbits,__clang_call_terminate,comdat
	.hidden	__clang_call_terminate          # -- Begin function __clang_call_terminate
	.weak	__clang_call_terminate
	.type	__clang_call_terminate,@function
__clang_call_terminate:                 # @__clang_call_terminate
	.cfi_startproc
# %bb.0:
	pushq	%rax
	.cfi_def_cfa_offset 16
	callq	__cxa_begin_catch
	callq	_ZSt9terminatev
.Lfunc_end11:
	.size	__clang_call_terminate, .Lfunc_end11-__clang_call_terminate
	.cfi_endproc
                                        # -- End function
	.text
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$32, %rsp
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -16
	movq	__hip_gpubin_handle(%rip), %rbx
	testq	%rbx, %rbx
	jne	.LBB12_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB12_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z11computeHistPjiPiii, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z7scatterPjS_iPiii, %esi
	movl	$.L__unnamed_2, %edx
	movl	$.L__unnamed_2, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$__hip_module_dtor, %edi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end12:
	.size	__hip_module_ctor, .Lfunc_end12-__hip_module_ctor
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_dtor
	.type	__hip_module_dtor,@function
__hip_module_dtor:                      # @__hip_module_dtor
	.cfi_startproc
# %bb.0:
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	je	.LBB13_2
# %bb.1:
	pushq	%rax
	.cfi_def_cfa_offset 16
	callq	__hipUnregisterFatBinary
	movq	$0, __hip_gpubin_handle(%rip)
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
.LBB13_2:
	retq
.Lfunc_end13:
	.size	__hip_module_dtor, .Lfunc_end13-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"%d\n"
	.size	.L.str, 4

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"%d >< %d\n"
	.size	.L.str.1, 10

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"Time of sortByHost: %.3f ms\n\n"
	.size	.L.str.2, 30

	.type	_Z11computeHistPjiPiii,@object  # @_Z11computeHistPjiPiii
	.section	.rodata,"a",@progbits
	.globl	_Z11computeHistPjiPiii
	.p2align	3, 0x0
_Z11computeHistPjiPiii:
	.quad	_Z26__device_stub__computeHistPjiPiii
	.size	_Z11computeHistPjiPiii, 8

	.type	.L.str.3,@object                # @.str.3
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.3:
	.asciz	"Error: %s:%d, "
	.size	.L.str.3, 15

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"/home/ubuntu/Datasets/stackv2/train-structured-repos-hip-sm89/TruongNgocTai/GPU_finalProject/master/final_v01.hip"
	.size	.L.str.4, 114

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"code: %d, reason: %s\n"
	.size	.L.str.5, 22

	.type	_Z7scatterPjS_iPiii,@object     # @_Z7scatterPjS_iPiii
	.section	.rodata,"a",@progbits
	.globl	_Z7scatterPjS_iPiii
	.p2align	3, 0x0
_Z7scatterPjS_iPiii:
	.quad	_Z22__device_stub__scatterPjS_iPiii
	.size	_Z7scatterPjS_iPiii, 8

	.type	.L.str.6,@object                # @.str.6
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.6:
	.asciz	"Time of sortByDevice: %.3f ms\n\n"
	.size	.L.str.6, 32

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"Name: %s\n"
	.size	.L.str.8, 10

	.type	.L.str.9,@object                # @.str.9
.L.str.9:
	.asciz	"Compute capability: %d.%d\n"
	.size	.L.str.9, 27

	.type	.L.str.10,@object               # @.str.10
.L.str.10:
	.asciz	"Num SMs: %d\n"
	.size	.L.str.10, 13

	.type	.L.str.11,@object               # @.str.11
.L.str.11:
	.asciz	"Max num threads per SM: %d\n"
	.size	.L.str.11, 28

	.type	.L.str.12,@object               # @.str.12
.L.str.12:
	.asciz	"Max num warps per SM: %d\n"
	.size	.L.str.12, 26

	.type	.L.str.13,@object               # @.str.13
.L.str.13:
	.asciz	"GMEM: %zu byte\n"
	.size	.L.str.13, 16

	.type	.L.str.14,@object               # @.str.14
.L.str.14:
	.asciz	"SMEM per SM: %zu byte\n"
	.size	.L.str.14, 23

	.type	.L.str.15,@object               # @.str.15
.L.str.15:
	.asciz	"SMEM per block: %zu byte\n"
	.size	.L.str.15, 26

	.type	.L.str.17,@object               # @.str.17
.L.str.17:
	.asciz	"Input size: %d\n\n"
	.size	.L.str.17, 17

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z11computeHistPjiPiii"
	.size	.L__unnamed_1, 23

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z7scatterPjS_iPiii"
	.size	.L__unnamed_2, 20

	.type	__hip_fatbin_wrapper,@object    # @__hip_fatbin_wrapper
	.section	.hipFatBinSegment,"a",@progbits
	.p2align	3, 0x0
__hip_fatbin_wrapper:
	.long	1212764230                      # 0x48495046
	.long	1                               # 0x1
	.quad	__hip_fatbin
	.quad	0
	.size	__hip_fatbin_wrapper, 24

	.type	__hip_gpubin_handle,@object     # @__hip_gpubin_handle
	.local	__hip_gpubin_handle
	.comm	__hip_gpubin_handle,8,8
	.section	.init_array,"aw",@init_array
	.p2align	3, 0x0
	.quad	__hip_module_ctor
	.type	__hip_cuid_,@object             # @__hip_cuid_
	.bss
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               # 0x0
	.size	__hip_cuid_, 1

	.type	.Lstr,@object                   # @str
	.section	.rodata.str1.1,"aMS",@progbits,1
.Lstr:
	.asciz	"**********GPU info**********"
	.size	.Lstr, 29

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"****************************\n"
	.size	.Lstr.1, 30

	.type	.Lstr.2,@object                 # @str.2
.Lstr.2:
	.asciz	"sortByDevice is INCORRECT!\n"
	.size	.Lstr.2, 28

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __gxx_personality_v0
	.addrsig_sym _Z26__device_stub__computeHistPjiPiii
	.addrsig_sym _Z22__device_stub__scatterPjS_iPiii
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Unwind_Resume
	.addrsig_sym _Z11computeHistPjiPiii
	.addrsig_sym _Z7scatterPjS_iPiii
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z11computeHistPjiPiii  ; -- Begin function _Z11computeHistPjiPiii
	.globl	_Z11computeHistPjiPiii
	.p2align	8
	.type	_Z11computeHistPjiPiii,@function
_Z11computeHistPjiPiii:                 ; @_Z11computeHistPjiPiii
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x2c
	s_load_b32 s3, s[0:1], 0x8
	s_waitcnt lgkmcnt(0)
	s_and_b32 s2, s2, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s15, s2, v[0:1]
	s_mov_b32 s2, exec_lo
	v_cmpx_gt_i32_e64 s3, v1
	s_cbranch_execz .LBB0_2
; %bb.1:
	s_load_b64 s[4:5], s[0:1], 0x0
	v_ashrrev_i32_e32 v2, 31, v1
	s_load_b128 s[0:3], s[0:1], 0x10
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[0:1], 2, v[1:2]
	s_waitcnt lgkmcnt(0)
	v_add_co_u32 v0, vcc_lo, s4, v0
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v1, vcc_lo, s5, v1, vcc_lo
	global_load_b32 v0, v[0:1], off
	s_waitcnt vmcnt(0)
	v_lshrrev_b32_e32 v0, s3, v0
	s_add_i32 s3, s2, -1
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	v_and_b32_e32 v0, s3, v0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s15, s2, v[0:1]
	v_ashrrev_i32_e32 v2, 31, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_lshlrev_b64 v[0:1], 2, v[1:2]
	v_mov_b32_e32 v2, 1
	v_add_co_u32 v0, vcc_lo, s0, v0
	s_delay_alu instid0(VALU_DEP_3)
	v_add_co_ci_u32_e32 v1, vcc_lo, s1, v1, vcc_lo
	global_atomic_add_u32 v[0:1], v2, off
.LBB0_2:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z11computeHistPjiPiii
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 288
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 3
		.amdhsa_next_free_sgpr 16
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end0:
	.size	_Z11computeHistPjiPiii, .Lfunc_end0-_Z11computeHistPjiPiii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 208
; NumSgprs: 18
; NumVgprs: 3
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 3
; Occupancy: 16
; WaveLimiterHint : 1
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.protected	_Z7scatterPjS_iPiii     ; -- Begin function _Z7scatterPjS_iPiii
	.globl	_Z7scatterPjS_iPiii
	.p2align	8
	.type	_Z7scatterPjS_iPiii,@function
_Z7scatterPjS_iPiii:                    ; @_Z7scatterPjS_iPiii
; %bb.0:
	s_load_b32 s2, s[0:1], 0x34
	v_cmp_eq_u32_e32 vcc_lo, 0, v0
	s_waitcnt lgkmcnt(0)
	s_and_b32 s12, s2, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(SALU_CYCLE_1)
	s_cmp_lg_u32 s12, 0
	s_cselect_b32 s2, -1, 0
	s_and_b32 s2, vcc_lo, s2
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_saveexec_b32 s3, s2
	s_cbranch_execz .LBB1_5
; %bb.1:                                ; %.lr.ph
	s_clause 0x2
	s_load_b128 s[4:7], s[0:1], 0x18
	s_load_b128 s[8:11], s[0:1], 0x0
	s_load_b32 s13, s[0:1], 0x10
	s_mul_i32 s0, s15, s12
	v_mov_b32_e32 v0, 0
	s_ashr_i32 s1, s0, 31
	s_delay_alu instid0(SALU_CYCLE_1)
	s_lshl_b64 s[2:3], s[0:1], 2
	s_waitcnt lgkmcnt(0)
	s_add_i32 s1, s6, -1
	s_add_u32 s2, s8, s2
	s_mul_i32 s15, s15, s6
	s_addc_u32 s3, s9, s3
.LBB1_2:                                ; =>This Inner Loop Header: Depth=1
	s_cmp_ge_i32 s0, s13
	s_cbranch_scc1 .LBB1_4
; %bb.3:                                ;   in Loop: Header=BB1_2 Depth=1
	global_load_b32 v3, v0, s[2:3]
	s_waitcnt vmcnt(0)
	v_readfirstlane_b32 s6, v3
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_lshr_b32 s6, s6, s7
	s_and_b32 s6, s6, s1
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_add_i32 s8, s6, s15
	s_ashr_i32 s9, s8, 31
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_lshl_b64 s[8:9], s[8:9], 2
	s_add_u32 s8, s4, s8
	s_addc_u32 s9, s5, s9
	global_load_b32 v1, v0, s[8:9]
	s_waitcnt vmcnt(0)
	v_ashrrev_i32_e32 v2, 31, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[1:2], 2, v[1:2]
	v_add_co_u32 v1, vcc_lo, s10, v1
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v2, vcc_lo, s11, v2, vcc_lo
	global_store_b32 v[1:2], v3, off
	global_load_b32 v1, v0, s[8:9]
	s_waitcnt vmcnt(0)
	v_add_nc_u32_e32 v1, 1, v1
	global_store_b32 v0, v1, s[8:9]
.LBB1_4:                                ;   in Loop: Header=BB1_2 Depth=1
	s_add_i32 s12, s12, -1
	s_add_u32 s2, s2, 4
	s_addc_u32 s3, s3, 0
	s_add_i32 s0, s0, 1
	s_cmp_lg_u32 s12, 0
	s_cbranch_scc1 .LBB1_2
.LBB1_5:                                ; %.loopexit
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z7scatterPjS_iPiii
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 296
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 4
		.amdhsa_next_free_sgpr 16
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end1:
	.size	_Z7scatterPjS_iPiii, .Lfunc_end1-_Z7scatterPjS_iPiii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 296
; NumSgprs: 18
; NumVgprs: 4
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 4
; Occupancy: 16
; WaveLimiterHint : 1
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_
	.amdgpu_metadata
---
amdhsa.kernels:
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .offset:         8
        .size:           4
        .value_kind:     by_value
      - .address_space:  global
        .offset:         16
        .size:           8
        .value_kind:     global_buffer
      - .offset:         24
        .size:           4
        .value_kind:     by_value
      - .offset:         28
        .size:           4
        .value_kind:     by_value
      - .offset:         32
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         36
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         40
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         44
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         46
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         48
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         50
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         52
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         54
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         88
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         96
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 288
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z11computeHistPjiPiii
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z11computeHistPjiPiii.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     3
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .offset:         16
        .size:           4
        .value_kind:     by_value
      - .address_space:  global
        .offset:         24
        .size:           8
        .value_kind:     global_buffer
      - .offset:         32
        .size:           4
        .value_kind:     by_value
      - .offset:         36
        .size:           4
        .value_kind:     by_value
      - .offset:         40
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         44
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         48
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         52
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         54
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         56
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         58
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         60
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         62
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         88
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         96
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         104
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 296
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z7scatterPjS_iPiii
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z7scatterPjS_iPiii.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     4
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
