#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include <cuda_runtime_api.h>

#define restrict __restrict__
#define PADDINGCLASS -2
#define OUTPUT_FILE "ocuda"
#define INPUT_FILE "data"
#define KMAX 20
#define CLASSESMAX 100
#define SPACEDIMMAX 100

void check_error(cudaError_t err, const char *msg);
void printStats(cudaEvent_t before, cudaEvent_t after, const char *msg);
void readInput(FILE* file, float* coords, int* classes, int spacedim, int numels, int totalElements);
void writeOutput(float* coords, int* classes, int spacedim, int numels);

__global__ void knn(float* const restrict coords, float2* restrict kOutput, const int totalElements, const int numels, const int spacedim, const int k, int* restrict classes, const int classes_num);
__global__ void knnPunisher(float2* restrict kOutput, int* restrict classes, const int numels, const int newels, const int k, const int classes_num);
__device__ float distance(float* const coords, float* const coords2, const int spacedim);
__device__ int insert(float* kPoints, float2 newDist, int* size, const int k, const int gid, const int offset);
__device__ void swap(float* x1, float* x2, float* y1, float* y2);
__device__ int deviceFindMode(int* kclasses, int classes_num, int k);
__device__ float distanceShm(float* coords, int left, int spacedim);

int main(int argc, char *argv[])
{  
  int newels;                      //number of points we want classify
  int k;                           //number of nearest points we use to classify
  int numels;                      //total element already classified
  int spacedim;
  char filePath[255];              //path + filname of input file
  int classes_num;                 //number of classes
  float* h_coords;                //coords of existing points with a class
  int* h_classes;                  //array contains the class for each points
  
  //*** Device-variables-declaration ***
  float* d_coords;
  int2* d_determinate;
  int* d_classes;
  float2* d_kOutput;
  //*** end-device-declaration
  
  //***cudaEvent-declaration***
  cudaEvent_t before_allocation, before_input, before_upload, before_knn, before_download;
  cudaEvent_t after_allocation, after_input, after_upload, after_knn, after_download;
  //***end-cudaEvent-declaration***
  
  //Requisiti: numels e newels devono essere maggiori di K
  if (argc > 2) 
  {
    strcpy(filePath, argv[1]);
    k = atoi(argv[2]);
  }
  else 
  {
    printf("how-to-use: knn <inputfile> <k> \n");
    exit(1);
  } 
  
  //***cuda-init-event***
  check_error(cudaEventCreate(&before_allocation), "create before_allocation cudaEvent");
  check_error(cudaEventCreate(&before_input), "create before_input cudaEvent");
  check_error(cudaEventCreate(&before_upload), "create before_upload cudaEvent");
  check_error(cudaEventCreate(&before_knn), "create before_knn cudaEvent");
  check_error(cudaEventCreate(&before_download), "create before_download cudaEvent");
  
  check_error(cudaEventCreate(&after_allocation), "create after_allocation cudaEvent");
  check_error(cudaEventCreate(&after_input), "create after_input cudaEvent");
  check_error(cudaEventCreate(&after_upload), "create after_upload cudaEvent");
  check_error(cudaEventCreate(&after_knn), "create after_knn cudaEvent");
  check_error(cudaEventCreate(&after_download), "create after_download cudaEvent");
  //***end-cuda-init-event***

  FILE *fp;
  if((fp = fopen(filePath, "r")) == NULL)
  {
        printf("No such file\n");
        exit(1);
  }
  
  fseek(fp, 0L, SEEK_END);
  float fileSize = ftell(fp);
  rewind(fp);
  
  int count = fscanf(fp, "%d,%d,%d,%d\n", &numels, &newels, &classes_num, &spacedim);
  int totalElements = numels + newels;

  //*** allocation ***
  cudaEventRecord(before_allocation);
  h_coords = (float*) malloc(sizeof(float)*totalElements*spacedim);
  h_classes = (int*) malloc(sizeof(int)*totalElements);
   
  //*** device-allocation ***
  check_error(cudaMalloc(&d_coords, totalElements*spacedim*sizeof(float)), "alloc d_coords_x");
  check_error(cudaMalloc(&d_classes, totalElements*sizeof(int)), "alloc d_classes");
  check_error(cudaMalloc(&d_determinate, newels*2*sizeof(int)), "alloc d_determinate");
  check_error(cudaMalloc(&d_kOutput, newels*KMAX*2*sizeof(float)), "alloc d_kOutput");

  //*** end-device-allocation ***
  cudaEventRecord(after_allocation);
  
  ///***input-from-file***
  cudaEventRecord(before_input);
  readInput(fp, h_coords, h_classes, spacedim, numels, totalElements);
  cudaEventRecord(after_input);
  fclose(fp);
  ///***end-input-from-file***

  //***copy-arrays-on-device***
  cudaEventRecord(before_upload);
  check_error(cudaMemcpy(d_coords, h_coords, totalElements*spacedim*sizeof(float), cudaMemcpyHostToDevice), "copy d_coords");
  check_error(cudaMemcpy(d_classes, h_classes, totalElements*sizeof(int), cudaMemcpyHostToDevice), "copy d_classes");
  cudaEventRecord(after_upload);
  //***end-copy-arrays-on-device***                              
  
  int blockSize = 512;
  int numBlocks = (newels + blockSize - 1)/blockSize;
   
  cudaEventRecord(before_knn);
  knn<<<numBlocks, blockSize, (blockSize*sizeof(float)*2*k)>>>(d_coords, d_kOutput, totalElements, numels, spacedim, k, d_classes, classes_num);
  blockSize = 32;
  numBlocks = (newels + blockSize - 1)/blockSize;
  knnPunisher<<<numBlocks, blockSize, newels*sizeof(int)>>>(d_kOutput, d_classes, numels, newels, k, classes_num);
  cudaEventRecord(after_knn);
  check_error(cudaMemcpy(h_classes+numels, d_classes+numels, newels*sizeof(int), cudaMemcpyDeviceToHost), "download classes");

  check_error(cudaEventSynchronize(after_knn), "sync cudaEvents");
  printStats(before_knn, after_knn, "knn");
    
  writeOutput(h_coords, h_classes, spacedim, totalElements);
  return 0;
}

void check_error(cudaError_t err, const char *msg)
{
  if (err != cudaSuccess) 
  {
    fprintf(stderr, "%s : error %d (%s)\n", msg, err, cudaGetErrorString(err));
    exit(err);
  }
}

float runtime;
void printStats(cudaEvent_t before, cudaEvent_t after, const char *msg)
{ 
  check_error(cudaEventElapsedTime(&runtime, before, after), msg);
  printf("%s %gms\n", msg, runtime);
}

__global__ void knn(float* const restrict coords, float2* restrict kOutput, const int totalElements, const int numels, const int spacedim, const int k, int* restrict classes, const int classes_num)
{
  extern __shared__ float shm[];
  int gid = numels + threadIdx.x + blockIdx.x*blockDim.x;
  if (gid >= totalElements) return;
  
  float* newPointCoords = coords+spacedim*gid;
  float* pointCoords;
  int offset = blockDim.x;
  int lid = threadIdx.x;

  int i = 0, size = 0, count = 0;
  float point[SPACEDIMMAX];

  for (i = 0; i < spacedim; i++)
   point[i] = newPointCoords[i];
  
  float2 dist;
  pointCoords = coords;
  for (i = 0; i < numels; i++)
  {
    dist = make_float2(distance(point, pointCoords, spacedim), i);
    insert(shm+lid, dist, &size, k, gid, offset);
    pointCoords += spacedim;
  }
  
  for (count=0; i < gid; i++)
  {
      dist = make_float2(distance(point, pointCoords, spacedim), i);
      count += insert(shm+lid, dist, &size, k, gid, offset);
      pointCoords += spacedim;
  }
    
  if (count > 0)
  {
    classes[gid] = -1;
  }
  else
  {
    int kclasses[KMAX];
    for (int j = 0; j < k; j++)
      kclasses[j] = classes[(int)(shm[(j+k)*offset+lid])];
    classes[gid] = deviceFindMode(kclasses, classes_num, k);
  }
  
  //copia kPoints in kOutput
  int newelId = gid-numels;
  for (i = 0; i < k; i++)
  {
    kOutput[newelId*KMAX + i].x = shm[i*offset + lid];
    kOutput[newelId*KMAX + i].y = shm[(i+k)*offset + lid];
  }
    
}


__global__ void knnPunisher(float2* restrict kOutput, int* restrict classes, const int numels, const int newels, const int k, const int classes_num)
{
  //Declaration of shared-memory. It's going to contains partial minimum of distances
  extern __shared__ int mPartial[];
  
  int gid = threadIdx.x + blockIdx.x*blockDim.x;
  if (gid >= newels) return;

  //stiamo lancio un kernel per ogni newels
  //prendiamo la classe del newels e la mettiamo nella shared memory
  int i, id, lid, kclasses[KMAX], kPoints[KMAX], count = 1;
  
  //Se sono qui la classe per il kPoint è da determinare
  for (i = 0; i < k; i++)
    kPoints[i] = kOutput[gid*KMAX+i].y; //gid

  while(count != 0)
  {
      for (i = 0; i < gid; i++)
              mPartial[i] = classes[i+numels];

      mPartial[gid] = classes[gid+numels];
      if (mPartial[gid] != -1) return;
      __syncthreads();

      //Le sue dipendenze, se già determinate stanno nella shared-memory
      count = 0;
      for (i = k-1; i >= 0; i--)
      {
        id = kPoints[i];
        lid = id - numels;
        if (id > numels && mPartial[lid] < 0)
        {
          //segno quelli indeterminati
          count++;
          break;
        }
      }

      if (count == 0)
      {
        //posso determinare il punto
        //le sue dipendenze si trovano in shared memory
          for (i = 0; i < k; i++)
              kclasses[i] = classes[kPoints[i]];
        classes[gid+numels] = deviceFindMode(kclasses, classes_num, k);
      }
  }
}

__device__ int deviceFindMode(int* kclasses, int classes_num, int k)
{
  int classesCount[CLASSESMAX];

  int i;
  int temp=0;
  
  for (i = 0; i < CLASSESMAX; i++)
    classesCount[i] = 0;
       
  for (i = 0; i < k; i++){
    temp=kclasses[i];
    classesCount[temp]+=1;
  } 

  int max = 0;
  int maxValue = classesCount[0];

  for (i = 1; i < classes_num; i++)
  {
    int value = classesCount[i];
    if (value > maxValue)
    {
      max = i;
      maxValue = value;
    }
    else if (value != 0 && maxValue == value)
    {
        int j = 0;
        for (j = 0; j < k; j++)
        {
          if (kclasses[j] == i)
          {
            max = i;
            break;
          }
          else if (kclasses[j] == max)
            break;
        }
    }
  }
  
  return max;
}

//inserimento smart in kPoints
__device__ int insert(float* kPoints, float2 newDist, int* size, const int k, const int gid, const int offset)
{  
    int inserted = 0;
    if (*size == 0)
    {
      //Caso base: inserimento su array vuoto
      kPoints[0] = newDist.x;
      kPoints[k*offset] = newDist.y;
      *size = *size + 1;
      return 1;
    }
  
    int i = 1;
    float* valueX, *valueY, *tailX, *tailY;
    valueX = &(newDist.x);
    valueY = &(newDist.y);
    tailX = &(kPoints[(*size-i)*offset]);
    tailY = &(kPoints[(*size-i+k)*offset]);

    if (*size < k)
    {  
        kPoints[(*size)*offset] = newDist.x;
        kPoints[((*size)+k)*offset] = newDist.y;
        valueX = &(kPoints[(*size)*offset]);
        valueY = &(kPoints[((*size)+k)*offset]);
        inserted = 1;
    }

    //partire della fine, swap se trovo elemento più grande - mi fermo se trovo elemento più piccolo
    while (i <= *size && *(tailX) > *(valueX))
    {
        swap(tailX, valueX, tailY, valueY);
        valueX = tailX;
        valueY = tailY;
        i++;
        tailX = &(kPoints[(*size-i)*offset]);
        tailY = &(kPoints[(*size-i+k)*offset]);
        inserted = 1;    
    }
    
    if (inserted && *size < k) *size = *size + 1;
    return inserted;
}

__device__ void swap(float* x1, float* x2, float* y1, float* y2)
{
  float tmp;
  
  tmp = *(x1);
  *(x1) = *(x2);
  *(x2) = tmp;
  
  tmp = *(y1);
  *(y1) = *(y2);
  *(y2) = tmp;
}


// read input from file
void readInput(FILE* file, float* coords, int* classes, int spacedim, int numels, int totalElements)
{
  int i, j;
  int count;
  for(i=0; i<numels; i++)
  {
    for (j = 0; j < spacedim; j++)
      count = fscanf(file, "%f,", &(coords[i*spacedim +j]));
    count = fscanf(file, "%d\n", &(classes[i]));
  }
   
  for(; i < totalElements; i++)
  {
    for (j = 0; j < spacedim; j++)
      count = fscanf(file, "%f,", &(coords[i*spacedim+j]));
    count = fscanf(file, "-1\n");
  }
  count++;
}

//Write Output on file
void writeOutput(float* coords, int* classes, int spacedim, int numels)
{
  FILE *fp;
  fp = fopen(OUTPUT_FILE, "w");
  int i, j;
  for( i = 0; i < numels; i++)
  {
    for (j = 0; j < spacedim; j++)
      fprintf(fp, "%lf,", coords[i*spacedim+j]);
    
    fprintf(fp, "%d\n", classes[i]);
  }
  fclose(fp); 
}

//multidimensional euclidian distance (without sqrt)
__device__ float distance(float* const coords, float* const coords2, const int spacedim)
{
  float sum = 0;
  int i;
  for (i = 0; i < spacedim; i++)
  {
    float diff = coords[i] - coords2[i];
    sum += diff*diff;
  }  
  return sum;
}

	.file	"tmpxft_0030112d_00000000-6_knn_punisher_roll_optimized.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2038:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2038:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%s : error %d (%s)\n"
	.text
	.globl	_Z11check_error9cudaErrorPKc
	.type	_Z11check_error9cudaErrorPKc, @function
_Z11check_error9cudaErrorPKc:
.LFB2028:
	.cfi_startproc
	endbr64
	testl	%edi, %edi
	je	.L2
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	movl	%edi, %ebx
	pushq	%rax
	.cfi_def_cfa_offset 32
	call	cudaGetErrorString@PLT
	movl	%ebx, %r8d
	movq	%rbp, %rcx
	movl	$2, %esi
	movq	stderr(%rip), %rdi
	movq	%rax, %r9
	xorl	%eax, %eax
	leaq	.LC0(%rip), %rdx
	call	__fprintf_chk@PLT
	movl	%ebx, %edi
	call	exit@PLT
.L2:
	.cfi_def_cfa_offset 8
	.cfi_restore 3
	.cfi_restore 6
	ret
	.cfi_endproc
.LFE2028:
	.size	_Z11check_error9cudaErrorPKc, .-_Z11check_error9cudaErrorPKc
	.section	.rodata.str1.1
.LC1:
	.string	"%s %gms\n"
	.text
	.globl	_Z10printStatsP10CUevent_stS0_PKc
	.type	_Z10printStatsP10CUevent_stS0_PKc, @function
_Z10printStatsP10CUevent_stS0_PKc:
.LFB2029:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	movq	%rdx, %rbx
	movq	%rsi, %rdx
	movq	%rdi, %rsi
	leaq	runtime(%rip), %rdi
	call	cudaEventElapsedTime@PLT
	movq	%rbx, %rsi
	movl	%eax, %edi
	call	_Z11check_error9cudaErrorPKc
	movq	%rbx, %rdx
	leaq	.LC1(%rip), %rsi
	popq	%rbx
	.cfi_def_cfa_offset 8
	movl	$2, %edi
	movb	$1, %al
	cvtss2sd	runtime(%rip), %xmm0
	jmp	__printf_chk@PLT
	.cfi_endproc
.LFE2029:
	.size	_Z10printStatsP10CUevent_stS0_PKc, .-_Z10printStatsP10CUevent_stS0_PKc
	.globl	_Z14deviceFindModePiii
	.type	_Z14deviceFindModePiii, @function
