#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <sstream>
#include <time.h>
#include <sys/time.h>

using namespace std;
double iStart1, iStart2, iStart3a, iStart3b, iStart4a, iStart4b, iStart4c, iStart5;
double iElaps1=0, iElaps2=0, iElaps3a=0, iElaps3b=0, iElaps4=0, iElaps5=0;
// Hold configurations for Kmeans
struct Info {
  int     numPoints;
  int     dim;
  int     numCentroids;
  int     numRepeats;
  int    *belongs;
  float **points;
  float **centroids;
  int     thresholdLoops;
  float   thresholdFraction;
  int     threadPerBlock;
};

// ************* Utils ************* //

double cpuSecond() {
    struct timeval tp;
    gettimeofday(&tp,NULL);
    return ((double)tp.tv_sec + (double)tp.tv_usec * 1.e-6);
}

static inline int nextPowerOfTwo(int v) {
  int res = v;
  for (int i = 1; i <= 16; i *= 2) {
    res |= res >> i;
  }
  return res + 1;
}

float** make2DArray(int x, int y) {
  float **res = (float **)malloc(x * sizeof(float *));

  // for (int i = 0; i < x; i++) {
  //   res[i] = (float *)malloc(y * sizeof(float));
  // }
  res[0] = (float *)malloc(x * y * sizeof(float));
  for (size_t i = 1; i < x; i++) res[i] = res[i-1] + y;
  for (size_t i = 0; i < x; i++) {
    for (size_t j = 0; j < y; j++) {
      res[i][j] = 0.0;
    }
  }
  return res;
}

void invert2DArray(float **A, float **B, int x, int y) {
  for (int i = 0; i < x; i++) {
    for (int j = 0; j < y; j++) {
      A[i][j] = B[j][i];
    }
  }
}

void copy2DArray(float **A, float **B, int x, int y) {
  for (int i = 0; i < x; i++) {
    for (int j = 0; j < y; j++) {
      A[i][j] = B[i][j];
    }
  }
}

// ************* Utils ************* //

__host__ __device__ inline static float
    computeDist(Info* info, int pointId, int centroidId, int distType, float *gPoints, float *gCentroids) {
  float res = 0;
  if (distType == 0) {
    for (int i = 0; i < info->dim; i++) {
      res +=
        (gPoints[i * (info->numPoints) + pointId] - gCentroids[i * (info->numCentroids) + centroidId]) *
        (gPoints[i * (info->numPoints) + pointId] - gCentroids[i * (info->numCentroids) + centroidId]);
    }
  }
  return res;
}

// Use reduction to compute the sum of an array
// Refer to
// http://developer.download.nvidia.com/compute/cuda/1.1-Beta/x86_website/projects/reduction/doc/reduction.pdf
__global__ static void reduce(int *g_idata, int l1, int l2) {
  extern __shared__ unsigned int sdata[];
  unsigned int tid = threadIdx.x;

  if (tid < l1) {
    sdata[tid] = g_idata[tid];
  } else {
    sdata[tid] = 0;
  }
  __syncthreads();

  // Parallel Reduction (l2 must be power of 2)
  for (unsigned int s = l2 / 2; s > 0; s >>= 1) {
    if (tid < s)     {
      sdata[tid] += sdata[tid + s];
    }
    __syncthreads();
  }

  if (tid == 0) {
    g_idata[0] = sdata[0];
  }
}

__global__ static void nearestCentroid(int *blockResult, int *gBelongs, float *gPoints, float *gCentroids, Info *gInfo) {

  int pointId = blockDim.x * blockIdx.x + threadIdx.x;
  if (pointId >= (gInfo->numPoints)) return;

  // For test on test.txt
  // printf("Thread: %d - %.2f,  %.2f, %.2f,  %.2f \n", pointId, gCentroids[0], gCentroids[1], gCentroids[2], gCentroids[3]);
  // printf("Thread: %d - %.2f,  %.2f, %.2f,  %.2f, %.2f,  %.2f, %.2f,  %.2f \n",
  //          pointId, gPoints[0], gPoints[1], gPoints[2], gPoints[3], gPoints[4], gPoints[5], gPoints[6], gPoints[7]);

  // Get the minimum distance
  float mDist = computeDist(gInfo, pointId, 0, 0, gPoints, gCentroids);

  int tmpIdx = 0;
  int numCentroids = gInfo->numCentroids;
  for (int i = 0; i < numCentroids; i++) {
    float tmpDist = computeDist(gInfo, pointId, i, 0, gPoints, gCentroids);
    if (tmpDist < mDist) {
      mDist  = tmpDist;
      tmpIdx = i;
    }
  }

  // use reduction to add the total number of changes (change from one centroid to another) in this block
  extern __shared__ int sdata2[];
  sdata2[threadIdx.x] = 0;
  if (gBelongs[pointId] != tmpIdx) {
    sdata2[threadIdx.x] = 1;
  }
  gBelongs[pointId] = tmpIdx;
  __syncthreads();

  // Reduction
  for (unsigned int s = blockDim.x / 2; s > 0; s >>= 1) {
    if (threadIdx.x < s) {
      sdata2[threadIdx.x] += sdata2[threadIdx.x + s];
    }
    __syncthreads();
  }

  // Put the sum to the location corresbonding to current block
  if (threadIdx.x == 0) {
    blockResult[blockIdx.x] = sdata2[0];
  }
}

void processData(char *fileName, Info *info) {
  float **X;
  int   **GUESS;

  int N_samples, N_features, N_clusters, N_repeat;

  // readX(FILE_NAME,&X,&GUESS,&N_samples,&N_features,&N_clusters,&N_repeat);

  // Test purpose
  N_samples  = 100;
  N_features = 9;
  N_clusters = 4;
  N_repeat   = 10;

  info->numPoints         = N_samples;
  info->dim               = N_features;
  info->numCentroids      = N_clusters;
  info->numRepeats        = N_repeat;
  info->thresholdFraction = 0.005;
  info->thresholdLoops    = 200;

  // Process data point
  X = make2DArray(N_samples, N_features);

  string str(fileName);
  ifstream file(str);
     string line1;
     int i = 0;
     while (getline(file, line1)) {
     std::istringstream iss(line1);
     int j = -1;
     for(string s; iss >> s;) {
             if (j == -1) {
                     j++;
                     continue;
             }
             // cout << s << " ";
             X[i][j] = stof(s);
             j++;
     }
     i++;
  }
  info->points = X;

  /* belongs: the cluster id for each data object */
  int *belongs = new int[N_samples];
  for (i = 0; i < N_samples; i++) belongs[i] = -1;
  info->belongs = belongs;
}



void cudaKmeans(Info *info) {
  // Initialization
  int numPoints         = info->numPoints;
  int dim               = info->dim;
  int numCentroids      = info->numCentroids;
  int thresholdLoops    = info->thresholdLoops;
  int thresholdFraction = info->thresholdFraction;
  int* belongs          = info->belongs;
  float **points        = info->points;
  float **centroids     = info->centroids;
  int threadPerBlock    = info->threadPerBlock;

  // invert (transpose matrix)
  float **iPoints = make2DArray(dim, numPoints);
  invert2DArray(iPoints, points, dim, numPoints);

  // initial guess
  float **iCentroids = make2DArray(dim, numCentroids);
  copy2DArray(iCentroids, iPoints, dim, numCentroids);
  // invert2DArray(iCentroids, points, dim, numCentroids);

  // centroid -> number of points
  int *pointsCount   = new int[numCentroids];
  float **iNewCentroids = make2DArray(dim, numCentroids);

  // Some cuda constants
  const unsigned int bthreads = threadPerBlock;
  const unsigned int l1       = (numPoints + bthreads - 1) / bthreads;
  const unsigned int l2       = nextPowerOfTwo(l1);
  const unsigned int sdsize2  = bthreads * sizeof(unsigned int); // shared memory size for sdata2
  const unsigned int sdsize1  = l2 * sizeof(unsigned int); // shared memory size for sdata1

  // Cuda device Initialization
  float *gPoints;
  float *gCentroids;
  int   *gBelongs;
  Info   *gInfo;
  int   *tmp;

  // Data transfer
  iStart4a = cpuSecond();
  cudaMalloc(&gPoints,    numPoints * dim * sizeof(float));
  cudaMalloc(&gCentroids, numCentroids * dim * sizeof(float));
  cudaMalloc(&gBelongs,   numPoints * sizeof(int));
  cudaMalloc((void**)&gInfo,   sizeof(Info));
  cudaMalloc(&tmp,        l2 * sizeof(unsigned int)); // For reduction
  cudaMemcpy(gBelongs,
             belongs,
             numPoints * sizeof(int),
             cudaMemcpyHostToDevice);
  cudaMemcpy(gPoints,
             iPoints[0],
             numPoints * dim * sizeof(float),
             cudaMemcpyHostToDevice);
  cudaMemcpy(gInfo,info,sizeof(Info),cudaMemcpyHostToDevice);

  iElaps4 += cpuSecond() - iStart4a;

  int count = 0;
  float frac = 1.0;

  while (count < thresholdLoops) {
    iStart4b = cpuSecond();
    cudaMemcpy(gCentroids, iCentroids[0], dim * numCentroids * sizeof(float), cudaMemcpyHostToDevice);
    iElaps4 += cpuSecond() - iStart4b;

    // E-Step: assign points to the nearest cluster center
    iStart2 = cpuSecond();
    // nearestCentroid<<<l1, bthreads, sdsize2>>>(dim, numPoints, numCentroids, gPoints, gCentroids, gBelongs, tmp);
    nearestCentroid<<<l1, bthreads, sdsize2>>>(tmp, gBelongs, gPoints, gCentroids, gInfo);
    cudaDeviceSynchronize();
    iElaps2 += (cpuSecond() - iStart2);

    // Update belongs
    iStart4c = cpuSecond();
    cudaMemcpy(belongs, gBelongs, numPoints * sizeof(int), cudaMemcpyDeviceToHost);
    iElaps4 += cpuSecond() - iStart4c;

    // M-Step first half: set the cluster centers to the mean
    iStart3a = cpuSecond();

    // Clear the two temp variables
    for (int i = 0; i < numCentroids; i++) {
      pointsCount[i] = 0;
      for (int j = 0; j < dim; j++) {
        iNewCentroids[j][i] = 0.0;
      }
    }

    // Add up points in each centroid
    for (int i = 0; i < numPoints; i++) {
      int idx = belongs[i];
      pointsCount[idx] += 1;
      for (int j = 0; j < dim; j++) {
        iNewCentroids[j][idx] += points[i][j];
      }
    }
    iElaps3a += cpuSecond() - iStart3a;

    // M-Step second half: convert the sum to the mean
    // Update to new centroids
    iStart3b = cpuSecond();
    for (int i = 0; i < numCentroids; i++) {
      for (int j = 0; j < dim; j++) {
        if (pointsCount[i] > 0) {
          iCentroids[j][i] = iNewCentroids[j][i] / pointsCount[i];
        }
      }
    }
    iElaps3b += cpuSecond() - iStart3b;

    // Check convergence
    iStart5 = cpuSecond();

    // Check if too few number of points change their centroids
    reduce <<<1, l2, sdsize1>>>(tmp, l1, l2);
    cudaDeviceSynchronize();
    int tmpFloat;
    cudaMemcpy(&tmpFloat, tmp, sizeof(int), cudaMemcpyDeviceToHost);
    frac = (float)tmpFloat / numPoints;
    cout << "Iteration: " << count << "," << frac << "," << tmpFloat  << "\n";
    count++;
    if (frac <= thresholdFraction) break;

    iElaps5 += cpuSecond() - iStart5;

  }

  centroids = make2DArray(numCentroids, dim);
  invert2DArray(centroids, iCentroids, numCentroids, dim);
  info->centroids = centroids;

  // Free device memory
  cudaFree(gPoints);
  cudaFree(gCentroids);
  cudaFree(gBelongs);
  cudaFree(tmp);

}

int main(int argc, char *argv[]) {
  Info *info     = new Info;
  info->threadPerBlock = atoi(argv[1]);
  char *fileName = argv[2];
  processData(fileName, info);

  for (int i = 0; i < info->numRepeats; i++) {
    iStart1 = cpuSecond();
    cudaKmeans(info);
    iElaps1 += cpuSecond() - iStart1;

    // cout << info->centroids[0][0] << "," << info->centroids[0][1] << ","
    //      << info->centroids[1][0] << "," << info->centroids[1][1] << "\n";

    // Reload info
    delete(info);
    info     = new Info;
    info->threadPerBlock = atoi(argv[1]);
    processData(fileName, info);
  }


  cout << "Total time: " << iElaps1*1000 << "\n";
  cout << "E-step time use (ms): " << iElaps2*1000 << "\n";
  cout << "M-step-1st-half time use (ms): " << iElaps3a*1000 << "\n";
  cout << "M-step-2nd-half time use (ms): " << iElaps3b*1000 << "\n";
  cout << "Cuda Data IO (ms): " << iElaps4*1000 << "\n";
  cout << "Other (ms): " << iElaps5*1000 << "\n";
}

	.file	"tmpxft_00333e91_00000000-6_kmeans_txt.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB4198:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE4198:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.type	_ZL48__device_stub__Z15nearestCentroidPiS_PfS0_P4InfoPiS_PfS0_P4Info, @function
