#include <stdio.h>
#include <iostream>
#include <math.h>
#include "cuda.h"
#include <time.h>

#define BLOCK_DIM 16

__global__ void computeDistance(float* A, int wA, int pA, float* B, int wB, int pB, int dim,  float* AB) {

    // Declaration of the shared memory arrays As and Bs used to store the sub-matrix of A and B
    // They will contain, for each thread, the current coordinates of A and B - block_dim in each step
	__shared__ float shared_A[BLOCK_DIM][BLOCK_DIM];
	__shared__ float shared_B[BLOCK_DIM][BLOCK_DIM];

    // Sub-matrix of A (begin, step, end) and sub-matrix of B (begin, step)
    __shared__ int begin_A;
    __shared__ int begin_B;
    __shared__ int step_A;
    __shared__ int step_B;
    __shared__ int end_A;
	
    // Thread index
    int tx = threadIdx.x;   // Local query point index
    int ty = threadIdx.y;   // Local ref point index
	
	// Other variables
	float tmp;
    float ssd = 0;
	
    // Loop parameters
    begin_A = BLOCK_DIM * blockIdx.y;   // Each block has its own start on ref points
    begin_B = BLOCK_DIM * blockIdx.x; // Each block has its own start on query points
    step_A  = BLOCK_DIM * pA; // next step = next row of the big matrix
    step_B  = BLOCK_DIM * pB;
    end_A   = begin_A + (dim-1) * pA; // Each submatrix treated by given block has BLOCK_DIM columns and dim rows
    
    // Conditions
	int cond0 = (begin_A + tx < wA); // current column is out of A
    int cond1 = (begin_B + tx < wB); // current column is out of B
    int cond2 = (begin_A + ty < wA); // ty is column number in A
    
    // Loop over all the sub-matrices of A and B required to compute the block sub-matrix
    for (int a = begin_A, b = begin_B; a <= end_A; a += step_A, b += step_B) {
        
        // Load the matrices from device memory to shared memory; each thread loads one element of each matrix
        // ty corresponds to row, tx to column in the resulting matrix, as well as ref and query points in input, 
        // but when copying to local memory, they work just as numbers for indeces (tx is column number in both cases)
        // a/pA + ty is the row number in A corresponding to this thread in this block
        if (a/pA + ty < dim){
            shared_A[ty][tx] = (cond0)? A[a + pA * ty + tx] : 0;
            shared_B[ty][tx] = (cond1)? B[b + pB * ty + tx] : 0; 
        }
        else {
            shared_A[ty][tx] = 0;
            shared_B[ty][tx] = 0;
        }
        
        // Synchronize to make sure the matrices are loaded
        __syncthreads();
        
        // Compute the difference between the two matrixes; each thread computes one element of the block sub-matrix
        if (cond2 && cond1) {
            for (int k = 0; k < BLOCK_DIM; ++k){
				tmp = shared_A[k][ty] - shared_B[k][tx];
                ssd += tmp*tmp;
			}
        }
        
        // Synchronize to make sure that the preceding computation is done before loading two new sub-matrices of A and B in the next iteration
        __syncthreads();
    }
    
    // Write the block sub-matrix to device memory; each thread writes one element
    if(cond2 && cond1)
        AB[ (begin_A + ty) * pB + begin_B + tx ] = ssd;

}

// Selection sort
__global__ void sort(float *dist, int *ind, int width, int pitch, int ind_pitch, int height, int k){

	// Variables
    int l, i, min_index;
    float *p_dist;
    int *p_ind;
    float min_value, tmp;
    // xIndex is column in the sorted matrix
    unsigned int xIndex = blockIdx.x * blockDim.x + threadIdx.x;
	
    if (xIndex < width) {
        
        p_dist      = dist+xIndex;
        p_ind       = ind+xIndex;
        min_value = *p_dist;
        
        for (l = 0; l < k; l++) {
            min_index = l;
            min_value = *(p_dist+l*pitch);
            for (i=l+1; i < height; i++) {
                if (*(p_dist+i*pitch) < min_value) {
                    min_index = i;
                    min_value = *(p_dist+i*pitch);
                }
            } 

            if (min_index != l) {
                tmp = *(p_dist+min_index*pitch);
                *(p_dist+min_index*pitch) = *(p_dist+l*pitch);
                *(p_dist+l*pitch) = tmp;
            }
            p_ind[l*ind_pitch] = min_index;
        }
   }
}

__global__ void parallelSqrt(float *dist, int width, int pitch, int k) {
    unsigned int xIndex = blockIdx.x * blockDim.x + threadIdx.x;
    unsigned int yIndex = blockIdx.y * blockDim.y + threadIdx.y;
    if (xIndex<width && yIndex<k)
        dist[yIndex*pitch + xIndex] = sqrt(dist[yIndex*pitch + xIndex]);
}


// Compute the mean of the first k elements
__global__ void mean(float *dist, int width, int pitch, float *res, int k) {
    
    float sum;
    float *p;
    unsigned int xIndex = blockIdx.x * blockDim.x + threadIdx.x;
	
    if (xIndex < width) {
        sum = 0;
        p = dist + xIndex;
        for (int l = 0; l < k*pitch; l += pitch) sum += *(p+l); 
        res[xIndex] = sum/k;
    }
}

void printErrorMessage(cudaError_t error, int memorySize){
    printf("==================================================\n");
    printf("MEMORY ALLOCATION ERROR  : %s\n", cudaGetErrorString(error));
    printf("Wished allocated memory : %d\n", memorySize);
    printf("==================================================\n");
}

void knn(float* ref_host, int ref_width, float* query_host, int query_width, int height, int k, float* dist_host, float* res_host, int *ind_host) {

    // Initialize variables
    float *ref_dev;
    float *query_dev;
    float *dist_dev;
    int   *ind_dev;
    float *res_dev;

    size_t ref_pitch_in_bytes;
    size_t query_pitch_in_bytes;
    size_t res_pitch_in_bytes;
    size_t ind_pitch_in_bytes;
    size_t dist_pitch_in_bytes;
    size_t ref_pitch;
    size_t query_pitch;
    // size_t res_pitch;
    size_t ind_pitch;
    cudaError_t  result;

    // Allocate device memory
    result = cudaMallocPitch((void **) &ref_dev,     &ref_pitch_in_bytes,    ref_width * sizeof(float), height);
    if (result){
        cudaFree(ref_dev);
        printErrorMessage(result, ref_width*sizeof(float)*height);
        return;
    }
    result = cudaMallocPitch((void **) &query_dev,   &query_pitch_in_bytes,  query_width*sizeof(float), height);
    if (result){
        cudaFree(query_dev);
        printErrorMessage(result, query_width*sizeof(float)*k);
        return;
    }
    result = cudaMallocPitch((void **) &dist_dev,    &dist_pitch_in_bytes,  query_width*sizeof(float), ref_width);
    if (result){
        cudaFree(dist_dev);
        printErrorMessage(result, query_width*sizeof(float)*ref_width);
        return;
    }
    result = cudaMallocPitch((void **) &ind_dev,     &ind_pitch_in_bytes,    query_width*sizeof(int),   k);
    if (result){
        cudaFree(ind_dev);
        printErrorMessage(result, query_width*sizeof(int)*k);
        return;
    }
    result = cudaMallocPitch((void **) &res_dev,     &res_pitch_in_bytes,    query_width*sizeof(float), 1);
    if (result){
        cudaFree(res_dev);
        printErrorMessage(result, query_width*sizeof(float));
        return;
    }

    // Copy reference and query points to global memory
    cudaMemcpy2D(ref_dev,   ref_pitch_in_bytes,     ref_host,   ref_width*sizeof(float),    ref_width*sizeof(float),    height, cudaMemcpyHostToDevice);
    cudaMemcpy2D(query_dev, query_pitch_in_bytes,   query_host, query_width*sizeof(float),  query_width*sizeof(float),  height, cudaMemcpyHostToDevice);
    
    // Compute the pitches
    ref_pitch = ref_pitch_in_bytes/sizeof(float); 
    query_pitch = query_pitch_in_bytes/sizeof(float);
    // res_pitch = res_pitch_in_bytes/sizeof(float);
    ind_pitch = ind_pitch_in_bytes/sizeof(int);

    // Set kernel dims
    // Each block has 16x16 threads, and processes 1/16 of ref width
    // It creates a local 16x16 matrix, which goes down the rows
    // The number of blocks depends on nb_ref, threads/block is fixed
    dim3 threads_per_block_2D(BLOCK_DIM, BLOCK_DIM, 1);   
    dim3 threads_per_block_1D(BLOCK_DIM * BLOCK_DIM, 1, 1);

    dim3 blocks_2D(std::ceil((float) query_width/BLOCK_DIM), std::ceil((float) ref_width/BLOCK_DIM), 1);
    dim3 blocks_2D_k(std::ceil((float) query_width/BLOCK_DIM), std::ceil((float) k/BLOCK_DIM), 1);
    dim3 blocks_1D(std::ceil((float) query_width/(BLOCK_DIM*BLOCK_DIM)), 1, 1);

    // Start kernels
    computeDistance<<<blocks_2D, threads_per_block_2D>>>(ref_dev, ref_width, ref_pitch, query_dev, query_width, query_pitch, height, dist_dev);
    sort<<<blocks_1D, threads_per_block_1D>>>(dist_dev, ind_dev, query_width, query_pitch, ind_pitch, ref_width, k);
    // insertionSort<<<blocks_1D, threads_per_block_1D>>>(dist_dev, query_pitch, ind_dev, ind_pitch, query_width, ref_width, k);


    parallelSqrt<<<blocks_2D_k, threads_per_block_2D>>>(dist_dev, query_width, query_pitch, k);
    mean<<<blocks_1D, threads_per_block_1D>>>(dist_dev, query_width, query_pitch, res_dev, k);


    // Copy memory from device to host
    cudaMemcpy2D(res_host, query_width*sizeof(float), res_dev, query_pitch_in_bytes, query_width*sizeof(float), 1, cudaMemcpyDeviceToHost);
    cudaMemcpy2D(dist_host, query_width*sizeof(float), dist_dev, dist_pitch_in_bytes, query_width*sizeof(float),k , cudaMemcpyDeviceToHost);
    cudaMemcpy2D(ind_host, query_width*sizeof(int)   , ind_dev, ind_pitch_in_bytes,   query_width*sizeof(int)  , k, cudaMemcpyDeviceToHost);

    cudaFree(ref_dev); cudaFree(query_dev); cudaFree(res_dev); cudaFree(ind_dev);
}

int main() {
    
    // Initialize variables
    float *ref;
    float *query;
    float *dist;
    float *res;
    int *ind;
    int ref_nb      = 4096;
    int query_nb    = 4096;
    int dim         = 32;
    int k           = 20;

    // Allocate host memory
    ref     = (float *)  malloc(ref_nb   * dim * sizeof(float));
    query   = (float *)  malloc(query_nb * dim * sizeof(float));
    dist    = (float *)  malloc(query_nb * k   * sizeof(float));
    res     = (float *)  malloc(query_nb * 1   * sizeof(float)); // Mean of the first k distances in the sorted matrix
    ind     = (int   *)  malloc(query_nb * k   * sizeof(int));
    
    // Generate random data
    srand(time(NULL));
    for (int i = 0; i<ref_nb * dim; i++)   ref[i]      = (float) (rand() % 100);
    for (int i = 0; i<query_nb * dim; i++) query[i]    = (float) (rand() % 100);

    knn(ref, ref_nb, query, query_nb, dim, k, dist, res, ind);

    for (int j = 0; j < 10; j++) {
        std::cout << "( ";
        for (int i = 0; i < dim; i++) std::cout << query[i*query_nb+j] << " ";
        std::cout << ")" << std::endl;
        std::cout << res[j] << std::endl;
        for (int i = 0; i < k; i++) std::cout << ind[i*query_nb+j] << " ";
        std::cout << std::endl << std::endl;
    }


    for (int i = 0; i < k; i++) {
        for (int j = 0; j < 10; j++) {
            std::cout << dist[i*query_nb + j] << " ";
        }
        std::cout << std::endl;
    }

    free(ref); free(query); free(dist); free(ind);
    return 0;
}

	.file	"tmpxft_0020d3c5_00000000-6_knn_cuda.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB3640:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE3640:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"==================================================\n"