_Z14deviceFindModePiii:
.LFB2030:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE2030:
	.size	_Z14deviceFindModePiii, .-_Z14deviceFindModePiii
	.globl	_Z6insertPf6float2Piiii
	.type	_Z6insertPf6float2Piiii, @function
_Z6insertPf6float2Piiii:
.LFB2031:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE2031:
	.size	_Z6insertPf6float2Piiii, .-_Z6insertPf6float2Piiii
	.globl	_Z4swapPfS_S_S_
	.type	_Z4swapPfS_S_S_, @function
_Z4swapPfS_S_S_:
.LFB2032:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE2032:
	.size	_Z4swapPfS_S_S_, .-_Z4swapPfS_S_S_
	.section	.rodata.str1.1
.LC2:
	.string	"%f,"
.LC3:
	.string	"%d\n"
.LC4:
	.string	"-1\n"
	.text
	.globl	_Z9readInputP8_IO_FILEPfPiiii
	.type	_Z9readInputP8_IO_FILEPfPiiii, @function
_Z9readInputP8_IO_FILEPfPiiii:
.LFB2033:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	xorl	%r15d, %r15d
	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
	movq	%rsi, %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movq	%rdx, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movl	%r8d, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movl	%ecx, %ebx
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	movq	%rdi, 8(%rsp)
	movl	%r9d, 24(%rsp)
.L17:
	cmpl	%ebp, %r15d
	jge	.L19
	movslq	%r14d, %rax
	xorl	%ecx, %ecx
	leaq	0(%r13,%rax,4), %rdx
.L20:
	cmpl	%ebx, %ecx
	jge	.L26
	movq	8(%rsp), %rdi
	leaq	.LC2(%rip), %rsi
	xorl	%eax, %eax
	movl	%ecx, 28(%rsp)
	movq	%rdx, 16(%rsp)
	call	__isoc23_fscanf@PLT
	movl	28(%rsp), %ecx
	movq	16(%rsp), %rdx
	incl	%ecx
	addq	$4, %rdx
	jmp	.L20
.L26:
	movq	8(%rsp), %rdi
	movq	%r12, %rdx
	xorl	%eax, %eax
	incl	%r15d
	leaq	.LC3(%rip), %rsi
	addq	$4, %r12
	addl	%ebx, %r14d
	call	__isoc23_fscanf@PLT
	jmp	.L17
.L19:
	xorl	%eax, %eax
	testl	%ebp, %ebp
	cmovs	%eax, %ebp
	movl	%ebp, %r12d
	imull	%ebx, %r12d
.L21:
	movl	24(%rsp), %eax
	cmpl	%eax, %ebp
	jge	.L16
	movslq	%r12d, %rax
	xorl	%r15d, %r15d
	leaq	0(%r13,%rax,4), %r14
.L24:
	cmpl	%ebx, %r15d
	jge	.L27
	movq	8(%rsp), %rdi
	movq	%r14, %rdx
	xorl	%eax, %eax
	incl	%r15d
	leaq	.LC2(%rip), %rsi
	addq	$4, %r14
	call	__isoc23_fscanf@PLT
	jmp	.L24
.L27:
	movq	8(%rsp), %rdi
	leaq	.LC4(%rip), %rsi
	xorl	%eax, %eax
	incl	%ebp
	addl	%ebx, %r12d
	call	__isoc23_fscanf@PLT
	jmp	.L21
.L16:
	addq	$40, %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
.LFE2033:
	.size	_Z9readInputP8_IO_FILEPfPiiii, .-_Z9readInputP8_IO_FILEPfPiiii
	.section	.rodata.str1.1
.LC5:
	.string	"w"
.LC6:
	.string	"ocuda"
.LC7:
	.string	"%lf,"
	.text
	.globl	_Z11writeOutputPfPiii
	.type	_Z11writeOutputPfPiii, @function
_Z11writeOutputPfPiii:
.LFB2034:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%rsi, %r13
	leaq	.LC5(%rip), %rsi
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	xorl	%r12d, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	xorl	%ebp, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movl	%edx, %ebx
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	movq	%rdi, 16(%rsp)
	leaq	.LC6(%rip), %rdi
	movl	%ecx, 28(%rsp)
	call	fopen@PLT
	movq	%rax, 8(%rsp)
.L29:
	cmpl	%ebp, 28(%rsp)
	jle	.L31
	movq	16(%rsp), %rcx
	movslq	%r12d, %rax
	xorl	%r15d, %r15d
	leaq	(%rcx,%rax,4), %r14
.L32:
	cmpl	%r15d, %ebx
	jle	.L34
	movq	8(%rsp), %rdi
	leaq	.LC7(%rip), %rdx
	movl	$2, %esi
	movb	$1, %al
	cvtss2sd	(%r14,%r15,4), %xmm0
	incq	%r15
	call	__fprintf_chk@PLT
	jmp	.L32
.L34:
	movl	0(%r13,%rbp,4), %ecx
	movq	8(%rsp), %rdi
	xorl	%eax, %eax
	incq	%rbp
	leaq	.LC3(%rip), %rdx
	movl	$2, %esi
	addl	%ebx, %r12d
	call	__fprintf_chk@PLT
	jmp	.L29
.L31:
	movq	8(%rsp), %rdi
	addq	$40, %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
	jmp	fclose@PLT
	.cfi_endproc
.LFE2034:
	.size	_Z11writeOutputPfPiii, .-_Z11writeOutputPfPiii
	.globl	_Z8distancePfS_i
	.type	_Z8distancePfS_i, @function
_Z8distancePfS_i:
.LFB2035:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE2035:
	.size	_Z8distancePfS_i, .-_Z8distancePfS_i
	.globl	_Z37__device_stub__Z3knnPfP6float2iiiiPiiPfP6float2iiiiPii
	.type	_Z37__device_stub__Z3knnPfP6float2iiiiPiiPfP6float2iiiiPii, @function