_ZL48__device_stub__Z15nearestCentroidPiS_PfS0_P4InfoPiS_PfS0_P4Info:
.LFB4222:
	.cfi_startproc
	subq	$168, %rsp
	.cfi_def_cfa_offset 176
	movq	%rdi, 40(%rsp)
	leaq	64(%rsp), %rdi
	movq	%rsi, 32(%rsp)
	leaq	76(%rsp), %rsi
	movq	%rdx, 24(%rsp)
	leaq	48(%rsp), %rdx
	movq	%rcx, 16(%rsp)
	leaq	56(%rsp), %rcx
	movq	%r8, 8(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 152(%rsp)
	xorl	%eax, %eax
	leaq	40(%rsp), %rax
	movl	$1, 72(%rsp)
	movq	%rax, 112(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 128(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 136(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 144(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 64(%rsp)
	movq	%rax, 76(%rsp)
	movl	$1, 84(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L2
	pushq	56(%rsp)
	.cfi_def_cfa_offset 184
	leaq	_ZL15nearestCentroidPiS_PfS0_P4Info(%rip), %rdi
	pushq	56(%rsp)
	.cfi_def_cfa_offset 192
	movq	92(%rsp), %rcx
	movl	100(%rsp), %r8d
	movq	80(%rsp), %rsi
	movl	88(%rsp), %edx
	leaq	128(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 184
	popq	%rdx
	.cfi_def_cfa_offset 176
.L2:
	movq	152(%rsp), %rax
	subq	%fs:40, %rax
	je	.L4
	call	__stack_chk_fail@PLT
.L4:
	addq	$168, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE4222:
	.size	_ZL48__device_stub__Z15nearestCentroidPiS_PfS0_P4InfoPiS_PfS0_P4Info, .-_ZL48__device_stub__Z15nearestCentroidPiS_PfS0_P4InfoPiS_PfS0_P4Info
	.type	_ZL15nearestCentroidPiS_PfS0_P4Info, @function
_ZL15nearestCentroidPiS_PfS0_P4Info:
.LFB4223:
	.cfi_startproc
	endbr64
	jmp	_ZL48__device_stub__Z15nearestCentroidPiS_PfS0_P4InfoPiS_PfS0_P4Info
	.cfi_endproc
.LFE4223:
	.size	_ZL15nearestCentroidPiS_PfS0_P4Info, .-_ZL15nearestCentroidPiS_PfS0_P4Info
	.type	_ZL27__device_stub__Z6reducePiiiPiii, @function
_ZL27__device_stub__Z6reducePiiiPiii:
.LFB4220:
	.cfi_startproc
	subq	$120, %rsp
	.cfi_def_cfa_offset 128
	movq	%rdi, 8(%rsp)
	leaq	24(%rsp), %rcx
	leaq	32(%rsp), %rdi
	movl	%esi, 4(%rsp)
	leaq	44(%rsp), %rsi
	movl	%edx, (%rsp)
	leaq	16(%rsp), %rdx
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rax
	movl	$1, 40(%rsp)
	movq	%rax, 80(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 88(%rsp)
	movq	%rsp, %rax
	movq	%rax, 96(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 32(%rsp)
	movq	%rax, 44(%rsp)
	movl	$1, 52(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L8
	pushq	24(%rsp)
	.cfi_def_cfa_offset 136
	leaq	_ZL6reducePiii(%rip), %rdi
	pushq	24(%rsp)
	.cfi_def_cfa_offset 144
	movq	60(%rsp), %rcx
	movl	68(%rsp), %r8d
	movq	48(%rsp), %rsi
	movl	56(%rsp), %edx
	leaq	96(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 136
	popq	%rdx
	.cfi_def_cfa_offset 128
.L8:
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L10
	call	__stack_chk_fail@PLT
.L10:
	addq	$120, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE4220:
	.size	_ZL27__device_stub__Z6reducePiiiPiii, .-_ZL27__device_stub__Z6reducePiiiPiii
	.type	_ZL6reducePiii, @function
_ZL6reducePiii:
.LFB4221:
	.cfi_startproc
	endbr64
	jmp	_ZL27__device_stub__Z6reducePiiiPiii
	.cfi_endproc
.LFE4221:
	.size	_ZL6reducePiii, .-_ZL6reducePiii
	.globl	_Z9cpuSecondv
	.type	_Z9cpuSecondv, @function
_Z9cpuSecondv:
.LFB4186:
	.cfi_startproc
	endbr64
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	xorl	%esi, %esi
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rdi
	call	gettimeofday@PLT
	cvtsi2sdq	16(%rsp), %xmm0
	mulsd	.LC0(%rip), %xmm0
	cvtsi2sdq	8(%rsp), %xmm1
	addsd	%xmm1, %xmm0
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	je	.L14
	call	__stack_chk_fail@PLT
.L14:
	addq	$40, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE4186:
	.size	_Z9cpuSecondv, .-_Z9cpuSecondv
	.globl	_Z11make2DArrayii
	.type	_Z11make2DArrayii, @function
_Z11make2DArrayii:
.LFB4188:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	movslq	%edi, %r13
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	movslq	%esi, %r12
	leaq	0(,%r13,8), %rdi
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	movq	%r13, %rbx
	pushq	%rcx
	.cfi_def_cfa_offset 48
	imull	%r12d, %ebx
	call	malloc@PLT
	movslq	%ebx, %rdi
	salq	$2, %rdi
	movq	%rax, %rbp
	call	malloc@PLT
	leaq	0(,%r12,4), %rdx
	movq	%rax, 0(%rbp)
	movl	$1, %eax
.L17:
	cmpq	%r13, %rax
	jnb	.L24
	movq	-8(%rbp,%rax,8), %rcx
	addq	%rdx, %rcx
	movq	%rcx, 0(%rbp,%rax,8)
	incq	%rax
	jmp	.L17
.L24:
	xorl	%eax, %eax
.L19:
	cmpq	%r13, %rax
	jnb	.L25
	xorl	%edx, %edx
.L21:
	cmpq	%r12, %rdx
	jnb	.L26
	movq	0(%rbp,%rax,8), %rcx
	movl	$0x00000000, (%rcx,%rdx,4)
	incq	%rdx
	jmp	.L21
.L26:
	incq	%rax
	jmp	.L19
.L25:
	popq	%rdx
	.cfi_def_cfa_offset 40
	movq	%rbp, %rax
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE4188:
	.size	_Z11make2DArrayii, .-_Z11make2DArrayii
	.globl	_Z13invert2DArrayPPfS0_ii
	.type	_Z13invert2DArrayPPfS0_ii, @function
_Z13invert2DArrayPPfS0_ii:
.LFB4189:
	.cfi_startproc
	endbr64
	movq	%rdi, %r8
	xorl	%edi, %edi
.L28:
	cmpl	%edi, %edx
	jle	.L27
	leaq	0(,%rdi,4), %r9
	xorl	%eax, %eax
.L31:
	cmpl	%eax, %ecx
	jle	.L32
	movq	(%rsi,%rax,8), %r10
	movss	(%r10,%r9), %xmm0
	movq	(%r8,%rdi,8), %r10
	movss	%xmm0, (%r10,%rax,4)
	incq	%rax
	jmp	.L31
.L32:
	incq	%rdi
	jmp	.L28
.L27:
	ret
	.cfi_endproc
.LFE4189:
	.size	_Z13invert2DArrayPPfS0_ii, .-_Z13invert2DArrayPPfS0_ii
	.globl	_Z11copy2DArrayPPfS0_ii
	.type	_Z11copy2DArrayPPfS0_ii, @function
_Z11copy2DArrayPPfS0_ii:
.LFB4190:
	.cfi_startproc
	endbr64
	xorl	%eax, %eax
.L34:
	cmpl	%eax, %edx
	jle	.L38
	xorl	%r8d, %r8d
.L36:
	cmpl	%r8d, %ecx
	jle	.L39
	movq	(%rsi,%rax,8), %r9
	movss	(%r9,%r8,4), %xmm0
	movq	(%rdi,%rax,8), %r9
	movss	%xmm0, (%r9,%r8,4)
	incq	%r8
	jmp	.L36
.L39:
	incq	%rax
	jmp	.L34
.L38:
	ret
	.cfi_endproc
.LFE4190:
	.size	_Z11copy2DArrayPPfS0_ii, .-_Z11copy2DArrayPPfS0_ii
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC2:
	.string	"Iteration: "
.LC3:
	.string	","
.LC4:
	.string	"\n"
	.text
	.globl	_Z10cudaKmeansP4Info
	.type	_Z10cudaKmeansP4Info, @function
_Z10cudaKmeansP4Info:
.LFB4194:
	.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
	movq	%rdi, %rbx
	subq	$184, %rsp
	.cfi_def_cfa_offset 240
	movl	(%rdi), %ebp
	movl	48(%rdi), %r13d
	movq	%fs:40, %rax
	movq	%rax, 168(%rsp)
	xorl	%eax, %eax
	movl	4(%rdi), %eax
	movl	%ebp, %esi
	movl	%eax, 8(%rsp)
	movl	8(%rdi), %eax
	movl	%eax, 12(%rsp)
	movl	40(%rdi), %eax
	movl	%eax, 84(%rsp)
	cvttss2sil	44(%rdi), %eax
	movl	%eax, 88(%rsp)
	movq	16(%rdi), %rax
	movq	%rax, 40(%rsp)
	movq	24(%rdi), %rax
	movl	8(%rsp), %edi
	movq	%rax, 72(%rsp)
	call	_Z11make2DArrayii
	movl	8(%rsp), %edx
	movq	72(%rsp), %rsi
	movl	%ebp, %ecx
	movq	%rax, %rdi
	movq	%rax, %r15
	call	_Z13invert2DArrayPPfS0_ii
	movl	12(%rsp), %esi
	movl	8(%rsp), %edi
	call	_Z11make2DArrayii
	movl	12(%rsp), %ecx
	movl	8(%rsp), %edx
	movq	%r15, %rsi
	movq	%rax, %rdi
	movq	%rax, 16(%rsp)
	call	_Z11copy2DArrayPPfS0_ii
	movslq	12(%rsp), %rdi
	movabsq	$2305843009213693950, %rax
	cmpq	%rdi, %rax
	jb	.L41
	salq	$2, %rdi
	call	_Znam@PLT
	movl	12(%rsp), %esi
	movl	8(%rsp), %edi
	movq	%rax, %r12
	call	_Z11make2DArrayii
	xorl	%edx, %edx
	movl	$1, %ecx
	movq	%rax, %r14
	leal	-1(%rbp,%r13), %eax
	divl	%r13d
	movl	$5, %edx
	movl	%eax, 52(%rsp)
.L42:
	movl	%eax, %esi
	sarl	%cl, %esi
	addl	%ecx, %ecx
	orl	%esi, %eax
	decl	%edx
	jne	.L42
	incl	%eax
	movl	%eax, 48(%rsp)
	leal	0(,%r13,4), %eax
	movl	%eax, 92(%rsp)
	call	_Z9cpuSecondv
	movl	8(%rsp), %eax
	leaq	104(%rsp), %rdi
	movsd	%xmm0, iStart4a(%rip)
	imull	%ebp, %eax
	cltq
	salq	$2, %rax
	movq	%rax, %rsi
	movq	%rax, 32(%rsp)
	call	cudaMalloc@PLT
	movl	12(%rsp), %ecx
	movl	8(%rsp), %eax
	leaq	112(%rsp), %rdi
	imull	%ecx, %eax
	cltq
	salq	$2, %rax
	movq	%rax, %rsi
	movq	%rax, 56(%rsp)
	call	cudaMalloc@PLT
	movslq	%ebp, %rax
	leaq	120(%rsp), %rdi
	salq	$2, %rax
	movq	%rax, %rsi
	movq	%rax, 24(%rsp)
	call	cudaMalloc@PLT
	leaq	128(%rsp), %rdi
	movl	$56, %esi
	call	cudaMalloc@PLT
	movl	48(%rsp), %eax
	leaq	136(%rsp), %rdi
	salq	$2, %rax
	movq	%rax, %rsi
	movq	%rax, 64(%rsp)
	call	cudaMalloc@PLT
	movq	24(%rsp), %rdx
	movq	40(%rsp), %rsi
	movl	$1, %ecx
	movq	120(%rsp), %rdi
	call	cudaMemcpy@PLT
	movq	(%r15), %rsi
	movq	32(%rsp), %rdx
	movl	$1, %ecx
	movabsq	$4294967297, %r15
	movq	104(%rsp), %rdi
	call	cudaMemcpy@PLT
	movq	128(%rsp), %rdi
	movl	$1, %ecx
	movq	%rbx, %rsi
	movl	$56, %edx
	call	cudaMemcpy@PLT
	call	_Z9cpuSecondv
	subsd	iStart4a(%rip), %xmm0
	xorl	%ecx, %ecx
	addsd	iElaps4(%rip), %xmm0
	movl	%ecx, 32(%rsp)
	movsd	%xmm0, iElaps4(%rip)
	jmp	.L43
.L41:
	movq	168(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L66
	call	__cxa_throw_bad_array_new_length@PLT
.L57:
	call	_Z9cpuSecondv
	subsd	iStart3b(%rip), %xmm0
	addsd	iElaps3b(%rip), %xmm0
	movsd	%xmm0, iElaps3b(%rip)
	call	_Z9cpuSecondv
	movl	48(%rsp), %eax
	xorl	%r9d, %r9d
	movq	%r15, %rdi
	movq	64(%rsp), %r8
	movq	%r15, 160(%rsp)
	movl	$1, %esi
	movl	%eax, 156(%rsp)
	movl	164(%rsp), %ecx
	movq	156(%rsp), %rdx
	andl	$4294967292, %r8d
	movq	%r15, 144(%rsp)
	movl	$1, 152(%rsp)
	movsd	%xmm0, iStart5(%rip)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L59
	movl	48(%rsp), %edx
	movl	52(%rsp), %esi
	movq	136(%rsp), %rdi
	call	_ZL27__device_stub__Z6reducePiiiPiii
.L59:
	call	cudaDeviceSynchronize@PLT
	movl	$2, %ecx
	movq	136(%rsp), %rsi
	movl	$4, %edx
	leaq	156(%rsp), %rdi
	call	cudaMemcpy@PLT
	cvtsi2ssl	%ebp, %xmm0
	leaq	.LC2(%rip), %rsi
	cvtsi2ssl	156(%rsp), %xmm1
	leaq	_ZSt4cout(%rip), %rdi
	divss	%xmm0, %xmm1
	movss	%xmm1, 80(%rsp)
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	32(%rsp), %esi
	movq	%rax, %rdi
	call	_ZNSolsEi@PLT
	leaq	.LC3(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	cvtss2sd	80(%rsp), %xmm0
	movq	%rax, %rdi
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	leaq	.LC3(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	156(%rsp), %esi
	movq	%rax, %rdi
	call	_ZNSolsEi@PLT
	leaq	.LC4(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	incl	32(%rsp)
	cvtsi2ssl	88(%rsp), %xmm0
	comiss	80(%rsp), %xmm0
	jnb	.L61
	call	_Z9cpuSecondv
	subsd	iStart5(%rip), %xmm0
	addsd	iElaps5(%rip), %xmm0
	movsd	%xmm0, iElaps5(%rip)
.L43:
	movl	84(%rsp), %edx
	cmpl	%edx, 32(%rsp)
	jge	.L61
	call	_Z9cpuSecondv
	movq	16(%rsp), %rax
	movq	56(%rsp), %rdx
	movl	$1, %ecx
	movq	112(%rsp), %rdi
	movsd	%xmm0, iStart4b(%rip)
	movq	(%rax), %rsi
	call	cudaMemcpy@PLT
	call	_Z9cpuSecondv
	subsd	iStart4b(%rip), %xmm0
	addsd	iElaps4(%rip), %xmm0
	movsd	%xmm0, iElaps4(%rip)
	call	_Z9cpuSecondv
	movl	52(%rsp), %eax
	xorl	%r9d, %r9d
	movq	%r15, 160(%rsp)
	movq	%r15, 148(%rsp)
	movl	164(%rsp), %ecx
	movl	%r13d, 156(%rsp)
	movl	92(%rsp), %r8d
	movl	%eax, 144(%rsp)
	movq	156(%rsp), %rdx
	movq	144(%rsp), %rdi
	movl	152(%rsp), %esi
	movsd	%xmm0, iStart2(%rip)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L45
	movq	128(%rsp), %r8
	movq	112(%rsp), %rcx
	movq	104(%rsp), %rdx
	movq	120(%rsp), %rsi
	movq	136(%rsp), %rdi
	call	_ZL48__device_stub__Z15nearestCentroidPiS_PfS0_P4InfoPiS_PfS0_P4Info
.L45:
	call	cudaDeviceSynchronize@PLT
	call	_Z9cpuSecondv
	subsd	iStart2(%rip), %xmm0
	addsd	iElaps2(%rip), %xmm0
	movsd	%xmm0, iElaps2(%rip)
	call	_Z9cpuSecondv
	movq	24(%rsp), %rdx
	movq	120(%rsp), %rsi
	movl	$2, %ecx
	movq	40(%rsp), %rdi
	movsd	%xmm0, iStart4c(%rip)
	call	cudaMemcpy@PLT
	call	_Z9cpuSecondv
	subsd	iStart4c(%rip), %xmm0
	addsd	iElaps4(%rip), %xmm0
	movsd	%xmm0, iElaps4(%rip)
	call	_Z9cpuSecondv
	xorl	%eax, %eax
	movsd	%xmm0, iStart3a(%rip)
.L46:
	cmpl	%eax, 12(%rsp)
	jle	.L67
	xorl	%edx, %edx
	leaq	0(,%rax,4), %rcx
	movl	%edx, (%r12,%rax,4)
	xorl	%edx, %edx
.L47:
	cmpl	%edx, 8(%rsp)
	jle	.L68
	movq	(%r14,%rdx,8), %rsi
	incq	%rdx
	movl	$0x00000000, (%rsi,%rcx)
	jmp	.L47
.L68:
	incq	%rax
	jmp	.L46
.L67:
	xorl	%eax, %eax
.L50:
	cmpl	%eax, %ebp
	jle	.L69
	movq	40(%rsp), %rcx
	xorl	%edx, %edx
	movslq	(%rcx,%rax,4), %rcx
	salq	$2, %rcx
	incl	(%r12,%rcx)
.L51:
	cmpl	%edx, 8(%rsp)
	jle	.L70
	movq	72(%rsp), %rdi
	movq	(%r14,%rdx,8), %rsi
	movq	(%rdi,%rax,8), %rdi
	addq	%rcx, %rsi
	movss	(%rsi), %xmm0
	addss	(%rdi,%rdx,4), %xmm0
	incq	%rdx
	movss	%xmm0, (%rsi)
	jmp	.L51
.L70:
	incq	%rax
	jmp	.L50
.L69:
	call	_Z9cpuSecondv
	subsd	iStart3a(%rip), %xmm0
	addsd	iElaps3a(%rip), %xmm0
	movsd	%xmm0, iElaps3a(%rip)
	call	_Z9cpuSecondv
	xorl	%edx, %edx
	movsd	%xmm0, iStart3b(%rip)
.L54:
	cmpl	%edx, 12(%rsp)
	jle	.L57
	leaq	0(,%rdx,4), %rcx
	xorl	%eax, %eax
.L58:
	cmpl	%eax, 8(%rsp)
	jle	.L71
	movl	(%r12,%rdx,4), %esi
	testl	%esi, %esi
	jle	.L55
	movq	(%r14,%rax,8), %r8
	cvtsi2ssl	%esi, %xmm1
	movq	16(%rsp), %rdi
	movss	(%r8,%rcx), %xmm0
	movq	(%rdi,%rax,8), %rdi
	divss	%xmm1, %xmm0
	movss	%xmm0, (%rdi,%rcx)
.L55:
	incq	%rax
	jmp	.L58
.L71:
	incq	%rdx
	jmp	.L54
.L61:
	movl	8(%rsp), %esi
	movl	12(%rsp), %edi
	call	_Z11make2DArrayii
	movl	8(%rsp), %ecx
	movl	12(%rsp), %edx
	movq	16(%rsp), %rsi
	movq	%rax, %r11
	movq	%rax, %rdi
	call	_Z13invert2DArrayPPfS0_ii
	movq	%r11, 32(%rbx)
	movq	104(%rsp), %rdi
	call	cudaFree@PLT
	movq	112(%rsp), %rdi
	call	cudaFree@PLT
	movq	120(%rsp), %rdi
	call	cudaFree@PLT
	movq	136(%rsp), %rdi
	call	cudaFree@PLT
	movq	168(%rsp), %rax
	subq	%fs:40, %rax
	je	.L63
.L66:
	call	__stack_chk_fail@PLT
.L63:
	addq	$184, %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
.LFE4194:
	.size	_Z10cudaKmeansP4Info, .-_Z10cudaKmeansP4Info
	.section	.rodata.str1.1
.LC5:
	.string	"_Z15nearestCentroidPiS_PfS0_P4Info"
.LC6:
	.string	"_Z6reducePiii"
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB4225:
	.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	.LC5(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_ZL15nearestCentroidPiS_PfS0_P4Info(%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	.LC6(%rip), %rdx
	orl	$-1, %r8d
	leaq	_ZL6reducePiii(%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
.LFE4225:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.text._ZZN9__gnu_cxx6__stoaIffcJEEET0_PFT_PKT1_PPS3_DpT2_EPKcS5_PmS9_EN11_Save_errnoD2Ev,"axG",@progbits,_ZZN9__gnu_cxx6__stoaIffcJEEET0_PFT_PKT1_PPS3_DpT2_EPKcS5_PmS9_EN11_Save_errnoD5Ev,comdat
	.align 2
	.weak	_ZZN9__gnu_cxx6__stoaIffcJEEET0_PFT_PKT1_PPS3_DpT2_EPKcS5_PmS9_EN11_Save_errnoD2Ev
	.type	_ZZN9__gnu_cxx6__stoaIffcJEEET0_PFT_PKT1_PPS3_DpT2_EPKcS5_PmS9_EN11_Save_errnoD2Ev, @function
_ZZN9__gnu_cxx6__stoaIffcJEEET0_PFT_PKT1_PPS3_DpT2_EPKcS5_PmS9_EN11_Save_errnoD2Ev:
.LFB4349:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	movq	%rdi, %rbx
	call	__errno_location@PLT
	cmpl	$0, (%rax)
	jne	.L74
	movl	(%rbx), %edx
	movl	%edx, (%rax)
.L74:
	popq	%rbx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE4349:
	.size	_ZZN9__gnu_cxx6__stoaIffcJEEET0_PFT_PKT1_PPS3_DpT2_EPKcS5_PmS9_EN11_Save_errnoD2Ev, .-_ZZN9__gnu_cxx6__stoaIffcJEEET0_PFT_PKT1_PPS3_DpT2_EPKcS5_PmS9_EN11_Save_errnoD2Ev
	.weak	_ZZN9__gnu_cxx6__stoaIffcJEEET0_PFT_PKT1_PPS3_DpT2_EPKcS5_PmS9_EN11_Save_errnoD1Ev
	.set	_ZZN9__gnu_cxx6__stoaIffcJEEET0_PFT_PKT1_PPS3_DpT2_EPKcS5_PmS9_EN11_Save_errnoD1Ev,_ZZN9__gnu_cxx6__stoaIffcJEEET0_PFT_PKT1_PPS3_DpT2_EPKcS5_PmS9_EN11_Save_errnoD2Ev
	.section	.rodata.str1.1
.LC7:
	.string	"basic_string: construction from null is not valid"
.LC8:
	.string	"stof"
	.text
	.globl	_Z11processDataPcP4Info
	.type	_Z11processDataPcP4Info, @function
_Z11processDataPcP4Info:
.LFB4192:
	.cfi_startproc
	.cfi_personality 0x9b,DW.ref.__gxx_personality_v0
	.cfi_lsda 0x1b,.LLSDA4192
	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
	movq	%rdi, %rbp
	movl	$100, %edi
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%rsi, %rbx
	subq	$1080, %rsp
	.cfi_def_cfa_offset 1136
	movq	%fs:40, %rax
	movq	%rax, 1064(%rsp)
	movabsq	$38654705764, %rax
	movq	%rax, (%rsi)
	movabsq	$42949672964, %rax
	movq	%rax, 8(%rsi)
	movabsq	$4297514907391230152, %rax
	movq	%rax, 40(%rsi)
	movl	$9, %esi
	call	_Z11make2DArrayii
	movq	%rax, %r12
	leaq	64(%rsp), %rax
	movq	%rax, (%rsp)
	leaq	80(%rsp), %rax
	movq	%rax, 64(%rsp)
	testq	%rbp, %rbp
	jne	.L78
	movq	1064(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L101
	leaq	.LC7(%rip), %rdi
.LEHB0:
	call	_ZSt19__throw_logic_errorPKc@PLT
.L78:
	movq	%rbp, %rdi
	call	strlen@PLT
	movq	%rax, 56(%rsp)
	leaq	0(%rbp,%rax), %r13
	cmpq	$15, %rax
	jbe	.L80
	movq	(%rsp), %rdi
	leaq	56(%rsp), %rsi
	xorl	%edx, %edx
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_createERmm@PLT
.LEHE0:
	movq	%rax, 64(%rsp)
	movq	56(%rsp), %rax
	movq	%rax, 80(%rsp)
.L80:
	movq	64(%rsp), %rdi
	movq	%r13, %rdx
	movq	%rbp, %rsi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE13_S_copy_charsEPcPKcS7_@PLT
	movq	56(%rsp), %rax
	movq	64(%rsp), %rdx
	movq	(%rsp), %rsi
	movq	%rax, 72(%rsp)
	movb	$0, (%rdx,%rax)
	leaq	544(%rsp), %rax
	movl	$8, %edx
	movq	%rax, %rdi
	movq	%rax, 8(%rsp)
.LEHB1:
	call	_ZNSt14basic_ifstreamIcSt11char_traitsIcEEC1ERKNSt7__cxx1112basic_stringIcS1_SaIcEEESt13_Ios_Openmode@PLT
.LEHE1:
	leaq	112(%rsp), %rax
	xorl	%esi, %esi
	movb	$0, 112(%rsp)
	movq	%r12, %r13
	movq	%rax, 96(%rsp)
	leaq	96(%rsp), %rax
	movq	%rsi, 104(%rsp)
	movq	%rax, 24(%rsp)
.L81:
	movq	24(%rsp), %rsi
	movq	8(%rsp), %rdi
.LEHB2:
	call	_ZSt7getlineIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RNSt7__cxx1112basic_stringIS4_S5_T1_EE@PLT
	movq	(%rax), %rdx
	movq	-24(%rdx), %rdx
	testb	$5, 32(%rax,%rdx)
	jne	.L104
	leaq	160(%rsp), %rax
	movq	24(%rsp), %rsi
	movl	$8, %edx
	movq	%rax, %rdi
	movq	%rax, 16(%rsp)
	call	_ZNSt7__cxx1119basic_istringstreamIcSt11char_traitsIcESaIcEEC1ERKNS_12basic_stringIcS2_S3_EESt13_Ios_Openmode@PLT
.LEHE2:
	leaq	144(%rsp), %rax
	xorl	%ecx, %ecx
	movb	$0, 144(%rsp)
	orl	$-1, %ebp
	movq	%rax, 128(%rsp)
	leaq	128(%rsp), %rax
	movq	%rcx, 136(%rsp)
	movq	%rax, 32(%rsp)
.L83:
	movq	32(%rsp), %rsi
	movq	16(%rsp), %rdi
.LEHB3:
	call	_ZStrsIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RNSt7__cxx1112basic_stringIS4_S5_T1_EE@PLT
.LEHE3:
	movq	(%rax), %rdx
	movq	-24(%rdx), %rdx
	testb	$5, 32(%rax,%rdx)
	jne	.L105
	cmpl	$-1, %ebp
	je	.L96
	movq	0(%r13), %rdx
	movslq	%ebp, %rax
	movq	128(%rsp), %r14
	leaq	(%rdx,%rax,4), %r15
	call	__errno_location@PLT
	movq	%r14, %rdi
	leaq	56(%rsp), %rsi
	movl	(%rax), %edx
	movq	%rax, 40(%rsp)
	movl	%edx, 52(%rsp)
	xorl	%edx, %edx
	movl	%edx, (%rax)
	call	strtof@PLT
	cmpq	56(%rsp), %r14
	movq	40(%rsp), %rax
	leaq	52(%rsp), %r14
	jne	.L84
	movq	1064(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L101
	leaq	.LC8(%rip), %rdi
.LEHB4:
	call	_ZSt24__throw_invalid_argumentPKc@PLT
.L84:
	cmpl	$34, (%rax)
	jne	.L86
	movq	1064(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L101
	leaq	.LC8(%rip), %rdi
	call	_ZSt20__throw_out_of_rangePKc@PLT
.LEHE4:
.L86:
	movq	%r14, %rdi
	movss	%xmm0, 40(%rsp)
	incl	%ebp
	call	_ZZN9__gnu_cxx6__stoaIffcJEEET0_PFT_PKT1_PPS3_DpT2_EPKcS5_PmS9_EN11_Save_errnoD1Ev
	movss	40(%rsp), %xmm0
	movss	%xmm0, (%r15)
	jmp	.L83
.L100:
	endbr64
	movq	%rax, %rbx
.L88:
	movq	%r14, %rdi
	call	_ZZN9__gnu_cxx6__stoaIffcJEEET0_PFT_PKT1_PPS3_DpT2_EPKcS5_PmS9_EN11_Save_errnoD1Ev
	jmp	.L89
.L96:
	xorl	%ebp, %ebp
	jmp	.L83
.L105:
	movq	32(%rsp), %rdi
	addq	$8, %r13
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT
	movq	16(%rsp), %rdi
	call	_ZNSt7__cxx1119basic_istringstreamIcSt11char_traitsIcESaIcEED1Ev@PLT
	jmp	.L81
.L104:
	movq	%r12, 24(%rbx)
	movl	$400, %edi
.LEHB5:
	call	_Znam@PLT
.LEHE5:
	movq	%rax, %rdx
	movl	$400, %ecx
	movb	$-1, %al
	movq	%rdx, %rdi
	movq	%rdx, 16(%rbx)
	rep stosb
	movq	24(%rsp), %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT
	movq	8(%rsp), %rdi
	call	_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev@PLT
	movq	(%rsp), %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT
	movq	1064(%rsp), %rax
	subq	%fs:40, %rax
	je	.L95
	jmp	.L101
.L98:
	endbr64
	movq	%rax, %rbx
.L89:
	movq	32(%rsp), %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT
	movq	16(%rsp), %rdi
	call	_ZNSt7__cxx1119basic_istringstreamIcSt11char_traitsIcESaIcEED1Ev@PLT
	jmp	.L92
.L99:
	endbr64
	movq	%rax, %rbx
.L92:
	movq	24(%rsp), %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT
	movq	8(%rsp), %rdi
	call	_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev@PLT
	jmp	.L93
.L97:
	endbr64
	movq	%rax, %rbx
.L93:
	movq	(%rsp), %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT
	movq	1064(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L101
	movq	%rbx, %rdi
.LEHB6:
	call	_Unwind_Resume@PLT
.LEHE6:
.L101:
	call	__stack_chk_fail@PLT
.L95:
	addq	$1080, %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
.LFE4192:
	.globl	__gxx_personality_v0
	.section	.gcc_except_table,"a",@progbits
.LLSDA4192:
	.byte	0xff
	.byte	0xff
	.byte	0x1
	.uleb128 .LLSDACSE4192-.LLSDACSB4192
.LLSDACSB4192:
	.uleb128 .LEHB0-.LFB4192
	.uleb128 .LEHE0-.LEHB0
	.uleb128 0
	.uleb128 0
	.uleb128 .LEHB1-.LFB4192
	.uleb128 .LEHE1-.LEHB1
	.uleb128 .L97-.LFB4192
	.uleb128 0
	.uleb128 .LEHB2-.LFB4192
	.uleb128 .LEHE2-.LEHB2
	.uleb128 .L99-.LFB4192
	.uleb128 0
	.uleb128 .LEHB3-.LFB4192
	.uleb128 .LEHE3-.LEHB3
	.uleb128 .L98-.LFB4192
	.uleb128 0
	.uleb128 .LEHB4-.LFB4192
	.uleb128 .LEHE4-.LEHB4
	.uleb128 .L100-.LFB4192
	.uleb128 0
	.uleb128 .LEHB5-.LFB4192
	.uleb128 .LEHE5-.LEHB5
	.uleb128 .L99-.LFB4192
	.uleb128 0
	.uleb128 .LEHB6-.LFB4192
	.uleb128 .LEHE6-.LEHB6
	.uleb128 0
	.uleb128 0
.LLSDACSE4192:
	.text
	.size	_Z11processDataPcP4Info, .-_Z11processDataPcP4Info
	.section	.rodata.str1.1
.LC9:
	.string	"Total time: "
.LC11:
	.string	"E-step time use (ms): "
.LC12:
	.string	"M-step-1st-half time use (ms): "
.LC13:
	.string	"M-step-2nd-half time use (ms): "
.LC14:
	.string	"Cuda Data IO (ms): "
.LC15:
	.string	"Other (ms): "
	.section	.text.startup
	.globl	main
	.type	main, @function
main:
.LFB4195:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	movl	$56, %edi
	xorl	%r13d, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	movq	%rsi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	pushq	%rcx
	.cfi_def_cfa_offset 48
	call	_Znwm@PLT
	movq	8(%rbp), %rdi
	movq	%rax, %rbx
	call	atoi@PLT
	movq	16(%rbp), %r12
	movq	%rbx, %rsi
	movl	%eax, 48(%rbx)
	movq	%r12, %rdi
	call	_Z11processDataPcP4Info
.L107:
	cmpl	%r13d, 12(%rbx)
	jle	.L110
	call	_Z9cpuSecondv
	movq	%rbx, %rdi
	incl	%r13d
	movsd	%xmm0, iStart1(%rip)
	call	_Z10cudaKmeansP4Info
	call	_Z9cpuSecondv
	subsd	iStart1(%rip), %xmm0
	movl	$56, %esi
	movq	%rbx, %rdi
	addsd	iElaps1(%rip), %xmm0
	movsd	%xmm0, iElaps1(%rip)
	call	_ZdlPvm@PLT
	movl	$56, %edi
	call	_Znwm@PLT
	movq	8(%rbp), %rdi
	movq	%rax, %rbx
	call	atoi@PLT
	movq	%rbx, %rsi
	movq	%r12, %rdi
	movl	%eax, 48(%rbx)
	call	_Z11processDataPcP4Info
	jmp	.L107
.L110:
	leaq	_ZSt4cout(%rip), %rbp
	leaq	.LC9(%rip), %rsi
	movq	%rbp, %rdi
	leaq	.LC4(%rip), %rbx
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movsd	.LC10(%rip), %xmm0
	mulsd	iElaps1(%rip), %xmm0
	movq	%rax, %rdi
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	movq	%rbx, %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC11(%rip), %rsi
	movq	%rbp, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movsd	.LC10(%rip), %xmm0
	mulsd	iElaps2(%rip), %xmm0
	movq	%rax, %rdi
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	movq	%rbx, %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC12(%rip), %rsi
	movq	%rbp, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movsd	.LC10(%rip), %xmm0
	mulsd	iElaps3a(%rip), %xmm0
	movq	%rax, %rdi
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	movq	%rbx, %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC13(%rip), %rsi
	movq	%rbp, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movsd	.LC10(%rip), %xmm0
	mulsd	iElaps3b(%rip), %xmm0
	movq	%rax, %rdi
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	movq	%rbx, %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC14(%rip), %rsi
	movq	%rbp, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movsd	.LC10(%rip), %xmm0
	mulsd	iElaps4(%rip), %xmm0
	movq	%rax, %rdi
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	movq	%rbx, %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC15(%rip), %rsi
	movq	%rbp, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movsd	.LC10(%rip), %xmm0
	mulsd	iElaps5(%rip), %xmm0
	movq	%rax, %rdi
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	movq	%rbx, %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	popq	%rdx
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE4195:
	.size	main, .-main
	.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	iElaps5
	.bss
	.align 8
	.type	iElaps5, @object
	.size	iElaps5, 8
iElaps5:
	.zero	8
	.globl	iElaps4
	.align 8
	.type	iElaps4, @object
	.size	iElaps4, 8
iElaps4:
	.zero	8
	.globl	iElaps3b
	.align 8
	.type	iElaps3b, @object
	.size	iElaps3b, 8
iElaps3b:
	.zero	8
	.globl	iElaps3a
	.align 8
	.type	iElaps3a, @object
	.size	iElaps3a, 8
iElaps3a:
	.zero	8
	.globl	iElaps2
	.align 8
	.type	iElaps2, @object
	.size	iElaps2, 8
iElaps2:
	.zero	8
	.globl	iElaps1
	.align 8
	.type	iElaps1, @object
	.size	iElaps1, 8
iElaps1:
	.zero	8
	.globl	iStart5
	.align 8
	.type	iStart5, @object
	.size	iStart5, 8
iStart5:
	.zero	8
	.globl	iStart4c
	.align 8
	.type	iStart4c, @object
	.size	iStart4c, 8
iStart4c:
	.zero	8
	.globl	iStart4b
	.align 8
	.type	iStart4b, @object
	.size	iStart4b, 8
iStart4b:
	.zero	8
	.globl	iStart4a
	.align 8
	.type	iStart4a, @object
	.size	iStart4a, 8
iStart4a:
	.zero	8
	.globl	iStart3b
	.align 8
	.type	iStart3b, @object
	.size	iStart3b, 8
iStart3b:
	.zero	8
	.globl	iStart3a
	.align 8
	.type	iStart3a, @object
	.size	iStart3a, 8
iStart3a:
	.zero	8
	.globl	iStart2
	.align 8
	.type	iStart2, @object
	.size	iStart2, 8
iStart2:
	.zero	8
	.globl	iStart1
	.align 8
	.type	iStart1, @object
	.size	iStart1, 8
iStart1:
	.zero	8
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC0:
	.long	-1598689907
	.long	1051772663
	.align 8
.LC10:
	.long	0
	.long	1083129856
	.hidden	DW.ref.__gxx_personality_v0
	.weak	DW.ref.__gxx_personality_v0
	.section	.data.rel.local.DW.ref.__gxx_personality_v0,"awG",@progbits,DW.ref.__gxx_personality_v0,comdat
	.align 8
	.type	DW.ref.__gxx_personality_v0, @object
	.size	DW.ref.__gxx_personality_v0, 8
DW.ref.__gxx_personality_v0:
	.quad	__gxx_personality_v0
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:


#include <hip/hip_runtime.h>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <sstream>
#include <time.h>
#include <sys/time.h>

using namespace std;
double iStart1, iStart2, iStart3a, iStart3b, iStart4a, iStart4b, iStart4c, iStart5;
double iElaps1=0, iElaps2=0, iElaps3a=0, iElaps3b=0, iElaps4=0, iElaps5=0;
// Hold configurations for Kmeans
struct Info {
  int     numPoints;
  int     dim;
  int     numCentroids;
  int     numRepeats;
  int    *belongs;
  float **points;
  float **centroids;
  int     thresholdLoops;
  float   thresholdFraction;
  int     threadPerBlock;
};

// ************* Utils ************* //

double cpuSecond() {
    struct timeval tp;
    gettimeofday(&tp,NULL);
    return ((double)tp.tv_sec + (double)tp.tv_usec * 1.e-6);
}

static inline int nextPowerOfTwo(int v) {
  int res = v;
  for (int i = 1; i <= 16; i *= 2) {
    res |= res >> i;
  }
  return res + 1;
}

float** make2DArray(int x, int y) {
  float **res = (float **)malloc(x * sizeof(float *));

  // for (int i = 0; i < x; i++) {
  //   res[i] = (float *)malloc(y * sizeof(float));
  // }
  res[0] = (float *)malloc(x * y * sizeof(float));
  for (size_t i = 1; i < x; i++) res[i] = res[i-1] + y;
  for (size_t i = 0; i < x; i++) {
    for (size_t j = 0; j < y; j++) {
      res[i][j] = 0.0;
    }
  }
  return res;
}

void invert2DArray(float **A, float **B, int x, int y) {
  for (int i = 0; i < x; i++) {
    for (int j = 0; j < y; j++) {
      A[i][j] = B[j][i];
    }
  }
}

void copy2DArray(float **A, float **B, int x, int y) {
  for (int i = 0; i < x; i++) {
    for (int j = 0; j < y; j++) {
      A[i][j] = B[i][j];
    }
  }
}

// ************* Utils ************* //

__host__ __device__ inline static float
    computeDist(Info* info, int pointId, int centroidId, int distType, float *gPoints, float *gCentroids) {
  float res = 0;
  if (distType == 0) {
    for (int i = 0; i < info->dim; i++) {
      res +=
        (gPoints[i * (info->numPoints) + pointId] - gCentroids[i * (info->numCentroids) + centroidId]) *
        (gPoints[i * (info->numPoints) + pointId] - gCentroids[i * (info->numCentroids) + centroidId]);
    }
  }
  return res;
}

// Use reduction to compute the sum of an array
// Refer to
// http://developer.download.nvidia.com/compute/cuda/1.1-Beta/x86_website/projects/reduction/doc/reduction.pdf
__global__ static void reduce(int *g_idata, int l1, int l2) {
  extern __shared__ unsigned int sdata[];
  unsigned int tid = threadIdx.x;

  if (tid < l1) {
    sdata[tid] = g_idata[tid];
  } else {
    sdata[tid] = 0;
  }
  __syncthreads();

  // Parallel Reduction (l2 must be power of 2)
  for (unsigned int s = l2 / 2; s > 0; s >>= 1) {
    if (tid < s)     {
      sdata[tid] += sdata[tid + s];
    }
    __syncthreads();
  }

  if (tid == 0) {
    g_idata[0] = sdata[0];
  }
}

__global__ static void nearestCentroid(int *blockResult, int *gBelongs, float *gPoints, float *gCentroids, Info *gInfo) {

  int pointId = blockDim.x * blockIdx.x + threadIdx.x;
  if (pointId >= (gInfo->numPoints)) return;

  // For test on test.txt
  // printf("Thread: %d - %.2f,  %.2f, %.2f,  %.2f \n", pointId, gCentroids[0], gCentroids[1], gCentroids[2], gCentroids[3]);
  // printf("Thread: %d - %.2f,  %.2f, %.2f,  %.2f, %.2f,  %.2f, %.2f,  %.2f \n",
  //          pointId, gPoints[0], gPoints[1], gPoints[2], gPoints[3], gPoints[4], gPoints[5], gPoints[6], gPoints[7]);

  // Get the minimum distance
  float mDist = computeDist(gInfo, pointId, 0, 0, gPoints, gCentroids);

  int tmpIdx = 0;
  int numCentroids = gInfo->numCentroids;
  for (int i = 0; i < numCentroids; i++) {
    float tmpDist = computeDist(gInfo, pointId, i, 0, gPoints, gCentroids);
    if (tmpDist < mDist) {
      mDist  = tmpDist;
      tmpIdx = i;
    }
  }

  // use reduction to add the total number of changes (change from one centroid to another) in this block
  extern __shared__ int sdata2[];
  sdata2[threadIdx.x] = 0;
  if (gBelongs[pointId] != tmpIdx) {
    sdata2[threadIdx.x] = 1;
  }
  gBelongs[pointId] = tmpIdx;
  __syncthreads();

  // Reduction
  for (unsigned int s = blockDim.x / 2; s > 0; s >>= 1) {
    if (threadIdx.x < s) {
      sdata2[threadIdx.x] += sdata2[threadIdx.x + s];
    }
    __syncthreads();
  }

  // Put the sum to the location corresbonding to current block
  if (threadIdx.x == 0) {
    blockResult[blockIdx.x] = sdata2[0];
  }
}

void processData(char *fileName, Info *info) {
  float **X;
  int   **GUESS;

  int N_samples, N_features, N_clusters, N_repeat;

  // readX(FILE_NAME,&X,&GUESS,&N_samples,&N_features,&N_clusters,&N_repeat);

  // Test purpose
  N_samples  = 100;
  N_features = 9;
  N_clusters = 4;
  N_repeat   = 10;

  info->numPoints         = N_samples;
  info->dim               = N_features;
  info->numCentroids      = N_clusters;
  info->numRepeats        = N_repeat;
  info->thresholdFraction = 0.005;
  info->thresholdLoops    = 200;

  // Process data point
  X = make2DArray(N_samples, N_features);

  string str(fileName);
  ifstream file(str);
     string line1;
     int i = 0;
     while (getline(file, line1)) {
     std::istringstream iss(line1);
     int j = -1;
     for(string s; iss >> s;) {
             if (j == -1) {
                     j++;
                     continue;
             }
             // cout << s << " ";
             X[i][j] = stof(s);
             j++;
     }
     i++;
  }
  info->points = X;

  /* belongs: the cluster id for each data object */
  int *belongs = new int[N_samples];
  for (i = 0; i < N_samples; i++) belongs[i] = -1;
  info->belongs = belongs;
}



void cudaKmeans(Info *info) {
  // Initialization
  int numPoints         = info->numPoints;
  int dim               = info->dim;
  int numCentroids      = info->numCentroids;
  int thresholdLoops    = info->thresholdLoops;
  int thresholdFraction = info->thresholdFraction;
  int* belongs          = info->belongs;
  float **points        = info->points;
  float **centroids     = info->centroids;
  int threadPerBlock    = info->threadPerBlock;

  // invert (transpose matrix)
  float **iPoints = make2DArray(dim, numPoints);
  invert2DArray(iPoints, points, dim, numPoints);

  // initial guess
  float **iCentroids = make2DArray(dim, numCentroids);
  copy2DArray(iCentroids, iPoints, dim, numCentroids);
  // invert2DArray(iCentroids, points, dim, numCentroids);

  // centroid -> number of points
  int *pointsCount   = new int[numCentroids];
  float **iNewCentroids = make2DArray(dim, numCentroids);

  // Some cuda constants
  const unsigned int bthreads = threadPerBlock;
  const unsigned int l1       = (numPoints + bthreads - 1) / bthreads;
  const unsigned int l2       = nextPowerOfTwo(l1);
  const unsigned int sdsize2  = bthreads * sizeof(unsigned int); // shared memory size for sdata2
  const unsigned int sdsize1  = l2 * sizeof(unsigned int); // shared memory size for sdata1

  // Cuda device Initialization
  float *gPoints;
  float *gCentroids;
  int   *gBelongs;
  Info   *gInfo;
  int   *tmp;

  // Data transfer
  iStart4a = cpuSecond();
  hipMalloc(&gPoints,    numPoints * dim * sizeof(float));
  hipMalloc(&gCentroids, numCentroids * dim * sizeof(float));
  hipMalloc(&gBelongs,   numPoints * sizeof(int));
  hipMalloc((void**)&gInfo,   sizeof(Info));
  hipMalloc(&tmp,        l2 * sizeof(unsigned int)); // For reduction
  hipMemcpy(gBelongs,
             belongs,
             numPoints * sizeof(int),
             hipMemcpyHostToDevice);
  hipMemcpy(gPoints,
             iPoints[0],
             numPoints * dim * sizeof(float),
             hipMemcpyHostToDevice);
  hipMemcpy(gInfo,info,sizeof(Info),hipMemcpyHostToDevice);

  iElaps4 += cpuSecond() - iStart4a;

  int count = 0;
  float frac = 1.0;

  while (count < thresholdLoops) {
    iStart4b = cpuSecond();
    hipMemcpy(gCentroids, iCentroids[0], dim * numCentroids * sizeof(float), hipMemcpyHostToDevice);
    iElaps4 += cpuSecond() - iStart4b;

    // E-Step: assign points to the nearest cluster center
    iStart2 = cpuSecond();
    // nearestCentroid<<<l1, bthreads, sdsize2>>>(dim, numPoints, numCentroids, gPoints, gCentroids, gBelongs, tmp);
    nearestCentroid<<<l1, bthreads, sdsize2>>>(tmp, gBelongs, gPoints, gCentroids, gInfo);
    hipDeviceSynchronize();
    iElaps2 += (cpuSecond() - iStart2);

    // Update belongs
    iStart4c = cpuSecond();
    hipMemcpy(belongs, gBelongs, numPoints * sizeof(int), hipMemcpyDeviceToHost);
    iElaps4 += cpuSecond() - iStart4c;

    // M-Step first half: set the cluster centers to the mean
    iStart3a = cpuSecond();

    // Clear the two temp variables
    for (int i = 0; i < numCentroids; i++) {
      pointsCount[i] = 0;
      for (int j = 0; j < dim; j++) {
        iNewCentroids[j][i] = 0.0;
      }
    }

    // Add up points in each centroid
    for (int i = 0; i < numPoints; i++) {
      int idx = belongs[i];
      pointsCount[idx] += 1;
      for (int j = 0; j < dim; j++) {
        iNewCentroids[j][idx] += points[i][j];
      }
    }
    iElaps3a += cpuSecond() - iStart3a;

    // M-Step second half: convert the sum to the mean
    // Update to new centroids
    iStart3b = cpuSecond();
    for (int i = 0; i < numCentroids; i++) {
      for (int j = 0; j < dim; j++) {
        if (pointsCount[i] > 0) {
          iCentroids[j][i] = iNewCentroids[j][i] / pointsCount[i];
        }
      }
    }
    iElaps3b += cpuSecond() - iStart3b;

    // Check convergence
    iStart5 = cpuSecond();

    // Check if too few number of points change their centroids
    reduce <<<1, l2, sdsize1>>>(tmp, l1, l2);
    hipDeviceSynchronize();
    int tmpFloat;
    hipMemcpy(&tmpFloat, tmp, sizeof(int), hipMemcpyDeviceToHost);
    frac = (float)tmpFloat / numPoints;
    cout << "Iteration: " << count << "," << frac << "," << tmpFloat  << "\n";
    count++;
    if (frac <= thresholdFraction) break;

    iElaps5 += cpuSecond() - iStart5;

  }

  centroids = make2DArray(numCentroids, dim);
  invert2DArray(centroids, iCentroids, numCentroids, dim);
  info->centroids = centroids;

  // Free device memory
  hipFree(gPoints);
  hipFree(gCentroids);
  hipFree(gBelongs);
  hipFree(tmp);

}

int main(int argc, char *argv[]) {
  Info *info     = new Info;
  info->threadPerBlock = atoi(argv[1]);
  char *fileName = argv[2];
  processData(fileName, info);

  for (int i = 0; i < info->numRepeats; i++) {
    iStart1 = cpuSecond();
    cudaKmeans(info);
    iElaps1 += cpuSecond() - iStart1;

    // cout << info->centroids[0][0] << "," << info->centroids[0][1] << ","
    //      << info->centroids[1][0] << "," << info->centroids[1][1] << "\n";

    // Reload info
    delete(info);
    info     = new Info;
    info->threadPerBlock = atoi(argv[1]);
    processData(fileName, info);
  }


  cout << "Total time: " << iElaps1*1000 << "\n";
  cout << "E-step time use (ms): " << iElaps2*1000 << "\n";
  cout << "M-step-1st-half time use (ms): " << iElaps3a*1000 << "\n";
  cout << "M-step-2nd-half time use (ms): " << iElaps3b*1000 << "\n";
  cout << "Cuda Data IO (ms): " << iElaps4*1000 << "\n";
  cout << "Other (ms): " << iElaps5*1000 << "\n";
}

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

                                        # End of file scope inline assembly
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z9cpuSecondv
.LCPI0_0:
	.quad	0x3eb0c6f7a0b5ed8d              # double 9.9999999999999995E-7
	.text
	.globl	_Z9cpuSecondv
	.type	_Z9cpuSecondv,@function
_Z9cpuSecondv:                          # @_Z9cpuSecondv
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$16, %rsp
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -16
	movq	%rsp, %rbx
	movq	%rbx, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	cvtsi2sdq	(%rbx), %xmm1
	cvtsi2sdq	8(%rbx), %xmm0
	mulsd	.LCPI0_0(%rip), %xmm0
	addsd	%xmm1, %xmm0
	addq	$16, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_Z9cpuSecondv, .Lfunc_end0-_Z9cpuSecondv
	.cfi_endproc
                                        # -- End function
	.globl	_Z11make2DArrayii               # -- Begin function _Z11make2DArrayii
	.type	_Z11make2DArrayii,@function
_Z11make2DArrayii:                      # @_Z11make2DArrayii
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	pushq	%rax
	.cfi_def_cfa_offset 64
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%esi, %ebx
	movl	%edi, %ebp
	movslq	%edi, %r12
	leaq	(,%r12,8), %rdi
	callq	malloc
	movq	%rax, %r14
	movl	%ebx, %eax
	imull	%ebp, %eax
	movslq	%eax, %rdi
	shlq	$2, %rdi
	callq	malloc
	movq	%rax, (%r14)
	movslq	%ebx, %r15
	cmpl	$2, %r12d
	jb	.LBB1_3
# %bb.1:                                # %.lr.ph
	leaq	(,%r15,4), %rax
	movq	(%r14), %rcx
	addq	%rax, %rcx
	movl	$1, %edx
.LBB1_2:                                # =>This Inner Loop Header: Depth=1
	movq	%rcx, (%r14,%rdx,8)
	incq	%rdx
	addq	%rax, %rcx
	cmpq	%rdx, %r12
	jne	.LBB1_2
.LBB1_3:                                # %.preheader24
	testl	%ebp, %ebp
	je	.LBB1_8
# %bb.4:                                # %.preheader.lr.ph
	shlq	$2, %r15
	xorl	%r13d, %r13d
.LBB1_5:                                # %.preheader
                                        # =>This Inner Loop Header: Depth=1
	testl	%ebx, %ebx
	je	.LBB1_7
# %bb.6:                                # %.lr.ph27
                                        #   in Loop: Header=BB1_5 Depth=1
	movq	(%r14,%r13,8), %rdi
	xorl	%esi, %esi
	movq	%r15, %rdx
	callq	memset@PLT
.LBB1_7:                                # %._crit_edge
                                        #   in Loop: Header=BB1_5 Depth=1
	incq	%r13
	cmpq	%r13, %r12
	jne	.LBB1_5
.LBB1_8:                                # %._crit_edge29
	movq	%r14, %rax
	addq	$8, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end1:
	.size	_Z11make2DArrayii, .Lfunc_end1-_Z11make2DArrayii
	.cfi_endproc
                                        # -- End function
	.globl	_Z13invert2DArrayPPfS0_ii       # -- Begin function _Z13invert2DArrayPPfS0_ii
	.type	_Z13invert2DArrayPPfS0_ii,@function
_Z13invert2DArrayPPfS0_ii:              # @_Z13invert2DArrayPPfS0_ii
	.cfi_startproc
# %bb.0:
	testl	%edx, %edx
	jle	.LBB2_6
# %bb.1:                                # %.preheader.lr.ph
	movl	%edx, %eax
	movl	%ecx, %edx
	xorl	%r8d, %r8d
.LBB2_2:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB2_4 Depth 2
	testl	%ecx, %ecx
	jle	.LBB2_5
# %bb.3:                                # %.lr.ph
                                        #   in Loop: Header=BB2_2 Depth=1
	movq	(%rdi,%r8,8), %r9
	xorl	%r10d, %r10d
.LBB2_4:                                #   Parent Loop BB2_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movq	(%rsi,%r10,8), %r11
	movss	(%r11,%r8,4), %xmm0             # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, (%r9,%r10,4)
	incq	%r10
	cmpq	%r10, %rdx
	jne	.LBB2_4
.LBB2_5:                                # %._crit_edge
                                        #   in Loop: Header=BB2_2 Depth=1
	incq	%r8
	cmpq	%rax, %r8
	jne	.LBB2_2
.LBB2_6:                                # %._crit_edge14
	retq
.Lfunc_end2:
	.size	_Z13invert2DArrayPPfS0_ii, .Lfunc_end2-_Z13invert2DArrayPPfS0_ii
	.cfi_endproc
                                        # -- End function
	.globl	_Z11copy2DArrayPPfS0_ii         # -- Begin function _Z11copy2DArrayPPfS0_ii
	.type	_Z11copy2DArrayPPfS0_ii,@function
_Z11copy2DArrayPPfS0_ii:                # @_Z11copy2DArrayPPfS0_ii
	.cfi_startproc
# %bb.0:
	testl	%edx, %edx
	jle	.LBB3_6
# %bb.1:                                # %.preheader.lr.ph
	movl	%edx, %eax
	movl	%ecx, %edx
	xorl	%r8d, %r8d
.LBB3_2:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB3_4 Depth 2
	testl	%ecx, %ecx
	jle	.LBB3_5
# %bb.3:                                # %.lr.ph
                                        #   in Loop: Header=BB3_2 Depth=1
	movq	(%rsi,%r8,8), %r9
	movq	(%rdi,%r8,8), %r10
	xorl	%r11d, %r11d
.LBB3_4:                                #   Parent Loop BB3_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movss	(%r9,%r11,4), %xmm0             # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, (%r10,%r11,4)
	incq	%r11
	cmpq	%r11, %rdx
	jne	.LBB3_4
.LBB3_5:                                # %._crit_edge
                                        #   in Loop: Header=BB3_2 Depth=1
	incq	%r8
	cmpq	%rax, %r8
	jne	.LBB3_2
.LBB3_6:                                # %._crit_edge14
	retq
.Lfunc_end3:
	.size	_Z11copy2DArrayPPfS0_ii, .Lfunc_end3-_Z11copy2DArrayPPfS0_ii
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0                          # -- Begin function _Z11processDataPcP4Info
.LCPI4_0:
	.long	100                             # 0x64
	.long	9                               # 0x9
	.long	4                               # 0x4
	.long	10                              # 0xa
	.text
	.globl	_Z11processDataPcP4Info
	.type	_Z11processDataPcP4Info,@function
_Z11processDataPcP4Info:                # @_Z11processDataPcP4Info
.Lfunc_begin0:
	.cfi_startproc
	.cfi_personality 3, __gxx_personality_v0
	.cfi_lsda 3, .Lexception0
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$1016, %rsp                     # imm = 0x3F8
	.cfi_def_cfa_offset 1072
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rsi, %r15
	movq	%rdi, %rbx
	movaps	.LCPI4_0(%rip), %xmm0           # xmm0 = [100,9,4,10]
	movups	%xmm0, (%rsi)
	movabsq	$4297514907391230152, %rax      # imm = 0x3BA3D70A000000C8
	movq	%rax, 40(%rsi)
	movl	$100, %edi
	movl	$9, %esi
	callq	_Z11make2DArrayii
	movq	%rax, (%rsp)                    # 8-byte Spill
	leaq	80(%rsp), %r14
	leaq	496(%rsp), %rdx
	movq	%r14, %rdi
	movq	%rbx, %rsi
	callq	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_
.Ltmp0:
	leaq	496(%rsp), %rbx
	movq	%rbx, %rdi
	movq	%r14, %rsi
	movl	$8, %edx
	callq	_ZNSt14basic_ifstreamIcSt11char_traitsIcEEC1ERKNSt7__cxx1112basic_stringIcS1_SaIcEEESt13_Ios_Openmode
.Ltmp1:
# %bb.1:
	leaq	64(%rsp), %rax
	movq	%rax, -16(%rax)
	movq	$0, -8(%rax)
	movb	$0, (%rax)
	xorl	%r14d, %r14d
.LBB4_2:                                # =>This Loop Header: Depth=1
                                        #     Child Loop BB4_7 Depth 2
	movq	496(%rsp), %rax
	movq	-24(%rax), %rdi
	addq	%rbx, %rdi
.Ltmp3:
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
.Ltmp4:
# %bb.3:                                # %.noexc
                                        #   in Loop: Header=BB4_2 Depth=1
.Ltmp5:
	movsbl	%al, %edx
	movq	%rbx, %rdi
	leaq	48(%rsp), %rsi
	callq	_ZSt7getlineIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RNSt7__cxx1112basic_stringIS4_S5_T1_EES4_
.Ltmp6:
# %bb.4:                                #   in Loop: Header=BB4_2 Depth=1
	movq	(%rax), %rcx
	movq	-24(%rcx), %rcx
	testb	$5, 32(%rax,%rcx)
	jne	.LBB4_30
# %bb.5:                                #   in Loop: Header=BB4_2 Depth=1
.Ltmp11:
	leaq	112(%rsp), %rdi
	leaq	48(%rsp), %rsi
	movl	$8, %edx
	callq	_ZNSt7__cxx1119basic_istringstreamIcSt11char_traitsIcESaIcEEC1ERKNS_12basic_stringIcS2_S3_EESt13_Ios_Openmode
.Ltmp12:
# %bb.6:                                #   in Loop: Header=BB4_2 Depth=1
	leaq	24(%rsp), %rax
	movq	%rax, 8(%rsp)
	movq	$0, 16(%rsp)
	movb	$0, 24(%rsp)
	movl	$-1, %eax
.LBB4_7:                                # %.backedge
                                        #   Parent Loop BB4_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
.Ltmp14:
	movl	%eax, %ebx
	leaq	112(%rsp), %rdi
	leaq	8(%rsp), %rsi
	callq	_ZStrsIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RNSt7__cxx1112basic_stringIS4_S5_T1_EE
.Ltmp15:
# %bb.8:                                #   in Loop: Header=BB4_7 Depth=2
	movq	(%rax), %rcx
	movq	-24(%rcx), %rcx
	testb	$5, 32(%rax,%rcx)
	jne	.LBB4_9
# %bb.18:                               #   in Loop: Header=BB4_7 Depth=2
	xorl	%eax, %eax
	cmpl	$-1, %ebx
	je	.LBB4_7
# %bb.19:                               #   in Loop: Header=BB4_7 Depth=2
	movq	8(%rsp), %r13
	callq	__errno_location
	movq	%rax, %r12
	movl	(%rax), %ebp
	movl	$0, (%rax)
	movq	%r13, %rdi
	leaq	40(%rsp), %rsi
	callq	strtof
	cmpq	%r13, 40(%rsp)
	je	.LBB4_20
# %bb.24:                               #   in Loop: Header=BB4_7 Depth=2
	movl	(%r12), %eax
	testl	%eax, %eax
	je	.LBB4_28
# %bb.25:                               #   in Loop: Header=BB4_7 Depth=2
	cmpl	$34, %eax
	jne	.LBB4_29
	jmp	.LBB4_26
.LBB4_28:                               #   in Loop: Header=BB4_7 Depth=2
	movl	%ebp, (%r12)
.LBB4_29:                               #   in Loop: Header=BB4_7 Depth=2
	movq	(%rsp), %rax                    # 8-byte Reload
	movq	(%rax,%r14,8), %rax
	movslq	%ebx, %rcx
	movss	%xmm0, (%rax,%rcx,4)
	incl	%ebx
	movl	%ebx, %eax
	jmp	.LBB4_7
.LBB4_9:                                #   in Loop: Header=BB4_2 Depth=1
	movq	8(%rsp), %rdi
	leaq	24(%rsp), %rax
	cmpq	%rax, %rdi
	je	.LBB4_11
# %bb.10:                               # %_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE11_M_is_localEv.exit.i.i
                                        #   in Loop: Header=BB4_2 Depth=1
	callq	_ZdlPv
.LBB4_11:                               # %_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev.exit
                                        #   in Loop: Header=BB4_2 Depth=1
	incq	%r14
	movl	$_ZTTNSt7__cxx1119basic_istringstreamIcSt11char_traitsIcESaIcEEE, %esi
	leaq	112(%rsp), %rdi
	callq	_ZNSt7__cxx1119basic_istringstreamIcSt11char_traitsIcESaIcEED2Ev
	leaq	232(%rsp), %rdi
	callq	_ZNSt8ios_baseD2Ev
	leaq	496(%rsp), %rbx
	jmp	.LBB4_2
.LBB4_30:
	movq	(%rsp), %rax                    # 8-byte Reload
	movq	%rax, 24(%r15)
.Ltmp8:
	movl	$400, %edi                      # imm = 0x190
	callq	_Znam
.Ltmp9:
# %bb.31:                               # %.preheader.preheader
	movq	%rax, %rbx
	movl	$400, %edx                      # imm = 0x190
	movq	%rax, %rdi
	movl	$255, %esi
	callq	memset@PLT
	movq	%rbx, 16(%r15)
	movq	48(%rsp), %rdi
	leaq	64(%rsp), %rax
	cmpq	%rax, %rdi
	je	.LBB4_33
# %bb.32:                               # %_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE11_M_is_localEv.exit.i.i47
	callq	_ZdlPv
.LBB4_33:                               # %_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev.exit49
	leaq	496(%rsp), %rdi
	callq	_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev
	leaq	96(%rsp), %rax
	movq	-16(%rax), %rdi
	cmpq	%rax, %rdi
	je	.LBB4_35
# %bb.34:                               # %_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE11_M_is_localEv.exit.i.i50
	callq	_ZdlPv
.LBB4_35:                               # %_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev.exit52
	addq	$1016, %rsp                     # imm = 0x3F8
	.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
.LBB4_20:
	.cfi_def_cfa_offset 1072
.Ltmp19:
	movl	$.L.str.9, %edi
	callq	_ZSt24__throw_invalid_argumentPKc
.Ltmp20:
# %bb.21:
.LBB4_26:                               # %.critedge.i.i
.Ltmp17:
	movl	$.L.str.9, %edi
	callq	_ZSt20__throw_out_of_rangePKc
.Ltmp18:
# %bb.27:
.LBB4_44:
.Ltmp10:
	jmp	.LBB4_37
.LBB4_12:
.Ltmp2:
	movq	%rax, %rbx
	jmp	.LBB4_41
.LBB4_13:
.Ltmp13:
	jmp	.LBB4_37
.LBB4_36:
.Ltmp7:
.LBB4_37:
	movq	%rax, %rbx
	jmp	.LBB4_38
.LBB4_22:
.Ltmp21:
	movq	%rax, %rbx
	cmpl	$0, (%r12)
	jne	.LBB4_15
# %bb.23:
	movl	%ebp, (%r12)
	jmp	.LBB4_15
.LBB4_14:
.Ltmp16:
	movq	%rax, %rbx
.LBB4_15:                               # %.body
	movq	8(%rsp), %rdi
	leaq	24(%rsp), %rax
	cmpq	%rax, %rdi
	je	.LBB4_17
# %bb.16:                               # %_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE11_M_is_localEv.exit.i.i44
	callq	_ZdlPv
.LBB4_17:                               # %_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev.exit46
	leaq	112(%rsp), %rdi
	movl	$_ZTTNSt7__cxx1119basic_istringstreamIcSt11char_traitsIcESaIcEEE, %esi
	callq	_ZNSt7__cxx1119basic_istringstreamIcSt11char_traitsIcESaIcEED2Ev
	leaq	232(%rsp), %rdi
	callq	_ZNSt8ios_baseD2Ev
.LBB4_38:
	movq	48(%rsp), %rdi
	leaq	64(%rsp), %rax
	cmpq	%rax, %rdi
	je	.LBB4_40
# %bb.39:                               # %_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE11_M_is_localEv.exit.i.i53
	callq	_ZdlPv
.LBB4_40:                               # %_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev.exit55
	leaq	496(%rsp), %rdi
	callq	_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev
.LBB4_41:
	leaq	96(%rsp), %rax
	movq	-16(%rax), %rdi
	cmpq	%rax, %rdi
	je	.LBB4_43
# %bb.42:                               # %_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE11_M_is_localEv.exit.i.i56
	callq	_ZdlPv
.LBB4_43:                               # %_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev.exit58
	movq	%rbx, %rdi
	callq	_Unwind_Resume@PLT
.Lfunc_end4:
	.size	_Z11processDataPcP4Info, .Lfunc_end4-_Z11processDataPcP4Info
	.cfi_endproc
	.section	.gcc_except_table,"a",@progbits
	.p2align	2, 0x0
GCC_except_table4:
.Lexception0:
	.byte	255                             # @LPStart Encoding = omit
	.byte	255                             # @TType Encoding = omit
	.byte	1                               # Call site Encoding = uleb128
	.uleb128 .Lcst_end0-.Lcst_begin0
.Lcst_begin0:
	.uleb128 .Lfunc_begin0-.Lfunc_begin0    # >> Call Site 1 <<
	.uleb128 .Ltmp0-.Lfunc_begin0           #   Call between .Lfunc_begin0 and .Ltmp0
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp0-.Lfunc_begin0           # >> Call Site 2 <<
	.uleb128 .Ltmp1-.Ltmp0                  #   Call between .Ltmp0 and .Ltmp1
	.uleb128 .Ltmp2-.Lfunc_begin0           #     jumps to .Ltmp2
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp3-.Lfunc_begin0           # >> Call Site 3 <<
	.uleb128 .Ltmp6-.Ltmp3                  #   Call between .Ltmp3 and .Ltmp6
	.uleb128 .Ltmp7-.Lfunc_begin0           #     jumps to .Ltmp7
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp11-.Lfunc_begin0          # >> Call Site 4 <<
	.uleb128 .Ltmp12-.Ltmp11                #   Call between .Ltmp11 and .Ltmp12
	.uleb128 .Ltmp13-.Lfunc_begin0          #     jumps to .Ltmp13
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp14-.Lfunc_begin0          # >> Call Site 5 <<
	.uleb128 .Ltmp15-.Ltmp14                #   Call between .Ltmp14 and .Ltmp15
	.uleb128 .Ltmp16-.Lfunc_begin0          #     jumps to .Ltmp16
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp8-.Lfunc_begin0           # >> Call Site 6 <<
	.uleb128 .Ltmp9-.Ltmp8                  #   Call between .Ltmp8 and .Ltmp9
	.uleb128 .Ltmp10-.Lfunc_begin0          #     jumps to .Ltmp10
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp9-.Lfunc_begin0           # >> Call Site 7 <<
	.uleb128 .Ltmp19-.Ltmp9                 #   Call between .Ltmp9 and .Ltmp19
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp19-.Lfunc_begin0          # >> Call Site 8 <<
	.uleb128 .Ltmp18-.Ltmp19                #   Call between .Ltmp19 and .Ltmp18
	.uleb128 .Ltmp21-.Lfunc_begin0          #     jumps to .Ltmp21
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp18-.Lfunc_begin0          # >> Call Site 9 <<
	.uleb128 .Lfunc_end4-.Ltmp18            #   Call between .Ltmp18 and .Lfunc_end4
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
.Lcst_end0:
	.p2align	2, 0x0
                                        # -- End function
	.section	.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_,"axG",@progbits,_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_,comdat
	.weak	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_ # -- Begin function _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_
	.p2align	1, 0x90
	.type	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_,@function
_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_: # @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_
	.cfi_startproc
# %bb.0:
	pushq	%r14
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	pushq	%rax
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -24
	.cfi_offset %r14, -16
	leaq	16(%rdi), %rax
	movq	%rax, (%rdi)
	testq	%rsi, %rsi
	je	.LBB5_1
# %bb.2:
	movq	%rsi, %rbx
	movq	%rdi, %r14
	movq	%rsi, %rdi
	callq	strlen
	leaq	(%rax,%rbx), %rdx
	movq	%r14, %rdi
	movq	%rbx, %rsi
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	jmp	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag # TAILCALL
.LBB5_1:
	.cfi_def_cfa_offset 32
	movl	$.L.str.10, %edi
	callq	_ZSt19__throw_logic_errorPKc
.Lfunc_end5:
	.size	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_, .Lfunc_end5-_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z10cudaKmeansP4Info
.LCPI6_0:
	.quad	0x3eb0c6f7a0b5ed8d              # double 9.9999999999999995E-7
	.text
	.globl	_Z10cudaKmeansP4Info
	.type	_Z10cudaKmeansP4Info,@function
_Z10cudaKmeansP4Info:                   # @_Z10cudaKmeansP4Info
	.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	$232, %rsp
	.cfi_def_cfa_offset 288
	.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	(%rdi), %esi
	movl	4(%rdi), %r14d
	movslq	8(%rdi), %rax
	movq	%rax, 40(%rsp)                  # 8-byte Spill
	movl	%eax, %r12d
	cvttss2si	44(%rdi), %eax
	movl	%eax, 80(%rsp)                  # 4-byte Spill
	movl	40(%rdi), %eax
	movl	%eax, 32(%rsp)                  # 4-byte Spill
	movq	16(%rdi), %rax
	movq	%rax, 160(%rsp)                 # 8-byte Spill
	movq	24(%rdi), %rax
	movq	%rax, 96(%rsp)                  # 8-byte Spill
	movq	%rdi, 144(%rsp)                 # 8-byte Spill
	movl	48(%rdi), %eax
	movq	%rax, 48(%rsp)                  # 8-byte Spill
	movl	%r14d, %edi
	movq	%rsi, 16(%rsp)                  # 8-byte Spill
                                        # kill: def $esi killed $esi killed $rsi
	callq	_Z11make2DArrayii
	testl	%r14d, %r14d
	movq	%rax, 56(%rsp)                  # 8-byte Spill
	jle	.LBB6_1
# %bb.2:                                # %.preheader.lr.ph.i
	movq	%rax, %r15
	xorl	%eax, %eax
	movq	16(%rsp), %rdi                  # 8-byte Reload
	movq	96(%rsp), %r8                   # 8-byte Reload
.LBB6_3:                                # %.preheader.i
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB6_5 Depth 2
	testl	%edi, %edi
	jle	.LBB6_6
# %bb.4:                                # %.lr.ph.i
                                        #   in Loop: Header=BB6_3 Depth=1
	movq	(%r15,%rax,8), %rcx
	xorl	%edx, %edx
.LBB6_5:                                #   Parent Loop BB6_3 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movq	(%r8,%rdx,8), %rsi
	movss	(%rsi,%rax,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, (%rcx,%rdx,4)
	incq	%rdx
	cmpq	%rdx, %rdi
	jne	.LBB6_5
.LBB6_6:                                # %._crit_edge.i
                                        #   in Loop: Header=BB6_3 Depth=1
	incq	%rax
	cmpq	%r14, %rax
	jne	.LBB6_3
# %bb.7:                                # %_Z13invert2DArrayPPfS0_ii.exit
	movl	%r14d, %edi
	movl	%r12d, %esi
	callq	_Z11make2DArrayii
	movq	%rax, %rbx
	xorl	%eax, %eax
.LBB6_8:                                # %.preheader.i134
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB6_10 Depth 2
	testl	%r12d, %r12d
	jle	.LBB6_11
# %bb.9:                                # %.lr.ph.i139
                                        #   in Loop: Header=BB6_8 Depth=1
	movq	(%r15,%rax,8), %rcx
	movq	(%rbx,%rax,8), %rdx
	xorl	%esi, %esi
.LBB6_10:                               #   Parent Loop BB6_8 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movss	(%rcx,%rsi,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, (%rdx,%rsi,4)
	incq	%rsi
	cmpq	%rsi, %r12
	jne	.LBB6_10
.LBB6_11:                               # %._crit_edge.i136
                                        #   in Loop: Header=BB6_8 Depth=1
	incq	%rax
	cmpq	%r14, %rax
	jne	.LBB6_8
	jmp	.LBB6_12
.LBB6_1:                                # %_Z13invert2DArrayPPfS0_ii.exit.thread
	movl	%r14d, %edi
	movl	%r12d, %esi
	callq	_Z11make2DArrayii
	movq	%rax, %rbx
.LBB6_12:
	movq	16(%rsp), %r15                  # 8-byte Reload
	movslq	%r15d, %r13
	movq	40(%rsp), %rcx                  # 8-byte Reload
	leaq	(,%rcx,4), %rax
	testl	%ecx, %ecx
	movq	$-1, %rdi
	cmovnsq	%rax, %rdi
	callq	_Znam
	movq	%rax, 112(%rsp)                 # 8-byte Spill
	movl	%r14d, %edi
	movq	%r12, 104(%rsp)                 # 8-byte Spill
	movl	%r12d, %esi
	callq	_Z11make2DArrayii
	movq	%rax, %rbp
	movq	48(%rsp), %rcx                  # 8-byte Reload
	leal	(%r15,%rcx), %eax
	decl	%eax
	xorl	%edx, %edx
	divl	%ecx
	movl	$1, %ecx
	movl	%eax, 28(%rsp)                  # 4-byte Spill
	movl	%eax, %edx
.LBB6_13:                               # =>This Inner Loop Header: Depth=1
	movl	%edx, %eax
	sarl	%cl, %edx
	orl	%eax, %edx
	leal	(%rcx,%rcx), %eax
	cmpl	$9, %ecx
	movl	%eax, %ecx
	jb	.LBB6_13
# %bb.14:                               # %_ZL14nextPowerOfTwoi.exit
	incl	%edx
	movq	%rdx, 152(%rsp)                 # 8-byte Spill
	leaq	(,%rdx,4), %r15
	xorl	%eax, %eax
	movq	%rax, 168(%rsp)                 # 8-byte Spill
	movq	%rsp, %r12
	movq	%r12, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	xorps	%xmm0, %xmm0
	cvtsi2sdq	(%r12), %xmm0
	cvtsi2sdq	8(%r12), %xmm1
	mulsd	.LCPI6_0(%rip), %xmm1
	addsd	%xmm0, %xmm1
	movsd	%xmm1, iStart4a(%rip)
	movq	16(%rsp), %rax                  # 8-byte Reload
                                        # kill: def $eax killed $eax killed $rax
	imull	%r14d, %eax
	movslq	%eax, %r12
	shlq	$2, %r12
	leaq	128(%rsp), %rdi
	movq	%r12, %rsi
	callq	hipMalloc
	movq	40(%rsp), %rax                  # 8-byte Reload
                                        # kill: def $eax killed $eax killed $rax
	imull	%r14d, %eax
	movslq	%eax, %rsi
	shlq	$2, %rsi
	leaq	120(%rsp), %rdi
	movq	%rsi, 216(%rsp)                 # 8-byte Spill
	callq	hipMalloc
	shlq	$2, %r13
	leaq	72(%rsp), %rdi
	movq	%r13, %rsi
	callq	hipMalloc
	leaq	176(%rsp), %rdi
	movl	$56, %esi
	callq	hipMalloc
	leaq	64(%rsp), %rdi
	movq	%r15, 88(%rsp)                  # 8-byte Spill
	movq	%r15, %rsi
	callq	hipMalloc
	leaq	72(%rsp), %rax
	movq	(%rax), %rdi
	movq	160(%rsp), %r15                 # 8-byte Reload
	movq	%r15, %rsi
	movq	%r13, 224(%rsp)                 # 8-byte Spill
	movq	%r13, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	leaq	128(%rsp), %rax
	movq	(%rax), %rdi
	movq	56(%rsp), %rax                  # 8-byte Reload
	movq	(%rax), %rsi
	movq	%r12, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	leaq	176(%rsp), %rax
	movq	(%rax), %rdi
	movl	$56, %edx
	movq	144(%rsp), %rsi                 # 8-byte Reload
	movl	$1, %ecx
	callq	hipMemcpy
	movq	%rsp, %r12
	movq	%r12, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	movsd	.LCPI6_0(%rip), %xmm2           # xmm2 = mem[0],zero
	xorps	%xmm0, %xmm0
	cvtsi2sdq	(%r12), %xmm0
	xorps	%xmm1, %xmm1
	cvtsi2sdq	8(%r12), %xmm1
	mulsd	%xmm2, %xmm1
	addsd	%xmm0, %xmm1
	subsd	iStart4a(%rip), %xmm1
	addsd	iElaps4(%rip), %xmm1
	movsd	%xmm1, iElaps4(%rip)
	cmpl	$0, 32(%rsp)                    # 4-byte Folded Reload
	jle	.LBB6_42
# %bb.15:                               # %.lr.ph185
	movabsq	$4294967296, %rcx               # imm = 0x100000000
	movq	48(%rsp), %rax                  # 8-byte Reload
	leal	(,%rax,4), %edx
	movq	%rdx, 208(%rsp)                 # 8-byte Spill
	movl	28(%rsp), %edx                  # 4-byte Reload
	btsq	$32, %rdx
	movq	%rdx, 200(%rsp)                 # 8-byte Spill
	btsq	$32, %rax
	movq	%rax, 48(%rsp)                  # 8-byte Spill
	movq	88(%rsp), %rax                  # 8-byte Reload
	andl	$-4, %eax
	movq	%rax, 88(%rsp)                  # 8-byte Spill
	movq	152(%rsp), %rax                 # 8-byte Reload
	btsq	$32, %rax
	movq	%rax, 192(%rsp)                 # 8-byte Spill
	xorps	%xmm0, %xmm0
	cvtsi2ssl	16(%rsp), %xmm0         # 4-byte Folded Reload
	movss	%xmm0, 140(%rsp)                # 4-byte Spill
	xorps	%xmm0, %xmm0
	cvtsi2ssl	80(%rsp), %xmm0         # 4-byte Folded Reload
	movss	%xmm0, 136(%rsp)                # 4-byte Spill
	movl	40(%rsp), %r13d                 # 4-byte Reload
	leaq	(,%r13,4), %rax
	movq	%rax, 184(%rsp)                 # 8-byte Spill
	movq	%rsp, %r12
	incq	%rcx
	movq	%rcx, 80(%rsp)                  # 8-byte Spill
.LBB6_16:                               # =>This Loop Header: Depth=1
                                        #     Child Loop BB6_20 Depth 2
                                        #       Child Loop BB6_22 Depth 3
                                        #     Child Loop BB6_26 Depth 2
                                        #       Child Loop BB6_28 Depth 3
                                        #     Child Loop BB6_32 Depth 2
                                        #       Child Loop BB6_34 Depth 3
	movq	%r12, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	xorps	%xmm0, %xmm0
	cvtsi2sdq	(%rsp), %xmm0
	xorps	%xmm1, %xmm1
	cvtsi2sdq	8(%rsp), %xmm1
	mulsd	.LCPI6_0(%rip), %xmm1
	addsd	%xmm0, %xmm1
	movsd	%xmm1, iStart4b(%rip)
	movq	120(%rsp), %rdi
	movq	(%rbx), %rsi
	movq	216(%rsp), %rdx                 # 8-byte Reload
	movl	$1, %ecx
	callq	hipMemcpy
	movq	%r12, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	xorps	%xmm0, %xmm0
	cvtsi2sdq	(%rsp), %xmm0
	xorps	%xmm1, %xmm1
	cvtsi2sdq	8(%rsp), %xmm1
	mulsd	.LCPI6_0(%rip), %xmm1
	addsd	%xmm0, %xmm1
	subsd	iStart4b(%rip), %xmm1
	addsd	iElaps4(%rip), %xmm1
	movsd	%xmm1, iElaps4(%rip)
	movq	%r12, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	xorps	%xmm0, %xmm0
	cvtsi2sdq	(%rsp), %xmm0
	xorps	%xmm1, %xmm1
	cvtsi2sdq	8(%rsp), %xmm1
	mulsd	.LCPI6_0(%rip), %xmm1
	addsd	%xmm0, %xmm1
	movsd	%xmm1, iStart2(%rip)
	movq	200(%rsp), %rdi                 # 8-byte Reload
	movl	$1, %esi
	movq	48(%rsp), %rdx                  # 8-byte Reload
	movl	$1, %ecx
	movq	208(%rsp), %r8                  # 8-byte Reload
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB6_18
# %bb.17:                               #   in Loop: Header=BB6_16 Depth=1
	movq	64(%rsp), %rdi
	movq	72(%rsp), %rsi
	movq	128(%rsp), %rdx
	movq	120(%rsp), %rcx
	movq	176(%rsp), %r8
	callq	_ZL30__device_stub__nearestCentroidPiS_PfS0_P4Info
.LBB6_18:                               #   in Loop: Header=BB6_16 Depth=1
	callq	hipDeviceSynchronize
	movq	%r12, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	xorps	%xmm0, %xmm0
	cvtsi2sdq	(%rsp), %xmm0
	xorps	%xmm1, %xmm1
	cvtsi2sdq	8(%rsp), %xmm1
	movsd	.LCPI6_0(%rip), %xmm2           # xmm2 = mem[0],zero
	mulsd	%xmm2, %xmm1
	addsd	%xmm0, %xmm1
	subsd	iStart2(%rip), %xmm1
	addsd	iElaps2(%rip), %xmm1
	movsd	%xmm1, iElaps2(%rip)
	movq	%r12, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	xorps	%xmm0, %xmm0
	cvtsi2sdq	(%rsp), %xmm0
	xorps	%xmm1, %xmm1
	cvtsi2sdq	8(%rsp), %xmm1
	mulsd	.LCPI6_0(%rip), %xmm1
	addsd	%xmm0, %xmm1
	movsd	%xmm1, iStart4c(%rip)
	movq	72(%rsp), %rsi
	movq	%r15, %rdi
	movq	224(%rsp), %rdx                 # 8-byte Reload
	movl	$2, %ecx
	callq	hipMemcpy
	movq	%r12, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	xorps	%xmm0, %xmm0
	cvtsi2sdq	(%rsp), %xmm0
	xorps	%xmm1, %xmm1
	cvtsi2sdq	8(%rsp), %xmm1
	mulsd	.LCPI6_0(%rip), %xmm1
	addsd	%xmm0, %xmm1
	subsd	iStart4c(%rip), %xmm1
	addsd	iElaps4(%rip), %xmm1
	movsd	%xmm1, iElaps4(%rip)
	movq	%r12, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	xorps	%xmm0, %xmm0
	cvtsi2sdq	(%rsp), %xmm0
	xorps	%xmm1, %xmm1
	cvtsi2sdq	8(%rsp), %xmm1
	mulsd	.LCPI6_0(%rip), %xmm1
	addsd	%xmm0, %xmm1
	movsd	%xmm1, iStart3a(%rip)
	cmpl	$0, 104(%rsp)                   # 4-byte Folded Reload
	movq	16(%rsp), %r8                   # 8-byte Reload
	movq	96(%rsp), %r9                   # 8-byte Reload
	movq	112(%rsp), %rdi                 # 8-byte Reload
	jle	.LBB6_24
# %bb.19:                               # %.lr.ph171.preheader
                                        #   in Loop: Header=BB6_16 Depth=1
	xorl	%esi, %esi
	movq	184(%rsp), %rdx                 # 8-byte Reload
	callq	memset@PLT
	movq	112(%rsp), %rdi                 # 8-byte Reload
	movq	96(%rsp), %r9                   # 8-byte Reload
	movq	16(%rsp), %r8                   # 8-byte Reload
	xorl	%eax, %eax
.LBB6_20:                               # %.lr.ph171
                                        #   Parent Loop BB6_16 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB6_22 Depth 3
	testl	%r14d, %r14d
	jle	.LBB6_23
# %bb.21:                               # %.lr.ph.preheader
                                        #   in Loop: Header=BB6_20 Depth=2
	xorl	%ecx, %ecx
.LBB6_22:                               # %.lr.ph
                                        #   Parent Loop BB6_16 Depth=1
                                        #     Parent Loop BB6_20 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movq	(%rbp,%rcx,8), %rdx
	movl	$0, (%rdx,%rax,4)
	incq	%rcx
	cmpq	%rcx, %r14
	jne	.LBB6_22
.LBB6_23:                               # %._crit_edge
                                        #   in Loop: Header=BB6_20 Depth=2
	incq	%rax
	cmpq	%r13, %rax
	jne	.LBB6_20
.LBB6_24:                               # %.preheader167
                                        #   in Loop: Header=BB6_16 Depth=1
	testl	%r8d, %r8d
	jle	.LBB6_30
# %bb.25:                               # %.lr.ph177.preheader
                                        #   in Loop: Header=BB6_16 Depth=1
	xorl	%eax, %eax
.LBB6_26:                               # %.lr.ph177
                                        #   Parent Loop BB6_16 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB6_28 Depth 3
	movslq	(%r15,%rax,4), %rcx
	incl	(%rdi,%rcx,4)
	testl	%r14d, %r14d
	jle	.LBB6_29
# %bb.27:                               # %.lr.ph174
                                        #   in Loop: Header=BB6_26 Depth=2
	movq	(%r9,%rax,8), %rdx
	xorl	%esi, %esi
.LBB6_28:                               #   Parent Loop BB6_16 Depth=1
                                        #     Parent Loop BB6_26 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movss	(%rdx,%rsi,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	movq	(%rbp,%rsi,8), %r10
	addss	(%r10,%rcx,4), %xmm0
	movss	%xmm0, (%r10,%rcx,4)
	incq	%rsi
	cmpq	%rsi, %r14
	jne	.LBB6_28
.LBB6_29:                               # %._crit_edge175
                                        #   in Loop: Header=BB6_26 Depth=2
	incq	%rax
	cmpq	%r8, %rax
	jne	.LBB6_26
.LBB6_30:                               # %._crit_edge178
                                        #   in Loop: Header=BB6_16 Depth=1
	movq	%r12, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	xorps	%xmm0, %xmm0
	cvtsi2sdq	(%rsp), %xmm0
	xorps	%xmm1, %xmm1
	cvtsi2sdq	8(%rsp), %xmm1
	movsd	.LCPI6_0(%rip), %xmm2           # xmm2 = mem[0],zero
	mulsd	%xmm2, %xmm1
	addsd	%xmm0, %xmm1
	subsd	iStart3a(%rip), %xmm1
	addsd	iElaps3a(%rip), %xmm1
	movsd	%xmm1, iElaps3a(%rip)
	movq	%r12, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	movq	112(%rsp), %rdi                 # 8-byte Reload
	xorps	%xmm0, %xmm0
	cvtsi2sdq	(%rsp), %xmm0
	xorps	%xmm1, %xmm1
	cvtsi2sdq	8(%rsp), %xmm1
	mulsd	.LCPI6_0(%rip), %xmm1
	addsd	%xmm0, %xmm1
	movsd	%xmm1, iStart3b(%rip)
	cmpl	$0, 104(%rsp)                   # 4-byte Folded Reload
	movq	168(%rsp), %r15                 # 8-byte Reload
	jle	.LBB6_38
# %bb.31:                               # %.preheader.preheader
                                        #   in Loop: Header=BB6_16 Depth=1
	xorl	%eax, %eax
.LBB6_32:                               # %.preheader
                                        #   Parent Loop BB6_16 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB6_34 Depth 3
	testl	%r14d, %r14d
	jle	.LBB6_37
# %bb.33:                               # %.lr.ph180
                                        #   in Loop: Header=BB6_32 Depth=2
	movl	(%rdi,%rax,4), %ecx
	xorps	%xmm0, %xmm0
	cvtsi2ss	%ecx, %xmm0
	xorl	%edx, %edx
.LBB6_34:                               #   Parent Loop BB6_16 Depth=1
                                        #     Parent Loop BB6_32 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	testl	%ecx, %ecx
	jle	.LBB6_36
# %bb.35:                               #   in Loop: Header=BB6_34 Depth=3
	movq	(%rbp,%rdx,8), %rsi
	movss	(%rsi,%rax,4), %xmm1            # xmm1 = mem[0],zero,zero,zero
	divss	%xmm0, %xmm1
	movq	(%rbx,%rdx,8), %rsi
	movss	%xmm1, (%rsi,%rax,4)
.LBB6_36:                               #   in Loop: Header=BB6_34 Depth=3
	incq	%rdx
	cmpq	%rdx, %r14
	jne	.LBB6_34
.LBB6_37:                               # %._crit_edge181
                                        #   in Loop: Header=BB6_32 Depth=2
	incq	%rax
	cmpq	%r13, %rax
	jne	.LBB6_32
.LBB6_38:                               # %._crit_edge183
                                        #   in Loop: Header=BB6_16 Depth=1
	movq	%r12, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	xorps	%xmm0, %xmm0
	cvtsi2sdq	(%rsp), %xmm0
	xorps	%xmm1, %xmm1
	cvtsi2sdq	8(%rsp), %xmm1
	movsd	.LCPI6_0(%rip), %xmm2           # xmm2 = mem[0],zero
	mulsd	%xmm2, %xmm1
	addsd	%xmm0, %xmm1
	subsd	iStart3b(%rip), %xmm1
	addsd	iElaps3b(%rip), %xmm1
	movsd	%xmm1, iElaps3b(%rip)
	movq	%r12, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	xorps	%xmm0, %xmm0
	cvtsi2sdq	(%rsp), %xmm0
	xorps	%xmm1, %xmm1
	cvtsi2sdq	8(%rsp), %xmm1
	mulsd	.LCPI6_0(%rip), %xmm1
	addsd	%xmm0, %xmm1
	movsd	%xmm1, iStart5(%rip)
	movq	80(%rsp), %rdi                  # 8-byte Reload
	movl	$1, %esi
	movq	192(%rsp), %rdx                 # 8-byte Reload
	movl	$1, %ecx
	movq	88(%rsp), %r8                   # 8-byte Reload
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB6_40
# %bb.39:                               #   in Loop: Header=BB6_16 Depth=1
	movq	64(%rsp), %rdi
	movl	28(%rsp), %esi                  # 4-byte Reload
	movq	152(%rsp), %rdx                 # 8-byte Reload
                                        # kill: def $edx killed $edx killed $rdx
	callq	_ZL21__device_stub__reducePiii
.LBB6_40:                               #   in Loop: Header=BB6_16 Depth=1
	callq	hipDeviceSynchronize
	movq	64(%rsp), %rsi
	movl	$4, %edx
	leaq	36(%rsp), %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	xorps	%xmm0, %xmm0
	cvtsi2ssl	36(%rsp), %xmm0
	divss	140(%rsp), %xmm0                # 4-byte Folded Reload
	movss	%xmm0, 56(%rsp)                 # 4-byte Spill
	movl	$_ZSt4cout, %edi
	movl	$.L.str, %esi
	movl	$11, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	$_ZSt4cout, %edi
	movl	%r15d, %esi
	callq	_ZNSolsEi
	movq	%r15, %r12
	movq	%rax, %r15
	movl	$.L.str.1, %esi
	movl	$1, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	xorps	%xmm0, %xmm0
	cvtss2sd	56(%rsp), %xmm0                 # 4-byte Folded Reload
	movq	%r15, %rdi
	callq	_ZNSo9_M_insertIdEERSoT_
	movq	%rax, %r15
	movl	$.L.str.1, %esi
	movl	$1, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	36(%rsp), %esi
	movq	%r15, %rdi
	callq	_ZNSolsEi
	movl	$.L.str.2, %esi
	movl	$1, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movss	136(%rsp), %xmm0                # 4-byte Reload
                                        # xmm0 = mem[0],zero,zero,zero
	ucomiss	56(%rsp), %xmm0                 # 4-byte Folded Reload
	jae	.LBB6_42
# %bb.41:                               #   in Loop: Header=BB6_16 Depth=1
	incl	%r12d
	movq	%rsp, %r15
	movq	%r15, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	xorps	%xmm0, %xmm0
	cvtsi2sdq	(%rsp), %xmm0
	xorps	%xmm1, %xmm1
	cvtsi2sdq	8(%rsp), %xmm1
	movsd	.LCPI6_0(%rip), %xmm2           # xmm2 = mem[0],zero
	mulsd	%xmm2, %xmm1
	addsd	%xmm0, %xmm1
	subsd	iStart5(%rip), %xmm1
	addsd	iElaps5(%rip), %xmm1
	movsd	%xmm1, iElaps5(%rip)
	movq	%r12, 168(%rsp)                 # 8-byte Spill
	cmpl	32(%rsp), %r12d                 # 4-byte Folded Reload
	movq	%r15, %r12
	movq	160(%rsp), %r15                 # 8-byte Reload
	jne	.LBB6_16
.LBB6_42:                               # %.loopexit
	movq	40(%rsp), %rdi                  # 8-byte Reload
                                        # kill: def $edi killed $edi killed $rdi
	movl	%r14d, %esi
	callq	_Z11make2DArrayii
	movq	104(%rsp), %r9                  # 8-byte Reload
	testl	%r9d, %r9d
	movq	144(%rsp), %r8                  # 8-byte Reload
	jle	.LBB6_48
# %bb.43:                               # %.preheader.lr.ph.i143
	xorl	%ecx, %ecx
.LBB6_44:                               # %.preheader.i146
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB6_46 Depth 2
	testl	%r14d, %r14d
	jle	.LBB6_47
# %bb.45:                               # %.lr.ph.i151
                                        #   in Loop: Header=BB6_44 Depth=1
	movq	(%rax,%rcx,8), %rdx
	xorl	%esi, %esi
.LBB6_46:                               #   Parent Loop BB6_44 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movq	(%rbx,%rsi,8), %rdi
	movss	(%rdi,%rcx,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, (%rdx,%rsi,4)
	incq	%rsi
	cmpq	%rsi, %r14
	jne	.LBB6_46
.LBB6_47:                               # %._crit_edge.i148
                                        #   in Loop: Header=BB6_44 Depth=1
	incq	%rcx
	cmpq	%r9, %rcx
	jne	.LBB6_44
.LBB6_48:                               # %_Z13invert2DArrayPPfS0_ii.exit155
	movq	%rax, 32(%r8)
	movq	128(%rsp), %rdi
	callq	hipFree
	movq	120(%rsp), %rdi
	callq	hipFree
	movq	72(%rsp), %rdi
	callq	hipFree
	movq	64(%rsp), %rdi
	callq	hipFree
	addq	$232, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end6:
	.size	_Z10cudaKmeansP4Info, .Lfunc_end6-_Z10cudaKmeansP4Info
	.cfi_endproc
                                        # -- End function
	.type	_ZL30__device_stub__nearestCentroidPiS_PfS0_P4Info,@function # -- Begin function _ZL30__device_stub__nearestCentroidPiS_PfS0_P4Info
_ZL30__device_stub__nearestCentroidPiS_PfS0_P4Info: # @_ZL30__device_stub__nearestCentroidPiS_PfS0_P4Info
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$144, %rsp
	.cfi_def_cfa_offset 192
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	56(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	48(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	40(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	32(%rsp), %rdx
	movq	%rcx, (%rdx)
	leaq	24(%rsp), %rcx
	movq	%r8, (%rcx)
	leaq	96(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	movq	%rcx, 32(%rbx)
	leaq	80(%rsp), %r14
	leaq	64(%rsp), %r15
	leaq	16(%rsp), %r12
	leaq	8(%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	$_ZL15nearestCentroidPiS_PfS0_P4Info, %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_end7:
	.size	_ZL30__device_stub__nearestCentroidPiS_PfS0_P4Info, .Lfunc_end7-_ZL30__device_stub__nearestCentroidPiS_PfS0_P4Info
	.cfi_endproc
                                        # -- End function
	.type	_ZL21__device_stub__reducePiii,@function # -- Begin function _ZL21__device_stub__reducePiii
_ZL21__device_stub__reducePiii:         # @_ZL21__device_stub__reducePiii
	.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	$96, %rsp
	.cfi_def_cfa_offset 144
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	24(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	4(%rsp), %rcx
	movl	%esi, (%rcx)
	movq	%rsp, %rsi
	movl	%edx, (%rsi)
	leaq	64(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	movq	%rsi, 16(%rbx)
	leaq	48(%rsp), %r14
	leaq	32(%rsp), %r15
	leaq	16(%rsp), %r12
	leaq	8(%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	$_ZL6reducePiii, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$112, %rsp
	.cfi_adjust_cfa_offset -112
	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_end8:
	.size	_ZL21__device_stub__reducePiii, .Lfunc_end8-_ZL21__device_stub__reducePiii
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI9_0:
	.quad	0x3eb0c6f7a0b5ed8d              # double 9.9999999999999995E-7
.LCPI9_1:
	.quad	0x408f400000000000              # double 1000
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
	.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	$16, %rsp
	.cfi_def_cfa_offset 64
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rsi, %rbx
	movl	$56, %edi
	callq	_Znwm
	movq	%rax, %r14
	movq	8(%rbx), %rdi
	callq	atoi
	movl	%eax, 48(%r14)
	movq	16(%rbx), %r15
	movq	%r15, %rdi
	movq	%r14, %rsi
	callq	_Z11processDataPcP4Info
	cmpl	$0, 12(%r14)
	jle	.LBB9_3
# %bb.1:                                # %.lr.ph
	xorl	%r13d, %r13d
	movq	%rsp, %r12
.LBB9_2:                                # =>This Inner Loop Header: Depth=1
	movq	%r12, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	xorps	%xmm0, %xmm0
	cvtsi2sdq	(%rsp), %xmm0
	xorps	%xmm1, %xmm1
	cvtsi2sdq	8(%rsp), %xmm1
	movsd	.LCPI9_0(%rip), %xmm2           # xmm2 = mem[0],zero
	mulsd	%xmm2, %xmm1
	addsd	%xmm0, %xmm1
	movsd	%xmm1, iStart1(%rip)
	movq	%r14, %rdi
	callq	_Z10cudaKmeansP4Info
	movq	%r12, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	xorps	%xmm0, %xmm0
	cvtsi2sdq	(%rsp), %xmm0
	xorps	%xmm1, %xmm1
	cvtsi2sdq	8(%rsp), %xmm1
	mulsd	.LCPI9_0(%rip), %xmm1
	addsd	%xmm0, %xmm1
	subsd	iStart1(%rip), %xmm1
	addsd	iElaps1(%rip), %xmm1
	movsd	%xmm1, iElaps1(%rip)
	movq	%r14, %rdi
	callq	_ZdlPv
	movl	$56, %edi
	callq	_Znwm
	movq	%rax, %r14
	movq	8(%rbx), %rdi
	callq	atoi
	movl	%eax, 48(%r14)
	movq	%r15, %rdi
	movq	%r14, %rsi
	callq	_Z11processDataPcP4Info
	incl	%r13d
	cmpl	12(%r14), %r13d
	jl	.LBB9_2
.LBB9_3:                                # %._crit_edge
	movl	$_ZSt4cout, %edi
	movl	$.L.str.3, %esi
	movl	$12, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movsd	iElaps1(%rip), %xmm0            # xmm0 = mem[0],zero
	mulsd	.LCPI9_1(%rip), %xmm0
	movl	$_ZSt4cout, %edi
	callq	_ZNSo9_M_insertIdEERSoT_
	movl	$.L.str.2, %esi
	movl	$1, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	$_ZSt4cout, %edi
	movl	$.L.str.4, %esi
	movl	$22, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movsd	iElaps2(%rip), %xmm0            # xmm0 = mem[0],zero
	mulsd	.LCPI9_1(%rip), %xmm0
	movl	$_ZSt4cout, %edi
	callq	_ZNSo9_M_insertIdEERSoT_
	movl	$.L.str.2, %esi
	movl	$1, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	$_ZSt4cout, %edi
	movl	$.L.str.5, %esi
	movl	$31, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movsd	iElaps3a(%rip), %xmm0           # xmm0 = mem[0],zero
	mulsd	.LCPI9_1(%rip), %xmm0
	movl	$_ZSt4cout, %edi
	callq	_ZNSo9_M_insertIdEERSoT_
	movl	$.L.str.2, %esi
	movl	$1, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	$_ZSt4cout, %edi
	movl	$.L.str.6, %esi
	movl	$31, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movsd	iElaps3b(%rip), %xmm0           # xmm0 = mem[0],zero
	mulsd	.LCPI9_1(%rip), %xmm0
	movl	$_ZSt4cout, %edi
	callq	_ZNSo9_M_insertIdEERSoT_
	movl	$.L.str.2, %esi
	movl	$1, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	$_ZSt4cout, %edi
	movl	$.L.str.7, %esi
	movl	$19, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movsd	iElaps4(%rip), %xmm0            # xmm0 = mem[0],zero
	mulsd	.LCPI9_1(%rip), %xmm0
	movl	$_ZSt4cout, %edi
	callq	_ZNSo9_M_insertIdEERSoT_
	movl	$.L.str.2, %esi
	movl	$1, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	$_ZSt4cout, %edi
	movl	$.L.str.8, %esi
	movl	$12, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movsd	.LCPI9_1(%rip), %xmm0           # xmm0 = mem[0],zero
	mulsd	iElaps5(%rip), %xmm0
	movl	$_ZSt4cout, %edi
	callq	_ZNSo9_M_insertIdEERSoT_
	movl	$.L.str.2, %esi
	movl	$1, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	xorl	%eax, %eax
	addq	$16, %rsp
	.cfi_def_cfa_offset 48
	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_end9:
	.size	main, .Lfunc_end9-main
	.cfi_endproc
                                        # -- End function
	.section	.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag,"axG",@progbits,_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag,comdat
	.weak	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag # -- Begin function _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag
	.p2align	1, 0x90
	.type	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag,@function
_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag: # @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r12
	.cfi_def_cfa_offset 32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	pushq	%rax
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -40
	.cfi_offset %r12, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rdx, %r14
	movq	%rsi, %r15
	movq	%rdi, %rbx
	subq	%rsi, %r14
	movq	%r14, (%rsp)
	cmpq	$15, %r14
	jbe	.LBB10_1
# %bb.2:
	movq	%rsp, %r12
	movq	%rbx, %rdi
	movq	%r12, %rsi
	xorl	%edx, %edx
	callq	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_createERmm
	movq	%rax, (%rbx)
	movq	(%r12), %rcx
	movq	%rcx, 16(%rbx)
	jmp	.LBB10_3
.LBB10_1:                               # %._crit_edge
	movq	(%rbx), %rax
.LBB10_3:
	testq	%r14, %r14
	je	.LBB10_7
# %bb.4:
	cmpq	$1, %r14
	jne	.LBB10_6
# %bb.5:
	movb	(%r15), %cl
	movb	%cl, (%rax)
	jmp	.LBB10_7
.LBB10_6:
	movq	%rax, %rdi
	movq	%r15, %rsi
	movq	%r14, %rdx
	callq	memcpy@PLT
.LBB10_7:                               # %_ZZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tagEN6_GuardD2Ev.exit
	movq	(%rsp), %rax
	movq	%rax, 8(%rbx)
	movq	(%rbx), %rcx
	movb	$0, (%rcx,%rax)
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end10:
	.size	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag, .Lfunc_end10-_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag
	.cfi_endproc
                                        # -- End function
	.text
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$32, %rsp
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -16
	movq	__hip_gpubin_handle(%rip), %rbx
	testq	%rbx, %rbx
	jne	.LBB11_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB11_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_ZL15nearestCentroidPiS_PfS0_P4Info, %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	$_ZL6reducePiii, %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_end11:
	.size	__hip_module_ctor, .Lfunc_end11-__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	.LBB12_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
.LBB12_2:
	retq
.Lfunc_end12:
	.size	__hip_module_dtor, .Lfunc_end12-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	iStart1,@object                 # @iStart1
	.bss
	.globl	iStart1
	.p2align	3, 0x0
iStart1:
	.quad	0x0000000000000000              # double 0
	.size	iStart1, 8

	.type	iStart2,@object                 # @iStart2
	.globl	iStart2
	.p2align	3, 0x0
iStart2:
	.quad	0x0000000000000000              # double 0
	.size	iStart2, 8

	.type	iStart3a,@object                # @iStart3a
	.globl	iStart3a
	.p2align	3, 0x0
iStart3a:
	.quad	0x0000000000000000              # double 0
	.size	iStart3a, 8

	.type	iStart3b,@object                # @iStart3b
	.globl	iStart3b
	.p2align	3, 0x0
iStart3b:
	.quad	0x0000000000000000              # double 0
	.size	iStart3b, 8

	.type	iStart4a,@object                # @iStart4a
	.globl	iStart4a
	.p2align	3, 0x0
iStart4a:
	.quad	0x0000000000000000              # double 0
	.size	iStart4a, 8

	.type	iStart4b,@object                # @iStart4b
	.globl	iStart4b
	.p2align	3, 0x0
iStart4b:
	.quad	0x0000000000000000              # double 0
	.size	iStart4b, 8

	.type	iStart4c,@object                # @iStart4c
	.globl	iStart4c
	.p2align	3, 0x0
iStart4c:
	.quad	0x0000000000000000              # double 0
	.size	iStart4c, 8

	.type	iStart5,@object                 # @iStart5
	.globl	iStart5
	.p2align	3, 0x0
iStart5:
	.quad	0x0000000000000000              # double 0
	.size	iStart5, 8

	.type	iElaps1,@object                 # @iElaps1
	.globl	iElaps1
	.p2align	3, 0x0
iElaps1:
	.quad	0x0000000000000000              # double 0
	.size	iElaps1, 8

	.type	iElaps2,@object                 # @iElaps2
	.globl	iElaps2
	.p2align	3, 0x0
iElaps2:
	.quad	0x0000000000000000              # double 0
	.size	iElaps2, 8

	.type	iElaps3a,@object                # @iElaps3a
	.globl	iElaps3a
	.p2align	3, 0x0
iElaps3a:
	.quad	0x0000000000000000              # double 0
	.size	iElaps3a, 8

	.type	iElaps3b,@object                # @iElaps3b
	.globl	iElaps3b
	.p2align	3, 0x0
iElaps3b:
	.quad	0x0000000000000000              # double 0
	.size	iElaps3b, 8

	.type	iElaps4,@object                 # @iElaps4
	.globl	iElaps4
	.p2align	3, 0x0
iElaps4:
	.quad	0x0000000000000000              # double 0
	.size	iElaps4, 8

	.type	iElaps5,@object                 # @iElaps5
	.globl	iElaps5
	.p2align	3, 0x0
iElaps5:
	.quad	0x0000000000000000              # double 0
	.size	iElaps5, 8

	.type	_ZL15nearestCentroidPiS_PfS0_P4Info,@object # @_ZL15nearestCentroidPiS_PfS0_P4Info
	.section	.rodata,"a",@progbits
	.p2align	3, 0x0
_ZL15nearestCentroidPiS_PfS0_P4Info:
	.quad	_ZL30__device_stub__nearestCentroidPiS_PfS0_P4Info
	.size	_ZL15nearestCentroidPiS_PfS0_P4Info, 8

	.type	_ZL6reducePiii,@object          # @_ZL6reducePiii
	.p2align	3, 0x0
_ZL6reducePiii:
	.quad	_ZL21__device_stub__reducePiii
	.size	_ZL6reducePiii, 8

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"Iteration: "
	.size	.L.str, 12

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

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

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"Total time: "
	.size	.L.str.3, 13

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"E-step time use (ms): "
	.size	.L.str.4, 23

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"M-step-1st-half time use (ms): "
	.size	.L.str.5, 32

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"M-step-2nd-half time use (ms): "
	.size	.L.str.6, 32

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"Cuda Data IO (ms): "
	.size	.L.str.7, 20

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"Other (ms): "
	.size	.L.str.8, 13

	.type	.L.str.9,@object                # @.str.9
.L.str.9:
	.asciz	"stof"
	.size	.L.str.9, 5

	.type	.L.str.10,@object               # @.str.10
.L.str.10:
	.asciz	"basic_string: construction from null is not valid"
	.size	.L.str.10, 50

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_ZL15nearestCentroidPiS_PfS0_P4Info"
	.size	.L__unnamed_1, 36

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_ZL6reducePiii"
	.size	.L__unnamed_2, 15

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

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

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

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.section	.text._ZL6reducePiii,"axG",@progbits,_ZL6reducePiii,comdat
	.globl	_ZL6reducePiii                  ; -- Begin function _ZL6reducePiii
	.p2align	8
	.type	_ZL6reducePiii,@function
_ZL6reducePiii:                         ; @_ZL6reducePiii
; %bb.0:
	s_load_b128 s[0:3], s[0:1], 0x0
	v_mov_b32_e32 v2, 0
	s_waitcnt lgkmcnt(0)
	v_cmp_gt_u32_e32 vcc_lo, s2, v0
	s_and_saveexec_b32 s2, vcc_lo
	s_cbranch_execz .LBB0_2
; %bb.1:
	v_lshlrev_b32_e32 v1, 2, v0
	global_load_b32 v2, v1, s[0:1]
.LBB0_2:
	s_or_b32 exec_lo, exec_lo, s2
	v_lshl_add_u32 v1, v0, 2, 0
	s_add_i32 s2, s3, 1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_cmp_lt_u32 s2, 3
	s_waitcnt vmcnt(0)
	ds_store_b32 v1, v2
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	s_cbranch_scc1 .LBB0_7
; %bb.3:                                ; %.lr.ph
	s_lshr_b32 s2, s3, 31
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_add_i32 s2, s3, s2
	s_ashr_i32 s2, s2, 1
.LBB0_4:                                ; =>This Inner Loop Header: Depth=1
	s_mov_b32 s3, exec_lo
	v_cmpx_gt_u32_e64 s2, v0
	s_cbranch_execz .LBB0_6
; %bb.5:                                ;   in Loop: Header=BB0_4 Depth=1
	v_lshl_add_u32 v2, s2, 2, v1
	ds_load_b32 v2, v2
	ds_load_b32 v3, v1
	s_waitcnt lgkmcnt(0)
	v_add_nc_u32_e32 v2, v3, v2
	ds_store_b32 v1, v2
.LBB0_6:                                ;   in Loop: Header=BB0_4 Depth=1
	s_or_b32 exec_lo, exec_lo, s3
	s_lshr_b32 s3, s2, 1
	s_cmp_lt_u32 s2, 2
	s_mov_b32 s2, s3
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	s_cbranch_scc0 .LBB0_4
.LBB0_7:                                ; %._crit_edge
	s_mov_b32 s2, exec_lo
	v_cmpx_eq_u32_e32 0, v0
	s_cbranch_execz .LBB0_9
; %bb.8:
	v_mov_b32_e32 v0, 0
	ds_load_b32 v1, v0
	s_waitcnt lgkmcnt(0)
	global_store_b32 v0, v1, s[0:1]
.LBB0_9:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _ZL6reducePiii
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 16
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 4
		.amdhsa_next_free_sgpr 4
		.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
	.section	.text._ZL6reducePiii,"axG",@progbits,_ZL6reducePiii,comdat
.Lfunc_end0:
	.size	_ZL6reducePiii, .Lfunc_end0-_ZL6reducePiii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 252
; NumSgprs: 6
; NumVgprs: 4
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 0
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 6
; NumVGPRsForWavesPerEU: 4
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.section	.text._ZL15nearestCentroidPiS_PfS0_P4Info,"axG",@progbits,_ZL15nearestCentroidPiS_PfS0_P4Info,comdat
	.globl	_ZL15nearestCentroidPiS_PfS0_P4Info ; -- Begin function _ZL15nearestCentroidPiS_PfS0_P4Info
	.p2align	8
	.type	_ZL15nearestCentroidPiS_PfS0_P4Info,@function
_ZL15nearestCentroidPiS_PfS0_P4Info:    ; @_ZL15nearestCentroidPiS_PfS0_P4Info
; %bb.0:
	s_clause 0x1
	s_load_b64 s[2:3], s[0:1], 0x20
	s_load_b32 s4, s[0:1], 0x34
	s_mov_b32 s8, s15
	s_waitcnt lgkmcnt(0)
	s_load_b32 s16, s[2:3], 0x0
	s_and_b32 s9, s4, 0xffff
	s_mov_b32 s4, exec_lo
	v_mad_u64_u32 v[1:2], null, s8, s9, v[0:1]
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_1)
	v_cmpx_gt_i32_e64 s16, v1
	s_cbranch_execz .LBB1_18
; %bb.1:
	s_load_b64 s[10:11], s[2:3], 0x4
	s_load_b256 s[0:7], s[0:1], 0x0
	s_waitcnt lgkmcnt(0)
	s_cmp_gt_i32 s10, 0
	s_cselect_b32 s17, -1, 0
	s_cmp_lt_i32 s10, 1
	s_cbranch_scc1 .LBB1_4
; %bb.2:                                ; %.lr.ph.i.preheader
	v_mov_b32_e32 v4, 0
	v_mov_b32_e32 v2, v1
	s_ashr_i32 s15, s11, 31
	s_mov_b32 s14, s11
	s_mov_b32 s12, s6
	s_mov_b32 s13, s7
	s_lshl_b64 s[14:15], s[14:15], 2
	s_mov_b32 s18, s10
.LBB1_3:                                ; %.lr.ph.i
                                        ; =>This Inner Loop Header: Depth=1
	v_ashrrev_i32_e32 v3, 31, v2
	s_load_b32 s19, s[12:13], 0x0
	s_add_i32 s18, s18, -1
	s_add_u32 s12, s12, s14
	s_addc_u32 s13, s13, s15
	v_lshlrev_b64 v[5:6], 2, v[2:3]
	s_cmp_lg_u32 s18, 0
	v_add_nc_u32_e32 v2, s16, v2
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_co_u32 v5, vcc_lo, s4, v5
	v_add_co_ci_u32_e32 v6, vcc_lo, s5, v6, vcc_lo
	global_load_b32 v3, v[5:6], off
	s_waitcnt vmcnt(0) lgkmcnt(0)
	v_subrev_f32_e32 v3, s19, v3
	s_delay_alu instid0(VALU_DEP_1)
	v_fmac_f32_e32 v4, v3, v3
	s_cbranch_scc1 .LBB1_3
	s_branch .LBB1_5
.LBB1_4:
	v_mov_b32_e32 v4, 0
.LBB1_5:                                ; %_ZL11computeDistP4InfoiiiPfS1_.exit
	v_mov_b32_e32 v5, 0
	s_cmp_lt_i32 s11, 1
	s_cbranch_scc1 .LBB1_11
; %bb.6:                                ; %.lr.ph.preheader
	s_mov_b32 s13, 0
	s_mov_b32 s14, 0
.LBB1_7:                                ; %.lr.ph
                                        ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB1_9 Depth 2
	v_mov_b32_e32 v6, 0
	s_and_not1_b32 vcc_lo, exec_lo, s17
	s_cbranch_vccnz .LBB1_10
; %bb.8:                                ; %.lr.ph.i43.preheader
                                        ;   in Loop: Header=BB1_7 Depth=1
	v_mov_b32_e32 v2, v1
	s_mov_b32 s12, s14
	s_mov_b32 s15, s10
.LBB1_9:                                ; %.lr.ph.i43
                                        ;   Parent Loop BB1_7 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(SALU_CYCLE_1)
	v_ashrrev_i32_e32 v3, 31, v2
	s_lshl_b64 s[18:19], s[12:13], 2
	s_add_u32 s18, s6, s18
	s_addc_u32 s19, s7, s19
	s_delay_alu instid0(VALU_DEP_1)
	v_lshlrev_b64 v[7:8], 2, v[2:3]
	s_load_b32 s18, s[18:19], 0x0
	s_add_i32 s15, s15, -1
	s_add_i32 s12, s12, s11
	s_cmp_lg_u32 s15, 0
	v_add_nc_u32_e32 v2, s16, v2
	v_add_co_u32 v7, vcc_lo, s4, v7
	v_add_co_ci_u32_e32 v8, vcc_lo, s5, v8, vcc_lo
	global_load_b32 v3, v[7:8], off
	s_waitcnt vmcnt(0) lgkmcnt(0)
	v_subrev_f32_e32 v3, s18, v3
	s_delay_alu instid0(VALU_DEP_1)
	v_fmac_f32_e32 v6, v3, v3
	s_cbranch_scc1 .LBB1_9
.LBB1_10:                               ; %_ZL11computeDistP4InfoiiiPfS1_.exit47
                                        ;   in Loop: Header=BB1_7 Depth=1
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_3) | instid1(SALU_CYCLE_1)
	v_cmp_lt_f32_e32 vcc_lo, v6, v4
	v_cndmask_b32_e64 v5, v5, s14, vcc_lo
	v_cndmask_b32_e32 v4, v4, v6, vcc_lo
	s_add_i32 s14, s14, 1
	s_cmp_eq_u32 s14, s11
	s_cbranch_scc0 .LBB1_7
.LBB1_11:                               ; %._crit_edge
	v_ashrrev_i32_e32 v2, 31, v1
	s_cmp_lt_u32 s9, 2
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[1:2], 2, v[1:2]
	v_add_co_u32 v3, vcc_lo, s2, v1
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v4, vcc_lo, s3, v2, vcc_lo
	v_lshl_add_u32 v1, v0, 2, 0
	global_load_b32 v2, v[3:4], off
	global_store_b32 v[3:4], v5, off
	s_waitcnt vmcnt(0)
	v_cmp_ne_u32_e32 vcc_lo, v2, v5
	v_cndmask_b32_e64 v2, 0, 1, vcc_lo
	ds_store_b32 v1, v2
	s_waitcnt lgkmcnt(0)
	s_waitcnt_vscnt null, 0x0
	s_barrier
.LBB1_12:                               ; %._crit_edge
                                        ; =>This Inner Loop Header: Depth=1
	buffer_gl0_inv
	s_cbranch_scc1 .LBB1_16
; %bb.13:                               ; %.lr.ph56
                                        ;   in Loop: Header=BB1_12 Depth=1
	s_lshr_b32 s2, s9, 1
	s_mov_b32 s3, exec_lo
	v_cmpx_gt_u32_e64 s2, v0
	s_cbranch_execz .LBB1_15
; %bb.14:                               ;   in Loop: Header=BB1_12 Depth=1
	v_lshl_add_u32 v2, s2, 2, v1
	ds_load_b32 v2, v2
	ds_load_b32 v3, v1
	s_waitcnt lgkmcnt(0)
	v_add_nc_u32_e32 v2, v3, v2
	ds_store_b32 v1, v2
.LBB1_15:                               ;   in Loop: Header=BB1_12 Depth=1
	s_or_b32 exec_lo, exec_lo, s3
	s_waitcnt lgkmcnt(0)
	s_barrier
	s_cmp_lt_u32 s9, 4
	s_mov_b32 s9, s2
	s_branch .LBB1_12
.LBB1_16:                               ; %._crit_edge57
	v_cmp_eq_u32_e32 vcc_lo, 0, v0
	s_and_b32 exec_lo, exec_lo, vcc_lo
	s_cbranch_execz .LBB1_18
; %bb.17:
	v_mov_b32_e32 v0, 0
	s_mov_b32 s9, 0
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_lshl_b64 s[2:3], s[8:9], 2
	s_add_u32 s0, s0, s2
	ds_load_b32 v1, v0
	s_addc_u32 s1, s1, s3
	s_waitcnt lgkmcnt(0)
	global_store_b32 v0, v1, s[0:1]
.LBB1_18:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _ZL15nearestCentroidPiS_PfS0_P4Info
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 296
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 9
		.amdhsa_next_free_sgpr 20
		.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
	.section	.text._ZL15nearestCentroidPiS_PfS0_P4Info,"axG",@progbits,_ZL15nearestCentroidPiS_PfS0_P4Info,comdat
.Lfunc_end1:
	.size	_ZL15nearestCentroidPiS_PfS0_P4Info, .Lfunc_end1-_ZL15nearestCentroidPiS_PfS0_P4Info
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 668
; NumSgprs: 22
; NumVgprs: 9
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 22
; NumVGPRsForWavesPerEU: 9
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

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

	.end_amdgpu_metadata