.LC1:
	.string	"MEMORY ALLOCATION ERROR  : %s\n"
.LC2:
	.string	"Wished allocated memory : %d\n"
	.text
	.globl	_Z17printErrorMessage9cudaErrori
	.type	_Z17printErrorMessage9cudaErrori, @function
_Z17printErrorMessage9cudaErrori:
.LFB3635:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	leaq	.LC0(%rip), %r12
	xorl	%eax, %eax
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movl	%edi, %ebp
	movl	$2, %edi
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movl	%esi, %ebx
	movq	%r12, %rsi
	call	__printf_chk@PLT
	movl	%ebp, %edi
	call	cudaGetErrorString@PLT
	leaq	.LC1(%rip), %rsi
	movl	$2, %edi
	movq	%rax, %rdx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	%ebx, %edx
	leaq	.LC2(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	popq	%rbx
	.cfi_def_cfa_offset 24
	movq	%r12, %rsi
	popq	%rbp
	.cfi_def_cfa_offset 16
	movl	$2, %edi
	xorl	%eax, %eax
	popq	%r12
	.cfi_def_cfa_offset 8
	jmp	__printf_chk@PLT
	.cfi_endproc
.LFE3635:
	.size	_Z17printErrorMessage9cudaErrori, .-_Z17printErrorMessage9cudaErrori
	.globl	_Z44__device_stub__Z15computeDistancePfiiS_iiiS_PfiiS_iiiS_
	.type	_Z44__device_stub__Z15computeDistancePfiiS_iiiS_PfiiS_iiiS_, @function
_Z44__device_stub__Z15computeDistancePfiiS_iiiS_PfiiS_iiiS_:
.LFB3662:
	.cfi_startproc
	endbr64
	subq	$200, %rsp
	.cfi_def_cfa_offset 208
	movq	216(%rsp), %rax
	movq	%rdi, 40(%rsp)
	leaq	72(%rsp), %rdi
	movl	%esi, 36(%rsp)
	leaq	84(%rsp), %rsi
	movl	%edx, 32(%rsp)
	leaq	56(%rsp), %rdx
	movq	%rcx, 24(%rsp)
	leaq	64(%rsp), %rcx
	movl	%r8d, 20(%rsp)
	movl	%r9d, 16(%rsp)
	movq	%rax, 8(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 184(%rsp)
	xorl	%eax, %eax
	leaq	40(%rsp), %rax
	movl	$1, 80(%rsp)
	movq	%rax, 120(%rsp)
	leaq	36(%rsp), %rax
	movq	%rax, 128(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 136(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 144(%rsp)
	leaq	20(%rsp), %rax
	movq	%rax, 152(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 160(%rsp)
	leaq	208(%rsp), %rax
	movq	%rax, 168(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 176(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 72(%rsp)
	movq	%rax, 84(%rsp)
	movl	$1, 92(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L4
	pushq	64(%rsp)
	.cfi_def_cfa_offset 216
	leaq	_Z15computeDistancePfiiS_iiiS_(%rip), %rdi
	pushq	64(%rsp)
	.cfi_def_cfa_offset 224
	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 216
	popq	%rdx
	.cfi_def_cfa_offset 208
.L4:
	movq	184(%rsp), %rax
	subq	%fs:40, %rax
	je	.L6
	call	__stack_chk_fail@PLT
.L6:
	addq	$200, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3662:
	.size	_Z44__device_stub__Z15computeDistancePfiiS_iiiS_PfiiS_iiiS_, .-_Z44__device_stub__Z15computeDistancePfiiS_iiiS_PfiiS_iiiS_
	.globl	_Z15computeDistancePfiiS_iiiS_
	.type	_Z15computeDistancePfiiS_iiiS_, @function
_Z15computeDistancePfiiS_iiiS_:
.LFB3663:
	.cfi_startproc
	endbr64
	jmp	_Z44__device_stub__Z15computeDistancePfiiS_iiiS_PfiiS_iiiS_
	.cfi_endproc
.LFE3663:
	.size	_Z15computeDistancePfiiS_iiiS_, .-_Z15computeDistancePfiiS_iiiS_
	.globl	_Z30__device_stub__Z4sortPfPiiiiiiPfPiiiiii
	.type	_Z30__device_stub__Z4sortPfPiiiiiiPfPiiiiii, @function
_Z30__device_stub__Z4sortPfPiiiiiiPfPiiiiii:
.LFB3664:
	.cfi_startproc
	endbr64
	subq	$168, %rsp
	.cfi_def_cfa_offset 176
	movq	%rdi, 24(%rsp)
	leaq	48(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	60(%rsp), %rsi
	movl	%edx, 12(%rsp)
	leaq	32(%rsp), %rdx
	movl	%ecx, 8(%rsp)
	leaq	40(%rsp), %rcx
	movl	%r8d, 4(%rsp)
	movl	%r9d, (%rsp)
	movq	%fs:40, %rax
	movq	%rax, 152(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 56(%rsp)
	movq	%rax, 96(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 104(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 128(%rsp)
	movq	%rsp, %rax
	movq	%rax, 136(%rsp)
	leaq	176(%rsp), %rax
	movq	%rax, 144(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 48(%rsp)
	movq	%rax, 60(%rsp)
	movl	$1, 68(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L10
	pushq	40(%rsp)
	.cfi_def_cfa_offset 184
	leaq	_Z4sortPfPiiiiii(%rip), %rdi
	pushq	40(%rsp)
	.cfi_def_cfa_offset 192
	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 184
	popq	%rdx
	.cfi_def_cfa_offset 176
.L10:
	movq	152(%rsp), %rax
	subq	%fs:40, %rax
	je	.L12
	call	__stack_chk_fail@PLT
.L12:
	addq	$168, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3664:
	.size	_Z30__device_stub__Z4sortPfPiiiiiiPfPiiiiii, .-_Z30__device_stub__Z4sortPfPiiiiiiPfPiiiiii
	.globl	_Z4sortPfPiiiiii
	.type	_Z4sortPfPiiiiii, @function
_Z4sortPfPiiiiii:
.LFB3665:
	.cfi_startproc
	endbr64
	jmp	_Z30__device_stub__Z4sortPfPiiiiiiPfPiiiiii
	.cfi_endproc
.LFE3665:
	.size	_Z4sortPfPiiiiii, .-_Z4sortPfPiiiiii
	.globl	_Z35__device_stub__Z12parallelSqrtPfiiiPfiii
	.type	_Z35__device_stub__Z12parallelSqrtPfiiiPfiii, @function
_Z35__device_stub__Z12parallelSqrtPfiiiPfiii:
.LFB3666:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdi, 24(%rsp)
	leaq	56(%rsp), %rdi
	movl	%esi, 20(%rsp)
	leaq	68(%rsp), %rsi
	movl	%edx, 16(%rsp)
	leaq	40(%rsp), %rdx
	movl	%ecx, 12(%rsp)
	leaq	48(%rsp), %rcx
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 64(%rsp)
	movq	%rax, 104(%rsp)
	leaq	20(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 128(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 56(%rsp)
	movq	%rax, 68(%rsp)
	movl	$1, 76(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L15
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z12parallelSqrtPfiii(%rip), %rdi
	pushq	48(%rsp)
	.cfi_def_cfa_offset 176
	movq	84(%rsp), %rcx
	movl	92(%rsp), %r8d
	movq	72(%rsp), %rsi
	movl	80(%rsp), %edx
	leaq	120(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 168
	popq	%rdx
	.cfi_def_cfa_offset 160
.L15:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L17
	call	__stack_chk_fail@PLT
.L17:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3666:
	.size	_Z35__device_stub__Z12parallelSqrtPfiiiPfiii, .-_Z35__device_stub__Z12parallelSqrtPfiiiPfiii
	.globl	_Z12parallelSqrtPfiii
	.type	_Z12parallelSqrtPfiii, @function
_Z12parallelSqrtPfiii:
.LFB3667:
	.cfi_startproc
	endbr64
	jmp	_Z35__device_stub__Z12parallelSqrtPfiiiPfiii
	.cfi_endproc
.LFE3667:
	.size	_Z12parallelSqrtPfiii, .-_Z12parallelSqrtPfiii
	.globl	_Z28__device_stub__Z4meanPfiiS_iPfiiS_i
	.type	_Z28__device_stub__Z4meanPfiiS_iPfiiS_i, @function
_Z28__device_stub__Z4meanPfiiS_iPfiiS_i:
.LFB3668:
	.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
	movl	%edx, 16(%rsp)
	leaq	32(%rsp), %rdx
	movq	%rcx, 8(%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	16(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	8(%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	.L20
	pushq	40(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z4meanPfiiS_i(%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
.L20:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L22
	call	__stack_chk_fail@PLT
.L22:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3668:
	.size	_Z28__device_stub__Z4meanPfiiS_iPfiiS_i, .-_Z28__device_stub__Z4meanPfiiS_iPfiiS_i
	.globl	_Z4meanPfiiS_i
	.type	_Z4meanPfiiS_i, @function
_Z4meanPfiiS_i:
.LFB3669:
	.cfi_startproc
	endbr64
	jmp	_Z28__device_stub__Z4meanPfiiS_iPfiiS_i
	.cfi_endproc
.LFE3669:
	.size	_Z4meanPfiiS_i, .-_Z4meanPfiiS_i
	.globl	_Z3knnPfiS_iiiS_S_Pi
	.type	_Z3knnPfiS_iiiS_S_Pi, @function
_Z3knnPfiS_iiiS_S_Pi:
.LFB3636:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	%ecx, %r15d
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movslq	%esi, %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	leaq	0(,%r13,4), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%r13, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movl	%r9d, %ebx
	subq	$248, %rsp
	.cfi_def_cfa_offset 304
	movq	304(%rsp), %rax
	movq	%rdi, 40(%rsp)
	leaq	128(%rsp), %rsi
	leaq	88(%rsp), %rdi
	movq	%rdx, 48(%rsp)
	movq	%r12, %rdx
	movq	%rax, 56(%rsp)
	movq	312(%rsp), %rax
	movl	%r8d, 28(%rsp)
	movq	%rax, 64(%rsp)
	movq	320(%rsp), %rax
	movq	%rax, 72(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 232(%rsp)
	xorl	%eax, %eax
	movslq	%r8d, %rax
	movq	%rax, %rcx
	movq	%rax, 16(%rsp)
	call	cudaMallocPitch@PLT
	testl	%eax, %eax
	je	.L26
	movq	88(%rsp), %rdi
	movl	%eax, %r14d
	call	cudaFree@PLT
	movl	28(%rsp), %eax
	imull	%eax, %ebp
	leal	0(,%rbp,4), %esi
	jmp	.L41
.L26:
	movslq	%r15d, %rax
	movq	16(%rsp), %rcx
	leaq	96(%rsp), %rdi
	leaq	136(%rsp), %rsi
	salq	$2, %rax
	movq	%rax, %rdx
	movq	%rax, 8(%rsp)
	call	cudaMallocPitch@PLT
	movl	%eax, %r14d
	testl	%eax, %eax
	je	.L28
	imull	%r15d, %ebx
	movq	96(%rsp), %rdi
	call	cudaFree@PLT
	leal	0(,%rbx,4), %esi
.L41:
	movl	%r14d, %edi
	jmp	.L40
.L28:
	movq	8(%rsp), %rdx
	movq	%r13, %rcx
	leaq	104(%rsp), %rdi
	leaq	160(%rsp), %rsi
	call	cudaMallocPitch@PLT
	movl	%eax, %r13d
	testl	%eax, %eax
	je	.L29
	imull	%r15d, %ebp
	movq	104(%rsp), %rdi
	call	cudaFree@PLT
	leal	0(,%rbp,4), %esi
	jmp	.L39
.L29:
	movslq	%ebx, %rax
	movq	8(%rsp), %rdx
	leaq	112(%rsp), %rdi
	leaq	152(%rsp), %rsi
	movq	%rax, %rcx
	movq	%rax, 32(%rsp)
	call	cudaMallocPitch@PLT
	movl	%eax, %r13d
	testl	%eax, %eax
	je	.L30
	imull	%r15d, %ebx
	movq	112(%rsp), %rdi
	call	cudaFree@PLT
	leal	0(,%rbx,4), %esi
	jmp	.L39
.L30:
	movq	8(%rsp), %rdx
	leaq	120(%rsp), %rdi
	movl	$1, %ecx
	leaq	144(%rsp), %rsi
	call	cudaMallocPitch@PLT
	movl	%eax, %r13d
	testl	%eax, %eax
	je	.L31
	movq	120(%rsp), %rdi
	call	cudaFree@PLT
	leal	0(,%r15,4), %esi
.L39:
	movl	%r13d, %edi
.L40:
	call	_Z17printErrorMessage9cudaErrori
	jmp	.L25
.L31:
	pushq	%r11
	.cfi_def_cfa_offset 312
	movq	%r12, %r8
	movq	%r12, %rcx
	pushq	$1
	.cfi_def_cfa_offset 320
	movq	32(%rsp), %r9
	movq	56(%rsp), %rdx
	movq	144(%rsp), %rsi
	movq	104(%rsp), %rdi
	call	cudaMemcpy2D@PLT
	movq	24(%rsp), %r8
	movq	32(%rsp), %r9
	movl	$1, (%rsp)
	movq	152(%rsp), %rsi
	movq	112(%rsp), %rdi
	movq	64(%rsp), %rdx
	movq	%r8, %rcx
	call	cudaMemcpy2D@PLT
	cvtsi2ssl	%ebp, %xmm0
	mulss	.LC3(%rip), %xmm0
	movq	144(%rsp), %rax
	movq	152(%rsp), %r12
	movq	168(%rsp), %r14
	movabsq	$68719476752, %rdx
	movl	$1, 196(%rsp)
	movq	%rax, 32(%rsp)
	movl	$16777217, %eax
	salq	$8, %rax
	movq	%rdx, 188(%rsp)
	shrq	$2, %r12
	movq	%rax, 200(%rsp)
	movl	$1, 208(%rsp)
	call	ceilf@PLT
	cvtsi2ssl	%r15d, %xmm1
	movss	%xmm0, 64(%rsp)
	movss	.LC3(%rip), %xmm0
	mulss	%xmm1, %xmm0
	movss	%xmm1, 56(%rsp)
	call	ceilf@PLT
	movss	64(%rsp), %xmm2
	cvttss2siq	%xmm0, %r13
	cvtsi2ssl	%ebx, %xmm0
	mulss	.LC3(%rip), %xmm0
	cvttss2siq	%xmm2, %rcx
	movl	%r13d, 212(%rsp)
	movl	%ecx, 216(%rsp)
	call	ceilf@PLT
	movss	56(%rsp), %xmm1
	mulss	.LC4(%rip), %xmm1
	movl	%r13d, 224(%rsp)
	movl	$1, 232(%rsp)
	cvttss2siq	%xmm0, %rax
	movaps	%xmm1, %xmm0
	movl	%eax, 228(%rsp)
	call	ceilf@PLT
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	$1, %ecx
	cvttss2siq	%xmm0, %rax
	movl	$1, %esi
	movabsq	$68719476752, %rdx
	movl	%eax, 236(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 240(%rsp)
	popq	%r13
	.cfi_def_cfa_offset 312
	popq	%rax
	.cfi_def_cfa_offset 304
	movq	196(%rsp), %rdi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L32
	movq	16(%rsp), %rdx
	pushq	104(%rsp)
	.cfi_def_cfa_offset 312
	movl	%r12d, %r9d
	movl	%r15d, %r8d
	movl	36(%rsp), %eax
	movl	%ebp, %esi
	shrq	$2, %rdx
	pushq	%rax
	.cfi_def_cfa_offset 320
	movq	112(%rsp), %rcx
	movq	104(%rsp), %rdi
	call	_Z44__device_stub__Z15computeDistancePfiiS_iiiS_PfiiS_iiiS_
	popq	%r9
	.cfi_def_cfa_offset 312
	popq	%r10
	.cfi_def_cfa_offset 304
.L32:
	movl	192(%rsp), %ecx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movq	184(%rsp), %rdx
	movq	220(%rsp), %rdi
	movl	228(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L33
	pushq	%rsi
	.cfi_def_cfa_offset 312
	shrq	$2, %r14
	movl	%ebp, %r9d
	movl	%r12d, %ecx
	pushq	%rbx
	.cfi_def_cfa_offset 320
	movq	128(%rsp), %rsi
	movq	%r14, %r8
	movl	%r15d, %edx
	movq	120(%rsp), %rdi
	call	_Z30__device_stub__Z4sortPfPiiiiiiPfPiiiiii
	popq	%rdi
	.cfi_def_cfa_offset 312
	popq	%r8
	.cfi_def_cfa_offset 304
.L33:
	movl	180(%rsp), %ecx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movq	172(%rsp), %rdx
	movq	208(%rsp), %rdi
	movl	216(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L34
	movq	104(%rsp), %rdi
	movl	%ebx, %ecx
	movl	%r12d, %edx
	movl	%r15d, %esi
	call	_Z35__device_stub__Z12parallelSqrtPfiiiPfiii
.L34:
	movl	192(%rsp), %ecx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movq	184(%rsp), %rdx
	movq	220(%rsp), %rdi
	movl	228(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L35
	movq	120(%rsp), %rcx
	movq	104(%rsp), %rdi
	movl	%ebx, %r8d
	movl	%r12d, %edx
	movl	%r15d, %esi
	call	_Z28__device_stub__Z4meanPfiiS_iPfiiS_i
.L35:
	pushq	%rax
	.cfi_def_cfa_offset 312
	movl	$1, %r9d
	pushq	$2
	.cfi_def_cfa_offset 320
	movq	24(%rsp), %r8
	movq	152(%rsp), %rcx
	movq	136(%rsp), %rdx
	movq	80(%rsp), %rdi
	movq	%r8, %rsi
	call	cudaMemcpy2D@PLT
	movq	24(%rsp), %r8
	movq	48(%rsp), %r9
	movl	$2, (%rsp)
	movq	176(%rsp), %rcx
	movq	120(%rsp), %rdx
	movq	72(%rsp), %rdi
	movq	%r8, %rsi
	call	cudaMemcpy2D@PLT
	movq	24(%rsp), %r8
	movq	48(%rsp), %r9
	movl	$2, (%rsp)
	movq	88(%rsp), %rdi
	movq	168(%rsp), %rcx
	movq	128(%rsp), %rdx
	movq	%r8, %rsi
	call	cudaMemcpy2D@PLT
	popq	%rdx
	.cfi_def_cfa_offset 312
	popq	%rcx
	.cfi_def_cfa_offset 304
	movq	88(%rsp), %rdi
	call	cudaFree@PLT
	movq	96(%rsp), %rdi
	call	cudaFree@PLT
	movq	120(%rsp), %rdi
	call	cudaFree@PLT
	movq	112(%rsp), %rdi
	call	cudaFree@PLT
.L25:
	movq	232(%rsp), %rax
	subq	%fs:40, %rax
	je	.L37
	call	__stack_chk_fail@PLT
.L37:
	addq	$248, %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
.LFE3636:
	.size	_Z3knnPfiS_iiiS_S_Pi, .-_Z3knnPfiS_iiiS_S_Pi
	.section	.rodata.str1.1
.LC5:
	.string	"( "
.LC6:
	.string	" "
.LC7:
	.string	")"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB3637:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	$524288, %edi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	xorl	%r14d, %r14d
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movl	$100, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	call	malloc@PLT
	movl	$524288, %edi
	movq	%rax, 8(%rsp)
	call	malloc@PLT
	movl	$327680, %edi
	movq	%rax, %rbx
	call	malloc@PLT
	movl	$16384, %edi
	movq	%rax, %r13
	call	malloc@PLT
	movl	$327680, %edi
	movq	%rax, %r15
	call	malloc@PLT
	xorl	%edi, %edi
	movq	%rax, %r12
	call	time@PLT
	movl	%eax, %edi
	call	srand@PLT
.L43:
	call	rand@PLT
	cltd
	idivl	%ebp
	movq	8(%rsp), %rax
	cvtsi2ssl	%edx, %xmm0
	movss	%xmm0, (%rax,%r14,4)
	incq	%r14
	cmpq	$131072, %r14
	jne	.L43
	xorl	%r14d, %r14d
	movl	$100, %ebp
.L44:
	call	rand@PLT
	cltd
	idivl	%ebp
	cvtsi2ssl	%edx, %xmm0
	movss	%xmm0, (%rbx,%r14,4)
	incq	%r14
	cmpq	$131072, %r14
	jne	.L44
	pushq	%rax
	.cfi_def_cfa_offset 104
	movl	$20, %r9d
	movl	$32, %r8d
	movq	%rbx, %rdx
	pushq	%r12
	.cfi_def_cfa_offset 112
	movl	$4096, %ecx
	movl	$4096, %esi
	xorl	%r14d, %r14d
	pushq	%r15
	.cfi_def_cfa_offset 120
	pushq	%r13
	.cfi_def_cfa_offset 128
	movq	40(%rsp), %rdi
	call	_Z3knnPfiS_iiiS_S_Pi
	addq	$32, %rsp
	.cfi_def_cfa_offset 96
.L47:
	leaq	.LC5(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	0(,%r14,4), %rbp
	movl	$32, %edx
	leaq	(%rbx,%rbp), %rcx
.L45:
	leaq	_ZSt4cout(%rip), %rdi
	movl	%edx, 28(%rsp)
	cvtss2sd	(%rcx), %xmm0
	movq	%rcx, 16(%rsp)
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	leaq	.LC6(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	16(%rsp), %rcx
	movl	28(%rsp), %edx
	addq	$16384, %rcx
	decl	%edx
	jne	.L45
	leaq	.LC7(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	addq	%r12, %rbp
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E@PLT
	leaq	_ZSt4cout(%rip), %rdi
	cvtss2sd	(%r15,%r14,4), %xmm0
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E@PLT
	movl	$20, %edx
.L46:
	movl	0(%rbp), %esi
	leaq	_ZSt4cout(%rip), %rdi
	movl	%edx, 16(%rsp)
	addq	$16384, %rbp
	call	_ZNSolsEi@PLT
	leaq	.LC6(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	16(%rsp), %edx
	decl	%edx
	jne	.L46
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	incq	%r14
	call	_ZNSolsEPFRSoS_E@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E@PLT
	cmpq	$10, %r14
	jne	.L47
	xorl	%ebp, %ebp
.L48:
	movq	%rbp, %r14
	xorl	%r15d, %r15d
	salq	$14, %r14
	addq	%r13, %r14
.L49:
	leaq	_ZSt4cout(%rip), %rdi
	cvtss2sd	(%r14,%r15,4), %xmm0
	incq	%r15
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	leaq	.LC6(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	cmpq	$10, %r15
	jne	.L49
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	incq	%rbp
	call	_ZNSolsEPFRSoS_E@PLT
	cmpq	$20, %rbp
	jne	.L48
	movq	8(%rsp), %rdi
	call	free@PLT
	movq	%rbx, %rdi
	call	free@PLT
	movq	%r13, %rdi
	call	free@PLT
	movq	%r12, %rdi
	call	free@PLT
	addq	$40, %rsp
	.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
.LFE3637:
	.size	main, .-main
	.section	.rodata.str1.1
.LC8:
	.string	"_Z4meanPfiiS_i"
.LC9:
	.string	"_Z12parallelSqrtPfiii"
.LC10:
	.string	"_Z4sortPfPiiiiii"
.LC11:
	.string	"_Z15computeDistancePfiiS_iiiS_"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB3671:
	.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	.LC8(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z4meanPfiiS_i(%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	.LC9(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z12parallelSqrtPfiii(%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
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r9d, %r9d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC10(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z4sortPfPiiiiii(%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
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r9d, %r9d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC11(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z15computeDistancePfiiS_iiiS_(%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
.LFE3671:
	.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
	.section	.rodata.cst4,"aM",@progbits,4
	.align 4
.LC3:
	.long	1031798784
	.align 4
.LC4:
	.long	998244352
	.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 <stdio.h>
#include <iostream>
#include <math.h>
#include "hip/hip_runtime.h"
#include <time.h>

#define BLOCK_DIM 16

__global__ void computeDistance(float* A, int wA, int pA, float* B, int wB, int pB, int dim,  float* AB) {

    // Declaration of the shared memory arrays As and Bs used to store the sub-matrix of A and B
    // They will contain, for each thread, the current coordinates of A and B - block_dim in each step
	__shared__ float shared_A[BLOCK_DIM][BLOCK_DIM];
	__shared__ float shared_B[BLOCK_DIM][BLOCK_DIM];

    // Sub-matrix of A (begin, step, end) and sub-matrix of B (begin, step)
    __shared__ int begin_A;
    __shared__ int begin_B;
    __shared__ int step_A;
    __shared__ int step_B;
    __shared__ int end_A;
	
    // Thread index
    int tx = threadIdx.x;   // Local query point index
    int ty = threadIdx.y;   // Local ref point index
	
	// Other variables
	float tmp;
    float ssd = 0;
	
    // Loop parameters
    begin_A = BLOCK_DIM * blockIdx.y;   // Each block has its own start on ref points
    begin_B = BLOCK_DIM * blockIdx.x; // Each block has its own start on query points
    step_A  = BLOCK_DIM * pA; // next step = next row of the big matrix
    step_B  = BLOCK_DIM * pB;
    end_A   = begin_A + (dim-1) * pA; // Each submatrix treated by given block has BLOCK_DIM columns and dim rows
    
    // Conditions
	int cond0 = (begin_A + tx < wA); // current column is out of A
    int cond1 = (begin_B + tx < wB); // current column is out of B
    int cond2 = (begin_A + ty < wA); // ty is column number in A
    
    // Loop over all the sub-matrices of A and B required to compute the block sub-matrix
    for (int a = begin_A, b = begin_B; a <= end_A; a += step_A, b += step_B) {
        
        // Load the matrices from device memory to shared memory; each thread loads one element of each matrix
        // ty corresponds to row, tx to column in the resulting matrix, as well as ref and query points in input, 
        // but when copying to local memory, they work just as numbers for indeces (tx is column number in both cases)
        // a/pA + ty is the row number in A corresponding to this thread in this block
        if (a/pA + ty < dim){
            shared_A[ty][tx] = (cond0)? A[a + pA * ty + tx] : 0;
            shared_B[ty][tx] = (cond1)? B[b + pB * ty + tx] : 0; 
        }
        else {
            shared_A[ty][tx] = 0;
            shared_B[ty][tx] = 0;
        }
        
        // Synchronize to make sure the matrices are loaded
        __syncthreads();
        
        // Compute the difference between the two matrixes; each thread computes one element of the block sub-matrix
        if (cond2 && cond1) {
            for (int k = 0; k < BLOCK_DIM; ++k){
				tmp = shared_A[k][ty] - shared_B[k][tx];
                ssd += tmp*tmp;
			}
        }
        
        // Synchronize to make sure that the preceding computation is done before loading two new sub-matrices of A and B in the next iteration
        __syncthreads();
    }
    
    // Write the block sub-matrix to device memory; each thread writes one element
    if(cond2 && cond1)
        AB[ (begin_A + ty) * pB + begin_B + tx ] = ssd;

}

// Selection sort
__global__ void sort(float *dist, int *ind, int width, int pitch, int ind_pitch, int height, int k){

	// Variables
    int l, i, min_index;
    float *p_dist;
    int *p_ind;
    float min_value, tmp;
    // xIndex is column in the sorted matrix
    unsigned int xIndex = blockIdx.x * blockDim.x + threadIdx.x;
	
    if (xIndex < width) {
        
        p_dist      = dist+xIndex;
        p_ind       = ind+xIndex;
        min_value = *p_dist;
        
        for (l = 0; l < k; l++) {
            min_index = l;
            min_value = *(p_dist+l*pitch);
            for (i=l+1; i < height; i++) {
                if (*(p_dist+i*pitch) < min_value) {
                    min_index = i;
                    min_value = *(p_dist+i*pitch);
                }
            } 

            if (min_index != l) {
                tmp = *(p_dist+min_index*pitch);
                *(p_dist+min_index*pitch) = *(p_dist+l*pitch);
                *(p_dist+l*pitch) = tmp;
            }
            p_ind[l*ind_pitch] = min_index;
        }
   }
}

__global__ void parallelSqrt(float *dist, int width, int pitch, int k) {
    unsigned int xIndex = blockIdx.x * blockDim.x + threadIdx.x;
    unsigned int yIndex = blockIdx.y * blockDim.y + threadIdx.y;
    if (xIndex<width && yIndex<k)
        dist[yIndex*pitch + xIndex] = sqrt(dist[yIndex*pitch + xIndex]);
}


// Compute the mean of the first k elements
__global__ void mean(float *dist, int width, int pitch, float *res, int k) {
    
    float sum;
    float *p;
    unsigned int xIndex = blockIdx.x * blockDim.x + threadIdx.x;
	
    if (xIndex < width) {
        sum = 0;
        p = dist + xIndex;
        for (int l = 0; l < k*pitch; l += pitch) sum += *(p+l); 
        res[xIndex] = sum/k;
    }
}

void printErrorMessage(hipError_t error, int memorySize){
    printf("==================================================\n");
    printf("MEMORY ALLOCATION ERROR  : %s\n", hipGetErrorString(error));
    printf("Wished allocated memory : %d\n", memorySize);
    printf("==================================================\n");
}

void knn(float* ref_host, int ref_width, float* query_host, int query_width, int height, int k, float* dist_host, float* res_host, int *ind_host) {

    // Initialize variables
    float *ref_dev;
    float *query_dev;
    float *dist_dev;
    int   *ind_dev;
    float *res_dev;

    size_t ref_pitch_in_bytes;
    size_t query_pitch_in_bytes;
    size_t res_pitch_in_bytes;
    size_t ind_pitch_in_bytes;
    size_t dist_pitch_in_bytes;
    size_t ref_pitch;
    size_t query_pitch;
    // size_t res_pitch;
    size_t ind_pitch;
    hipError_t  result;

    // Allocate device memory
    result = hipMallocPitch((void **) &ref_dev,     &ref_pitch_in_bytes,    ref_width * sizeof(float), height);
    if (result){
        hipFree(ref_dev);
        printErrorMessage(result, ref_width*sizeof(float)*height);
        return;
    }
    result = hipMallocPitch((void **) &query_dev,   &query_pitch_in_bytes,  query_width*sizeof(float), height);
    if (result){
        hipFree(query_dev);
        printErrorMessage(result, query_width*sizeof(float)*k);
        return;
    }
    result = hipMallocPitch((void **) &dist_dev,    &dist_pitch_in_bytes,  query_width*sizeof(float), ref_width);
    if (result){
        hipFree(dist_dev);
        printErrorMessage(result, query_width*sizeof(float)*ref_width);
        return;
    }
    result = hipMallocPitch((void **) &ind_dev,     &ind_pitch_in_bytes,    query_width*sizeof(int),   k);
    if (result){
        hipFree(ind_dev);
        printErrorMessage(result, query_width*sizeof(int)*k);
        return;
    }
    result = hipMallocPitch((void **) &res_dev,     &res_pitch_in_bytes,    query_width*sizeof(float), 1);
    if (result){
        hipFree(res_dev);
        printErrorMessage(result, query_width*sizeof(float));
        return;
    }

    // Copy reference and query points to global memory
    hipMemcpy2D(ref_dev,   ref_pitch_in_bytes,     ref_host,   ref_width*sizeof(float),    ref_width*sizeof(float),    height, hipMemcpyHostToDevice);
    hipMemcpy2D(query_dev, query_pitch_in_bytes,   query_host, query_width*sizeof(float),  query_width*sizeof(float),  height, hipMemcpyHostToDevice);
    
    // Compute the pitches
    ref_pitch = ref_pitch_in_bytes/sizeof(float); 
    query_pitch = query_pitch_in_bytes/sizeof(float);
    // res_pitch = res_pitch_in_bytes/sizeof(float);
    ind_pitch = ind_pitch_in_bytes/sizeof(int);

    // Set kernel dims
    // Each block has 16x16 threads, and processes 1/16 of ref width
    // It creates a local 16x16 matrix, which goes down the rows
    // The number of blocks depends on nb_ref, threads/block is fixed
    dim3 threads_per_block_2D(BLOCK_DIM, BLOCK_DIM, 1);   
    dim3 threads_per_block_1D(BLOCK_DIM * BLOCK_DIM, 1, 1);

    dim3 blocks_2D(std::ceil((float) query_width/BLOCK_DIM), std::ceil((float) ref_width/BLOCK_DIM), 1);
    dim3 blocks_2D_k(std::ceil((float) query_width/BLOCK_DIM), std::ceil((float) k/BLOCK_DIM), 1);
    dim3 blocks_1D(std::ceil((float) query_width/(BLOCK_DIM*BLOCK_DIM)), 1, 1);

    // Start kernels
    computeDistance<<<blocks_2D, threads_per_block_2D>>>(ref_dev, ref_width, ref_pitch, query_dev, query_width, query_pitch, height, dist_dev);
    sort<<<blocks_1D, threads_per_block_1D>>>(dist_dev, ind_dev, query_width, query_pitch, ind_pitch, ref_width, k);
    // insertionSort<<<blocks_1D, threads_per_block_1D>>>(dist_dev, query_pitch, ind_dev, ind_pitch, query_width, ref_width, k);


    parallelSqrt<<<blocks_2D_k, threads_per_block_2D>>>(dist_dev, query_width, query_pitch, k);
    mean<<<blocks_1D, threads_per_block_1D>>>(dist_dev, query_width, query_pitch, res_dev, k);


    // Copy memory from device to host
    hipMemcpy2D(res_host, query_width*sizeof(float), res_dev, query_pitch_in_bytes, query_width*sizeof(float), 1, hipMemcpyDeviceToHost);
    hipMemcpy2D(dist_host, query_width*sizeof(float), dist_dev, dist_pitch_in_bytes, query_width*sizeof(float),k , hipMemcpyDeviceToHost);
    hipMemcpy2D(ind_host, query_width*sizeof(int)   , ind_dev, ind_pitch_in_bytes,   query_width*sizeof(int)  , k, hipMemcpyDeviceToHost);

    hipFree(ref_dev); hipFree(query_dev); hipFree(res_dev); hipFree(ind_dev);
}

int main() {
    
    // Initialize variables
    float *ref;
    float *query;
    float *dist;
    float *res;
    int *ind;
    int ref_nb      = 4096;
    int query_nb    = 4096;
    int dim         = 32;
    int k           = 20;

    // Allocate host memory
    ref     = (float *)  malloc(ref_nb   * dim * sizeof(float));
    query   = (float *)  malloc(query_nb * dim * sizeof(float));
    dist    = (float *)  malloc(query_nb * k   * sizeof(float));
    res     = (float *)  malloc(query_nb * 1   * sizeof(float)); // Mean of the first k distances in the sorted matrix
    ind     = (int   *)  malloc(query_nb * k   * sizeof(int));
    
    // Generate random data
    srand(time(NULL));
    for (int i = 0; i<ref_nb * dim; i++)   ref[i]      = (float) (rand() % 100);
    for (int i = 0; i<query_nb * dim; i++) query[i]    = (float) (rand() % 100);

    knn(ref, ref_nb, query, query_nb, dim, k, dist, res, ind);

    for (int j = 0; j < 10; j++) {
        std::cout << "( ";
        for (int i = 0; i < dim; i++) std::cout << query[i*query_nb+j] << " ";
        std::cout << ")" << std::endl;
        std::cout << res[j] << std::endl;
        for (int i = 0; i < k; i++) std::cout << ind[i*query_nb+j] << " ";
        std::cout << std::endl << std::endl;
    }


    for (int i = 0; i < k; i++) {
        for (int j = 0; j < 10; j++) {
            std::cout << dist[i*query_nb + j] << " ";
        }
        std::cout << std::endl;
    }

    free(ref); free(query); free(dist); free(ind);
    return 0;
}

	.text
	.file	"knn_cuda.hip"
                                        # Start of file scope inline assembly
	.globl	_ZSt21ios_base_library_initv

                                        # End of file scope inline assembly
	.globl	_Z30__device_stub__computeDistancePfiiS_iiiS_ # -- Begin function _Z30__device_stub__computeDistancePfiiS_iiiS_
	.type	_Z30__device_stub__computeDistancePfiiS_iiiS_,@function
_Z30__device_stub__computeDistancePfiiS_iiiS_: # @_Z30__device_stub__computeDistancePfiiS_iiiS_
	.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	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	12(%rsp), %rdi
	movl	%esi, (%rdi)
	leaq	8(%rsp), %rsi
	movl	%edx, (%rsi)
	leaq	32(%rsp), %rdx
	movq	%rcx, (%rdx)
	leaq	4(%rsp), %rcx
	movl	%r8d, (%rcx)
	movq	%rsp, %r8
	movl	%r9d, (%r8)
	leaq	80(%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	192(%rsp), %rax
	movq	%rax, 48(%rbx)
	leaq	200(%rsp), %rax
	movq	%rax, 56(%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	$_Z15computeDistancePfiiS_iiiS_, %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_end0:
	.size	_Z30__device_stub__computeDistancePfiiS_iiiS_, .Lfunc_end0-_Z30__device_stub__computeDistancePfiiS_iiiS_
	.cfi_endproc
                                        # -- End function
	.globl	_Z19__device_stub__sortPfPiiiiii # -- Begin function _Z19__device_stub__sortPfPiiiiii
	.type	_Z19__device_stub__sortPfPiiiiii,@function
_Z19__device_stub__sortPfPiiiiii:       # @_Z19__device_stub__sortPfPiiiiii
	.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	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	32(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	12(%rsp), %rsi
	movl	%edx, (%rsi)
	leaq	8(%rsp), %rdx
	movl	%ecx, (%rdx)
	leaq	4(%rsp), %rcx
	movl	%r8d, (%rcx)
	movq	%rsp, %r8
	movl	%r9d, (%r8)
	leaq	80(%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	192(%rsp), %rax
	movq	%rax, 48(%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	$_Z4sortPfPiiiiii, %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_end1:
	.size	_Z19__device_stub__sortPfPiiiiii, .Lfunc_end1-_Z19__device_stub__sortPfPiiiiii
	.cfi_endproc
                                        # -- End function
	.globl	_Z27__device_stub__parallelSqrtPfiii # -- Begin function _Z27__device_stub__parallelSqrtPfiii
	.type	_Z27__device_stub__parallelSqrtPfiii,@function
_Z27__device_stub__parallelSqrtPfiii:   # @_Z27__device_stub__parallelSqrtPfiii
	.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	$112, %rsp
	.cfi_def_cfa_offset 160
	.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	20(%rsp), %rdi
	movl	%esi, (%rdi)
	leaq	16(%rsp), %rsi
	movl	%edx, (%rsi)
	leaq	12(%rsp), %rdx
	movl	%ecx, (%rdx)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%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	$_Z12parallelSqrtPfiii, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$128, %rsp
	.cfi_adjust_cfa_offset -128
	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_end2:
	.size	_Z27__device_stub__parallelSqrtPfiii, .Lfunc_end2-_Z27__device_stub__parallelSqrtPfiii
	.cfi_endproc
                                        # -- End function
	.globl	_Z19__device_stub__meanPfiiS_i  # -- Begin function _Z19__device_stub__meanPfiiS_i
	.type	_Z19__device_stub__meanPfiiS_i,@function
_Z19__device_stub__meanPfiiS_i:         # @_Z19__device_stub__meanPfiiS_i
	.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	8(%rsp), %rsi
	movl	%edx, (%rsi)
	leaq	32(%rsp), %rdx
	movq	%rcx, (%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	$_Z4meanPfiiS_i, %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_end3:
	.size	_Z19__device_stub__meanPfiiS_i, .Lfunc_end3-_Z19__device_stub__meanPfiiS_i
	.cfi_endproc
                                        # -- End function
	.globl	_Z17printErrorMessage10hipError_ti # -- Begin function _Z17printErrorMessage10hipError_ti
	.type	_Z17printErrorMessage10hipError_ti,@function
_Z17printErrorMessage10hipError_ti:     # @_Z17printErrorMessage10hipError_ti
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	pushq	%rax
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -24
	.cfi_offset %rbp, -16
	movl	%esi, %ebx
	movl	%edi, %ebp
	movl	$.Lstr.1, %edi
	callq	puts@PLT
	movl	%ebp, %edi
	callq	hipGetErrorString
	movl	$.L.str.1, %edi
	movq	%rax, %rsi
	xorl	%eax, %eax
	callq	printf
	movl	$.L.str.2, %edi
	movl	%ebx, %esi
	xorl	%eax, %eax
	callq	printf
	movl	$.Lstr.1, %edi
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	jmp	puts@PLT                        # TAILCALL
.Lfunc_end4:
	.size	_Z17printErrorMessage10hipError_ti, .Lfunc_end4-_Z17printErrorMessage10hipError_ti
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function _Z3knnPfiS_iiiS_S_Pi
.LCPI5_0:
	.long	0x3d800000                      # float 0.0625
.LCPI5_1:
	.long	0x3b800000                      # float 0.00390625
	.text
	.globl	_Z3knnPfiS_iiiS_S_Pi
	.type	_Z3knnPfiS_iiiS_S_Pi,@function
_Z3knnPfiS_iiiS_S_Pi:                   # @_Z3knnPfiS_iiiS_S_Pi
	.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	$168, %rsp
	.cfi_def_cfa_offset 224
	.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, 36(%rsp)                  # 4-byte Spill
	movl	%r8d, %r13d
	movl	%ecx, 28(%rsp)                  # 4-byte Spill
	movq	%rdx, 40(%rsp)                  # 8-byte Spill
	movl	%esi, %ebp
	movq	%rdi, 96(%rsp)                  # 8-byte Spill
	movslq	%esi, %r15
	leaq	(,%r15,4), %rbx
	movslq	%r8d, %r14
	leaq	80(%rsp), %rdi
	leaq	120(%rsp), %rsi
	movq	%rbx, %rdx
	movq	%r14, %rcx
	callq	hipMallocPitch
	testl	%eax, %eax
	je	.LBB5_2
# %bb.1:
	movl	%eax, %r12d
	movq	80(%rsp), %rdi
	callq	hipFree
	imull	%r13d, %ebx
	movl	%r12d, %edi
	movl	%ebx, %esi
	jmp	.LBB5_12
.LBB5_2:
	movq	%rbx, 88(%rsp)                  # 8-byte Spill
	movl	%ebp, 32(%rsp)                  # 4-byte Spill
	movl	28(%rsp), %eax                  # 4-byte Reload
	movslq	%eax, %r12
	shlq	$2, %r12
	leaq	72(%rsp), %rdi
	leaq	104(%rsp), %rsi
	movq	%r12, %rdx
	movq	%r14, %rcx
	callq	hipMallocPitch
	testl	%eax, %eax
	je	.LBB5_4
# %bb.3:
	movl	%eax, %ebx
	movq	72(%rsp), %rdi
	callq	hipFree
	imull	36(%rsp), %r12d                 # 4-byte Folded Reload
	movl	%ebx, %edi
	jmp	.LBB5_11
.LBB5_4:
	leaq	48(%rsp), %rdi
	leaq	152(%rsp), %rsi
	movq	%r12, %rdx
	movq	%r15, %rcx
	callq	hipMallocPitch
	testl	%eax, %eax
	je	.LBB5_6
# %bb.5:
	movl	%eax, %r15d
	movq	48(%rsp), %rdi
	callq	hipFree
	imull	32(%rsp), %r12d                 # 4-byte Folded Reload
	jmp	.LBB5_10
.LBB5_6:
	movl	36(%rsp), %ebp                  # 4-byte Reload
	movslq	%ebp, %rbx
	leaq	64(%rsp), %rdi
	leaq	112(%rsp), %rsi
	movq	%r12, %rdx
	movq	%rbx, %rcx
	callq	hipMallocPitch
	testl	%eax, %eax
	je	.LBB5_8
# %bb.7:
	movl	%eax, %r15d
	movq	64(%rsp), %rdi
	callq	hipFree
	imull	%ebp, %r12d
	jmp	.LBB5_10
.LBB5_8:
	movq	%rbx, 144(%rsp)                 # 8-byte Spill
	leaq	56(%rsp), %rdi
	leaq	160(%rsp), %rsi
	movl	$1, %ecx
	movq	%r12, %rdx
	callq	hipMallocPitch
	testl	%eax, %eax
	je	.LBB5_14
# %bb.9:
	movl	%eax, %r15d
	movq	56(%rsp), %rdi
	callq	hipFree
.LBB5_10:
	movl	%r15d, %edi
.LBB5_11:
	movl	%r12d, %esi
.LBB5_12:
	callq	_Z17printErrorMessage10hipError_ti
.LBB5_13:
	addq	$168, %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_14:
	.cfi_def_cfa_offset 224
	movq	80(%rsp), %rdi
	movq	120(%rsp), %rsi
	movl	$1, %r15d
	movl	%r15d, (%rsp)
	movq	96(%rsp), %rdx                  # 8-byte Reload
	movq	88(%rsp), %rcx                  # 8-byte Reload
	movq	%rcx, %r8
	movq	%r14, %r9
	callq	hipMemcpy2D
	movq	72(%rsp), %rdi
	movq	104(%rsp), %rsi
	movl	%r15d, (%rsp)
	movq	40(%rsp), %rdx                  # 8-byte Reload
	movq	%r12, %rcx
	movq	%r12, 96(%rsp)                  # 8-byte Spill
	movq	%r12, %r8
	movq	%r14, %r9
	callq	hipMemcpy2D
	movq	120(%rsp), %rax
	movq	%rax, 128(%rsp)                 # 8-byte Spill
	movq	104(%rsp), %rax
	shrq	$2, %rax
	movq	%rax, 40(%rsp)                  # 8-byte Spill
	cvtsi2ssl	28(%rsp), %xmm0         # 4-byte Folded Reload
	movss	%xmm0, 88(%rsp)                 # 4-byte Spill
	movq	112(%rsp), %rax
	movq	%rax, 136(%rsp)                 # 8-byte Spill
	mulss	.LCPI5_0(%rip), %xmm0
	callq	ceilf@PLT
	cvttss2si	%xmm0, %r14
	xorps	%xmm0, %xmm0
	cvtsi2ssl	32(%rsp), %xmm0         # 4-byte Folded Reload
	mulss	.LCPI5_0(%rip), %xmm0
	callq	ceilf@PLT
	cvttss2si	%xmm0, %r15
	movl	%r14d, %r12d
	shlq	$32, %r15
	orq	%r12, %r15
	xorps	%xmm0, %xmm0
	cvtsi2ss	%ebp, %xmm0
	movabsq	$4294967552, %rbx               # imm = 0x100000100
	mulss	.LCPI5_0(%rip), %xmm0
	callq	ceilf@PLT
	cvttss2si	%xmm0, %r14
	shlq	$32, %r14
	movss	88(%rsp), %xmm0                 # 4-byte Reload
                                        # xmm0 = mem[0],zero,zero,zero
	mulss	.LCPI5_1(%rip), %xmm0
	callq	ceilf@PLT
	cvttss2si	%xmm0, %rax
	movl	%eax, %eax
	leaq	(%rax,%rbx), %rbp
	addq	$-256, %rbp
	movq	%r15, %rdi
	movl	$1, %esi
	movabsq	$68719476752, %rdx              # imm = 0x1000000010
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB5_16
# %bb.15:
	movq	128(%rsp), %rdx                 # 8-byte Reload
	shrq	$2, %rdx
	movq	80(%rsp), %rdi
	movq	72(%rsp), %rcx
	movq	48(%rsp), %rax
	movq	%rax, 8(%rsp)
	movl	%r13d, (%rsp)
	movl	32(%rsp), %esi                  # 4-byte Reload
                                        # kill: def $edx killed $edx killed $rdx
	movl	28(%rsp), %r8d                  # 4-byte Reload
	movq	40(%rsp), %r9                   # 8-byte Reload
                                        # kill: def $r9d killed $r9d killed $r9
	callq	_Z30__device_stub__computeDistancePfiiS_iiiS_
.LBB5_16:
	orq	%r12, %r14
	movq	%rbp, %r15
	movq	%rbp, %rdi
	movl	$1, %esi
	movq	%rbx, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	movl	36(%rsp), %ebx                  # 4-byte Reload
	movq	144(%rsp), %r13                 # 8-byte Reload
	jne	.LBB5_18
# %bb.17:
	movq	136(%rsp), %r8                  # 8-byte Reload
	shrq	$2, %r8
	movq	48(%rsp), %rdi
	movq	64(%rsp), %rsi
	movl	%ebx, (%rsp)
	movl	28(%rsp), %edx                  # 4-byte Reload
	movq	40(%rsp), %rcx                  # 8-byte Reload
                                        # kill: def $ecx killed $ecx killed $rcx
                                        # kill: def $r8d killed $r8d killed $r8
	movl	32(%rsp), %r9d                  # 4-byte Reload
	callq	_Z19__device_stub__sortPfPiiiiii
.LBB5_18:
	movq	%r14, %rdi
	movl	$1, %esi
	movabsq	$68719476752, %rdx              # imm = 0x1000000010
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	movq	96(%rsp), %r12                  # 8-byte Reload
	jne	.LBB5_20
# %bb.19:
	movq	48(%rsp), %rdi
	movl	28(%rsp), %esi                  # 4-byte Reload
	movq	40(%rsp), %rdx                  # 8-byte Reload
                                        # kill: def $edx killed $edx killed $rdx
	movl	%ebx, %ecx
	callq	_Z27__device_stub__parallelSqrtPfiii
.LBB5_20:
	movq	232(%rsp), %rbx
	movq	224(%rsp), %r14
	movq	%r15, %rdi
	movl	$1, %esi
	movabsq	$4294967552, %rdx               # imm = 0x100000100
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB5_22
# %bb.21:
	movq	48(%rsp), %rdi
	movq	56(%rsp), %rcx
	movl	28(%rsp), %esi                  # 4-byte Reload
	movq	40(%rsp), %rdx                  # 8-byte Reload
                                        # kill: def $edx killed $edx killed $rdx
	movl	36(%rsp), %r8d                  # 4-byte Reload
	callq	_Z19__device_stub__meanPfiiS_i
.LBB5_22:
	movq	56(%rsp), %rdx
	movq	104(%rsp), %rcx
	movl	$2, %ebp
	movl	%ebp, (%rsp)
	movl	$1, %r9d
	movq	%rbx, %rdi
	movq	%r12, %rsi
	movq	%r12, %r8
	callq	hipMemcpy2D
	movq	48(%rsp), %rdx
	movq	152(%rsp), %rcx
	movl	%ebp, (%rsp)
	movq	%r14, %rdi
	movq	%r12, %rsi
	movq	%r12, %r8
	movq	%r13, %r9
	callq	hipMemcpy2D
	movq	64(%rsp), %rdx
	movq	112(%rsp), %rcx
	movl	%ebp, (%rsp)
	movq	240(%rsp), %rdi
	movq	%r12, %rsi
	movq	%r12, %r8
	movq	%r13, %r9
	callq	hipMemcpy2D
	movq	80(%rsp), %rdi
	callq	hipFree
	movq	72(%rsp), %rdi
	callq	hipFree
	movq	56(%rsp), %rdi
	callq	hipFree
	movq	64(%rsp), %rdi
	callq	hipFree
	jmp	.LBB5_13
.Lfunc_end5:
	.size	_Z3knnPfiS_iiiS_S_Pi, .Lfunc_end5-_Z3knnPfiS_iiiS_S_Pi
	.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
	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	$524288, %edi                   # imm = 0x80000
	callq	malloc
	movq	%rax, %r14
	movl	$524288, %edi                   # imm = 0x80000
	callq	malloc
	movq	%rax, %rbp
	movl	$327680, %edi                   # imm = 0x50000
	callq	malloc
	movq	%rax, 8(%rsp)                   # 8-byte Spill
	movl	$16384, %edi                    # imm = 0x4000
	callq	malloc
	movq	%rax, %r13
	movl	$327680, %edi                   # imm = 0x50000
	callq	malloc
	movq	%rax, 16(%rsp)                  # 8-byte Spill
	xorl	%ebx, %ebx
	xorl	%edi, %edi
	callq	time
	movl	%eax, %edi
	callq	srand
.LBB6_1:                                # =>This Inner Loop Header: Depth=1
	callq	rand
	cltq
	imulq	$1374389535, %rax, %rcx         # imm = 0x51EB851F
	movq	%rcx, %rdx
	shrq	$63, %rdx
	sarq	$37, %rcx
	addl	%edx, %ecx
	imull	$100, %ecx, %ecx
	subl	%ecx, %eax
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	movss	%xmm0, (%r14,%rbx,4)
	incq	%rbx
	cmpq	$131072, %rbx                   # imm = 0x20000
	jne	.LBB6_1
# %bb.2:                                # %.preheader68.preheader
	xorl	%ebx, %ebx
.LBB6_3:                                # %.preheader68
                                        # =>This Inner Loop Header: Depth=1
	callq	rand
	cltq
	imulq	$1374389535, %rax, %rcx         # imm = 0x51EB851F
	movq	%rcx, %rdx
	shrq	$63, %rdx
	sarq	$37, %rcx
	addl	%edx, %ecx
	imull	$100, %ecx, %ecx
	subl	%ecx, %eax
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	movss	%xmm0, (%rbp,%rbx,4)
	incq	%rbx
	cmpq	$131072, %rbx                   # imm = 0x20000
	jne	.LBB6_3
# %bb.4:
	subq	$8, %rsp
	.cfi_adjust_cfa_offset 8
	movq	%r14, 40(%rsp)                  # 8-byte Spill
	movq	%r14, %rdi
	movl	$4096, %esi                     # imm = 0x1000
	movq	%rbp, %rdx
	movl	$4096, %ecx                     # imm = 0x1000
	movl	$32, %r8d
	movl	$20, %r9d
	movq	24(%rsp), %rbx                  # 8-byte Reload
	pushq	%rbx
	.cfi_adjust_cfa_offset 8
	pushq	%r13
	.cfi_adjust_cfa_offset 8
	pushq	32(%rsp)                        # 8-byte Folded Reload
	.cfi_adjust_cfa_offset 8
	callq	_Z3knnPfiS_iiiS_S_Pi
	addq	$32, %rsp
	.cfi_adjust_cfa_offset -32
	xorl	%r15d, %r15d
	movl	$_ZSt4cout, %r12d
	movq	%rbp, 24(%rsp)                  # 8-byte Spill
	movq	%rbp, %r14
.LBB6_5:                                # =>This Loop Header: Depth=1
                                        #     Child Loop BB6_6 Depth 2
                                        #     Child Loop BB6_8 Depth 2
	movl	$_ZSt4cout, %edi
	movl	$.L.str.3, %esi
	movl	$2, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	xorl	%ebp, %ebp
.LBB6_6:                                #   Parent Loop BB6_5 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	xorps	%xmm0, %xmm0
	cvtss2sd	(%r14,%rbp), %xmm0
	movl	$_ZSt4cout, %edi
	callq	_ZNSo9_M_insertIdEERSoT_
	movl	$.L.str.4, %esi
	movl	$1, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	addq	$16384, %rbp                    # imm = 0x4000
	cmpq	$524288, %rbp                   # imm = 0x80000
	jne	.LBB6_6
# %bb.7:                                #   in Loop: Header=BB6_5 Depth=1
	movl	$_ZSt4cout, %edi
	movl	$.L.str.5, %esi
	movl	$1, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rdi
	addq	%r12, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	xorps	%xmm0, %xmm0
	cvtss2sd	(%r13,%r15,4), %xmm0
	movl	$_ZSt4cout, %edi
	callq	_ZNSo9_M_insertIdEERSoT_
	movq	%rax, %rbp
	movq	(%rax), %rax
	movq	-24(%rax), %rdi
	addq	%rbp, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movq	%rbp, %rdi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movq	$-327680, %rbp                  # imm = 0xFFFB0000
.LBB6_8:                                #   Parent Loop BB6_5 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	327680(%rbx,%rbp), %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSolsEi
	movl	$.L.str.4, %esi
	movl	$1, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	addq	$16384, %rbp                    # imm = 0x4000
	jne	.LBB6_8
# %bb.9:                                #   in Loop: Header=BB6_5 Depth=1
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rdi
	addq	%r12, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movq	%rax, %rbp
	movq	(%rax), %rax
	movq	-24(%rax), %rdi
	addq	%rbp, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movq	%rbp, %rdi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	incq	%r15
	addq	$4, %r14
	addq	$4, %rbx
	cmpq	$10, %r15
	jne	.LBB6_5
# %bb.10:                               # %.preheader.preheader
	xorl	%ebx, %ebx
	movl	$_ZSt4cout, %r14d
	movq	8(%rsp), %r15                   # 8-byte Reload
	movq	24(%rsp), %r13                  # 8-byte Reload
.LBB6_11:                               # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB6_12 Depth 2
	xorl	%r12d, %r12d
.LBB6_12:                               #   Parent Loop BB6_11 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	xorps	%xmm0, %xmm0
	cvtss2sd	(%r15,%r12,4), %xmm0
	movl	$_ZSt4cout, %edi
	callq	_ZNSo9_M_insertIdEERSoT_
	movl	$.L.str.4, %esi
	movl	$1, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	incq	%r12
	cmpq	$10, %r12
	jne	.LBB6_12
# %bb.13:                               #   in Loop: Header=BB6_11 Depth=1
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rdi
	addq	%r14, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	incq	%rbx
	addq	$16384, %r15                    # imm = 0x4000
	cmpq	$20, %rbx
	jne	.LBB6_11
# %bb.14:
	movq	32(%rsp), %rdi                  # 8-byte Reload
	callq	free
	movq	%r13, %rdi
	callq	free
	movq	8(%rsp), %rdi                   # 8-byte Reload
	callq	free
	movq	16(%rsp), %rdi                  # 8-byte Reload
	callq	free
	xorl	%eax, %eax
	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
.Lfunc_end6:
	.size	main, .Lfunc_end6-main
	.cfi_endproc
                                        # -- End function
	.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	.LBB7_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB7_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z15computeDistancePfiiS_iiiS_, %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	$_Z4sortPfPiiiiii, %esi
	movl	$.L__unnamed_2, %edx
	movl	$.L__unnamed_2, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z12parallelSqrtPfiii, %esi
	movl	$.L__unnamed_3, %edx
	movl	$.L__unnamed_3, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z4meanPfiiS_i, %esi
	movl	$.L__unnamed_4, %edx
	movl	$.L__unnamed_4, %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_end7:
	.size	__hip_module_ctor, .Lfunc_end7-__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	.LBB8_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
.LBB8_2:
	retq
.Lfunc_end8:
	.size	__hip_module_dtor, .Lfunc_end8-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	_Z15computeDistancePfiiS_iiiS_,@object # @_Z15computeDistancePfiiS_iiiS_
	.section	.rodata,"a",@progbits
	.globl	_Z15computeDistancePfiiS_iiiS_
	.p2align	3, 0x0
_Z15computeDistancePfiiS_iiiS_:
	.quad	_Z30__device_stub__computeDistancePfiiS_iiiS_
	.size	_Z15computeDistancePfiiS_iiiS_, 8

	.type	_Z4sortPfPiiiiii,@object        # @_Z4sortPfPiiiiii
	.globl	_Z4sortPfPiiiiii
	.p2align	3, 0x0
_Z4sortPfPiiiiii:
	.quad	_Z19__device_stub__sortPfPiiiiii
	.size	_Z4sortPfPiiiiii, 8

	.type	_Z12parallelSqrtPfiii,@object   # @_Z12parallelSqrtPfiii
	.globl	_Z12parallelSqrtPfiii
	.p2align	3, 0x0
_Z12parallelSqrtPfiii:
	.quad	_Z27__device_stub__parallelSqrtPfiii
	.size	_Z12parallelSqrtPfiii, 8

	.type	_Z4meanPfiiS_i,@object          # @_Z4meanPfiiS_i
	.globl	_Z4meanPfiiS_i
	.p2align	3, 0x0
_Z4meanPfiiS_i:
	.quad	_Z19__device_stub__meanPfiiS_i
	.size	_Z4meanPfiiS_i, 8

	.type	.L.str.1,@object                # @.str.1
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.1:
	.asciz	"MEMORY ALLOCATION ERROR  : %s\n"
	.size	.L.str.1, 31

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"Wished allocated memory : %d\n"
	.size	.L.str.2, 30

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"( "
	.size	.L.str.3, 3

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	" "
	.size	.L.str.4, 2

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	")"
	.size	.L.str.5, 2

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z15computeDistancePfiiS_iiiS_"
	.size	.L__unnamed_1, 31

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z4sortPfPiiiiii"
	.size	.L__unnamed_2, 17

	.type	.L__unnamed_3,@object           # @2
.L__unnamed_3:
	.asciz	"_Z12parallelSqrtPfiii"
	.size	.L__unnamed_3, 22

	.type	.L__unnamed_4,@object           # @3
.L__unnamed_4:
	.asciz	"_Z4meanPfiiS_i"
	.size	.L__unnamed_4, 15

	.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.1,@object                 # @str.1
	.section	.rodata.str1.1,"aMS",@progbits,1
.Lstr.1:
	.asciz	"=================================================="
	.size	.Lstr.1, 51

	.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 _Z30__device_stub__computeDistancePfiiS_iiiS_
	.addrsig_sym _Z19__device_stub__sortPfPiiiiii
	.addrsig_sym _Z27__device_stub__parallelSqrtPfiii
	.addrsig_sym _Z19__device_stub__meanPfiiS_i
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z15computeDistancePfiiS_iiiS_
	.addrsig_sym _Z4sortPfPiiiiii
	.addrsig_sym _Z12parallelSqrtPfiii
	.addrsig_sym _Z4meanPfiiS_i
	.addrsig_sym _ZSt4cout
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z15computeDistancePfiiS_iiiS_ ; -- Begin function _Z15computeDistancePfiiS_iiiS_
	.globl	_Z15computeDistancePfiiS_iiiS_
	.p2align	8
	.type	_Z15computeDistancePfiiS_iiiS_,@function
_Z15computeDistancePfiiS_iiiS_:         ; @_Z15computeDistancePfiiS_iiiS_
; %bb.0:
	s_clause 0x1
	s_load_b64 s[12:13], s[0:1], 0x8
	s_load_b128 s[4:7], s[0:1], 0x18
	s_lshl_b32 s16, s14, 4
	s_waitcnt lgkmcnt(0)
	s_lshl_b32 s7, s15, 4
	v_dual_mov_b32 v5, 0 :: v_dual_mov_b32 v2, s16
	s_lshl_b32 s2, s13, 4
	s_lshl_b32 s8, s5, 4
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_4) | instid1(VALU_DEP_2)
	v_dual_mov_b32 v8, s8 :: v_dual_and_b32 v1, 0x3ff, v0
	v_bfe_u32 v0, v0, 10, 10
	s_add_i32 s3, s6, -1
	v_mov_b32_e32 v9, s7
	s_mul_i32 s9, s3, s13
	v_dual_mov_b32 v7, s2 :: v_dual_add_nc_u32 v4, s7, v0
	s_add_i32 s2, s9, s7
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_dual_mov_b32 v6, s2 :: v_dual_add_nc_u32 v3, s16, v1
	s_cmp_gt_i32 s9, -1
	v_cmp_gt_i32_e64 s3, s12, v4
	ds_store_b32 v5, v2 offset:2064
	ds_store_b128 v5, v[6:9] offset:2048
	v_cmp_gt_i32_e64 s2, s4, v3
	s_mov_b32 s4, -1
	s_cbranch_scc0 .LBB0_15
; %bb.1:                                ; %.lr.ph
	s_ashr_i32 s14, s13, 31
	s_clause 0x1
	s_load_b64 s[8:9], s[0:1], 0x0
	s_load_b64 s[10:11], s[0:1], 0x10
	s_add_i32 s4, s13, s14
	v_add_nc_u32_e32 v8, s7, v1
	s_xor_b32 s15, s4, s14
	v_lshlrev_b32_e32 v10, 6, v0
	v_cvt_f32_u32_e32 v2, s15
	v_lshlrev_b32_e32 v6, 2, v0
	v_cmp_gt_i32_e64 s4, s12, v8
	s_sub_i32 s12, 0, s15
	v_lshlrev_b32_e32 v9, 2, v1
	v_rcp_iflag_f32_e32 v2, v2
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_add_nc_u32_e32 v7, 0x400, v9
	v_add_nc_u32_e32 v8, v10, v9
	v_add_nc_u32_e32 v9, v7, v10
	s_waitcnt_depctr 0xfff
	v_mul_f32_e32 v4, 0x4f7ffffe, v2
	v_mad_u64_u32 v[2:3], null, v0, s13, v[1:2]
	v_mov_b32_e32 v10, s16
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_cvt_u32_f32_e32 v11, v4
	v_mad_u64_u32 v[3:4], null, v0, s5, v[1:2]
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_readfirstlane_b32 s13, v11
	v_mov_b32_e32 v4, 0
	s_mul_i32 s12, s12, s13
	s_delay_alu instid0(SALU_CYCLE_1)
	s_mul_hi_u32 s16, s13, s12
	s_and_b32 s12, s3, s2
	s_add_i32 s13, s13, s16
.LBB0_2:                                ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_12 Depth 2
	s_ashr_i32 s16, s7, 31
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_add_i32 s17, s7, s16
	s_xor_b32 s17, s17, s16
	s_xor_b32 s16, s16, s14
	s_mul_hi_u32 s18, s17, s13
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_mul_i32 s19, s18, s15
	s_sub_i32 s17, s17, s19
	s_add_i32 s19, s18, 1
	s_sub_i32 s20, s17, s15
	s_cmp_ge_u32 s17, s15
	s_cselect_b32 s18, s19, s18
	s_cselect_b32 s17, s20, s17
	s_add_i32 s19, s18, 1
	s_cmp_ge_u32 s17, s15
	s_cselect_b32 s17, s19, s18
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_xor_b32 s17, s17, s16
	s_sub_i32 s16, s17, s16
                                        ; implicit-def: $sgpr17
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_add_nc_u32_e32 v11, s16, v0
	s_mov_b32 s16, exec_lo
	v_cmpx_le_i32_e64 s6, v11
	s_xor_b32 s16, exec_lo, s16
	s_cbranch_execz .LBB0_4
; %bb.3:                                ;   in Loop: Header=BB0_2 Depth=1
	s_mov_b32 s17, 0
	ds_store_b32 v8, v5
.LBB0_4:                                ; %Flow96
                                        ;   in Loop: Header=BB0_2 Depth=1
	s_or_saveexec_b32 s16, s16
	v_mov_b32_e32 v11, s17
	s_xor_b32 exec_lo, exec_lo, s16
	s_cbranch_execz .LBB0_10
; %bb.5:                                ;   in Loop: Header=BB0_2 Depth=1
	v_dual_mov_b32 v11, 0 :: v_dual_mov_b32 v12, 0
	s_and_saveexec_b32 s17, s4
	s_cbranch_execz .LBB0_7
; %bb.6:                                ;   in Loop: Header=BB0_2 Depth=1
	v_add_nc_u32_e32 v12, s7, v2
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v13, 31, v12
	v_lshlrev_b64 v[12:13], 2, v[12:13]
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v12, vcc_lo, s8, v12
	v_add_co_ci_u32_e32 v13, vcc_lo, s9, v13, vcc_lo
	global_load_b32 v12, v[12:13], off
.LBB0_7:                                ;   in Loop: Header=BB0_2 Depth=1
	s_or_b32 exec_lo, exec_lo, s17
	s_waitcnt vmcnt(0)
	ds_store_b32 v8, v12
	s_and_saveexec_b32 s17, s2
	s_cbranch_execz .LBB0_9
; %bb.8:                                ;   in Loop: Header=BB0_2 Depth=1
	v_add_nc_u32_e32 v11, v3, v10
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v12, 31, v11
	v_lshlrev_b64 v[11:12], 2, v[11:12]
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v11, vcc_lo, s10, v11
	v_add_co_ci_u32_e32 v12, vcc_lo, s11, v12, vcc_lo
	global_load_b32 v11, v[11:12], off
.LBB0_9:                                ; %Flow95
                                        ;   in Loop: Header=BB0_2 Depth=1
	s_or_b32 exec_lo, exec_lo, s17
.LBB0_10:                               ; %Flow97
                                        ;   in Loop: Header=BB0_2 Depth=1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_or_b32 exec_lo, exec_lo, s16
	s_waitcnt vmcnt(0)
	ds_store_b32 v9, v11
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	s_and_saveexec_b32 s16, s12
	s_cbranch_execz .LBB0_13
; %bb.11:                               ; %.preheader.preheader
                                        ;   in Loop: Header=BB0_2 Depth=1
	s_mov_b32 s17, 0
.LBB0_12:                               ; %.preheader
                                        ;   Parent Loop BB0_2 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	s_delay_alu instid0(SALU_CYCLE_1)
	v_add_nc_u32_e32 v11, s17, v6
	v_add_nc_u32_e32 v12, s17, v7
	s_add_i32 s17, s17, 64
	ds_load_b32 v11, v11
	ds_load_b32 v12, v12
	s_cmpk_lg_i32 s17, 0x400
	s_waitcnt lgkmcnt(0)
	v_sub_f32_e32 v11, v11, v12
	s_delay_alu instid0(VALU_DEP_1)
	v_fmac_f32_e32 v4, v11, v11
	s_cbranch_scc1 .LBB0_12
.LBB0_13:                               ; %Flow94
                                        ;   in Loop: Header=BB0_2 Depth=1
	s_or_b32 exec_lo, exec_lo, s16
	s_barrier
	buffer_gl0_inv
	ds_load_b96 v[11:13], v5 offset:2048
	s_waitcnt lgkmcnt(0)
	v_readfirstlane_b32 s16, v12
	v_add_nc_u32_e32 v10, v13, v10
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_add_i32 s7, s16, s7
	v_cmp_gt_i32_e32 vcc_lo, s7, v11
	s_cbranch_vccz .LBB0_2
; %bb.14:                               ; %Flow98
	s_mov_b32 s4, 0
	s_branch .LBB0_16
.LBB0_15:
                                        ; implicit-def: $sgpr12
                                        ; implicit-def: $vgpr4
.LBB0_16:                               ; %Flow99
	s_and_b32 vcc_lo, exec_lo, s4
	s_cbranch_vccz .LBB0_18
; %bb.17:                               ; %.._crit_edge_crit_edge
	s_and_b32 s2, s3, s2
	v_mov_b32_e32 v4, 0
	s_and_not1_b32 s3, s12, exec_lo
	s_and_b32 s2, s2, exec_lo
	s_delay_alu instid0(SALU_CYCLE_1)
	s_or_b32 s12, s3, s2
.LBB0_18:                               ; %._crit_edge
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_saveexec_b32 s2, s12
	s_cbranch_execz .LBB0_20
; %bb.19:
	v_mov_b32_e32 v2, 0x80c
	s_load_b64 s[0:1], s[0:1], 0x28
	ds_load_2addr_b32 v[2:3], v2 offset1:1
	s_waitcnt lgkmcnt(0)
	v_add_nc_u32_e32 v0, v2, v0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_lo_u32 v0, v0, s5
	v_add3_u32 v0, v3, v1, v0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v1, 31, v0
	v_lshlrev_b64 v[0:1], 2, v[0:1]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v0, vcc_lo, s0, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s1, v1, vcc_lo
	global_store_b32 v[0:1], v4, off
.LBB0_20:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z15computeDistancePfiiS_iiiS_
		.amdhsa_group_segment_fixed_size 2068
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 48
		.amdhsa_user_sgpr_count 14
		.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 1
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 1
		.amdhsa_next_free_vgpr 14
		.amdhsa_next_free_sgpr 21
		.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	_Z15computeDistancePfiiS_iiiS_, .Lfunc_end0-_Z15computeDistancePfiiS_iiiS_
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 900
; NumSgprs: 23
; NumVgprs: 14
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 2068 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 23
; NumVGPRsForWavesPerEU: 14
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 14
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 1
	.text
	.protected	_Z4sortPfPiiiiii        ; -- Begin function _Z4sortPfPiiiiii
	.globl	_Z4sortPfPiiiiii
	.p2align	8
	.type	_Z4sortPfPiiiiii,@function
_Z4sortPfPiiiiii:                       ; @_Z4sortPfPiiiiii
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x34
	s_load_b128 s[4:7], s[0:1], 0x10
	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_u32_e64 s4, v1
	s_cbranch_execz .LBB1_9
; %bb.1:
	s_load_b32 s2, s[0:1], 0x20
	s_waitcnt lgkmcnt(0)
	s_cmp_lt_i32 s2, 1
	s_cbranch_scc1 .LBB1_9
; %bb.2:                                ; %.lr.ph57.preheader
	s_load_b128 s[8:11], s[0:1], 0x0
	v_mov_b32_e32 v2, 0
	s_mov_b32 s4, 0
	s_mov_b32 s3, s5
	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 v2, vcc_lo, s8, v0
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v3, vcc_lo, s9, v1, vcc_lo
	v_add_co_u32 v4, vcc_lo, s10, v0
	v_add_co_ci_u32_e32 v5, vcc_lo, s11, v1, vcc_lo
.LBB1_3:                                ; %.lr.ph57
                                        ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB1_5 Depth 2
	s_mul_i32 s0, s4, s5
	v_mov_b32_e32 v6, s4
	s_ashr_i32 s1, s0, 31
	s_add_i32 s8, s4, 1
	s_lshl_b64 s[0:1], s[0:1], 2
	s_cmp_ge_i32 s8, s7
	v_add_co_u32 v0, vcc_lo, v2, s0
	v_add_co_ci_u32_e32 v1, vcc_lo, s1, v3, vcc_lo
	global_load_b32 v7, v[0:1], off
	s_cbranch_scc1 .LBB1_6
; %bb.4:                                ; %.lr.ph.preheader
                                        ;   in Loop: Header=BB1_3 Depth=1
	v_mov_b32_e32 v6, s4
	s_waitcnt vmcnt(0)
	v_mov_b32_e32 v8, v7
	s_mov_b32 s0, s3
	s_mov_b32 s9, s8
.LBB1_5:                                ; %.lr.ph
                                        ;   Parent Loop BB1_3 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	s_ashr_i32 s1, s0, 31
	s_delay_alu instid0(SALU_CYCLE_1)
	s_lshl_b64 s[10:11], s[0:1], 2
	s_add_i32 s0, s0, s5
	v_add_co_u32 v9, vcc_lo, v2, s10
	v_add_co_ci_u32_e32 v10, vcc_lo, s11, v3, vcc_lo
	global_load_b32 v9, v[9:10], off
	s_waitcnt vmcnt(0)
	v_cmp_lt_f32_e32 vcc_lo, v9, v8
	v_cndmask_b32_e64 v6, v6, s9, vcc_lo
	v_cndmask_b32_e32 v8, v8, v9, vcc_lo
	s_add_i32 s9, s9, 1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_cmp_lt_i32 s9, s7
	s_cbranch_scc1 .LBB1_5
.LBB1_6:                                ; %._crit_edge
                                        ;   in Loop: Header=BB1_3 Depth=1
	s_mov_b32 s0, exec_lo
	v_cmpx_ne_u32_e64 s4, v6
	s_cbranch_execz .LBB1_8
; %bb.7:                                ;   in Loop: Header=BB1_3 Depth=1
	v_mul_lo_u32 v8, v6, s5
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v9, 31, v8
	v_lshlrev_b64 v[8:9], 2, v[8:9]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v8, vcc_lo, v2, v8
	v_add_co_ci_u32_e32 v9, vcc_lo, v3, v9, vcc_lo
	global_load_b32 v10, v[8:9], off
	s_waitcnt vmcnt(1)
	global_store_b32 v[8:9], v7, off
	s_waitcnt vmcnt(0)
	global_store_b32 v[0:1], v10, off
.LBB1_8:                                ;   in Loop: Header=BB1_3 Depth=1
	s_or_b32 exec_lo, exec_lo, s0
	s_mul_i32 s0, s4, s6
	s_add_i32 s3, s3, s5
	s_ashr_i32 s1, s0, 31
	s_mov_b32 s4, s8
	s_lshl_b64 s[0:1], s[0:1], 2
	s_cmp_lg_u32 s8, s2
	v_add_co_u32 v0, vcc_lo, v4, s0
	v_add_co_ci_u32_e32 v1, vcc_lo, s1, v5, vcc_lo
	global_store_b32 v[0:1], v6, off
	s_cbranch_scc1 .LBB1_3
.LBB1_9:                                ; %.loopexit
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z4sortPfPiiiiii
		.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 11
		.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	_Z4sortPfPiiiiii, .Lfunc_end1-_Z4sortPfPiiiiii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 436
; NumSgprs: 18
; NumVgprs: 11
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 11
; Occupancy: 16
; WaveLimiterHint : 0
; 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	_Z12parallelSqrtPfiii   ; -- Begin function _Z12parallelSqrtPfiii
	.globl	_Z12parallelSqrtPfiii
	.p2align	8
	.type	_Z12parallelSqrtPfiii,@function
_Z12parallelSqrtPfiii:                  ; @_Z12parallelSqrtPfiii
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x24
	s_load_b128 s[4:7], s[0:1], 0x8
	v_and_b32_e32 v2, 0x3ff, v0
	v_bfe_u32 v3, v0, 10, 10
	s_waitcnt lgkmcnt(0)
	s_lshr_b32 s3, s2, 16
	s_and_b32 s2, s2, 0xffff
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	v_mad_u64_u32 v[0:1], null, s14, s2, v[2:3]
	v_mad_u64_u32 v[1:2], null, s15, s3, v[3:4]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_cmp_gt_u32_e32 vcc_lo, s4, v0
	v_cmp_gt_u32_e64 s2, s6, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_and_b32 s2, vcc_lo, s2
	s_and_saveexec_b32 s3, s2
	s_cbranch_execz .LBB2_2
; %bb.1:
	s_load_b64 s[0:1], s[0:1], 0x0
	v_mad_u64_u32 v[2:3], null, v1, s5, v[0:1]
	v_mov_b32_e32 v3, 0
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[0:1], 2, v[2:3]
	s_waitcnt lgkmcnt(0)
	v_add_co_u32 v0, vcc_lo, s0, v0
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_4) | instid1(VALU_DEP_2)
	v_add_co_ci_u32_e32 v1, vcc_lo, s1, v1, vcc_lo
	global_load_b32 v2, v[0:1], off
	s_waitcnt vmcnt(0)
	v_mul_f32_e32 v3, 0x4f800000, v2
	v_cmp_gt_f32_e32 vcc_lo, 0xf800000, v2
	v_cndmask_b32_e32 v2, v2, v3, vcc_lo
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_3) | instid1(VALU_DEP_2)
	v_sqrt_f32_e32 v3, v2
	s_waitcnt_depctr 0xfff
	v_add_nc_u32_e32 v4, -1, v3
	v_add_nc_u32_e32 v5, 1, v3
	v_fma_f32 v6, -v4, v3, v2
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_fma_f32 v7, -v5, v3, v2
	v_cmp_ge_f32_e64 s0, 0, v6
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_cndmask_b32_e64 v3, v3, v4, s0
	v_cmp_lt_f32_e64 s0, 0, v7
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cndmask_b32_e64 v3, v3, v5, s0
	v_mul_f32_e32 v4, 0x37800000, v3
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_cndmask_b32_e32 v3, v3, v4, vcc_lo
	v_cmp_class_f32_e64 vcc_lo, v2, 0x260
	v_cndmask_b32_e32 v2, v3, v2, vcc_lo
	global_store_b32 v[0:1], v2, off
.LBB2_2:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z12parallelSqrtPfiii
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 280
		.amdhsa_user_sgpr_count 14
		.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 1
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 1
		.amdhsa_next_free_vgpr 8
		.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_end2:
	.size	_Z12parallelSqrtPfiii, .Lfunc_end2-_Z12parallelSqrtPfiii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 320
; NumSgprs: 18
; NumVgprs: 8
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 8
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 14
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 1
	.text
	.protected	_Z4meanPfiiS_i          ; -- Begin function _Z4meanPfiiS_i
	.globl	_Z4meanPfiiS_i
	.p2align	8
	.type	_Z4meanPfiiS_i,@function
_Z4meanPfiiS_i:                         ; @_Z4meanPfiiS_i
; %bb.0:
	s_clause 0x1
	s_load_b32 s4, s[0:1], 0x2c
	s_load_b64 s[2:3], s[0:1], 0x8
	s_waitcnt lgkmcnt(0)
	s_and_b32 s4, s4, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s15, s4, v[0:1]
	v_cmp_gt_u32_e32 vcc_lo, s2, v1
	s_and_saveexec_b32 s2, vcc_lo
	s_cbranch_execz .LBB3_5
; %bb.1:
	s_load_b32 s2, s[0:1], 0x18
	v_mov_b32_e32 v2, 0
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(SALU_CYCLE_1)
	v_lshlrev_b64 v[0:1], 2, v[1:2]
	s_waitcnt lgkmcnt(0)
	s_mul_i32 s6, s2, s3
	s_cmp_lt_i32 s6, 1
	s_cbranch_scc1 .LBB3_4
; %bb.2:                                ; %.lr.ph.preheader
	s_load_b64 s[4:5], s[0:1], 0x0
	v_mov_b32_e32 v2, 0
	s_ashr_i32 s9, s3, 31
	s_mov_b32 s8, s3
	s_mov_b32 s7, 0
	s_waitcnt lgkmcnt(0)
	v_add_co_u32 v3, vcc_lo, s4, v0
	v_add_co_ci_u32_e32 v4, vcc_lo, s5, v1, vcc_lo
	s_lshl_b64 s[4:5], s[8:9], 2
.LBB3_3:                                ; %.lr.ph
                                        ; =>This Inner Loop Header: Depth=1
	global_load_b32 v5, v[3:4], off
	v_add_co_u32 v3, vcc_lo, v3, s4
	v_add_co_ci_u32_e32 v4, vcc_lo, s5, v4, vcc_lo
	s_add_i32 s7, s7, s3
	s_delay_alu instid0(SALU_CYCLE_1)
	s_cmp_ge_i32 s7, s6
	s_waitcnt vmcnt(0)
	v_add_f32_e32 v2, v2, v5
	s_cbranch_scc0 .LBB3_3
.LBB3_4:                                ; %Flow32
	v_cvt_f32_i32_e32 v3, s2
	s_load_b64 s[0:1], s[0:1], 0x10
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_div_scale_f32 v4, null, v3, v3, v2
	v_div_scale_f32 v7, vcc_lo, v2, v3, v2
	v_rcp_f32_e32 v5, v4
	s_waitcnt_depctr 0xfff
	v_fma_f32 v6, -v4, v5, 1.0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fmac_f32_e32 v5, v6, v5
	v_mul_f32_e32 v6, v7, v5
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f32 v8, -v4, v6, v7
	v_fmac_f32_e32 v6, v8, v5
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f32 v4, -v4, v6, v7
	v_div_fmas_f32 v4, v4, v5, v6
	s_waitcnt lgkmcnt(0)
	v_add_co_u32 v0, vcc_lo, s0, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s1, v1, vcc_lo
	s_delay_alu instid0(VALU_DEP_3)
	v_div_fixup_f32 v2, v4, v3, v2
	global_store_b32 v[0:1], v2, off
.LBB3_5:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z4meanPfiiS_i
		.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 9
		.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_end3:
	.size	_Z4meanPfiiS_i, .Lfunc_end3-_Z4meanPfiiS_i
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 328
; NumSgprs: 18
; NumVgprs: 9
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 9
; Occupancy: 16
; WaveLimiterHint : 0
; 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
      - .offset:         12
        .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:     by_value
      - .address_space:  global
        .offset:         40
        .size:           8
        .value_kind:     global_buffer
    .group_segment_fixed_size: 2068
    .kernarg_segment_align: 8
    .kernarg_segment_size: 48
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z15computeDistancePfiiS_iiiS_
    .private_segment_fixed_size: 0
    .sgpr_count:     23
    .sgpr_spill_count: 0
    .symbol:         _Z15computeDistancePfiiS_iiiS_.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     14
    .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
      - .offset:         20
        .size:           4
        .value_kind:     by_value
      - .offset:         24
        .size:           4
        .value_kind:     by_value
      - .offset:         28
        .size:           4
        .value_kind:     by_value
      - .offset:         32
        .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:           _Z4sortPfPiiiiii
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z4sortPfPiiiiii.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     11
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .offset:         8
        .size:           4
        .value_kind:     by_value
      - .offset:         12
        .size:           4
        .value_kind:     by_value
      - .offset:         16
        .size:           4
        .value_kind:     by_value
      - .offset:         24
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         28
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         32
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         36
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         38
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         40
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         42
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         44
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         46
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         64
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         88
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 280
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z12parallelSqrtPfiii
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z12parallelSqrtPfiii.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     8
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .offset:         8
        .size:           4
        .value_kind:     by_value
      - .offset:         12
        .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:         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:           _Z4meanPfiiS_i
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z4meanPfiiS_i.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     9
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