_Z37__device_stub__Z3knnPfP6float2iiiiPiiPfP6float2iiiiPii:
.LFB2060:
	.cfi_startproc
	endbr64
	subq	$184, %rsp
	.cfi_def_cfa_offset 192
	movl	%edx, 12(%rsp)
	leaq	40(%rsp), %rdx
	movl	%ecx, 8(%rsp)
	leaq	48(%rsp), %rcx
	movl	%r8d, 4(%rsp)
	movl	%r9d, (%rsp)
	movq	%fs:40, %rax
	movq	%rax, 168(%rsp)
	xorl	%eax, %eax
	leaq	16(%rsp), %rax
	movq	%rdi, 16(%rsp)
	leaq	56(%rsp), %rdi
	movq	%rax, 104(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 128(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 136(%rsp)
	movq	%rsp, %rax
	movq	%rax, 144(%rsp)
	movq	192(%rsp), %rax
	movq	%rsi, 24(%rsp)
	leaq	68(%rsp), %rsi
	movq	%rax, 32(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 152(%rsp)
	leaq	200(%rsp), %rax
	movq	%rax, 160(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 56(%rsp)
	movl	$1, 64(%rsp)
	movq	%rax, 68(%rsp)
	movl	$1, 76(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L37
	pushq	48(%rsp)
	.cfi_def_cfa_offset 200
	leaq	_Z3knnPfP6float2iiiiPii(%rip), %rdi
	pushq	48(%rsp)
	.cfi_def_cfa_offset 208
	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 200
	popq	%rdx
	.cfi_def_cfa_offset 192
.L37:
	movq	168(%rsp), %rax
	subq	%fs:40, %rax
	je	.L39
	call	__stack_chk_fail@PLT
.L39:
	addq	$184, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2060:
	.size	_Z37__device_stub__Z3knnPfP6float2iiiiPiiPfP6float2iiiiPii, .-_Z37__device_stub__Z3knnPfP6float2iiiiPiiPfP6float2iiiiPii
	.globl	_Z3knnPfP6float2iiiiPii
	.type	_Z3knnPfP6float2iiiiPii, @function
_Z3knnPfP6float2iiiiPii:
.LFB2061:
	.cfi_startproc
	endbr64
	jmp	_Z37__device_stub__Z3knnPfP6float2iiiiPiiPfP6float2iiiiPii
	.cfi_endproc
.LFE2061:
	.size	_Z3knnPfP6float2iiiiPii, .-_Z3knnPfP6float2iiiiPii
	.globl	_Z43__device_stub__Z11knnPunisherP6float2PiiiiiP6float2Piiiii
	.type	_Z43__device_stub__Z11knnPunisherP6float2PiiiiiP6float2Piiiii, @function
_Z43__device_stub__Z11knnPunisherP6float2PiiiiiP6float2Piiiii:
.LFB2062:
	.cfi_startproc
	endbr64
	subq	$168, %rsp
	.cfi_def_cfa_offset 176
	movl	%edx, 12(%rsp)
	leaq	40(%rsp), %rdx
	movl	%ecx, 8(%rsp)
	leaq	48(%rsp), %rcx
	movl	%r8d, 4(%rsp)
	movl	%r9d, (%rsp)
	movq	%fs:40, %rax
	movq	%rax, 152(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movq	%rdi, 24(%rsp)
	leaq	56(%rsp), %rdi
	movq	%rax, 104(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 128(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 136(%rsp)
	movq	%rsp, %rax
	movq	%rsi, 32(%rsp)
	leaq	68(%rsp), %rsi
	movq	%rax, 144(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 56(%rsp)
	movl	$1, 64(%rsp)
	movq	%rax, 68(%rsp)
	movl	$1, 76(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L42
	pushq	48(%rsp)
	.cfi_def_cfa_offset 184
	leaq	_Z11knnPunisherP6float2Piiiii(%rip), %rdi
	pushq	48(%rsp)
	.cfi_def_cfa_offset 192
	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 184
	popq	%rdx
	.cfi_def_cfa_offset 176
.L42:
	movq	152(%rsp), %rax
	subq	%fs:40, %rax
	je	.L44
	call	__stack_chk_fail@PLT
.L44:
	addq	$168, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2062:
	.size	_Z43__device_stub__Z11knnPunisherP6float2PiiiiiP6float2Piiiii, .-_Z43__device_stub__Z11knnPunisherP6float2PiiiiiP6float2Piiiii
	.globl	_Z11knnPunisherP6float2Piiiii
	.type	_Z11knnPunisherP6float2Piiiii, @function
_Z11knnPunisherP6float2Piiiii:
.LFB2063:
	.cfi_startproc
	endbr64
	jmp	_Z43__device_stub__Z11knnPunisherP6float2PiiiiiP6float2Piiiii
	.cfi_endproc
.LFE2063:
	.size	_Z11knnPunisherP6float2Piiiii, .-_Z11knnPunisherP6float2Piiiii
	.section	.rodata.str1.1
.LC8:
	.string	"create before_allocation cudaEvent"
.LC9:
	.string	"create before_input cudaEvent"
.LC10:
	.string	"create before_upload cudaEvent"
.LC11:
	.string	"create before_knn cudaEvent"
.LC12:
	.string	"create before_download cudaEvent"
.LC13:
	.string	"create after_allocation cudaEvent"
.LC14:
	.string	"create after_input cudaEvent"
.LC15:
	.string	"create after_upload cudaEvent"
.LC16:
	.string	"create after_knn cudaEvent"
.LC17:
	.string	"create after_download cudaEvent"
.LC18:
	.string	"r"
.LC19:
	.string	"how-to-use: knn <inputfile> <k> \n"
.LC20:
	.string	"No such file\n"
.LC21:
	.string	"%d,%d,%d,%d\n"
.LC22:
	.string	"alloc d_coords_x"
.LC23:
	.string	"alloc d_classes"
.LC24:
	.string	"alloc d_determinate"
.LC25:
	.string	"alloc d_kOutput"
.LC26:
	.string	"copy d_coords"
.LC27:
	.string	"copy d_classes"
.LC28:
	.string	"download classes"
.LC29:
	.string	"sync cudaEvents"
.LC30:
	.string	"knn"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2027:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	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
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$440, %rsp
	.cfi_def_cfa_offset 496
	movq	%fs:40, %rax
	movq	%rax, 424(%rsp)
	xorl	%eax, %eax
	cmpl	$2, %edi
	jle	.L48
	movq	%rsi, %rbx
	leaq	169(%rsp), %rbp
	movq	8(%rsi), %rsi
	movl	$255, %edx
	movq	%rbp, %rdi
	call	__strcpy_chk@PLT
	movq	16(%rbx), %rdi
	call	atoi@PLT
	leaq	64(%rsp), %rdi
	movl	%eax, %r15d
	call	cudaEventCreate@PLT
	leaq	.LC8(%rip), %rsi
	movl	%eax, %edi
	call	_Z11check_error9cudaErrorPKc
	leaq	72(%rsp), %rdi
	call	cudaEventCreate@PLT
	leaq	.LC9(%rip), %rsi
	movl	%eax, %edi
	call	_Z11check_error9cudaErrorPKc
	leaq	80(%rsp), %rdi
	call	cudaEventCreate@PLT
	leaq	.LC10(%rip), %rsi
	movl	%eax, %edi
	call	_Z11check_error9cudaErrorPKc
	leaq	88(%rsp), %rdi
	call	cudaEventCreate@PLT
	leaq	.LC11(%rip), %rsi
	movl	%eax, %edi
	call	_Z11check_error9cudaErrorPKc
	leaq	96(%rsp), %rdi
	call	cudaEventCreate@PLT
	leaq	.LC12(%rip), %rsi
	movl	%eax, %edi
	call	_Z11check_error9cudaErrorPKc
	leaq	104(%rsp), %rdi
	call	cudaEventCreate@PLT
	leaq	.LC13(%rip), %rsi
	movl	%eax, %edi
	call	_Z11check_error9cudaErrorPKc
	leaq	112(%rsp), %rdi
	call	cudaEventCreate@PLT
	leaq	.LC14(%rip), %rsi
	movl	%eax, %edi
	call	_Z11check_error9cudaErrorPKc
	leaq	120(%rsp), %rdi
	call	cudaEventCreate@PLT
	leaq	.LC15(%rip), %rsi
	movl	%eax, %edi
	call	_Z11check_error9cudaErrorPKc
	leaq	128(%rsp), %rdi
	call	cudaEventCreate@PLT
	leaq	.LC16(%rip), %rsi
	movl	%eax, %edi
	call	_Z11check_error9cudaErrorPKc
	leaq	136(%rsp), %rdi
	call	cudaEventCreate@PLT
	leaq	.LC17(%rip), %rsi
	movl	%eax, %edi
	call	_Z11check_error9cudaErrorPKc
	leaq	.LC18(%rip), %rsi
	movq	%rbp, %rdi
	call	fopen@PLT
	movq	%rax, %rbx
	testq	%rax, %rax
	jne	.L54
	leaq	.LC20(%rip), %rsi
	jmp	.L56
.L48:
	leaq	.LC19(%rip), %rsi
.L56:
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$1, %edi
	call	exit@PLT
.L54:
	xorl	%esi, %esi
	movl	$2, %edx
	movq	%rax, %rdi
	call	fseek@PLT
	movq	%rbx, %rdi
	call	ftell@PLT
	movq	%rbx, %rdi
	call	rewind@PLT
	leaq	16(%rsp), %rcx
	movq	%rbx, %rdi
	xorl	%eax, %eax
	leaq	20(%rsp), %rdx
	leaq	24(%rsp), %r9
	leaq	28(%rsp), %r8
	leaq	.LC21(%rip), %rsi
	call	__isoc23_fscanf@PLT
	movq	64(%rsp), %rdi
	xorl	%esi, %esi
	movl	16(%rsp), %ebp
	addl	20(%rsp), %ebp
	call	cudaEventRecord@PLT
	movslq	24(%rsp), %rsi
	movslq	%ebp, %r13
	imulq	%r13, %rsi
	salq	$2, %r13
	salq	$2, %rsi
	movq	%rsi, %rdi
	movq	%rsi, 8(%rsp)
	call	malloc@PLT
	movq	%r13, %rdi
	movq	%rax, %r14
	call	malloc@PLT
	movq	8(%rsp), %rsi
	leaq	32(%rsp), %rdi
	movq	%rax, %r12
	call	cudaMalloc@PLT
	leaq	.LC22(%rip), %rsi
	movl	%eax, %edi
	call	_Z11check_error9cudaErrorPKc
	leaq	48(%rsp), %rdi
	movq	%r13, %rsi
	call	cudaMalloc@PLT
	leaq	.LC23(%rip), %rsi
	movl	%eax, %edi
	call	_Z11check_error9cudaErrorPKc
	movl	16(%rsp), %eax
	leaq	40(%rsp), %rdi
	leal	(%rax,%rax), %esi
	movslq	%esi, %rsi
	salq	$2, %rsi
	call	cudaMalloc@PLT
	leaq	.LC24(%rip), %rsi
	movl	%eax, %edi
	call	_Z11check_error9cudaErrorPKc
	imull	$40, 16(%rsp), %esi
	leaq	56(%rsp), %rdi
	movslq	%esi, %rsi
	salq	$2, %rsi
	call	cudaMalloc@PLT
	leaq	.LC25(%rip), %rsi
	movl	%eax, %edi
	call	_Z11check_error9cudaErrorPKc
	movq	104(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	72(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movl	20(%rsp), %r8d
	movl	%ebp, %r9d
	movq	%r12, %rdx
	movl	24(%rsp), %ecx
	movq	%rbx, %rdi
	movq	%r14, %rsi
	call	_Z9readInputP8_IO_FILEPfPiiii
	movq	112(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	%rbx, %rdi
	call	fclose@PLT
	movq	80(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movl	24(%rsp), %edx
	movq	32(%rsp), %rdi
	movq	%r14, %rsi
	movl	$1, %ecx
	imull	%ebp, %edx
	movslq	%edx, %rdx
	salq	$2, %rdx
	call	cudaMemcpy@PLT
	leaq	.LC26(%rip), %rsi
	movl	%eax, %edi
	call	_Z11check_error9cudaErrorPKc
	movq	48(%rsp), %rdi
	movq	%r13, %rdx
	movq	%r12, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	leaq	.LC27(%rip), %rsi
	movl	%eax, %edi
	call	_Z11check_error9cudaErrorPKc
	movq	120(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movl	16(%rsp), %eax
	movl	$512, %ecx
	xorl	%esi, %esi
	movq	88(%rsp), %rdi
	addl	$511, %eax
	cltd
	idivl	%ecx
	movl	%eax, %ebx
	call	cudaEventRecord@PLT
	movl	$8388609, %edx
	movslq	%r15d, %r8
	xorl	%r9d, %r9d
	movl	%ebx, 144(%rsp)
	salq	$9, %rdx
	salq	$12, %r8
	movabsq	$4294967297, %rax
	movq	%rax, 148(%rsp)
	movl	$1, %ecx
	movq	144(%rsp), %rdi
	movl	152(%rsp), %esi
	movq	%rdx, 156(%rsp)
	movl	$1, 164(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L51
	movl	28(%rsp), %eax
	movl	%ebp, %edx
	movl	%r15d, %r9d
	pushq	%rax
	.cfi_def_cfa_offset 504
	pushq	56(%rsp)
	.cfi_def_cfa_offset 512
	movl	40(%rsp), %r8d
	movl	36(%rsp), %ecx
	movq	72(%rsp), %rsi
	movq	48(%rsp), %rdi
	call	_Z37__device_stub__Z3knnPfP6float2iiiiPiiPfP6float2iiiiPii
	popq	%rax
	.cfi_def_cfa_offset 504
	popq	%rdx
	.cfi_def_cfa_offset 496
.L51:
	movslq	16(%rsp), %rcx
	movl	$32, %edi
	movl	$134217729, %esi
	xorl	%r9d, %r9d
	movl	$1, 164(%rsp)
	salq	$5, %rsi
	leal	31(%rcx), %eax
	movq	%rsi, 156(%rsp)
	leaq	0(,%rcx,4), %r8
	movl	$1, %ecx
	cltd
	idivl	%edi
	movq	%rsi, %rdx
	movl	%eax, 144(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 148(%rsp)
	movq	144(%rsp), %rdi
	movl	152(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L52
	movl	28(%rsp), %r9d
	movl	16(%rsp), %ecx
	movl	%r15d, %r8d
	movl	20(%rsp), %edx
	movq	48(%rsp), %rsi
	movq	56(%rsp), %rdi
	call	_Z43__device_stub__Z11knnPunisherP6float2PiiiiiP6float2Piiiii
.L52:
	movq	128(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movslq	20(%rsp), %rdi
	movslq	16(%rsp), %rdx
	movl	$2, %ecx
	movq	48(%rsp), %rsi
	salq	$2, %rdi
	salq	$2, %rdx
	addq	%rdi, %rsi
	addq	%r12, %rdi
	call	cudaMemcpy@PLT
	leaq	.LC28(%rip), %rsi
	movl	%eax, %edi
	call	_Z11check_error9cudaErrorPKc
	movq	128(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	leaq	.LC29(%rip), %rsi
	movl	%eax, %edi
	call	_Z11check_error9cudaErrorPKc
	movq	128(%rsp), %rsi
	movq	88(%rsp), %rdi
	leaq	.LC30(%rip), %rdx
	call	_Z10printStatsP10CUevent_stS0_PKc
	movl	24(%rsp), %edx
	movl	%ebp, %ecx
	movq	%r12, %rsi
	movq	%r14, %rdi
	call	_Z11writeOutputPfPiii
	movq	424(%rsp), %rax
	subq	%fs:40, %rax
	je	.L53
	call	__stack_chk_fail@PLT
.L53:
	addq	$440, %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
.LFE2027:
	.size	main, .-main
	.section	.rodata.str1.1
.LC31:
	.string	"_Z11knnPunisherP6float2Piiiii"
.LC32:
	.string	"_Z3knnPfP6float2iiiiPii"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2065:
	.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	.LC31(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z11knnPunisherP6float2Piiiii(%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	.LC32(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z3knnPfP6float2iiiiPii(%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
.LFE2065:
	.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
	.globl	runtime
	.bss
	.align 4
	.type	runtime, @object
	.size	runtime, 4
runtime:
	.zero	4
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:


#include <hip/hip_runtime.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include <hip/hip_runtime_api.h>

#define restrict __restrict__
#define PADDINGCLASS -2
#define OUTPUT_FILE "ocuda"
#define INPUT_FILE "data"
#define KMAX 20
#define CLASSESMAX 100
#define SPACEDIMMAX 100

void check_error(hipError_t err, const char *msg);
void printStats(hipEvent_t before, hipEvent_t after, const char *msg);
void readInput(FILE* file, float* coords, int* classes, int spacedim, int numels, int totalElements);
void writeOutput(float* coords, int* classes, int spacedim, int numels);

__global__ void knn(float* const restrict coords, float2* restrict kOutput, const int totalElements, const int numels, const int spacedim, const int k, int* restrict classes, const int classes_num);
__global__ void knnPunisher(float2* restrict kOutput, int* restrict classes, const int numels, const int newels, const int k, const int classes_num);
__device__ float distance(float* const coords, float* const coords2, const int spacedim);
__device__ int insert(float* kPoints, float2 newDist, int* size, const int k, const int gid, const int offset);
__device__ void swap(float* x1, float* x2, float* y1, float* y2);
__device__ int deviceFindMode(int* kclasses, int classes_num, int k);
__device__ float distanceShm(float* coords, int left, int spacedim);

int main(int argc, char *argv[])
{  
  int newels;                      //number of points we want classify
  int k;                           //number of nearest points we use to classify
  int numels;                      //total element already classified
  int spacedim;
  char filePath[255];              //path + filname of input file
  int classes_num;                 //number of classes
  float* h_coords;                //coords of existing points with a class
  int* h_classes;                  //array contains the class for each points
  
  //*** Device-variables-declaration ***
  float* d_coords;
  int2* d_determinate;
  int* d_classes;
  float2* d_kOutput;
  //*** end-device-declaration
  
  //***cudaEvent-declaration***
  hipEvent_t before_allocation, before_input, before_upload, before_knn, before_download;
  hipEvent_t after_allocation, after_input, after_upload, after_knn, after_download;
  //***end-cudaEvent-declaration***
  
  //Requisiti: numels e newels devono essere maggiori di K
  if (argc > 2) 
  {
    strcpy(filePath, argv[1]);
    k = atoi(argv[2]);
  }
  else 
  {
    printf("how-to-use: knn <inputfile> <k> \n");
    exit(1);
  } 
  
  //***cuda-init-event***
  check_error(hipEventCreate(&before_allocation), "create before_allocation cudaEvent");
  check_error(hipEventCreate(&before_input), "create before_input cudaEvent");
  check_error(hipEventCreate(&before_upload), "create before_upload cudaEvent");
  check_error(hipEventCreate(&before_knn), "create before_knn cudaEvent");
  check_error(hipEventCreate(&before_download), "create before_download cudaEvent");
  
  check_error(hipEventCreate(&after_allocation), "create after_allocation cudaEvent");
  check_error(hipEventCreate(&after_input), "create after_input cudaEvent");
  check_error(hipEventCreate(&after_upload), "create after_upload cudaEvent");
  check_error(hipEventCreate(&after_knn), "create after_knn cudaEvent");
  check_error(hipEventCreate(&after_download), "create after_download cudaEvent");
  //***end-cuda-init-event***

  FILE *fp;
  if((fp = fopen(filePath, "r")) == NULL)
  {
        printf("No such file\n");
        exit(1);
  }
  
  fseek(fp, 0L, SEEK_END);
  float fileSize = ftell(fp);
  rewind(fp);
  
  int count = fscanf(fp, "%d,%d,%d,%d\n", &numels, &newels, &classes_num, &spacedim);
  int totalElements = numels + newels;

  //*** allocation ***
  hipEventRecord(before_allocation);
  h_coords = (float*) malloc(sizeof(float)*totalElements*spacedim);
  h_classes = (int*) malloc(sizeof(int)*totalElements);
   
  //*** device-allocation ***
  check_error(hipMalloc(&d_coords, totalElements*spacedim*sizeof(float)), "alloc d_coords_x");
  check_error(hipMalloc(&d_classes, totalElements*sizeof(int)), "alloc d_classes");
  check_error(hipMalloc(&d_determinate, newels*2*sizeof(int)), "alloc d_determinate");
  check_error(hipMalloc(&d_kOutput, newels*KMAX*2*sizeof(float)), "alloc d_kOutput");

  //*** end-device-allocation ***
  hipEventRecord(after_allocation);
  
  ///***input-from-file***
  hipEventRecord(before_input);
  readInput(fp, h_coords, h_classes, spacedim, numels, totalElements);
  hipEventRecord(after_input);
  fclose(fp);
  ///***end-input-from-file***

  //***copy-arrays-on-device***
  hipEventRecord(before_upload);
  check_error(hipMemcpy(d_coords, h_coords, totalElements*spacedim*sizeof(float), hipMemcpyHostToDevice), "copy d_coords");
  check_error(hipMemcpy(d_classes, h_classes, totalElements*sizeof(int), hipMemcpyHostToDevice), "copy d_classes");
  hipEventRecord(after_upload);
  //***end-copy-arrays-on-device***                              
  
  int blockSize = 512;
  int numBlocks = (newels + blockSize - 1)/blockSize;
   
  hipEventRecord(before_knn);
  knn<<<numBlocks, blockSize, (blockSize*sizeof(float)*2*k)>>>(d_coords, d_kOutput, totalElements, numels, spacedim, k, d_classes, classes_num);
  blockSize = 32;
  numBlocks = (newels + blockSize - 1)/blockSize;
  knnPunisher<<<numBlocks, blockSize, newels*sizeof(int)>>>(d_kOutput, d_classes, numels, newels, k, classes_num);
  hipEventRecord(after_knn);
  check_error(hipMemcpy(h_classes+numels, d_classes+numels, newels*sizeof(int), hipMemcpyDeviceToHost), "download classes");

  check_error(hipEventSynchronize(after_knn), "sync cudaEvents");
  printStats(before_knn, after_knn, "knn");
    
  writeOutput(h_coords, h_classes, spacedim, totalElements);
  return 0;
}

void check_error(hipError_t err, const char *msg)
{
  if (err != hipSuccess) 
  {
    fprintf(stderr, "%s : error %d (%s)\n", msg, err, hipGetErrorString(err));
    exit(err);
  }
}

float runtime;
void printStats(hipEvent_t before, hipEvent_t after, const char *msg)
{ 
  check_error(hipEventElapsedTime(&runtime, before, after), msg);
  printf("%s %gms\n", msg, runtime);
}

__global__ void knn(float* const restrict coords, float2* restrict kOutput, const int totalElements, const int numels, const int spacedim, const int k, int* restrict classes, const int classes_num)
{
  extern __shared__ float shm[];
  int gid = numels + threadIdx.x + blockIdx.x*blockDim.x;
  if (gid >= totalElements) return;
  
  float* newPointCoords = coords+spacedim*gid;
  float* pointCoords;
  int offset = blockDim.x;
  int lid = threadIdx.x;

  int i = 0, size = 0, count = 0;
  float point[SPACEDIMMAX];

  for (i = 0; i < spacedim; i++)
   point[i] = newPointCoords[i];
  
  float2 dist;
  pointCoords = coords;
  for (i = 0; i < numels; i++)
  {
    dist = make_float2(distance(point, pointCoords, spacedim), i);
    insert(shm+lid, dist, &size, k, gid, offset);
    pointCoords += spacedim;
  }
  
  for (count=0; i < gid; i++)
  {
      dist = make_float2(distance(point, pointCoords, spacedim), i);
      count += insert(shm+lid, dist, &size, k, gid, offset);
      pointCoords += spacedim;
  }
    
  if (count > 0)
  {
    classes[gid] = -1;
  }
  else
  {
    int kclasses[KMAX];
    for (int j = 0; j < k; j++)
      kclasses[j] = classes[(int)(shm[(j+k)*offset+lid])];
    classes[gid] = deviceFindMode(kclasses, classes_num, k);
  }
  
  //copia kPoints in kOutput
  int newelId = gid-numels;
  for (i = 0; i < k; i++)
  {
    kOutput[newelId*KMAX + i].x = shm[i*offset + lid];
    kOutput[newelId*KMAX + i].y = shm[(i+k)*offset + lid];
  }
    
}


__global__ void knnPunisher(float2* restrict kOutput, int* restrict classes, const int numels, const int newels, const int k, const int classes_num)
{
  //Declaration of shared-memory. It's going to contains partial minimum of distances
  extern __shared__ int mPartial[];
  
  int gid = threadIdx.x + blockIdx.x*blockDim.x;
  if (gid >= newels) return;

  //stiamo lancio un kernel per ogni newels
  //prendiamo la classe del newels e la mettiamo nella shared memory
  int i, id, lid, kclasses[KMAX], kPoints[KMAX], count = 1;
  
  //Se sono qui la classe per il kPoint è da determinare
  for (i = 0; i < k; i++)
    kPoints[i] = kOutput[gid*KMAX+i].y; //gid

  while(count != 0)
  {
      for (i = 0; i < gid; i++)
              mPartial[i] = classes[i+numels];

      mPartial[gid] = classes[gid+numels];
      if (mPartial[gid] != -1) return;
      __syncthreads();

      //Le sue dipendenze, se già determinate stanno nella shared-memory
      count = 0;
      for (i = k-1; i >= 0; i--)
      {
        id = kPoints[i];
        lid = id - numels;
        if (id > numels && mPartial[lid] < 0)
        {
          //segno quelli indeterminati
          count++;
          break;
        }
      }

      if (count == 0)
      {
        //posso determinare il punto
        //le sue dipendenze si trovano in shared memory
          for (i = 0; i < k; i++)
              kclasses[i] = classes[kPoints[i]];
        classes[gid+numels] = deviceFindMode(kclasses, classes_num, k);
      }
  }
}

__device__ int deviceFindMode(int* kclasses, int classes_num, int k)
{
  int classesCount[CLASSESMAX];

  int i;
  int temp=0;
  
  for (i = 0; i < CLASSESMAX; i++)
    classesCount[i] = 0;
       
  for (i = 0; i < k; i++){
    temp=kclasses[i];
    classesCount[temp]+=1;
  } 

  int max = 0;
  int maxValue = classesCount[0];

  for (i = 1; i < classes_num; i++)
  {
    int value = classesCount[i];
    if (value > maxValue)
    {
      max = i;
      maxValue = value;
    }
    else if (value != 0 && maxValue == value)
    {
        int j = 0;
        for (j = 0; j < k; j++)
        {
          if (kclasses[j] == i)
          {
            max = i;
            break;
          }
          else if (kclasses[j] == max)
            break;
        }
    }
  }
  
  return max;
}

//inserimento smart in kPoints
__device__ int insert(float* kPoints, float2 newDist, int* size, const int k, const int gid, const int offset)
{  
    int inserted = 0;
    if (*size == 0)
    {
      //Caso base: inserimento su array vuoto
      kPoints[0] = newDist.x;
      kPoints[k*offset] = newDist.y;
      *size = *size + 1;
      return 1;
    }
  
    int i = 1;
    float* valueX, *valueY, *tailX, *tailY;
    valueX = &(newDist.x);
    valueY = &(newDist.y);
    tailX = &(kPoints[(*size-i)*offset]);
    tailY = &(kPoints[(*size-i+k)*offset]);

    if (*size < k)
    {  
        kPoints[(*size)*offset] = newDist.x;
        kPoints[((*size)+k)*offset] = newDist.y;
        valueX = &(kPoints[(*size)*offset]);
        valueY = &(kPoints[((*size)+k)*offset]);
        inserted = 1;
    }

    //partire della fine, swap se trovo elemento più grande - mi fermo se trovo elemento più piccolo
    while (i <= *size && *(tailX) > *(valueX))
    {
        swap(tailX, valueX, tailY, valueY);
        valueX = tailX;
        valueY = tailY;
        i++;
        tailX = &(kPoints[(*size-i)*offset]);
        tailY = &(kPoints[(*size-i+k)*offset]);
        inserted = 1;    
    }
    
    if (inserted && *size < k) *size = *size + 1;
    return inserted;
}

__device__ void swap(float* x1, float* x2, float* y1, float* y2)
{
  float tmp;
  
  tmp = *(x1);
  *(x1) = *(x2);
  *(x2) = tmp;
  
  tmp = *(y1);
  *(y1) = *(y2);
  *(y2) = tmp;
}


// read input from file
void readInput(FILE* file, float* coords, int* classes, int spacedim, int numels, int totalElements)
{
  int i, j;
  int count;
  for(i=0; i<numels; i++)
  {
    for (j = 0; j < spacedim; j++)
      count = fscanf(file, "%f,", &(coords[i*spacedim +j]));
    count = fscanf(file, "%d\n", &(classes[i]));
  }
   
  for(; i < totalElements; i++)
  {
    for (j = 0; j < spacedim; j++)
      count = fscanf(file, "%f,", &(coords[i*spacedim+j]));
    count = fscanf(file, "-1\n");
  }
  count++;
}

//Write Output on file
void writeOutput(float* coords, int* classes, int spacedim, int numels)
{
  FILE *fp;
  fp = fopen(OUTPUT_FILE, "w");
  int i, j;
  for( i = 0; i < numels; i++)
  {
    for (j = 0; j < spacedim; j++)
      fprintf(fp, "%lf,", coords[i*spacedim+j]);
    
    fprintf(fp, "%d\n", classes[i]);
  }
  fclose(fp); 
}

//multidimensional euclidian distance (without sqrt)
__device__ float distance(float* const coords, float* const coords2, const int spacedim)
{
  float sum = 0;
  int i;
  for (i = 0; i < spacedim; i++)
  {
    float diff = coords[i] - coords2[i];
    sum += diff*diff;
  }  
  return sum;
}

	.text
	.file	"knn_punisher_roll_optimized.hip"
	.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	$424, %rsp                      # imm = 0x1A8
	.cfi_def_cfa_offset 480
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	cmpl	$3, %edi
	jl	.LBB0_3
# %bb.1:
	movq	%rsi, %r14
	movq	8(%rsi), %rsi
	leaq	160(%rsp), %rbx
	movq	%rbx, %rdi
	callq	strcpy
	movq	16(%r14), %rdi
	callq	atoi
	movl	%eax, 36(%rsp)                  # 4-byte Spill
	leaq	128(%rsp), %rdi
	callq	hipEventCreate
	movl	$.L.str.1, %esi
	movl	%eax, %edi
	callq	_Z11check_error10hipError_tPKc
	leaq	120(%rsp), %rdi
	callq	hipEventCreate
	movl	$.L.str.2, %esi
	movl	%eax, %edi
	callq	_Z11check_error10hipError_tPKc
	leaq	112(%rsp), %rdi
	callq	hipEventCreate
	movl	$.L.str.3, %esi
	movl	%eax, %edi
	callq	_Z11check_error10hipError_tPKc
	leaq	48(%rsp), %rdi
	callq	hipEventCreate
	movl	$.L.str.4, %esi
	movl	%eax, %edi
	callq	_Z11check_error10hipError_tPKc
	leaq	144(%rsp), %rdi
	callq	hipEventCreate
	movl	$.L.str.5, %esi
	movl	%eax, %edi
	callq	_Z11check_error10hipError_tPKc
	leaq	104(%rsp), %rdi
	callq	hipEventCreate
	movl	$.L.str.6, %esi
	movl	%eax, %edi
	callq	_Z11check_error10hipError_tPKc
	leaq	96(%rsp), %rdi
	callq	hipEventCreate
	movl	$.L.str.7, %esi
	movl	%eax, %edi
	callq	_Z11check_error10hipError_tPKc
	leaq	88(%rsp), %rdi
	callq	hipEventCreate
	movl	$.L.str.8, %esi
	movl	%eax, %edi
	callq	_Z11check_error10hipError_tPKc
	leaq	24(%rsp), %rdi
	callq	hipEventCreate
	movl	$.L.str.9, %esi
	movl	%eax, %edi
	callq	_Z11check_error10hipError_tPKc
	leaq	136(%rsp), %rdi
	callq	hipEventCreate
	movl	$.L.str.10, %esi
	movl	%eax, %edi
	callq	_Z11check_error10hipError_tPKc
	movl	$.L.str.11, %esi
	movq	%rbx, %rdi
	callq	fopen
	testq	%rax, %rax
	je	.LBB0_2
# %bb.5:
	movq	%rax, %rbx
	movq	%rax, %rdi
	xorl	%esi, %esi
	movl	$2, %edx
	callq	fseek
	movq	%rbx, %rdi
	callq	ftell
	movq	%rbx, %rdi
	callq	rewind
	leaq	4(%rsp), %r12
	movq	%rsp, %r14
	leaq	12(%rsp), %r8
	leaq	8(%rsp), %r9
	movl	$.L.str.13, %esi
	movq	%rbx, %rdi
	movq	%r12, %rdx
	movq	%r14, %rcx
	movq	%r9, %r15
	xorl	%eax, %eax
	callq	__isoc23_fscanf
	movslq	(%r12), %rax
	movslq	(%r14), %r12
	addq	%rax, %r12
	movq	128(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	%r12, %r14
	shlq	$2, %r14
	movslq	(%r15), %rbp
	movq	%r14, %rdi
	imulq	%rbp, %rdi
	callq	malloc
	movq	%rax, 80(%rsp)                  # 8-byte Spill
	movq	%r14, %rdi
	callq	malloc
	movq	%rax, 72(%rsp)                  # 8-byte Spill
	movq	%r12, 40(%rsp)                  # 8-byte Spill
	movslq	%r12d, %r13
	imulq	%r13, %rbp
	shlq	$2, %rbp
	leaq	64(%rsp), %rdi
	movq	%rbp, %rsi
	callq	hipMalloc
	movl	$.L.str.14, %esi
	movl	%eax, %edi
	callq	_Z11check_error10hipError_tPKc
	leaq	16(%rsp), %rdi
	movq	%r14, %rsi
	callq	hipMalloc
	movl	$.L.str.15, %esi
	movl	%eax, %edi
	callq	_Z11check_error10hipError_tPKc
	movq	%rsp, %r15
	movslq	(%r15), %rsi
	shlq	$3, %rsi
	leaq	152(%rsp), %rdi
	callq	hipMalloc
	movl	$.L.str.16, %esi
	movl	%eax, %edi
	callq	_Z11check_error10hipError_tPKc
	movl	(%r15), %eax
	shll	$3, %eax
	leal	(%rax,%rax,4), %eax
	movslq	%eax, %rsi
	shlq	$2, %rsi
	leaq	56(%rsp), %rdi
	callq	hipMalloc
	movl	$.L.str.17, %esi
	movl	%eax, %edi
	callq	_Z11check_error10hipError_tPKc
	movq	104(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	120(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	leaq	8(%rsp), %rbp
	movl	(%rbp), %ecx
	leaq	4(%rsp), %rax
	movl	(%rax), %r8d
	movq	%rbx, %rdi
	movq	80(%rsp), %r12                  # 8-byte Reload
	movq	%r12, %rsi
	movq	72(%rsp), %r15                  # 8-byte Reload
	movq	%r15, %rdx
	movl	%r13d, %r9d
	callq	_Z9readInputP8_IO_FILEPfPiiii
	movq	96(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	%rbx, %rdi
	callq	fclose
	movq	112(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	leaq	64(%rsp), %rax
	movq	(%rax), %rdi
	movslq	(%rbp), %rdx
	imulq	%r13, %rdx
	shlq	$2, %rdx
	movq	%r12, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	movl	$.L.str.18, %esi
	movl	%eax, %edi
	callq	_Z11check_error10hipError_tPKc
	leaq	16(%rsp), %rax
	movq	(%rax), %rdi
	movq	%r15, %rsi
	movq	%r14, %rdx
	movabsq	$4294967296, %r14               # imm = 0x100000000
	movl	$1, %ecx
	callq	hipMemcpy
	movl	$.L.str.19, %esi
	movl	%eax, %edi
	callq	_Z11check_error10hipError_tPKc
	movq	88(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	%rsp, %rax
	movl	(%rax), %ebx
	leal	511(%rbx), %eax
	addl	$1022, %ebx                     # imm = 0x3FE
	testl	%eax, %eax
	cmovnsl	%eax, %ebx
	sarl	$9, %ebx
	movq	48(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movl	36(%rsp), %ebp                  # 4-byte Reload
	movslq	%ebp, %r8
	shlq	$12, %r8
	btsq	$32, %rbx
	leaq	512(%r14), %rdx
	movq	%rbx, %rdi
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	movl	%ebp, %ebx
	jne	.LBB0_7
# %bb.6:
	movq	64(%rsp), %rdi
	movq	56(%rsp), %rsi
	movl	4(%rsp), %ecx
	movl	8(%rsp), %r8d
	movl	12(%rsp), %eax
	movq	40(%rsp), %rdx                  # 8-byte Reload
                                        # kill: def $edx killed $edx killed $rdx
	movl	%ebx, %r9d
	pushq	%rax
	.cfi_adjust_cfa_offset 8
	pushq	24(%rsp)
	.cfi_adjust_cfa_offset 8
	callq	_Z18__device_stub__knnPfP15HIP_vector_typeIfLj2EEiiiiPii
	addq	$16, %rsp
	.cfi_adjust_cfa_offset -16
.LBB0_7:
	movslq	(%rsp), %r8
	leal	31(%r8), %eax
	leal	62(%r8), %edi
	testl	%eax, %eax
	cmovnsl	%eax, %edi
	sarl	$5, %edi
	shlq	$2, %r8
	orq	%r14, %rdi
	addq	$32, %r14
	movl	$1, %esi
	movq	%r14, %rdx
	movl	$1, %ecx
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB0_9
# %bb.8:
	movq	56(%rsp), %rdi
	movq	16(%rsp), %rsi
	movl	4(%rsp), %edx
	movl	(%rsp), %ecx
	movl	12(%rsp), %r9d
	movl	%ebx, %r8d
	callq	_Z26__device_stub__knnPunisherP15HIP_vector_typeIfLj2EEPiiiii
.LBB0_9:
	movq	24(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movslq	4(%rsp), %rsi
	leaq	(%r15,%rsi,4), %rdi
	shlq	$2, %rsi
	addq	16(%rsp), %rsi
	movslq	(%rsp), %rdx
	shlq	$2, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	movl	$.L.str.20, %esi
	movl	%eax, %edi
	callq	_Z11check_error10hipError_tPKc
	movq	24(%rsp), %rdi
	callq	hipEventSynchronize
	movl	$.L.str.21, %esi
	movl	%eax, %edi
	callq	_Z11check_error10hipError_tPKc
	movq	48(%rsp), %rdi
	movq	24(%rsp), %rsi
	movl	$.L.str.22, %edx
	callq	_Z10printStatsP11ihipEvent_tS0_PKc
	movl	8(%rsp), %edx
	movq	%r12, %rdi
	movq	%r15, %rsi
	movq	40(%rsp), %rcx                  # 8-byte Reload
                                        # kill: def $ecx killed $ecx killed $rcx
	callq	_Z11writeOutputPfPiii
	xorl	%eax, %eax
	addq	$424, %rsp                      # imm = 0x1A8
	.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
.LBB0_3:
	.cfi_def_cfa_offset 480
	movl	$.Lstr, %edi
	jmp	.LBB0_4
.LBB0_2:
	movl	$.Lstr.1, %edi
.LBB0_4:
	callq	puts@PLT
	movl	$1, %edi
	callq	exit
.Lfunc_end0:
	.size	main, .Lfunc_end0-main
	.cfi_endproc
                                        # -- End function
	.globl	_Z11check_error10hipError_tPKc  # -- Begin function _Z11check_error10hipError_tPKc
	.type	_Z11check_error10hipError_tPKc,@function
_Z11check_error10hipError_tPKc:         # @_Z11check_error10hipError_tPKc
	.cfi_startproc
# %bb.0:
	testl	%edi, %edi
	jne	.LBB1_2
# %bb.1:
	retq
.LBB1_2:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rsi, %r14
	movl	%edi, %ebx
	movq	stderr(%rip), %r15
	callq	hipGetErrorString
	movl	$.L.str.23, %esi
	movq	%r15, %rdi
	movq	%r14, %rdx
	movl	%ebx, %ecx
	movq	%rax, %r8
	xorl	%eax, %eax
	callq	fprintf
	movl	%ebx, %edi
	callq	exit
.Lfunc_end1:
	.size	_Z11check_error10hipError_tPKc, .Lfunc_end1-_Z11check_error10hipError_tPKc
	.cfi_endproc
                                        # -- End function
	.globl	_Z9readInputP8_IO_FILEPfPiiii   # -- Begin function _Z9readInputP8_IO_FILEPfPiiii
	.type	_Z9readInputP8_IO_FILEPfPiiii,@function
_Z9readInputP8_IO_FILEPfPiiii:          # @_Z9readInputP8_IO_FILEPfPiiii
	.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	%ecx, %ebx
	movq	%rdx, 8(%rsp)                   # 8-byte Spill
	movq	%rsi, 24(%rsp)                  # 8-byte Spill
	movq	%rdi, %r14
	movl	%ecx, %eax
	movq	%rax, 32(%rsp)                  # 8-byte Spill
	testl	%r8d, %r8d
	jle	.LBB2_1
# %bb.9:                                # %.preheader33.lr.ph
	movl	%r9d, 20(%rsp)                  # 4-byte Spill
	movl	%r8d, 16(%rsp)                  # 4-byte Spill
	movl	%r8d, %eax
	movq	%rax, (%rsp)                    # 8-byte Spill
	xorl	%r15d, %r15d
	xorl	%r13d, %r13d
.LBB2_10:                               # %.preheader33
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB2_12 Depth 2
	testl	%ebx, %ebx
	jle	.LBB2_13
# %bb.11:                               #   in Loop: Header=BB2_10 Depth=1
	movl	%r15d, %eax
	movq	24(%rsp), %rcx                  # 8-byte Reload
	leaq	(%rcx,%rax,4), %rbp
	movq	32(%rsp), %r12                  # 8-byte Reload
.LBB2_12:                               #   Parent Loop BB2_10 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	$.L.str.25, %esi
	movq	%r14, %rdi
	movq	%rbp, %rdx
	xorl	%eax, %eax
	callq	__isoc23_fscanf
	addq	$4, %rbp
	decq	%r12
	jne	.LBB2_12
.LBB2_13:                               # %._crit_edge
                                        #   in Loop: Header=BB2_10 Depth=1
	movq	8(%rsp), %rax                   # 8-byte Reload
	leaq	(%rax,%r13,4), %rdx
	movl	$.L.str.26, %esi
	movq	%r14, %rdi
	xorl	%eax, %eax
	callq	__isoc23_fscanf
	incq	%r13
	addl	%ebx, %r15d
	cmpq	(%rsp), %r13                    # 8-byte Folded Reload
	jne	.LBB2_10
# %bb.14:
	movl	20(%rsp), %r9d                  # 4-byte Reload
	movl	16(%rsp), %eax                  # 4-byte Reload
	jmp	.LBB2_2
.LBB2_1:
	xorl	%eax, %eax
.LBB2_2:                                # %.preheader32
	cmpl	%r9d, %eax
	jge	.LBB2_8
# %bb.3:                                # %.preheader.lr.ph
	movl	%eax, %r13d
	movslq	%ebx, %rdx
	movl	%r9d, %eax
	movq	%rax, (%rsp)                    # 8-byte Spill
	movq	%rdx, %rax
	imulq	%r13, %rax
	movq	24(%rsp), %rcx                  # 8-byte Reload
	leaq	(%rcx,%rax,4), %r12
	shlq	$2, %rdx
	movq	%rdx, 8(%rsp)                   # 8-byte Spill
.LBB2_4:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB2_6 Depth 2
	testl	%ebx, %ebx
	jle	.LBB2_7
# %bb.5:                                # %.lr.ph37
                                        #   in Loop: Header=BB2_4 Depth=1
	movq	32(%rsp), %rbp                  # 8-byte Reload
	movq	%r12, %r15
.LBB2_6:                                #   Parent Loop BB2_4 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	$.L.str.25, %esi
	movq	%r14, %rdi
	movq	%r15, %rdx
	xorl	%eax, %eax
	callq	__isoc23_fscanf
	addq	$4, %r15
	decq	%rbp
	jne	.LBB2_6
.LBB2_7:                                # %._crit_edge38
                                        #   in Loop: Header=BB2_4 Depth=1
	movl	$.L.str.27, %esi
	movq	%r14, %rdi
	xorl	%eax, %eax
	callq	__isoc23_fscanf
	incq	%r13
	addq	8(%rsp), %r12                   # 8-byte Folded Reload
	cmpq	(%rsp), %r13                    # 8-byte Folded Reload
	jne	.LBB2_4
.LBB2_8:                                # %._crit_edge40
	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_end2:
	.size	_Z9readInputP8_IO_FILEPfPiiii, .Lfunc_end2-_Z9readInputP8_IO_FILEPfPiiii
	.cfi_endproc
                                        # -- End function
	.globl	_Z18__device_stub__knnPfP15HIP_vector_typeIfLj2EEiiiiPii # -- Begin function _Z18__device_stub__knnPfP15HIP_vector_typeIfLj2EEiiiiPii
	.type	_Z18__device_stub__knnPfP15HIP_vector_typeIfLj2EEiiiiPii,@function
_Z18__device_stub__knnPfP15HIP_vector_typeIfLj2EEiiiiPii: # @_Z18__device_stub__knnPfP15HIP_vector_typeIfLj2EEiiiiPii
	.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	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	$_Z3knnPfP15HIP_vector_typeIfLj2EEiiiiPii, %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_end3:
	.size	_Z18__device_stub__knnPfP15HIP_vector_typeIfLj2EEiiiiPii, .Lfunc_end3-_Z18__device_stub__knnPfP15HIP_vector_typeIfLj2EEiiiiPii
	.cfi_endproc
                                        # -- End function
	.globl	_Z26__device_stub__knnPunisherP15HIP_vector_typeIfLj2EEPiiiii # -- Begin function _Z26__device_stub__knnPunisherP15HIP_vector_typeIfLj2EEPiiiii
	.type	_Z26__device_stub__knnPunisherP15HIP_vector_typeIfLj2EEPiiiii,@function
_Z26__device_stub__knnPunisherP15HIP_vector_typeIfLj2EEPiiiii: # @_Z26__device_stub__knnPunisherP15HIP_vector_typeIfLj2EEPiiiii
	.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	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	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	$_Z11knnPunisherP15HIP_vector_typeIfLj2EEPiiiii, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$144, %rsp
	.cfi_adjust_cfa_offset -144
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end4:
	.size	_Z26__device_stub__knnPunisherP15HIP_vector_typeIfLj2EEPiiiii, .Lfunc_end4-_Z26__device_stub__knnPunisherP15HIP_vector_typeIfLj2EEPiiiii
	.cfi_endproc
                                        # -- End function
	.globl	_Z10printStatsP11ihipEvent_tS0_PKc # -- Begin function _Z10printStatsP11ihipEvent_tS0_PKc
	.type	_Z10printStatsP11ihipEvent_tS0_PKc,@function
_Z10printStatsP11ihipEvent_tS0_PKc:     # @_Z10printStatsP11ihipEvent_tS0_PKc
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset %rbx, -16
	movq	%rdx, %rbx
	movq	%rsi, %rdx
	movq	%rdi, %rsi
	movl	$runtime, %edi
	callq	hipEventElapsedTime
	movl	%eax, %edi
	movq	%rbx, %rsi
	callq	_Z11check_error10hipError_tPKc
	cvtss2sd	runtime(%rip), %xmm0
	movl	$.L.str.24, %edi
	movq	%rbx, %rsi
	movb	$1, %al
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	printf                          # TAILCALL
.Lfunc_end5:
	.size	_Z10printStatsP11ihipEvent_tS0_PKc, .Lfunc_end5-_Z10printStatsP11ihipEvent_tS0_PKc
	.cfi_endproc
                                        # -- End function
	.globl	_Z11writeOutputPfPiii           # -- Begin function _Z11writeOutputPfPiii
	.type	_Z11writeOutputPfPiii,@function
_Z11writeOutputPfPiii:                  # @_Z11writeOutputPfPiii
	.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	%ecx, %ebp
	movl	%edx, %ebx
	movq	%rsi, 32(%rsp)                  # 8-byte Spill
	movq	%rdi, 16(%rsp)                  # 8-byte Spill
	movl	$.L.str.28, %edi
	movl	$.L.str.29, %esi
	callq	fopen
	movq	%rax, %r12
	testl	%ebp, %ebp
	jle	.LBB6_6
# %bb.1:                                # %.preheader.lr.ph
	movl	%ebp, %eax
	movq	%rax, 24(%rsp)                  # 8-byte Spill
	movl	%ebx, %ebp
	xorl	%r15d, %r15d
	xorl	%r14d, %r14d
	movl	%ebx, 12(%rsp)                  # 4-byte Spill
.LBB6_2:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB6_4 Depth 2
	testl	%ebx, %ebx
	jle	.LBB6_5
# %bb.3:                                # %.lr.ph
                                        #   in Loop: Header=BB6_2 Depth=1
	movl	%r15d, %eax
	movq	16(%rsp), %rcx                  # 8-byte Reload
	leaq	(%rcx,%rax,4), %r13
	xorl	%ebx, %ebx
.LBB6_4:                                #   Parent Loop BB6_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	xorps	%xmm0, %xmm0
	cvtss2sd	(%r13,%rbx,4), %xmm0
	movl	$.L.str.30, %esi
	movq	%r12, %rdi
	movb	$1, %al
	callq	fprintf
	incq	%rbx
	cmpq	%rbx, %rbp
	jne	.LBB6_4
.LBB6_5:                                # %._crit_edge
                                        #   in Loop: Header=BB6_2 Depth=1
	movq	32(%rsp), %rax                  # 8-byte Reload
	movl	(%rax,%r14,4), %edx
	movl	$.L.str.26, %esi
	movq	%r12, %rdi
	xorl	%eax, %eax
	callq	fprintf
	incq	%r14
	movl	12(%rsp), %ebx                  # 4-byte Reload
	addl	%ebx, %r15d
	cmpq	24(%rsp), %r14                  # 8-byte Folded Reload
	jne	.LBB6_2
.LBB6_6:                                # %._crit_edge18
	movq	%r12, %rdi
	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
	jmp	fclose                          # TAILCALL
.Lfunc_end6:
	.size	_Z11writeOutputPfPiii, .Lfunc_end6-_Z11writeOutputPfPiii
	.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	$_Z3knnPfP15HIP_vector_typeIfLj2EEiiiiPii, %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	$_Z11knnPunisherP15HIP_vector_typeIfLj2EEPiiiii, %esi
	movl	$.L__unnamed_2, %edx
	movl	$.L__unnamed_2, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$__hip_module_dtor, %edi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_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	.L.str.1,@object                # @.str.1
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.1:
	.asciz	"create before_allocation cudaEvent"
	.size	.L.str.1, 35

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"create before_input cudaEvent"
	.size	.L.str.2, 30

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"create before_upload cudaEvent"
	.size	.L.str.3, 31

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"create before_knn cudaEvent"
	.size	.L.str.4, 28

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"create before_download cudaEvent"
	.size	.L.str.5, 33

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"create after_allocation cudaEvent"
	.size	.L.str.6, 34

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"create after_input cudaEvent"
	.size	.L.str.7, 29

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"create after_upload cudaEvent"
	.size	.L.str.8, 30

	.type	.L.str.9,@object                # @.str.9
.L.str.9:
	.asciz	"create after_knn cudaEvent"
	.size	.L.str.9, 27

	.type	.L.str.10,@object               # @.str.10
.L.str.10:
	.asciz	"create after_download cudaEvent"
	.size	.L.str.10, 32

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

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

	.type	.L.str.14,@object               # @.str.14
.L.str.14:
	.asciz	"alloc d_coords_x"
	.size	.L.str.14, 17

	.type	.L.str.15,@object               # @.str.15
.L.str.15:
	.asciz	"alloc d_classes"
	.size	.L.str.15, 16

	.type	.L.str.16,@object               # @.str.16
.L.str.16:
	.asciz	"alloc d_determinate"
	.size	.L.str.16, 20

	.type	.L.str.17,@object               # @.str.17
.L.str.17:
	.asciz	"alloc d_kOutput"
	.size	.L.str.17, 16

	.type	.L.str.18,@object               # @.str.18
.L.str.18:
	.asciz	"copy d_coords"
	.size	.L.str.18, 14

	.type	.L.str.19,@object               # @.str.19
.L.str.19:
	.asciz	"copy d_classes"
	.size	.L.str.19, 15

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

	.type	_Z11knnPunisherP15HIP_vector_typeIfLj2EEPiiiii,@object # @_Z11knnPunisherP15HIP_vector_typeIfLj2EEPiiiii
	.globl	_Z11knnPunisherP15HIP_vector_typeIfLj2EEPiiiii
	.p2align	3, 0x0
_Z11knnPunisherP15HIP_vector_typeIfLj2EEPiiiii:
	.quad	_Z26__device_stub__knnPunisherP15HIP_vector_typeIfLj2EEPiiiii
	.size	_Z11knnPunisherP15HIP_vector_typeIfLj2EEPiiiii, 8

	.type	.L.str.20,@object               # @.str.20
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.20:
	.asciz	"download classes"
	.size	.L.str.20, 17

	.type	.L.str.21,@object               # @.str.21
.L.str.21:
	.asciz	"sync cudaEvents"
	.size	.L.str.21, 16

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

	.type	.L.str.23,@object               # @.str.23
.L.str.23:
	.asciz	"%s : error %d (%s)\n"
	.size	.L.str.23, 20

	.type	runtime,@object                 # @runtime
	.bss
	.globl	runtime
	.p2align	2, 0x0
runtime:
	.long	0x00000000                      # float 0
	.size	runtime, 4

	.type	.L.str.24,@object               # @.str.24
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.24:
	.asciz	"%s %gms\n"
	.size	.L.str.24, 9

	.type	.L.str.25,@object               # @.str.25
.L.str.25:
	.asciz	"%f,"
	.size	.L.str.25, 4

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

	.type	.L.str.27,@object               # @.str.27
.L.str.27:
	.asciz	"-1\n"
	.size	.L.str.27, 4

	.type	.L.str.28,@object               # @.str.28
.L.str.28:
	.asciz	"ocuda"
	.size	.L.str.28, 6

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

	.type	.L.str.30,@object               # @.str.30
.L.str.30:
	.asciz	"%lf,"
	.size	.L.str.30, 5

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z3knnPfP15HIP_vector_typeIfLj2EEiiiiPii"
	.size	.L__unnamed_1, 41

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z11knnPunisherP15HIP_vector_typeIfLj2EEPiiiii"
	.size	.L__unnamed_2, 47

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

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

	.type	.Lstr,@object                   # @str
	.section	.rodata.str1.1,"aMS",@progbits,1
.Lstr:
	.asciz	"how-to-use: knn <inputfile> <k> "
	.size	.Lstr, 33

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"No such file"
	.size	.Lstr.1, 13

	.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 _Z18__device_stub__knnPfP15HIP_vector_typeIfLj2EEiiiiPii
	.addrsig_sym _Z26__device_stub__knnPunisherP15HIP_vector_typeIfLj2EEPiiiii
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z3knnPfP15HIP_vector_typeIfLj2EEiiiiPii
	.addrsig_sym _Z11knnPunisherP15HIP_vector_typeIfLj2EEPiiiii
	.addrsig_sym runtime
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z3knnPfP15HIP_vector_typeIfLj2EEiiiiPii ; -- Begin function _Z3knnPfP15HIP_vector_typeIfLj2EEiiiiPii
	.globl	_Z3knnPfP15HIP_vector_typeIfLj2EEiiiiPii
	.p2align	8
	.type	_Z3knnPfP15HIP_vector_typeIfLj2EEiiiiPii,@function
_Z3knnPfP15HIP_vector_typeIfLj2EEiiiiPii: ; @_Z3knnPfP15HIP_vector_typeIfLj2EEiiiiPii
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x3c
	s_load_b128 s[4:7], s[0:1], 0x10
	s_waitcnt lgkmcnt(0)
	s_and_b32 s22, s2, 0xffff
	s_mov_b32 s2, exec_lo
	s_mul_i32 s15, s15, s22
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add3_u32 v1, s15, s5, v0
	v_cmpx_gt_i32_e64 s4, v1
	s_cbranch_execz .LBB0_77
; %bb.1:
	s_load_b64 s[12:13], s[0:1], 0x0
	s_cmp_gt_i32 s6, 0
	s_mov_b32 s24, 0
	s_cselect_b32 s25, -1, 0
	s_cmp_lt_i32 s6, 1
	s_cbranch_scc1 .LBB0_4
; %bb.2:                                ; %.lr.ph.preheader
	v_mul_lo_u32 v2, v1, s6
	v_mov_b32_e32 v4, 0x1a0
	s_mov_b32 s2, s6
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v3, 31, v2
	v_lshlrev_b64 v[2:3], 2, v[2:3]
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v2, vcc_lo, s12, v2
	v_add_co_ci_u32_e32 v3, vcc_lo, s13, v3, vcc_lo
.LBB0_3:                                ; %.lr.ph
                                        ; =>This Inner Loop Header: Depth=1
	global_load_b32 v5, v[2:3], off
	v_add_co_u32 v2, vcc_lo, v2, 4
	v_add_co_ci_u32_e32 v3, vcc_lo, 0, v3, vcc_lo
	s_add_i32 s2, s2, -1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_cmp_eq_u32 s2, 0
	s_waitcnt vmcnt(0)
	scratch_store_b32 v4, v5, off
	v_add_nc_u32_e32 v4, 4, v4
	s_cbranch_scc0 .LBB0_3
.LBB0_4:                                ; %.preheader147
	s_clause 0x1
	s_load_b64 s[8:9], s[0:1], 0x8
	s_load_b64 s[10:11], s[0:1], 0x20
	v_cndmask_b32_e64 v6, 0, 1, s25
	v_lshl_add_u32 v7, v0, 2, 0
	s_cmp_lt_i32 s5, 1
	s_mul_i32 s4, s22, s7
	s_cbranch_scc1 .LBB0_25
; %bb.5:                                ; %.lr.ph153
	v_lshl_add_u32 v8, v0, 2, 0
	s_mov_b64 s[14:15], src_private_base
	s_ashr_i32 s3, s6, 31
	s_mov_b32 s2, s6
	s_lshl_b32 s26, s22, 2
	v_lshl_add_u32 v9, s4, 2, v8
	s_mov_b32 s24, 0
	s_movk_i32 s14, 0x330
	s_mov_b32 s16, 16
	s_mov_b32 s17, s15
	s_lshl_b64 s[18:19], s[2:3], 2
	s_add_i32 s27, s7, -1
	s_sub_i32 s28, 0, s26
	s_mov_b64 s[2:3], src_shared_base
	s_mov_b32 s23, 0
.LBB0_6:                                ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_8 Depth 2
                                        ;     Child Loop BB0_15 Depth 2
	s_and_not1_b32 vcc_lo, exec_lo, s25
	s_cbranch_vccnz .LBB0_9
; %bb.7:                                ; %.lr.ph.i.preheader
                                        ;   in Loop: Header=BB0_6 Depth=1
	v_mov_b32_e32 v2, 0x1a0
	v_mov_b32_e32 v10, 0
	s_waitcnt lgkmcnt(0)
	s_mov_b64 s[20:21], s[12:13]
	s_mov_b32 s2, s6
.LBB0_8:                                ; %.lr.ph.i
                                        ;   Parent Loop BB0_6 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	scratch_load_b32 v3, v2, off
	s_load_b32 s29, s[20:21], 0x0
	s_add_i32 s2, s2, -1
	s_add_u32 s20, s20, 4
	s_addc_u32 s21, s21, 0
	s_cmp_lg_u32 s2, 0
	s_waitcnt vmcnt(0) lgkmcnt(0)
	v_dual_subrev_f32 v3, s29, v3 :: v_dual_add_nc_u32 v2, 4, v2
	s_delay_alu instid0(VALU_DEP_1)
	v_fmac_f32_e32 v10, v3, v3
	s_cbranch_scc1 .LBB0_8
	s_branch .LBB0_10
.LBB0_9:                                ;   in Loop: Header=BB0_6 Depth=1
	v_mov_b32_e32 v10, 0
.LBB0_10:                               ; %_Z8distancePfS_i.exit
                                        ;   in Loop: Header=BB0_6 Depth=1
	v_cvt_f32_i32_e32 v11, s24
	s_cmp_lg_u32 s23, 0
	s_clause 0x1
	scratch_store_b32 off, v10, off offset:16
	scratch_store_b32 off, v11, off offset:816
	s_cbranch_scc0 .LBB0_20
; %bb.11:                               ;   in Loop: Header=BB0_6 Depth=1
	v_dual_mov_b32 v4, s16 :: v_dual_mov_b32 v5, s17
	v_dual_mov_b32 v2, s14 :: v_dual_mov_b32 v3, s15
	s_cmp_lt_i32 s23, s7
	s_cselect_b32 s20, -1, 0
	s_cmp_ge_i32 s23, s7
	s_cbranch_scc1 .LBB0_13
; %bb.12:                               ;   in Loop: Header=BB0_6 Depth=1
	s_add_i32 s21, s23, s7
	s_mul_i32 s2, s23, s22
	s_mul_i32 s21, s21, s22
	v_lshl_add_u32 v12, s2, 2, v8
	v_lshl_add_u32 v13, s21, 2, v8
	ds_store_b32 v12, v10
	ds_store_b32 v13, v11
	v_cmp_ne_u32_e32 vcc_lo, -1, v12
	v_cmp_ne_u32_e64 s2, -1, v13
	v_cndmask_b32_e32 v4, 0, v12, vcc_lo
	v_cndmask_b32_e64 v5, 0, s3, vcc_lo
	s_delay_alu instid0(VALU_DEP_3)
	v_cndmask_b32_e64 v2, 0, v13, s2
	v_cndmask_b32_e64 v3, 0, s3, s2
.LBB0_13:                               ;   in Loop: Header=BB0_6 Depth=1
	s_cmp_lt_i32 s23, 1
	s_cbranch_scc1 .LBB0_19
; %bb.14:                               ; %.lr.ph.i97.preheader
                                        ;   in Loop: Header=BB0_6 Depth=1
	v_mov_b32_e32 v12, v8
	s_add_i32 s2, s27, s23
	s_add_i32 s29, s23, -1
	s_mul_i32 s21, s26, s2
	s_mul_i32 s30, s26, s29
	s_mov_b32 s29, 0
	s_mov_b32 s31, s23
                                        ; implicit-def: $sgpr33
.LBB0_15:                               ; %.lr.ph.i97
                                        ;   Parent Loop BB0_6 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	flat_load_b32 v14, v[4:5]
	v_add_nc_u32_e32 v13, s30, v12
	s_or_b32 s33, s33, exec_lo
	s_mov_b32 s34, exec_lo
	ds_load_b32 v15, v13
	s_waitcnt vmcnt(0) lgkmcnt(0)
	v_cmpx_gt_f32_e32 v15, v14
	s_cbranch_execz .LBB0_17
; %bb.16:                               ;   in Loop: Header=BB0_15 Depth=2
	ds_store_b32 v13, v14
	flat_store_b32 v[4:5], v15
	flat_load_b32 v15, v[2:3]
	v_add_nc_u32_e32 v16, s21, v12
	v_cmp_ne_u32_e32 vcc_lo, -1, v13
	s_add_i32 s31, s31, -1
	v_add_nc_u32_e32 v12, s28, v12
	s_cmp_eq_u32 s31, 0
	ds_load_b32 v17, v16
	v_cmp_ne_u32_e64 s2, -1, v16
	v_cndmask_b32_e32 v4, 0, v13, vcc_lo
	s_cselect_b32 s35, -1, 0
	v_cndmask_b32_e64 v5, 0, s3, vcc_lo
	s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_3) | instid1(SALU_CYCLE_1)
	v_cndmask_b32_e64 v13, 0, v16, s2
	v_cndmask_b32_e64 v14, 0, s3, s2
	s_and_not1_b32 s2, s33, exec_lo
	s_and_b32 s33, s35, exec_lo
	s_or_b32 s33, s2, s33
	s_waitcnt vmcnt(0) lgkmcnt(1)
	ds_store_b32 v16, v15
	s_waitcnt lgkmcnt(1)
	flat_store_b32 v[2:3], v17
	v_dual_mov_b32 v2, v13 :: v_dual_mov_b32 v3, v14
.LBB0_17:                               ; %Flow299
                                        ;   in Loop: Header=BB0_15 Depth=2
	s_or_b32 exec_lo, exec_lo, s34
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_and_b32 s2, exec_lo, s33
	s_or_b32 s29, s2, s29
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_not1_b32 exec_lo, exec_lo, s29
	s_cbranch_execnz .LBB0_15
; %bb.18:                               ; %Flow300
                                        ;   in Loop: Header=BB0_6 Depth=1
	s_or_b32 exec_lo, exec_lo, s29
.LBB0_19:                               ; %.critedge.i
                                        ;   in Loop: Header=BB0_6 Depth=1
	v_cndmask_b32_e64 v2, 0, 1, s20
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_readfirstlane_b32 s2, v2
	s_add_i32 s23, s23, s2
	s_mov_b32 s2, 0
	s_branch .LBB0_21
.LBB0_20:                               ;   in Loop: Header=BB0_6 Depth=1
	s_mov_b32 s2, -1
                                        ; implicit-def: $sgpr23
.LBB0_21:                               ; %Flow303
                                        ;   in Loop: Header=BB0_6 Depth=1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_b32 vcc_lo, exec_lo, s2
	s_cbranch_vccz .LBB0_23
; %bb.22:                               ;   in Loop: Header=BB0_6 Depth=1
	s_mov_b32 s23, 1
	ds_store_b32 v8, v10
	ds_store_b32 v9, v11
.LBB0_23:                               ; %_Z6insertPf15HIP_vector_typeIfLj2EEPiiii.exit
                                        ;   in Loop: Header=BB0_6 Depth=1
	s_waitcnt lgkmcnt(0)
	s_add_u32 s12, s12, s18
	s_addc_u32 s13, s13, s19
	s_add_i32 s24, s24, 1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_cmp_eq_u32 s24, s5
	s_cbranch_scc0 .LBB0_6
; %bb.24:                               ; %Flow306
	s_mov_b32 s24, s5
	s_branch .LBB0_26
.LBB0_25:
	s_mov_b32 s23, 0
.LBB0_26:                               ; %.preheader
	s_mov_b32 s3, -1
	s_mov_b32 s25, exec_lo
	v_cmpx_lt_i32_e64 s24, v1
	s_cbranch_execz .LBB0_52
; %bb.27:                               ; %.lr.ph170
	v_lshl_add_u32 v8, s4, 2, v7
	v_dual_mov_b32 v9, 0 :: v_dual_mov_b32 v10, 0
	s_mov_b64 s[14:15], src_private_base
	s_ashr_i32 s3, s6, 31
	s_mov_b32 s2, s6
	s_lshl_b32 s27, s22, 2
	s_mov_b32 s26, 0
	s_movk_i32 s14, 0x330
	s_mov_b32 s16, 16
	s_mov_b32 s17, s15
	s_lshl_b64 s[18:19], s[2:3], 2
	s_add_i32 s28, s7, -1
	s_sub_i32 s29, 0, s27
	s_mov_b64 s[2:3], src_shared_base
.LBB0_28:                               ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_30 Depth 2
                                        ;     Child Loop BB0_37 Depth 2
	v_cmp_ne_u32_e32 vcc_lo, 1, v6
	v_mov_b32_e32 v11, 0
	s_cbranch_vccnz .LBB0_31
; %bb.29:                               ; %.lr.ph.i100.preheader
                                        ;   in Loop: Header=BB0_28 Depth=1
	v_dual_mov_b32 v2, 0x1a0 :: v_dual_mov_b32 v11, 0
	s_waitcnt lgkmcnt(0)
	s_mov_b64 s[20:21], s[12:13]
	s_mov_b32 s2, s6
.LBB0_30:                               ; %.lr.ph.i100
                                        ;   Parent Loop BB0_28 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	scratch_load_b32 v3, v2, off
	global_load_b32 v4, v10, s[20:21]
	s_add_i32 s2, s2, -1
	s_add_u32 s20, s20, 4
	s_addc_u32 s21, s21, 0
	s_cmp_lg_u32 s2, 0
	s_waitcnt vmcnt(0)
	v_dual_sub_f32 v3, v3, v4 :: v_dual_add_nc_u32 v2, 4, v2
	s_delay_alu instid0(VALU_DEP_1)
	v_fmac_f32_e32 v11, v3, v3
	s_cbranch_scc1 .LBB0_30
.LBB0_31:                               ; %_Z8distancePfS_i.exit104
                                        ;   in Loop: Header=BB0_28 Depth=1
	v_cvt_f32_i32_e32 v12, s24
	s_cmp_lg_u32 s23, 0
	s_clause 0x1
	scratch_store_b32 off, v11, off offset:16
	scratch_store_b32 off, v12, off offset:816
	s_cbranch_scc0 .LBB0_43
; %bb.32:                               ;   in Loop: Header=BB0_28 Depth=1
	s_cmp_ge_i32 s23, s7
	v_dual_mov_b32 v4, s16 :: v_dual_mov_b32 v5, s17
	v_dual_mov_b32 v2, s14 :: v_dual_mov_b32 v3, s15
	s_cselect_b32 s20, -1, 0
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_b32 vcc_lo, exec_lo, s20
	s_cbranch_vccnz .LBB0_34
; %bb.33:                               ;   in Loop: Header=BB0_28 Depth=1
	s_add_i32 s21, s23, s7
	s_mul_i32 s2, s23, s22
	s_mul_i32 s21, s21, s22
	v_lshl_add_u32 v13, s2, 2, v7
	v_lshl_add_u32 v14, s21, 2, v7
	ds_store_b32 v13, v11
	ds_store_b32 v14, v12
	v_cmp_ne_u32_e32 vcc_lo, -1, v13
	v_cmp_ne_u32_e64 s2, -1, v14
	v_cndmask_b32_e32 v4, 0, v13, vcc_lo
	v_cndmask_b32_e64 v5, 0, s3, vcc_lo
	s_delay_alu instid0(VALU_DEP_3)
	v_cndmask_b32_e64 v2, 0, v14, s2
	v_cndmask_b32_e64 v3, 0, s3, s2
.LBB0_34:                               ;   in Loop: Header=BB0_28 Depth=1
	s_cmp_lt_i32 s23, 1
	s_cbranch_scc1 .LBB0_44
; %bb.35:                               ; %.lr.ph.i114.preheader
                                        ;   in Loop: Header=BB0_28 Depth=1
	flat_load_b32 v14, v[4:5]
	s_add_i32 s2, s23, -1
	s_mov_b32 s21, exec_lo
	s_mul_i32 s2, s2, s22
	s_delay_alu instid0(SALU_CYCLE_1)
	v_lshl_add_u32 v13, s2, 2, v7
	s_mov_b32 s2, s20
	ds_load_b32 v15, v13
	s_waitcnt vmcnt(0) lgkmcnt(0)
	v_cmpx_gt_f32_e32 v15, v14
	s_cbranch_execz .LBB0_42
; %bb.36:                               ; %.lr.ph163.preheader
                                        ;   in Loop: Header=BB0_28 Depth=1
	v_mov_b32_e32 v16, v7
	s_add_i32 s2, s28, s23
	s_add_i32 s31, s23, -2
	s_mul_i32 s30, s27, s2
	s_mul_i32 s31, s27, s31
	s_mov_b32 s34, 1
	s_mov_b32 s33, 0
	s_mov_b32 s35, s23
                                        ; implicit-def: $sgpr36
.LBB0_37:                               ; %.lr.ph163
                                        ;   Parent Loop BB0_28 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	ds_store_b32 v13, v14
	flat_store_b32 v[4:5], v15
	flat_load_b32 v5, v[2:3]
	v_add_nc_u32_e32 v4, s30, v16
	s_add_i32 s35, s35, -1
	s_or_b32 s36, s36, exec_lo
	s_cmp_lg_u32 s35, 0
	ds_load_b32 v14, v4
	s_waitcnt vmcnt(0) lgkmcnt(1)
	ds_store_b32 v4, v5
	s_waitcnt lgkmcnt(1)
	flat_store_b32 v[2:3], v14
	s_cbranch_scc0 .LBB0_39
; %bb.38:                               ; %.lr.ph.i114
                                        ;   in Loop: Header=BB0_37 Depth=2
	s_add_i32 s34, s34, 1
	v_cmp_ne_u32_e32 vcc_lo, -1, v4
	s_sub_i32 s2, s23, s34
	s_delay_alu instid0(SALU_CYCLE_1)
	s_mul_i32 s37, s2, s22
	v_cmp_ne_u32_e64 s2, -1, v13
	v_lshl_add_u32 v17, s37, 2, v7
	v_add_nc_u32_e32 v2, s31, v16
	v_cndmask_b32_e64 v3, 0, s3, vcc_lo
	v_add_nc_u32_e32 v16, s29, v16
	v_cndmask_b32_e64 v5, 0, s3, s2
	ds_load_b32 v15, v2
	ds_load_b32 v14, v13
	v_cndmask_b32_e32 v2, 0, v4, vcc_lo
	v_cndmask_b32_e64 v4, 0, v13, s2
	v_mov_b32_e32 v13, v17
	s_and_not1_b32 s2, s36, exec_lo
	s_waitcnt lgkmcnt(0)
	v_cmp_ngt_f32_e32 vcc_lo, v15, v14
	s_and_b32 s36, vcc_lo, exec_lo
	s_delay_alu instid0(SALU_CYCLE_1)
	s_or_b32 s36, s2, s36
	s_branch .LBB0_40
.LBB0_39:                               ;   in Loop: Header=BB0_37 Depth=2
                                        ; implicit-def: $vgpr2_vgpr3
                                        ; implicit-def: $vgpr4_vgpr5
                                        ; implicit-def: $sgpr34
                                        ; implicit-def: $vgpr13
                                        ; implicit-def: $vgpr15
                                        ; implicit-def: $vgpr14
                                        ; implicit-def: $vgpr16
                                        ; implicit-def: $sgpr35
.LBB0_40:                               ; %Flow287
                                        ;   in Loop: Header=BB0_37 Depth=2
	s_and_b32 s2, exec_lo, s36
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_or_b32 s33, s2, s33
	s_and_not1_b32 exec_lo, exec_lo, s33
	s_cbranch_execnz .LBB0_37
; %bb.41:                               ; %Flow288
                                        ;   in Loop: Header=BB0_28 Depth=1
	s_or_b32 exec_lo, exec_lo, s33
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_not1_b32 s2, s20, exec_lo
.LBB0_42:                               ; %Flow289
                                        ;   in Loop: Header=BB0_28 Depth=1
	s_or_b32 exec_lo, exec_lo, s21
	s_branch .LBB0_45
.LBB0_43:                               ;   in Loop: Header=BB0_28 Depth=1
	s_mov_b32 s2, -1
                                        ; implicit-def: $vgpr2
                                        ; implicit-def: $sgpr23
	s_branch .LBB0_46
.LBB0_44:                               ;   in Loop: Header=BB0_28 Depth=1
	s_mov_b32 s2, s20
.LBB0_45:                               ; %.critedge.i123
                                        ;   in Loop: Header=BB0_28 Depth=1
	s_xor_b32 s21, s20, -1
	s_and_b32 s2, s20, s2
	v_cndmask_b32_e64 v2, 0, 1, s21
	s_xor_b32 s2, s2, -1
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_2)
	v_readfirstlane_b32 s20, v2
	v_cndmask_b32_e64 v2, 0, 1, s2
	s_mov_b32 s2, 0
	s_add_i32 s23, s23, s20
.LBB0_46:                               ; %Flow291
                                        ;   in Loop: Header=BB0_28 Depth=1
	s_and_b32 vcc_lo, exec_lo, s2
	s_cbranch_vccz .LBB0_48
; %bb.47:                               ;   in Loop: Header=BB0_28 Depth=1
	v_mov_b32_e32 v2, 1
	s_mov_b32 s23, 1
	ds_store_b32 v7, v11
	ds_store_b32 v8, v12
.LBB0_48:                               ; %_Z6insertPf15HIP_vector_typeIfLj2EEPiiii.exit135
                                        ;   in Loop: Header=BB0_28 Depth=1
	s_add_i32 s24, s24, 1
	v_add_nc_u32_e32 v9, v2, v9
	v_cmp_ge_i32_e32 vcc_lo, s24, v1
	s_waitcnt lgkmcnt(0)
	s_add_u32 s12, s12, s18
	s_addc_u32 s13, s13, s19
	s_or_b32 s26, vcc_lo, s26
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_not1_b32 exec_lo, exec_lo, s26
	s_cbranch_execnz .LBB0_28
; %bb.49:                               ; %._crit_edge.loopexit
	s_or_b32 exec_lo, exec_lo, s26
	s_mov_b32 s3, -1
	s_mov_b32 s2, exec_lo
	v_cmpx_ne_u32_e32 0, v9
	s_cbranch_execz .LBB0_51
; %bb.50:
	v_ashrrev_i32_e32 v2, 31, v1
	v_mov_b32_e32 v4, -1
	s_xor_b32 s3, exec_lo, -1
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[2:3], 2, v[1:2]
	v_add_co_u32 v2, vcc_lo, s10, v2
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v3, vcc_lo, s11, v3, vcc_lo
	global_store_b32 v[2:3], v4, off
.LBB0_51:                               ; %Flow297
	s_or_b32 exec_lo, exec_lo, s2
	s_delay_alu instid0(SALU_CYCLE_1)
	s_or_not1_b32 s3, s3, exec_lo
.LBB0_52:                               ; %Flow296
	s_or_b32 exec_lo, exec_lo, s25
	s_and_saveexec_b32 s2, s3
	s_cbranch_execz .LBB0_74
; %bb.53:                               ; %.critedge
	s_cmp_gt_i32 s7, 0
	s_mov_b32 s6, 0
	s_cselect_b32 s3, -1, 0
	s_cmp_lt_i32 s7, 1
	s_cbranch_scc1 .LBB0_56
; %bb.54:                               ; %.lr.ph174.preheader
	v_mad_u64_u32 v[2:3], null, s7, s22, v[0:1]
	v_mov_b32_e32 v3, 0x330
	s_waitcnt lgkmcnt(0)
	s_lshl_b32 s12, s22, 2
	s_mov_b32 s13, s7
	s_delay_alu instid0(VALU_DEP_2)
	v_lshl_add_u32 v2, v2, 2, 0
.LBB0_55:                               ; %.lr.ph174
                                        ; =>This Inner Loop Header: Depth=1
	ds_load_b32 v4, v2
	v_add_nc_u32_e32 v2, s12, v2
	s_add_i32 s13, s13, -1
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	s_cmp_eq_u32 s13, 0
	s_waitcnt lgkmcnt(0)
	v_cvt_i32_f32_e32 v4, v4
	v_ashrrev_i32_e32 v5, 31, v4
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[4:5], 2, v[4:5]
	v_add_co_u32 v4, vcc_lo, s10, v4
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v5, vcc_lo, s11, v5, vcc_lo
	global_load_b32 v4, v[4:5], off
	s_waitcnt vmcnt(0)
	scratch_store_b32 v3, v4, off
	v_add_nc_u32_e32 v3, 4, v3
	s_cbranch_scc0 .LBB0_55
.LBB0_56:                               ; %._crit_edge175
	v_mov_b32_e32 v2, 0
.LBB0_57:                               ; =>This Inner Loop Header: Depth=1
	s_waitcnt lgkmcnt(0)
	s_add_i32 s12, s6, 16
	s_add_i32 s6, s6, 4
	scratch_store_b32 off, v2, s12
	s_cmpk_eq_i32 s6, 0x190
	s_cbranch_scc0 .LBB0_57
; %bb.58:                               ; %.preheader40.i
	s_and_not1_b32 vcc_lo, exec_lo, s3
	s_cbranch_vccnz .LBB0_61
; %bb.59:                               ; %.lr.ph.i137.preheader
	v_mov_b32_e32 v2, 0x330
	s_mov_b32 s3, s7
.LBB0_60:                               ; %.lr.ph.i137
                                        ; =>This Inner Loop Header: Depth=1
	scratch_load_b32 v3, v2, off
	v_add_nc_u32_e32 v2, 4, v2
	s_add_i32 s3, s3, -1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_cmp_lg_u32 s3, 0
	s_waitcnt vmcnt(0)
	v_lshl_add_u32 v3, v3, 2, 16
	scratch_load_b32 v4, v3, off
	s_waitcnt vmcnt(0)
	v_add_nc_u32_e32 v4, 1, v4
	scratch_store_b32 v3, v4, off
	s_cbranch_scc1 .LBB0_60
.LBB0_61:                               ; %._crit_edge.i
	s_load_b32 s1, s[0:1], 0x28
	v_mov_b32_e32 v4, 0
	s_waitcnt lgkmcnt(0)
	s_cmp_lt_i32 s1, 2
	s_cbranch_scc1 .LBB0_73
; %bb.62:                               ; %.lr.ph54.i
	scratch_load_b32 v2, off, off offset:16
	v_mov_b32_e32 v3, 0
	s_cmp_lt_i32 s7, 1
	s_mov_b32 s3, 1
	s_cselect_b32 s6, -1, 0
.LBB0_63:                               ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_66 Depth 2
	s_lshl_b32 s0, s3, 2
	v_mov_b32_e32 v4, s3
	s_add_i32 s0, s0, 16
	s_mov_b32 s12, exec_lo
	scratch_load_b32 v5, off, s0
	s_waitcnt vmcnt(0)
	v_cmpx_le_i32_e64 v5, v2
	s_cbranch_execz .LBB0_71
; %bb.64:                               ;   in Loop: Header=BB0_63 Depth=1
	v_cmp_eq_u32_e32 vcc_lo, 0, v5
	v_cmp_ne_u32_e64 s0, v2, v5
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_or_b32 s0, vcc_lo, s0
	s_or_b32 s0, s6, s0
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_xor_b32 s13, s0, -1
	s_and_saveexec_b32 s0, s13
	s_cbranch_execz .LBB0_70
; %bb.65:                               ; %.lr.ph44.i.preheader
                                        ;   in Loop: Header=BB0_63 Depth=1
	v_mov_b32_e32 v4, 0x330
	s_mov_b32 s14, 1
	s_mov_b32 s13, 0
                                        ; implicit-def: $sgpr15
.LBB0_66:                               ; %.lr.ph44.i
                                        ;   Parent Loop BB0_63 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	scratch_load_b32 v6, v4, off
	v_mov_b32_e32 v5, s3
	s_or_b32 s15, s15, exec_lo
	s_mov_b32 s16, exec_lo
	s_waitcnt vmcnt(0)
	v_cmpx_ne_u32_e64 s3, v6
; %bb.67:                               ;   in Loop: Header=BB0_66 Depth=2
	v_cmp_eq_u32_e32 vcc_lo, v6, v3
	s_cmp_ge_i32 s14, s7
	v_dual_mov_b32 v5, v3 :: v_dual_add_nc_u32 v4, 4, v4
	s_cselect_b32 s17, -1, 0
	s_and_not1_b32 s15, s15, exec_lo
	s_or_b32 s17, vcc_lo, s17
	s_add_i32 s14, s14, 1
	s_and_b32 s17, s17, exec_lo
	s_delay_alu instid0(SALU_CYCLE_1)
	s_or_b32 s15, s15, s17
; %bb.68:                               ; %Flow278
                                        ;   in Loop: Header=BB0_66 Depth=2
	s_or_b32 exec_lo, exec_lo, s16
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_and_b32 s16, exec_lo, s15
	s_or_b32 s13, s16, s13
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_not1_b32 exec_lo, exec_lo, s13
	s_cbranch_execnz .LBB0_66
; %bb.69:                               ; %Flow279
                                        ;   in Loop: Header=BB0_63 Depth=1
	s_or_b32 exec_lo, exec_lo, s13
	v_mov_b32_e32 v3, v5
.LBB0_70:                               ; %Flow280
                                        ;   in Loop: Header=BB0_63 Depth=1
	s_or_b32 exec_lo, exec_lo, s0
	s_delay_alu instid0(VALU_DEP_1)
	v_dual_mov_b32 v4, v3 :: v_dual_mov_b32 v5, v2
.LBB0_71:                               ; %.loopexit.i
                                        ;   in Loop: Header=BB0_63 Depth=1
	s_or_b32 exec_lo, exec_lo, s12
	s_add_i32 s3, s3, 1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_cmp_lg_u32 s3, s1
	s_cbranch_scc0 .LBB0_73
; %bb.72:                               ;   in Loop: Header=BB0_63 Depth=1
	v_dual_mov_b32 v2, v5 :: v_dual_mov_b32 v3, v4
	s_branch .LBB0_63
.LBB0_73:                               ; %_Z14deviceFindModePiii.exit
	v_ashrrev_i32_e32 v2, 31, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[2:3], 2, v[1:2]
	v_add_co_u32 v2, vcc_lo, s10, v2
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v3, vcc_lo, s11, v3, vcc_lo
	global_store_b32 v[2:3], v4, off
.LBB0_74:                               ; %Flow298
	s_or_b32 exec_lo, exec_lo, s2
	s_cmp_lt_i32 s7, 1
	s_cbranch_scc1 .LBB0_77
; %bb.75:                               ; %.lr.ph178
	v_subrev_nc_u32_e32 v1, s5, v1
	v_add_lshl_u32 v3, v0, s4, 2
	v_lshlrev_b32_e32 v0, 2, v0
	s_lshl_b32 s0, s22, 2
	s_mov_b32 s1, 0
	v_mul_lo_u32 v1, v1, 20
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v2, 31, v1
	v_lshlrev_b64 v[1:2], 3, v[1:2]
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v1, vcc_lo, v1, s8
	v_add_co_ci_u32_e32 v2, vcc_lo, s9, v2, vcc_lo
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v1, vcc_lo, v1, 4
	v_add_co_ci_u32_e32 v2, vcc_lo, 0, v2, vcc_lo
.LBB0_76:                               ; =>This Inner Loop Header: Depth=1
	v_add_nc_u32_e32 v4, s1, v0
	v_add_nc_u32_e32 v5, s1, v3
	s_add_i32 s7, s7, -1
	s_add_i32 s1, s1, s0
	s_cmp_lg_u32 s7, 0
	ds_load_b32 v4, v4
	ds_load_b32 v5, v5
	s_waitcnt lgkmcnt(0)
	global_store_b64 v[1:2], v[4:5], off offset:-4
	v_add_co_u32 v1, vcc_lo, v1, 8
	v_add_co_ci_u32_e32 v2, vcc_lo, 0, v2, vcc_lo
	s_cbranch_scc1 .LBB0_76
.LBB0_77:
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z3knnPfP15HIP_vector_typeIfLj2EEiiiiPii
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 896
		.amdhsa_kernarg_size 304
		.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 1
		.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 18
		.amdhsa_next_free_sgpr 38
		.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	_Z3knnPfP15HIP_vector_typeIfLj2EEiiiiPii, .Lfunc_end0-_Z3knnPfP15HIP_vector_typeIfLj2EEiiiiPii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 2576
; NumSgprs: 40
; NumVgprs: 18
; ScratchSize: 896
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 4
; VGPRBlocks: 2
; NumSGPRsForWavesPerEU: 40
; NumVGPRsForWavesPerEU: 18
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 1
; 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	_Z11knnPunisherP15HIP_vector_typeIfLj2EEPiiiii ; -- Begin function _Z11knnPunisherP15HIP_vector_typeIfLj2EEPiiiii
	.globl	_Z11knnPunisherP15HIP_vector_typeIfLj2EEPiiiii
	.p2align	8
	.type	_Z11knnPunisherP15HIP_vector_typeIfLj2EEPiiiii,@function
_Z11knnPunisherP15HIP_vector_typeIfLj2EEPiiiii: ; @_Z11knnPunisherP15HIP_vector_typeIfLj2EEPiiiii
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x2c
	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_i32_e64 s5, v1
	s_cbranch_execz .LBB1_41
; %bb.1:
	s_load_b64 s[2:3], s[0:1], 0x8
	s_cmp_gt_i32 s6, 0
	s_mov_b32 s13, 0
	s_cselect_b32 s12, -1, 0
	s_cmp_lt_i32 s6, 1
	s_cbranch_scc1 .LBB1_4
; %bb.2:                                ; %.lr.ph
	s_load_b64 s[0:1], s[0:1], 0x0
	v_mul_lo_u32 v2, v1, 20
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v3, 31, v2
	v_lshlrev_b64 v[2:3], 3, v[2:3]
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v0, vcc_lo, v2, s0
	v_add_co_ci_u32_e32 v3, vcc_lo, s1, v3, vcc_lo
	s_mov_b32 s0, s6
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v2, vcc_lo, v0, 4
	v_add_co_ci_u32_e32 v3, vcc_lo, 0, v3, vcc_lo
	v_mov_b32_e32 v0, 0x1f0
.LBB1_3:                                ; =>This Inner Loop Header: Depth=1
	global_load_b32 v4, v[2:3], off
	v_add_co_u32 v2, vcc_lo, v2, 8
	v_add_co_ci_u32_e32 v3, vcc_lo, 0, v3, vcc_lo
	s_add_i32 s0, s0, -1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_cmp_eq_u32 s0, 0
	s_waitcnt vmcnt(0)
	v_cvt_i32_f32_e32 v4, v4
	scratch_store_b32 v0, v4, off
	v_add_nc_u32_e32 v0, 4, v0
	s_cbranch_scc0 .LBB1_3
.LBB1_4:                                ; %.preheader52
	s_cmp_lt_i32 s6, 1
	v_dual_mov_b32 v5, 0 :: v_dual_add_nc_u32 v2, s4, v1
	s_cselect_b32 s14, -1, 0
	s_cmp_gt_i32 s6, 0
	v_lshl_add_u32 v0, v1, 2, 0
	s_cselect_b32 s15, -1, 0
	s_cmp_gt_i32 s7, 1
	v_ashrrev_i32_e32 v3, 31, v2
	s_cselect_b32 s16, -1, 0
	s_ashr_i32 s5, s4, 31
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	s_lshl_b64 s[0:1], s[4:5], 2
	v_lshlrev_b64 v[2:3], 2, v[2:3]
	s_waitcnt lgkmcnt(0)
	s_add_u32 s8, s2, s0
	s_addc_u32 s9, s3, s1
	s_lshl_b32 s0, s6, 2
	s_add_i32 s5, s6, 1
	v_add_nc_u32_e64 v4, 0x1f0, s0
	v_add_co_u32 v2, vcc_lo, s2, v2
	v_add_co_ci_u32_e32 v3, vcc_lo, s3, v3, vcc_lo
	v_cmp_lt_i32_e64 s0, 0, v1
	s_delay_alu instid0(VALU_DEP_4)
	v_add_nc_u32_e32 v4, -4, v4
.LBB1_5:                                ; %.preheader51
                                        ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB1_7 Depth 2
                                        ;     Child Loop BB1_11 Depth 2
                                        ;     Child Loop BB1_20 Depth 2
                                        ;     Child Loop BB1_22 Depth 2
                                        ;     Child Loop BB1_25 Depth 2
                                        ;     Child Loop BB1_28 Depth 2
                                        ;       Child Loop BB1_31 Depth 3
	s_delay_alu instid0(VALU_DEP_2)
	s_and_saveexec_b32 s1, s0
	s_cbranch_execz .LBB1_8
; %bb.6:                                ; %.lr.ph55.preheader
                                        ;   in Loop: Header=BB1_5 Depth=1
	v_mov_b32_e32 v6, v1
	s_mov_b32 s17, 0
	s_mov_b32 s18, 0
	s_mov_b64 s[10:11], s[8:9]
.LBB1_7:                                ; %.lr.ph55
                                        ;   Parent Loop BB1_5 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	global_load_b32 v7, v5, s[10:11]
	v_add_nc_u32_e32 v6, -1, v6
	v_mov_b32_e32 v8, s17
	s_add_u32 s10, s10, 4
	s_addc_u32 s11, s11, 0
	s_add_i32 s17, s17, 4
	v_cmp_eq_u32_e32 vcc_lo, 0, v6
	s_or_b32 s18, vcc_lo, s18
	s_waitcnt vmcnt(0)
	ds_store_b32 v8, v7
	s_and_not1_b32 exec_lo, exec_lo, s18
	s_cbranch_execnz .LBB1_7
.LBB1_8:                                ; %Flow129
                                        ;   in Loop: Header=BB1_5 Depth=1
	s_or_b32 exec_lo, exec_lo, s1
	global_load_b32 v6, v[2:3], off
	s_mov_b32 s1, -1
	s_mov_b32 s10, exec_lo
	s_waitcnt vmcnt(0)
	ds_store_b32 v0, v6
	v_cmpx_eq_u32_e32 -1, v6
	s_cbranch_execz .LBB1_40
; %bb.9:                                ;   in Loop: Header=BB1_5 Depth=1
	s_and_not1_b32 vcc_lo, exec_lo, s15
	s_mov_b32 s11, -1
	s_waitcnt lgkmcnt(0)
	s_waitcnt_vscnt null, 0x0
	s_barrier
	buffer_gl0_inv
	s_cbranch_vccnz .LBB1_17
; %bb.10:                               ; %.lr.ph59.preheader
                                        ;   in Loop: Header=BB1_5 Depth=1
	v_mov_b32_e32 v6, v4
	s_mov_b32 s1, 0
	s_mov_b32 s17, s5
                                        ; implicit-def: $sgpr11
                                        ; implicit-def: $sgpr18
.LBB1_11:                               ; %.lr.ph59
                                        ;   Parent Loop BB1_5 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	scratch_load_b32 v7, v6, off
	s_mov_b32 s19, -1
	s_mov_b32 s20, -1
	s_mov_b32 s21, exec_lo
                                        ; implicit-def: $sgpr22
	s_waitcnt vmcnt(0)
	v_cmpx_lt_i32_e64 s4, v7
	s_cbranch_execz .LBB1_13
; %bb.12:                               ;   in Loop: Header=BB1_11 Depth=2
	v_subrev_nc_u32_e32 v7, s4, v7
	s_mov_b32 s22, 0
	s_delay_alu instid0(VALU_DEP_1)
	v_lshl_add_u32 v7, v7, 2, 0
	ds_load_b32 v7, v7
	s_waitcnt lgkmcnt(0)
	v_cmp_lt_i32_e32 vcc_lo, -1, v7
	s_or_not1_b32 s20, vcc_lo, exec_lo
.LBB1_13:                               ; %Flow124
                                        ;   in Loop: Header=BB1_11 Depth=2
	s_or_b32 exec_lo, exec_lo, s21
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(SALU_CYCLE_1)
	s_and_not1_b32 s18, s18, exec_lo
	s_and_b32 s21, s22, exec_lo
	s_or_b32 s18, s18, s21
	s_and_saveexec_b32 s21, s20
; %bb.14:                               ;   in Loop: Header=BB1_11 Depth=2
	s_add_i32 s17, s17, -1
	v_add_nc_u32_e32 v6, -4, v6
	s_cmp_lt_u32 s17, 2
	s_cselect_b32 s19, -1, 0
	s_or_b32 s18, s18, exec_lo
	s_or_not1_b32 s19, s19, exec_lo
; %bb.15:                               ; %Flow125
                                        ;   in Loop: Header=BB1_11 Depth=2
	s_or_b32 exec_lo, exec_lo, s21
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_and_b32 s19, exec_lo, s19
	s_or_b32 s1, s19, s1
	s_and_not1_b32 s11, s11, exec_lo
	s_and_b32 s19, s18, exec_lo
	s_delay_alu instid0(SALU_CYCLE_1)
	s_or_b32 s11, s11, s19
	s_and_not1_b32 exec_lo, exec_lo, s1
	s_cbranch_execnz .LBB1_11
; %bb.16:                               ; %Flow126
                                        ;   in Loop: Header=BB1_5 Depth=1
	s_or_b32 exec_lo, exec_lo, s1
.LBB1_17:                               ; %._crit_edge60
                                        ;   in Loop: Header=BB1_5 Depth=1
	s_and_saveexec_b32 s17, s11
	s_cbranch_execz .LBB1_39
; %bb.18:                               ; %.preheader
                                        ;   in Loop: Header=BB1_5 Depth=1
	s_and_not1_b32 vcc_lo, exec_lo, s12
	s_cbranch_vccnz .LBB1_21
; %bb.19:                               ; %.lr.ph66.preheader
                                        ;   in Loop: Header=BB1_5 Depth=1
	v_mov_b32_e32 v6, 0x1f0
	v_mov_b32_e32 v7, 0x1a0
	s_mov_b32 s1, s6
.LBB1_20:                               ; %.lr.ph66
                                        ;   Parent Loop BB1_5 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	scratch_load_b32 v8, v6, off
	v_add_nc_u32_e32 v6, 4, v6
	s_add_i32 s1, s1, -1
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	s_cmp_lg_u32 s1, 0
	s_waitcnt vmcnt(0)
	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, s2, v8
	v_add_co_ci_u32_e32 v9, vcc_lo, s3, v9, vcc_lo
	global_load_b32 v8, v[8:9], off
	s_waitcnt vmcnt(0)
	scratch_store_b32 v7, v8, off
	v_add_nc_u32_e32 v7, 4, v7
	s_cbranch_scc1 .LBB1_20
.LBB1_21:                               ; %._crit_edge67
                                        ;   in Loop: Header=BB1_5 Depth=1
	s_mov_b32 s1, 0
.LBB1_22:                               ;   Parent Loop BB1_5 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	s_delay_alu instid0(SALU_CYCLE_1)
	s_add_i32 s18, s1, 16
	s_add_i32 s1, s1, 4
	scratch_store_b32 off, v5, s18
	s_cmpk_eq_i32 s1, 0x190
	s_cbranch_scc0 .LBB1_22
; %bb.23:                               ; %.preheader40.i
                                        ;   in Loop: Header=BB1_5 Depth=1
	s_and_not1_b32 vcc_lo, exec_lo, s12
	s_cbranch_vccnz .LBB1_26
; %bb.24:                               ; %.lr.ph.i.preheader
                                        ;   in Loop: Header=BB1_5 Depth=1
	v_mov_b32_e32 v6, 0x1a0
	s_mov_b32 s1, s6
.LBB1_25:                               ; %.lr.ph.i
                                        ;   Parent Loop BB1_5 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	scratch_load_b32 v7, v6, off
	v_add_nc_u32_e32 v6, 4, v6
	s_add_i32 s1, s1, -1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_cmp_lg_u32 s1, 0
	s_waitcnt vmcnt(0)
	v_lshl_add_u32 v7, v7, 2, 16
	scratch_load_b32 v8, v7, off
	s_waitcnt vmcnt(0)
	v_add_nc_u32_e32 v8, 1, v8
	scratch_store_b32 v7, v8, off
	s_cbranch_scc1 .LBB1_25
.LBB1_26:                               ; %._crit_edge.i
                                        ;   in Loop: Header=BB1_5 Depth=1
	v_mov_b32_e32 v8, 0
	s_and_not1_b32 vcc_lo, exec_lo, s16
	s_cbranch_vccnz .LBB1_38
; %bb.27:                               ; %.lr.ph54.i
                                        ;   in Loop: Header=BB1_5 Depth=1
	scratch_load_b32 v6, off, off offset:16
	v_mov_b32_e32 v7, 0
	s_mov_b32 s18, 1
.LBB1_28:                               ;   Parent Loop BB1_5 Depth=1
                                        ; =>  This Loop Header: Depth=2
                                        ;       Child Loop BB1_31 Depth 3
	s_delay_alu instid0(SALU_CYCLE_1)
	s_lshl_b32 s1, s18, 2
	v_mov_b32_e32 v8, s18
	s_add_i32 s1, s1, 16
	s_mov_b32 s19, exec_lo
	scratch_load_b32 v9, off, s1
	s_waitcnt vmcnt(0)
	v_cmpx_le_i32_e64 v9, v6
	s_cbranch_execz .LBB1_36
; %bb.29:                               ;   in Loop: Header=BB1_28 Depth=2
	v_cmp_eq_u32_e32 vcc_lo, 0, v9
	v_cmp_ne_u32_e64 s1, v6, v9
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_or_b32 s1, vcc_lo, s1
	s_or_b32 s1, s14, s1
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_xor_b32 s20, s1, -1
	s_and_saveexec_b32 s1, s20
	s_cbranch_execz .LBB1_35
; %bb.30:                               ; %.lr.ph44.i.preheader
                                        ;   in Loop: Header=BB1_28 Depth=2
	v_mov_b32_e32 v8, 0x1a0
	s_mov_b32 s21, 1
	s_mov_b32 s20, 0
                                        ; implicit-def: $sgpr22
.LBB1_31:                               ; %.lr.ph44.i
                                        ;   Parent Loop BB1_5 Depth=1
                                        ;     Parent Loop BB1_28 Depth=2
                                        ; =>    This Inner Loop Header: Depth=3
	scratch_load_b32 v10, v8, off
	v_mov_b32_e32 v9, s18
	s_or_b32 s22, s22, exec_lo
	s_mov_b32 s23, exec_lo
	s_waitcnt vmcnt(0)
	v_cmpx_ne_u32_e64 s18, v10
; %bb.32:                               ;   in Loop: Header=BB1_31 Depth=3
	v_cmp_eq_u32_e32 vcc_lo, v10, v7
	s_cmp_ge_i32 s21, s6
	v_dual_mov_b32 v9, v7 :: v_dual_add_nc_u32 v8, 4, v8
	s_cselect_b32 s24, -1, 0
	s_and_not1_b32 s22, s22, exec_lo
	s_or_b32 s24, vcc_lo, s24
	s_add_i32 s21, s21, 1
	s_and_b32 s24, s24, exec_lo
	s_delay_alu instid0(SALU_CYCLE_1)
	s_or_b32 s22, s22, s24
; %bb.33:                               ; %Flow
                                        ;   in Loop: Header=BB1_31 Depth=3
	s_or_b32 exec_lo, exec_lo, s23
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_and_b32 s23, exec_lo, s22
	s_or_b32 s20, s23, s20
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_not1_b32 exec_lo, exec_lo, s20
	s_cbranch_execnz .LBB1_31
; %bb.34:                               ; %Flow116
                                        ;   in Loop: Header=BB1_28 Depth=2
	s_or_b32 exec_lo, exec_lo, s20
	v_mov_b32_e32 v7, v9
.LBB1_35:                               ; %Flow117
                                        ;   in Loop: Header=BB1_28 Depth=2
	s_or_b32 exec_lo, exec_lo, s1
	s_delay_alu instid0(VALU_DEP_1)
	v_dual_mov_b32 v8, v7 :: v_dual_mov_b32 v9, v6
.LBB1_36:                               ; %.loopexit.i
                                        ;   in Loop: Header=BB1_28 Depth=2
	s_or_b32 exec_lo, exec_lo, s19
	s_add_i32 s18, s18, 1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_cmp_lg_u32 s18, s7
	s_cbranch_scc0 .LBB1_38
; %bb.37:                               ;   in Loop: Header=BB1_28 Depth=2
	v_dual_mov_b32 v6, v9 :: v_dual_mov_b32 v7, v8
	s_branch .LBB1_28
.LBB1_38:                               ; %_Z14deviceFindModePiii.exit
                                        ;   in Loop: Header=BB1_5 Depth=1
	global_store_b32 v[2:3], v8, off
.LBB1_39:                               ; %Flow131
                                        ;   in Loop: Header=BB1_5 Depth=1
	s_or_b32 exec_lo, exec_lo, s17
	s_delay_alu instid0(SALU_CYCLE_1)
	s_or_not1_b32 s1, s11, exec_lo
.LBB1_40:                               ; %Flow130
                                        ;   in Loop: Header=BB1_5 Depth=1
	s_or_b32 exec_lo, exec_lo, s10
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_and_b32 s1, exec_lo, s1
	s_or_b32 s13, s1, s13
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_not1_b32 exec_lo, exec_lo, s13
	s_cbranch_execnz .LBB1_5
.LBB1_41:
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z11knnPunisherP15HIP_vector_typeIfLj2EEPiiiii
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 576
		.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 1
		.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 25
		.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	_Z11knnPunisherP15HIP_vector_typeIfLj2EEPiiiii, .Lfunc_end1-_Z11knnPunisherP15HIP_vector_typeIfLj2EEPiiiii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 1260
; NumSgprs: 27
; NumVgprs: 11
; ScratchSize: 576
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 3
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 27
; NumVGPRsForWavesPerEU: 11
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 1
; 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:
      - .actual_access:  read_only
        .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .actual_access:  write_only
        .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
      - .address_space:  global
        .offset:         32
        .size:           8
        .value_kind:     global_buffer
      - .offset:         40
        .size:           4
        .value_kind:     by_value
      - .offset:         48
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         52
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         56
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         60
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         62
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         64
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         66
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         68
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         70
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         88
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         96
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         104
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         112
        .size:           2
        .value_kind:     hidden_grid_dims
      - .offset:         168
        .size:           4
        .value_kind:     hidden_dynamic_lds_size
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 304
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z3knnPfP15HIP_vector_typeIfLj2EEiiiiPii
    .private_segment_fixed_size: 896
    .sgpr_count:     40
    .sgpr_spill_count: 0
    .symbol:         _Z3knnPfP15HIP_vector_typeIfLj2EEiiiiPii.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     18
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
  - .args:
      - .actual_access:  read_only
        .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:     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
      - .offset:         152
        .size:           4
        .value_kind:     hidden_dynamic_lds_size
    .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:           _Z11knnPunisherP15HIP_vector_typeIfLj2EEPiiiii
    .private_segment_fixed_size: 576
    .sgpr_count:     27
    .sgpr_spill_count: 0
    .symbol:         _Z11knnPunisherP15HIP_vector_typeIfLj2EEPiiiii.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     11
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
