#include <stdio.h>
#include <stdlib.h>
#include <float.h>
#include <math.h>
#include <cuda.h>
#include <curand.h>

// Type for points
typedef struct{
    float x;    // x coordinate
    float y;    // y coordinate
    int cluster; // cluster this point belongs to
} Point;

// Type for centroids
typedef struct{
    float x;    // x coordinate
    float y;    // y coordinate
    int nPoints; // number of points in this cluster
} Centroid;

// Global variables
int nPoints;   // Number of points
int nClusters; // Number of clusters/centroids

Point* points;       // Array containig all points
Centroid* centroids; // Array containing all centroids


// Reading command line arguments
void parse_args(int argc, char** argv){
    if(argc != 3){
        printf("Useage: kmeans nClusters nPoints\n");
        exit(-1);
    }
    nClusters = atoi(argv[1]);
    nPoints = atoi(argv[2]);

    if (nPoints < 64 || nClusters < 1) {
        printf("nClusters must be greater than 0\nnPoints must be greater than or equal to 64\n");
        exit(1);
    }
}


// Create random point
Point create_random_point(){
    Point p;
    p.x = ((float)rand() / (float)RAND_MAX) * 1000.0 - 500.0;
    p.y = ((float)rand() / (float)RAND_MAX) * 1000.0 - 500.0;
    p.cluster = rand() % nClusters;
    return p;
}

// Create random centroid
Centroid create_random_centroid(){
    Centroid p;
    p.x = ((float)rand() / (float)RAND_MAX) * 1000.0 - 500.0;
    p.y = ((float)rand() / (float)RAND_MAX) * 1000.0 - 500.0;
    p.nPoints = 0;
    return p;
}

__host__ Centroid device_create_random_centroid(){
    Centroid c;
    c.x = ((float)rand() / (float)RAND_MAX) * 1000.0 - 500.0;
    c.y = ((float)rand() / (float)RAND_MAX) * 1000.0 - 500.0;
    c.nPoints = 0;
    return c;
}


// Initialize random data
// Points will be uniformly distributed
void init_data(){
    points = (Point*)malloc(sizeof(Point)*nPoints);
    for(int i = 0; i < nPoints; i++){
        points[i] = create_random_point();
        if(i < nClusters){
            points[i].cluster = i;
        }
    }

    centroids = (Centroid*)malloc(sizeof(Centroid)*nClusters);
    for(int i = 0; i < nClusters; i++){
        centroids[i] = create_random_centroid();
    }
}

// Initialize random data
// Points will be placed in circular clusters 
void init_clustered_data(){
    float diameter = 500.0/sqrt(nClusters);

    centroids = (Centroid*)malloc(sizeof(Centroid)*nClusters);
    for(int i = 0; i < nClusters; i++){
        centroids[i] = create_random_centroid();
    }

    points = (Point*)malloc(sizeof(Point)*nPoints);
    for(int i = 0; i < nPoints; i++){
        points[i] = create_random_point();
        if(i < nClusters){
            points[i].cluster = i;
        }
    }

    for(int i = 0; i < nPoints; i++){
        int c = points[i].cluster;
        points[i].x = centroids[c].x + ((float)rand() / (float)RAND_MAX) * diameter - (diameter/2);
        points[i].y = centroids[c].y + ((float)rand() / (float)RAND_MAX) * diameter - (diameter/2);
        points[i].cluster = rand() % nClusters;
    }

    for(int i = 0; i < nClusters; i++){
        centroids[i] = create_random_centroid();
    }
}


// Print all points and centroids to standard output
void print_data(){
    for(int i = 0; i < nPoints; i++){
        printf("%f\t%f\t%d\t\n", points[i].x, points[i].y, points[i].cluster);
    }
    printf("\n\n");
    for(int i = 0; i < nClusters; i++){
        printf("%f\t%f\t%d\t\n", centroids[i].x, centroids[i].y, i);
    }
}

// Print all points and centroids to a file
// File name will be based on input argument
// Can be used to print result after each iteration
void print_data_to_file(int i){
    char filename[15];
    sprintf(filename, "%04d.dat", i);
    FILE* f = fopen(filename, "w+");

    for(int i = 0; i < nPoints; i++){
        fprintf(f, "%f\t%f\t%d\t\n", points[i].x, points[i].y, points[i].cluster);
    }
    fprintf(f,"\n\n");
    for(int i = 0; i < nClusters; i++){
        fprintf(f,"%f\t%f\t%d\t\n", centroids[i].x, centroids[i].y, i);
    }

    fclose(f);
}


// Computing distance between point and centroid
float distance(Point a, Centroid b){
    float dx = a.x - b.x;
    float dy = a.y - b.y;

    return sqrt(dx*dx + dy*dy);
}

// Cuda variables
Point *input_points;
Centroid *input_centroids;
int *cuda_updated;
int *cuda_nClusters;
int *cuda_nPoints;
int *cuda_nthreads;


__global__ void device_compute_centroids1(Point *d_points, Centroid *d_centroids, 
    int *d_nClusters, int *d_nPoints, int *d_nthreads);

__global__ void device_compute_centroids2(Point *d_points, Centroid *d_centroids, 
    int *d_nClusters, int *d_nPoints);

__global__ void device_reassign_points(Point *d_points, Centroid *d_centroids, 
    int *d_updated, int *d_nClusters, int *d_nPoints, int *d_nthreads);

int main(int argc, char** argv) {
    srand(0);
    parse_args(argc, argv);

    // Create random data, either function can be used.
    //init_clustered_data();
    init_data();

    int nThreadsPerBlock = 64;

    dim3 numBlocks, threadsPerBlock;
    numBlocks.x = nPoints / nThreadsPerBlock;
    threadsPerBlock.x = nThreadsPerBlock;

    // 1. Allocate buffers for the points and clusters
    cudaMalloc((void**) &input_points, sizeof(Point) * nPoints);
    cudaMalloc((void**) &input_centroids, sizeof(Centroid) * nClusters);
    cudaMalloc((void**) &cuda_updated, sizeof(int));
    cudaMalloc((void**) &cuda_nClusters, sizeof(int));
    cudaMalloc((void**) &cuda_nPoints, sizeof(int));
    cudaMalloc((void**) &cuda_nthreads, sizeof(int));

    cudaMemcpy(cuda_nClusters, &nClusters, sizeof(int), cudaMemcpyHostToDevice);
    cudaMemcpy(cuda_nPoints, &nPoints, sizeof(int), cudaMemcpyHostToDevice);
    cudaMemcpy(cuda_nthreads, &nThreadsPerBlock, sizeof(int), cudaMemcpyHostToDevice);

    // Iterate until no points are updated
    int updated = 1;
    
    cudaMemcpy(input_points, points, sizeof(Point) * nPoints, cudaMemcpyHostToDevice);
    cudaMemcpy(input_centroids, centroids, sizeof(Centroid) * nClusters, cudaMemcpyHostToDevice);

    size_t smem_size = sizeof(Point) * nThreadsPerBlock + sizeof(Centroid) * nClusters;

    // Because the 'device_compute_centroids1' function does not work correctly,
    // this variable is set to 0 to go for more serial appreach that works, 
    // but is slower (maybe even than a serial approach running on the host, 
    // because of the data movement between host and device. This of course, 
    // depends on the amount of Centroids.)
    int use_function1 = 0;

    while(updated) {
        updated = 0;

        if (use_function1) {
            // Transfer the points and clusters to device
            cudaMemcpy(input_points, points, sizeof(Point) * nPoints, cudaMemcpyHostToDevice);
            size_t size = sizeof(Centroid) * nThreadsPerBlock + sizeof(Point) * nPoints;
            // Reset centroid positions
            device_compute_centroids1<<<nClusters, threadsPerBlock, size>>>(input_points, 
                input_centroids, cuda_nClusters, cuda_nPoints, cuda_nthreads);
            // Transfer data to host
            cudaMemcpy(centroids, input_centroids, sizeof(Centroid) * nClusters, 
                cudaMemcpyDeviceToHost);
        } else {
            // Transfer the points and clusters to device
            cudaMemcpy(input_points, points, sizeof(Point) * nPoints, cudaMemcpyHostToDevice);
            // Reset centroid positions
            device_compute_centroids2<<<nClusters, 1>>>(input_points, input_centroids, 
                cuda_nClusters, cuda_nPoints);
            // Transfer data to host
            cudaMemcpy(centroids, input_centroids, sizeof(Centroid) * nClusters, 
                cudaMemcpyDeviceToHost);
        }

        // Because this function involes MATH rand(), it cannot be called from the kernel
        // By using the cuRand(), random numbers could have been generated on the device as well,
        // but it results in different results on host and device, and is thus hard to debug.
        for(int i = 0; i < nClusters; i++) {
            // If a centroid lost all its points, we give it a random position
            // (to avoid dividing by 0)
            if(centroids[i].nPoints == 0) {
                centroids[i] = create_random_centroid();
            }
            else {
                centroids[i].x /= centroids[i].nPoints;
                centroids[i].y /= centroids[i].nPoints;
            }
        }

        // Transfer the Centroids to the device, 
        // the Points is unchanged from the last time this function was called
        cudaMemcpy(input_centroids, centroids, sizeof(Centroid) * nClusters, 
            cudaMemcpyHostToDevice);
        // Reassign points
        device_reassign_points<<<numBlocks, threadsPerBlock, smem_size>>>(input_points, 
            input_centroids, cuda_updated, cuda_nClusters, cuda_nPoints, cuda_nthreads);
        // Transfer the points back to the host, the Centroids remains unchanged
        cudaMemcpy(points, input_points, sizeof(Point) * nPoints, cudaMemcpyDeviceToHost);
        cudaMemcpy(&updated, cuda_updated, sizeof(int), cudaMemcpyDeviceToHost);
    }

    cudaFree(input_points);
    cudaFree(input_centroids);
    cudaFree(cuda_updated);
    cudaFree(cuda_nClusters);
    cudaFree(cuda_nPoints);
    cudaFree(cuda_nthreads);

    print_data();
}

// A quite naive approach, without any use of reduction for the Points
// Some kind of reduction is tried implemented in the _next_ function, but the results
// is not completely satisfactory, thus this function is included as well.
// Note: set the variable 'use_function1' to 0 to call this function
__global__ void device_compute_centroids2(Point *d_points, Centroid *d_centroids, 
    int *d_nClusters, int *d_nPoints) 
{
    // extern __shared__ Centroid shared[];
    __shared__ Centroid s_centroid[1];

    int gid = blockIdx.x * blockDim.x; // + threadIdx.x
    
    int tid = threadIdx.x;

    // Reset centroid to 0
    s_centroid[tid] = (Centroid) {0.0, 0.0, 0};

    // Compute new centroids positions
    for (int i = 0; i < *d_nPoints; i++) {
        if (gid == d_points[i].cluster) {
            s_centroid[tid].x += d_points[i].x;
            s_centroid[tid].y += d_points[i].y;
            s_centroid[tid].nPoints++;
        }
    }
    // Transfer computed centroid back to global memory
    d_centroids[gid] = s_centroid[tid];
}

// This function is called for each of the Clusters, 64 threads run in parallel
// reducing all the points connected to the Cluster (identified by the block id)
// It does not seam to produce a 100% correct output, but sometimes look all right
// Note: set the variable 'use_function1' to 1 to call this function
__global__ void device_compute_centroids1(Point *d_points, Centroid *d_centroids, 
    int *d_nClusters, int *d_nPoints, int *d_nthreads) 
{
    extern __shared__ Centroid s_compute_centroids[];
    Centroid *s_centroid = s_compute_centroids;
    Point *s_points = (Point *) &s_centroid[*d_nthreads];

    int bid = blockIdx.x;
    int tid = threadIdx.x;

    // Reset centroid to 0
    s_centroid[tid] = (Centroid) {0.0, 0.0, 0};

    int length = *d_nPoints / *d_nthreads;
    int start = tid * length;
    int end = start + length;

    if (tid == 0 && length < 0) {
        for (int i = 0; i < *d_nPoints; i++) {
            s_points[i] = d_points[i];
        }
    } else {
        for (int i = start; i < end; i++) {
            s_points[i] = d_points[i];
        }
    }
    __syncthreads();

    // If the length is small (i.e. there is fewer points than 64),
    // thread 0 does all the work
    if (tid == 0 && length < 0) {
        for (int i = 0; i < *d_nPoints; i++) {
            int cluster_id = d_points[i].cluster;

            if (cluster_id == bid) {
                s_centroid[0].x += d_points[i].x;
                s_centroid[0].y += d_points[i].y;
                s_centroid[0].nPoints++;
            }
        }
    } else {
        // A kind of reduction, where each thread runs through it's dedicated part
        // of the Points array and checks to see if the points is connected to the 
        // corresponding block. If it is, each thread updates it's own centroid
        // in shared memory
        for (int i = start; i < end; i++) {
            int cluster_id = d_points[i].cluster;

            if (cluster_id == bid) {
                s_centroid[tid].x += d_points[i].x;
                s_centroid[tid].y += d_points[i].y;
                s_centroid[tid].nPoints += 1;
            }
        }
        __syncthreads();

        // Thread 0 goes over the centroids in shared memory, and sums them together
        if (tid == 0) {
            for (int i = 0; i < 64; i++) {
                s_centroid[0].x += s_centroid[i].x;
                s_centroid[0].y += s_centroid[i].y;
                s_centroid[0].nPoints += s_centroid[i].nPoints;
            }
        }
    }

    // Transfer computed centroid back to global memory
    if (tid == 0) {
        d_centroids[bid] = s_centroid[0];
    }
}

// This function is runs with one thread for every point, calculating what
// centroid the respective point belongs to
__global__ void device_reassign_points(Point *d_points, Centroid *d_centroids, 
    int *d_updated, int *d_nClusters, int *d_nPoints, int *d_nthreads) 
{
    // The shared memory consists of 64 points (1 for each thread per block), and 'd_nClusters' Centroids
    extern __shared__ Point s_reassign_points[];
    Point *s_points = s_reassign_points;
    Centroid *s_centroids = (Centroid *) &s_points[*d_nthreads];

    int gid = blockIdx.x * blockDim.x + threadIdx.x;
    int tid = threadIdx.x;

    // Make sure that updated is 0
    if (tid == 0) {
        *d_updated = 0;
    }

    // Init shared Points
    s_points[tid] = d_points[gid];

    // Init shared Centroids
    int length = *d_nClusters / *d_nthreads;
    int start = tid * length;
    int end = start + length;

    // If number of clusters is small, let thread 0 do all the work.
    // For some reason this initialization does not work in parallel, so thread 0 does all the work.
    if (tid == 0) {
        for (int i = 0; i < *d_nClusters; i++) {
            s_centroids[i] = d_centroids[i];
        }
    } 
    else if (length > 1 && 0) {
        for (int i = start; i < end; i++) {
            s_centroids[i] = d_centroids[i];
        }
    }
    __syncthreads();

    //Reassign points to closest centroid
    float bestDistance = DBL_MAX;
    int bestCluster = -1;

    for(int i = 0; i < *d_nClusters; i++) {
        Point a = s_points[tid];
        Centroid b = s_centroids[i];
        float dx = a.x - b.x;
        float dy = a.y - b.y;
        float d = sqrt(dx*dx + dy*dy);

        if(d < bestDistance) {
            bestDistance = d;
            bestCluster = i;
        }
    }

    // If one point got reassigned to a new cluster, we have to do another iteration
    if(bestCluster != s_points[tid].cluster) {
        *d_updated = 1;
    }

    // Update the points in the global memory
    d_points[gid].cluster = bestCluster;
}

	.file	"tmpxft_002c81ae_00000000-6_kmeans_cuda.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2039:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2039:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"Useage: kmeans nClusters nPoints\n"
.LC1:
	.string	"nClusters must be greater than 0\nnPoints must be greater than or equal to 64\n"
	.text
	.globl	_Z10parse_argsiPPc
	.type	_Z10parse_argsiPPc, @function
_Z10parse_argsiPPc:
.LFB2027:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	pushq	%rdx
	.cfi_def_cfa_offset 32
	cmpl	$3, %edi
	je	.L3
	movl	$2, %edi
	leaq	.LC0(%rip), %rsi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	orl	$-1, %edi
	jmp	.L8
.L3:
	movq	8(%rsi), %rdi
	movq	%rsi, %rbp
	call	atoi@PLT
	movq	16(%rbp), %rdi
	movl	%eax, nClusters(%rip)
	movl	%eax, %ebx
	call	atoi@PLT
	movl	%eax, nPoints(%rip)
	testl	%ebx, %ebx
	jle	.L6
	cmpl	$63, %eax
	jg	.L2
.L6:
	movl	$2, %edi
	leaq	.LC1(%rip), %rsi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$1, %edi
.L8:
	call	exit@PLT
.L2:
	popq	%rax
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2027:
	.size	_Z10parse_argsiPPc, .-_Z10parse_argsiPPc
	.globl	_Z19create_random_pointv
	.type	_Z19create_random_pointv, @function
_Z19create_random_pointv:
.LFB2028:
	.cfi_startproc
	endbr64
	subq	$56, %rsp
	.cfi_def_cfa_offset 64
	call	rand@PLT
	cvtsi2ssl	%eax, %xmm1
	mulss	.LC2(%rip), %xmm1
	cvtss2sd	%xmm1, %xmm1
	mulsd	.LC3(%rip), %xmm1
	subsd	.LC4(%rip), %xmm1
	cvtsd2ss	%xmm1, %xmm1
	movss	%xmm1, 12(%rsp)
	call	rand@PLT
	cvtsi2ssl	%eax, %xmm0
	mulss	.LC2(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	mulsd	.LC3(%rip), %xmm0
	subsd	.LC4(%rip), %xmm0
	cvtsd2ss	%xmm0, %xmm0
	movss	%xmm0, 8(%rsp)
	call	rand@PLT
	movss	8(%rsp), %xmm0
	movss	12(%rsp), %xmm1
	cltd
	idivl	nClusters(%rip)
	movss	%xmm1, 36(%rsp)
	movss	%xmm0, 40(%rsp)
	movq	36(%rsp), %xmm0
	addq	$56, %rsp
	.cfi_def_cfa_offset 8
	movl	%edx, %eax
	ret
	.cfi_endproc
.LFE2028:
	.size	_Z19create_random_pointv, .-_Z19create_random_pointv
	.globl	_Z22create_random_centroidv
	.type	_Z22create_random_centroidv, @function
_Z22create_random_centroidv:
.LFB2029:
	.cfi_startproc
	endbr64
	subq	$56, %rsp
	.cfi_def_cfa_offset 64
	call	rand@PLT
	cvtsi2ssl	%eax, %xmm0
	mulss	.LC2(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	mulsd	.LC3(%rip), %xmm0
	subsd	.LC4(%rip), %xmm0
	cvtsd2ss	%xmm0, %xmm0
	movss	%xmm0, 12(%rsp)
	call	rand@PLT
	movss	12(%rsp), %xmm0
	movss	%xmm0, 36(%rsp)
	cvtsi2ssl	%eax, %xmm0
	xorl	%eax, %eax
	mulss	.LC2(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	mulsd	.LC3(%rip), %xmm0
	subsd	.LC4(%rip), %xmm0
	cvtsd2ss	%xmm0, %xmm0
	movss	%xmm0, 40(%rsp)
	movq	36(%rsp), %xmm0
	addq	$56, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2029:
	.size	_Z22create_random_centroidv, .-_Z22create_random_centroidv
	.globl	_Z29device_create_random_centroidv
	.type	_Z29device_create_random_centroidv, @function
_Z29device_create_random_centroidv:
.LFB2187:
	.cfi_startproc
	endbr64
	jmp	_Z22create_random_centroidv
	.cfi_endproc
.LFE2187:
	.size	_Z29device_create_random_centroidv, .-_Z29device_create_random_centroidv
	.globl	_Z9init_datav
	.type	_Z9init_datav, @function
_Z9init_datav:
.LFB2031:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	xorl	%ebx, %ebx
	pushq	%rdx
	.cfi_def_cfa_offset 32
	movslq	nPoints(%rip), %rdi
	imulq	$12, %rdi, %rdi
	call	malloc@PLT
	movq	%rax, points(%rip)
.L16:
	cmpl	%ebx, nPoints(%rip)
	jle	.L22
	call	_Z19create_random_pointv
	imulq	$12, %rbx, %rbp
	cmpl	%ebx, nClusters(%rip)
	movl	%eax, %edx
	movq	points(%rip), %rax
	movl	%edx, 8(%rax,%rbp)
	movq	%xmm0, (%rax,%rbp)
	movq	points(%rip), %rax
	jle	.L17
	movl	%ebx, 8(%rax,%rbp)
.L17:
	incq	%rbx
	jmp	.L16
.L22:
	movslq	nClusters(%rip), %rdi
	xorl	%ebx, %ebx
	imulq	$12, %rdi, %rdi
	call	malloc@PLT
	movq	%rax, centroids(%rip)
.L19:
	cmpl	%ebx, nClusters(%rip)
	jle	.L23
	call	_Z22create_random_centroidv
	movl	%eax, %edx
	imulq	$12, %rbx, %rax
	addq	centroids(%rip), %rax
	incq	%rbx
	movl	%edx, 8(%rax)
	movq	%xmm0, (%rax)
	jmp	.L19
.L23:
	popq	%rax
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2031:
	.size	_Z9init_datav, .-_Z9init_datav
	.globl	_Z19init_clustered_datav
	.type	_Z19init_clustered_datav, @function
_Z19init_clustered_datav:
.LFB2032:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	subq	$16, %rsp
	.cfi_def_cfa_offset 48
	movl	nClusters(%rip), %ebx
	cvtsi2sdl	%ebx, %xmm0
	call	sqrt@PLT
	movslq	%ebx, %rdi
	xorl	%ebx, %ebx
	movaps	%xmm0, %xmm1
	movsd	.LC4(%rip), %xmm0
	imulq	$12, %rdi, %rdi
	divsd	%xmm1, %xmm0
	cvtsd2ss	%xmm0, %xmm2
	movss	%xmm2, 4(%rsp)
	call	malloc@PLT
	movq	%rax, centroids(%rip)
.L25:
	cmpl	%ebx, nClusters(%rip)
	jle	.L35
	call	_Z22create_random_centroidv
	movl	%eax, %edx
	imulq	$12, %rbx, %rax
	addq	centroids(%rip), %rax
	incq	%rbx
	movl	%edx, 8(%rax)
	movq	%xmm0, (%rax)
	jmp	.L25
.L35:
	movslq	nPoints(%rip), %rdi
	xorl	%ebx, %ebx
	imulq	$12, %rdi, %rdi
	call	malloc@PLT
	movq	%rax, points(%rip)
.L27:
	cmpl	%ebx, nPoints(%rip)
	jle	.L36
	call	_Z19create_random_pointv
	imulq	$12, %rbx, %rbp
	cmpl	%ebx, nClusters(%rip)
	movl	%eax, %edx
	movq	points(%rip), %rax
	movl	%edx, 8(%rax,%rbp)
	movq	%xmm0, (%rax,%rbp)
	movq	points(%rip), %rax
	jle	.L28
	movl	%ebx, 8(%rax,%rbp)
.L28:
	incq	%rbx
	jmp	.L27
.L36:
	xorl	%ebp, %ebp
.L30:
	cmpl	%ebp, nPoints(%rip)
	jle	.L37
	imulq	$12, %rbp, %rbx
	movq	points(%rip), %rax
	incq	%rbp
	movslq	8(%rax,%rbx), %r12
	movq	centroids(%rip), %rax
	imulq	$12, %r12, %r12
	movss	(%rax,%r12), %xmm3
	movss	%xmm3, 8(%rsp)
	call	rand@PLT
	movss	.LC5(%rip), %xmm1
	mulss	4(%rsp), %xmm1
	cvtsi2ssl	%eax, %xmm0
	mulss	.LC2(%rip), %xmm0
	movq	points(%rip), %rax
	mulss	4(%rsp), %xmm0
	addss	8(%rsp), %xmm0
	movss	%xmm1, 12(%rsp)
	subss	%xmm1, %xmm0
	movss	%xmm0, (%rax,%rbx)
	movq	centroids(%rip), %rax
	movss	4(%rax,%r12), %xmm7
	movss	%xmm7, 8(%rsp)
	call	rand@PLT
	movss	12(%rsp), %xmm1
	cvtsi2ssl	%eax, %xmm0
	mulss	.LC2(%rip), %xmm0
	movq	points(%rip), %rax
	mulss	4(%rsp), %xmm0
	addss	8(%rsp), %xmm0
	subss	%xmm1, %xmm0
	movss	%xmm0, 4(%rax,%rbx)
	call	rand@PLT
	cltd
	idivl	nClusters(%rip)
	movq	points(%rip), %rax
	movl	%edx, 8(%rax,%rbx)
	jmp	.L30
.L37:
	xorl	%ebx, %ebx
.L32:
	cmpl	%ebx, nClusters(%rip)
	jle	.L38
	call	_Z22create_random_centroidv
	movl	%eax, %edx
	imulq	$12, %rbx, %rax
	addq	centroids(%rip), %rax
	incq	%rbx
	movl	%edx, 8(%rax)
	movq	%xmm0, (%rax)
	jmp	.L32
.L38:
	addq	$16, %rsp
	.cfi_def_cfa_offset 32
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2032:
	.size	_Z19init_clustered_datav, .-_Z19init_clustered_datav
	.section	.rodata.str1.1
.LC6:
	.string	"%f\t%f\t%d\t\n"
.LC7:
	.string	"\n\n"
	.text
	.globl	_Z10print_datav
	.type	_Z10print_datav, @function
_Z10print_datav:
.LFB2033:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	leaq	.LC6(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	xorl	%ebx, %ebx
	pushq	%rdx
	.cfi_def_cfa_offset 32
.L40:
	cmpl	%ebx, nPoints(%rip)
	jle	.L45
	imulq	$12, %rbx, %rax
	movq	%rbp, %rsi
	movl	$2, %edi
	incq	%rbx
	addq	points(%rip), %rax
	movl	8(%rax), %edx
	cvtss2sd	(%rax), %xmm0
	cvtss2sd	4(%rax), %xmm1
	movb	$2, %al
	call	__printf_chk@PLT
	jmp	.L40
.L45:
	leaq	.LC7(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	xorl	%ebx, %ebx
	call	__printf_chk@PLT
	leaq	.LC6(%rip), %rbp
.L42:
	cmpl	%ebx, nClusters(%rip)
	movl	%ebx, %edx
	jle	.L46
	imulq	$12, %rbx, %rax
	movq	%rbp, %rsi
	movl	$2, %edi
	incq	%rbx
	addq	centroids(%rip), %rax
	cvtss2sd	(%rax), %xmm0
	cvtss2sd	4(%rax), %xmm1
	movb	$2, %al
	call	__printf_chk@PLT
	jmp	.L42
.L46:
	popq	%rax
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2033:
	.size	_Z10print_datav, .-_Z10print_datav
	.section	.rodata.str1.1
.LC8:
	.string	"%04d.dat"
.LC9:
	.string	"w+"
	.text
	.globl	_Z18print_data_to_filei
	.type	_Z18print_data_to_filei, @function
_Z18print_data_to_filei:
.LFB2034:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movl	%edi, %r8d
	movl	$15, %edx
	movl	$2, %esi
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	leaq	.LC8(%rip), %rcx
	xorl	%ebp, %ebp
	leaq	.LC6(%rip), %r12
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	subq	$32, %rsp
	.cfi_def_cfa_offset 64
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	9(%rsp), %rbx
	movq	%rbx, %rdi
	call	__sprintf_chk@PLT
	movq	%rbx, %rdi
	leaq	.LC9(%rip), %rsi
	call	fopen@PLT
	movq	%rax, %rbx
.L48:
	cmpl	%ebp, nPoints(%rip)
	jle	.L54
	imulq	$12, %rbp, %rax
	movq	%r12, %rdx
	movl	$2, %esi
	movq	%rbx, %rdi
	addq	points(%rip), %rax
	incq	%rbp
	movl	8(%rax), %ecx
	cvtss2sd	(%rax), %xmm0
	cvtss2sd	4(%rax), %xmm1
	movb	$2, %al
	call	__fprintf_chk@PLT
	jmp	.L48
.L54:
	leaq	.LC7(%rip), %rdx
	movl	$2, %esi
	xorl	%eax, %eax
	xorl	%ebp, %ebp
	movq	%rbx, %rdi
	leaq	.LC6(%rip), %r12
	call	__fprintf_chk@PLT
.L50:
	cmpl	%ebp, nClusters(%rip)
	movl	%ebp, %ecx
	jle	.L55
	imulq	$12, %rbp, %rax
	movq	%r12, %rdx
	movl	$2, %esi
	movq	%rbx, %rdi
	addq	centroids(%rip), %rax
	incq	%rbp
	cvtss2sd	(%rax), %xmm0
	cvtss2sd	4(%rax), %xmm1
	movb	$2, %al
	call	__fprintf_chk@PLT
	jmp	.L50
.L55:
	movq	%rbx, %rdi
	call	fclose@PLT
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	je	.L52
	call	__stack_chk_fail@PLT
.L52:
	addq	$32, %rsp
	.cfi_def_cfa_offset 32
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2034:
	.size	_Z18print_data_to_filei, .-_Z18print_data_to_filei
	.globl	_Z8distance5Point8Centroid
	.type	_Z8distance5Point8Centroid, @function
_Z8distance5Point8Centroid:
.LFB2035:
	.cfi_startproc
	endbr64
	movq	%xmm1, -40(%rsp)
	movq	%xmm0, -24(%rsp)
	movss	-24(%rsp), %xmm0
	movss	-20(%rsp), %xmm1
	subss	-40(%rsp), %xmm0
	subss	-36(%rsp), %xmm1
	mulss	%xmm0, %xmm0
	mulss	%xmm1, %xmm1
	addss	%xmm1, %xmm0
	jmp	sqrtf@PLT
	.cfi_endproc
.LFE2035:
	.size	_Z8distance5Point8Centroid, .-_Z8distance5Point8Centroid
	.globl	_Z65__device_stub__Z25device_compute_centroids2P5PointP8CentroidPiS3_P5PointP8CentroidPiS3_
	.type	_Z65__device_stub__Z25device_compute_centroids2P5PointP8CentroidPiS3_P5PointP8CentroidPiS3_, @function
_Z65__device_stub__Z25device_compute_centroids2P5PointP8CentroidPiS3_P5PointP8CentroidPiS3_:
.LFB2061:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdi, 24(%rsp)
	leaq	56(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	68(%rsp), %rsi
	movq	%rdx, 8(%rsp)
	leaq	40(%rsp), %rdx
	movq	%rcx, (%rsp)
	leaq	48(%rsp), %rcx
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 64(%rsp)
	movq	%rax, 104(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 120(%rsp)
	movq	%rsp, %rax
	movq	%rax, 128(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 56(%rsp)
	movq	%rax, 68(%rsp)
	movl	$1, 76(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L57
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z25device_compute_centroids2P5PointP8CentroidPiS3_(%rip), %rdi
	pushq	48(%rsp)
	.cfi_def_cfa_offset 176
	movq	84(%rsp), %rcx
	movl	92(%rsp), %r8d
	movq	72(%rsp), %rsi
	movl	80(%rsp), %edx
	leaq	120(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 168
	popq	%rdx
	.cfi_def_cfa_offset 160
.L57:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L59
	call	__stack_chk_fail@PLT
.L59:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2061:
	.size	_Z65__device_stub__Z25device_compute_centroids2P5PointP8CentroidPiS3_P5PointP8CentroidPiS3_, .-_Z65__device_stub__Z25device_compute_centroids2P5PointP8CentroidPiS3_P5PointP8CentroidPiS3_
	.globl	_Z25device_compute_centroids2P5PointP8CentroidPiS3_
	.type	_Z25device_compute_centroids2P5PointP8CentroidPiS3_, @function
_Z25device_compute_centroids2P5PointP8CentroidPiS3_:
.LFB2062:
	.cfi_startproc
	endbr64
	jmp	_Z65__device_stub__Z25device_compute_centroids2P5PointP8CentroidPiS3_P5PointP8CentroidPiS3_
	.cfi_endproc
.LFE2062:
	.size	_Z25device_compute_centroids2P5PointP8CentroidPiS3_, .-_Z25device_compute_centroids2P5PointP8CentroidPiS3_
	.globl	_Z68__device_stub__Z25device_compute_centroids1P5PointP8CentroidPiS3_S3_P5PointP8CentroidPiS3_S3_
	.type	_Z68__device_stub__Z25device_compute_centroids1P5PointP8CentroidPiS3_S3_P5PointP8CentroidPiS3_S3_, @function
_Z68__device_stub__Z25device_compute_centroids1P5PointP8CentroidPiS3_S3_P5PointP8CentroidPiS3_S3_:
.LFB2063:
	.cfi_startproc
	endbr64
	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	.L62
	pushq	56(%rsp)
	.cfi_def_cfa_offset 184
	leaq	_Z25device_compute_centroids1P5PointP8CentroidPiS3_S3_(%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
.L62:
	movq	152(%rsp), %rax
	subq	%fs:40, %rax
	je	.L64
	call	__stack_chk_fail@PLT
.L64:
	addq	$168, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2063:
	.size	_Z68__device_stub__Z25device_compute_centroids1P5PointP8CentroidPiS3_S3_P5PointP8CentroidPiS3_S3_, .-_Z68__device_stub__Z25device_compute_centroids1P5PointP8CentroidPiS3_S3_P5PointP8CentroidPiS3_S3_
	.globl	_Z25device_compute_centroids1P5PointP8CentroidPiS3_S3_
	.type	_Z25device_compute_centroids1P5PointP8CentroidPiS3_S3_, @function
_Z25device_compute_centroids1P5PointP8CentroidPiS3_S3_:
.LFB2064:
	.cfi_startproc
	endbr64
	jmp	_Z68__device_stub__Z25device_compute_centroids1P5PointP8CentroidPiS3_S3_P5PointP8CentroidPiS3_S3_
	.cfi_endproc
.LFE2064:
	.size	_Z25device_compute_centroids1P5PointP8CentroidPiS3_S3_, .-_Z25device_compute_centroids1P5PointP8CentroidPiS3_S3_
	.globl	_Z68__device_stub__Z22device_reassign_pointsP5PointP8CentroidPiS3_S3_S3_P5PointP8CentroidPiS3_S3_S3_
	.type	_Z68__device_stub__Z22device_reassign_pointsP5PointP8CentroidPiS3_S3_S3_P5PointP8CentroidPiS3_S3_S3_, @function
_Z68__device_stub__Z22device_reassign_pointsP5PointP8CentroidPiS3_S3_S3_P5PointP8CentroidPiS3_S3_S3_:
.LFB2065:
	.cfi_startproc
	endbr64
	subq	$184, %rsp
	.cfi_def_cfa_offset 192
	movq	%rdi, 40(%rsp)
	leaq	72(%rsp), %rdi
	movq	%rsi, 32(%rsp)
	leaq	84(%rsp), %rsi
	movq	%rdx, 24(%rsp)
	leaq	56(%rsp), %rdx
	movq	%rcx, 16(%rsp)
	leaq	64(%rsp), %rcx
	movq	%r8, 8(%rsp)
	movq	%r9, (%rsp)
	movq	%fs:40, %rax
	movq	%rax, 168(%rsp)
	xorl	%eax, %eax
	leaq	40(%rsp), %rax
	movl	$1, 80(%rsp)
	movq	%rax, 120(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 128(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 136(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 144(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 152(%rsp)
	movq	%rsp, %rax
	movq	%rax, 160(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 72(%rsp)
	movq	%rax, 84(%rsp)
	movl	$1, 92(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L67
	pushq	64(%rsp)
	.cfi_def_cfa_offset 200
	leaq	_Z22device_reassign_pointsP5PointP8CentroidPiS3_S3_S3_(%rip), %rdi
	pushq	64(%rsp)
	.cfi_def_cfa_offset 208
	movq	100(%rsp), %rcx
	movl	108(%rsp), %r8d
	movq	88(%rsp), %rsi
	movl	96(%rsp), %edx
	leaq	136(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 200
	popq	%rdx
	.cfi_def_cfa_offset 192
.L67:
	movq	168(%rsp), %rax
	subq	%fs:40, %rax
	je	.L69
	call	__stack_chk_fail@PLT
.L69:
	addq	$184, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2065:
	.size	_Z68__device_stub__Z22device_reassign_pointsP5PointP8CentroidPiS3_S3_S3_P5PointP8CentroidPiS3_S3_S3_, .-_Z68__device_stub__Z22device_reassign_pointsP5PointP8CentroidPiS3_S3_S3_P5PointP8CentroidPiS3_S3_S3_
	.globl	_Z22device_reassign_pointsP5PointP8CentroidPiS3_S3_S3_
	.type	_Z22device_reassign_pointsP5PointP8CentroidPiS3_S3_S3_, @function
_Z22device_reassign_pointsP5PointP8CentroidPiS3_S3_S3_:
.LFB2066:
	.cfi_startproc
	endbr64
	jmp	_Z68__device_stub__Z22device_reassign_pointsP5PointP8CentroidPiS3_S3_S3_P5PointP8CentroidPiS3_S3_S3_
	.cfi_endproc
.LFE2066:
	.size	_Z22device_reassign_pointsP5PointP8CentroidPiS3_S3_S3_, .-_Z22device_reassign_pointsP5PointP8CentroidPiS3_S3_S3_
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2036:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	movabsq	$4294967297, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	movl	%edi, %ebx
	xorl	%edi, %edi
	subq	$88, %rsp
	.cfi_def_cfa_offset 128
	movq	%rsi, 8(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 72(%rsp)
	xorl	%eax, %eax
	call	srand@PLT
	movq	8(%rsp), %rsi
	movl	%ebx, %edi
	call	_Z10parse_argsiPPc
	call	_Z9init_datav
	movl	nPoints(%rip), %eax
	movl	$64, %ecx
	movslq	nPoints(%rip), %rsi
	leaq	input_points(%rip), %rdi
	movl	$64, 16(%rsp)
	cltd
	imulq	$12, %rsi, %rsi
	movq	%rbp, 28(%rsp)
	idivl	%ecx
	movl	$1, 44(%rsp)
	movl	%eax, 24(%rsp)
	movl	$67108865, %eax
	salq	$6, %rax
	movq	%rax, 36(%rsp)
	call	cudaMalloc@PLT
	movslq	nClusters(%rip), %rsi
	leaq	input_centroids(%rip), %rdi
	imulq	$12, %rsi, %rsi
	call	cudaMalloc@PLT
	movl	$4, %esi
	leaq	cuda_updated(%rip), %rdi
	call	cudaMalloc@PLT
	movl	$4, %esi
	leaq	cuda_nClusters(%rip), %rdi
	call	cudaMalloc@PLT
	movl	$4, %esi
	leaq	cuda_nPoints(%rip), %rdi
	call	cudaMalloc@PLT
	movl	$4, %esi
	leaq	cuda_nthreads(%rip), %rdi
	call	cudaMalloc@PLT
	movl	$1, %ecx
	movq	cuda_nClusters(%rip), %rdi
	movl	$4, %edx
	leaq	nClusters(%rip), %rsi
	call	cudaMemcpy@PLT
	movl	$1, %ecx
	movq	cuda_nPoints(%rip), %rdi
	movl	$4, %edx
	leaq	nPoints(%rip), %rsi
	call	cudaMemcpy@PLT
	leaq	16(%rsp), %rsi
	movl	$1, %ecx
	movq	cuda_nthreads(%rip), %rdi
	movl	$4, %edx
	call	cudaMemcpy@PLT
	movslq	nPoints(%rip), %rdx
	movl	$1, %ecx
	movq	points(%rip), %rsi
	movq	input_points(%rip), %rdi
	movl	$1, 20(%rsp)
	imulq	$12, %rdx, %rdx
	call	cudaMemcpy@PLT
	movslq	nClusters(%rip), %rdx
	movl	$1, %ecx
	movq	centroids(%rip), %rsi
	movq	input_centroids(%rip), %rdi
	imulq	$12, %rdx, %rdx
	call	cudaMemcpy@PLT
	movslq	16(%rsp), %r12
	movslq	nClusters(%rip), %rax
	addq	%rax, %r12
	imulq	$12, %r12, %r12
.L73:
	cmpl	$0, 20(%rsp)
	movq	input_points(%rip), %rdi
	je	.L83
	movslq	nPoints(%rip), %rdx
	movq	points(%rip), %rsi
	xorl	%eax, %eax
	movl	$1, %ecx
	movl	%eax, 20(%rsp)
	imulq	$12, %rdx, %rdx
	call	cudaMemcpy@PLT
	movq	%rbp, 52(%rsp)
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	nClusters(%rip), %eax
	movl	56(%rsp), %esi
	movq	%rbp, %rdx
	movl	$1, %ecx
	movq	%rbp, 60(%rsp)
	movl	%eax, 48(%rsp)
	movq	48(%rsp), %rdi
	movl	$1, 68(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L74
	movq	cuda_nPoints(%rip), %rcx
	movq	cuda_nClusters(%rip), %rdx
	movq	input_centroids(%rip), %rsi
	movq	input_points(%rip), %rdi
	call	_Z65__device_stub__Z25device_compute_centroids2P5PointP8CentroidPiS3_P5PointP8CentroidPiS3_
.L74:
	movslq	nClusters(%rip), %rdx
	movq	input_centroids(%rip), %rsi
	movl	$2, %ecx
	xorl	%r13d, %r13d
	movq	centroids(%rip), %rdi
	imulq	$12, %rdx, %rdx
	call	cudaMemcpy@PLT
.L75:
	movslq	nClusters(%rip), %rdx
	movq	centroids(%rip), %rsi
	cmpl	%r13d, %edx
	jle	.L84
	imulq	$12, %r13, %rax
	leaq	(%rsi,%rax), %rbx
	movl	8(%rbx), %eax
	testl	%eax, %eax
	jne	.L76
	call	_Z22create_random_centroidv
	movl	%eax, 8(%rbx)
	movq	%xmm0, (%rbx)
	jmp	.L77
.L76:
	cvtsi2ssl	%eax, %xmm1
	movss	(%rbx), %xmm0
	divss	%xmm1, %xmm0
	movss	%xmm0, (%rbx)
	movss	4(%rbx), %xmm0
	divss	%xmm1, %xmm0
	movss	%xmm0, 4(%rbx)
.L77:
	incq	%r13
	jmp	.L75
.L84:
	imulq	$12, %rdx, %rdx
	movq	input_centroids(%rip), %rdi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movl	44(%rsp), %ecx
	movl	32(%rsp), %esi
	xorl	%r9d, %r9d
	movq	36(%rsp), %rdx
	movq	24(%rsp), %rdi
	movq	%r12, %r8
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L79
	movq	cuda_nthreads(%rip), %r9
	movq	cuda_nPoints(%rip), %r8
	movq	cuda_nClusters(%rip), %rcx
	movq	cuda_updated(%rip), %rdx
	movq	input_centroids(%rip), %rsi
	movq	input_points(%rip), %rdi
	call	_Z68__device_stub__Z22device_reassign_pointsP5PointP8CentroidPiS3_S3_S3_P5PointP8CentroidPiS3_S3_S3_
.L79:
	movslq	nPoints(%rip), %rdx
	movq	input_points(%rip), %rsi
	movl	$2, %ecx
	movq	points(%rip), %rdi
	imulq	$12, %rdx, %rdx
	call	cudaMemcpy@PLT
	leaq	20(%rsp), %rdi
	movl	$2, %ecx
	movq	cuda_updated(%rip), %rsi
	movl	$4, %edx
	call	cudaMemcpy@PLT
	jmp	.L73
.L83:
	call	cudaFree@PLT
	movq	input_centroids(%rip), %rdi
	call	cudaFree@PLT
	movq	cuda_updated(%rip), %rdi
	call	cudaFree@PLT
	movq	cuda_nClusters(%rip), %rdi
	call	cudaFree@PLT
	movq	cuda_nPoints(%rip), %rdi
	call	cudaFree@PLT
	movq	cuda_nthreads(%rip), %rdi
	call	cudaFree@PLT
	call	_Z10print_datav
	movq	72(%rsp), %rax
	subq	%fs:40, %rax
	je	.L81
	call	__stack_chk_fail@PLT
.L81:
	addq	$88, %rsp
	.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
.LFE2036:
	.size	main, .-main
	.section	.rodata.str1.1
.LC10:
	.string	"_Z22device_reassign_pointsP5PointP8CentroidPiS3_S3_S3_"
.LC11:
	.string	"_Z25device_compute_centroids1P5PointP8CentroidPiS3_S3_"
.LC12:
	.string	"_Z25device_compute_centroids2P5PointP8CentroidPiS3_"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2068:
	.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	.LC10(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z22device_reassign_pointsP5PointP8CentroidPiS3_S3_S3_(%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	.LC11(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z25device_compute_centroids1P5PointP8CentroidPiS3_S3_(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 40
	pushq	$0
	.cfi_def_cfa_offset 48
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r9d, %r9d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC12(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z25device_compute_centroids2P5PointP8CentroidPiS3_(%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
.LFE2068:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.globl	cuda_nthreads
	.bss
	.align 8
	.type	cuda_nthreads, @object
	.size	cuda_nthreads, 8
cuda_nthreads:
	.zero	8
	.globl	cuda_nPoints
	.align 8
	.type	cuda_nPoints, @object
	.size	cuda_nPoints, 8
cuda_nPoints:
	.zero	8
	.globl	cuda_nClusters
	.align 8
	.type	cuda_nClusters, @object
	.size	cuda_nClusters, 8
cuda_nClusters:
	.zero	8
	.globl	cuda_updated
	.align 8
	.type	cuda_updated, @object
	.size	cuda_updated, 8
cuda_updated:
	.zero	8
	.globl	input_centroids
	.align 8
	.type	input_centroids, @object
	.size	input_centroids, 8
input_centroids:
	.zero	8
	.globl	input_points
	.align 8
	.type	input_points, @object
	.size	input_points, 8
input_points:
	.zero	8
	.globl	centroids
	.align 8
	.type	centroids, @object
	.size	centroids, 8
centroids:
	.zero	8
	.globl	points
	.align 8
	.type	points, @object
	.size	points, 8
points:
	.zero	8
	.globl	nClusters
	.align 4
	.type	nClusters, @object
	.size	nClusters, 4
nClusters:
	.zero	4
	.globl	nPoints
	.align 4
	.type	nPoints, @object
	.size	nPoints, 4
nPoints:
	.zero	4
	.section	.rodata.cst4,"aM",@progbits,4
	.align 4
.LC2:
	.long	805306368
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC3:
	.long	0
	.long	1083129856
	.align 8
.LC4:
	.long	0
	.long	1082081280
	.section	.rodata.cst4
	.align 4
.LC5:
	.long	1056964608
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

#include <stdio.h>
#include <stdlib.h>
#include <float.h>
#include <math.h>
#include <hip/hip_runtime.h>
#include <hiprand/hiprand.h>

// Type for points
typedef struct{
    float x;    // x coordinate
    float y;    // y coordinate
    int cluster; // cluster this point belongs to
} Point;

// Type for centroids
typedef struct{
    float x;    // x coordinate
    float y;    // y coordinate
    int nPoints; // number of points in this cluster
} Centroid;

// Global variables
int nPoints;   // Number of points
int nClusters; // Number of clusters/centroids

Point* points;       // Array containig all points
Centroid* centroids; // Array containing all centroids


// Reading command line arguments
void parse_args(int argc, char** argv){
    if(argc != 3){
        printf("Useage: kmeans nClusters nPoints\n");
        exit(-1);
    }
    nClusters = atoi(argv[1]);
    nPoints = atoi(argv[2]);

    if (nPoints < 64 || nClusters < 1) {
        printf("nClusters must be greater than 0\nnPoints must be greater than or equal to 64\n");
        exit(1);
    }
}


// Create random point
Point create_random_point(){
    Point p;
    p.x = ((float)rand() / (float)RAND_MAX) * 1000.0 - 500.0;
    p.y = ((float)rand() / (float)RAND_MAX) * 1000.0 - 500.0;
    p.cluster = rand() % nClusters;
    return p;
}

// Create random centroid
Centroid create_random_centroid(){
    Centroid p;
    p.x = ((float)rand() / (float)RAND_MAX) * 1000.0 - 500.0;
    p.y = ((float)rand() / (float)RAND_MAX) * 1000.0 - 500.0;
    p.nPoints = 0;
    return p;
}

__host__ Centroid device_create_random_centroid(){
    Centroid c;
    c.x = ((float)rand() / (float)RAND_MAX) * 1000.0 - 500.0;
    c.y = ((float)rand() / (float)RAND_MAX) * 1000.0 - 500.0;
    c.nPoints = 0;
    return c;
}


// Initialize random data
// Points will be uniformly distributed
void init_data(){
    points = (Point*)malloc(sizeof(Point)*nPoints);
    for(int i = 0; i < nPoints; i++){
        points[i] = create_random_point();
        if(i < nClusters){
            points[i].cluster = i;
        }
    }

    centroids = (Centroid*)malloc(sizeof(Centroid)*nClusters);
    for(int i = 0; i < nClusters; i++){
        centroids[i] = create_random_centroid();
    }
}

// Initialize random data
// Points will be placed in circular clusters 
void init_clustered_data(){
    float diameter = 500.0/sqrt(nClusters);

    centroids = (Centroid*)malloc(sizeof(Centroid)*nClusters);
    for(int i = 0; i < nClusters; i++){
        centroids[i] = create_random_centroid();
    }

    points = (Point*)malloc(sizeof(Point)*nPoints);
    for(int i = 0; i < nPoints; i++){
        points[i] = create_random_point();
        if(i < nClusters){
            points[i].cluster = i;
        }
    }

    for(int i = 0; i < nPoints; i++){
        int c = points[i].cluster;
        points[i].x = centroids[c].x + ((float)rand() / (float)RAND_MAX) * diameter - (diameter/2);
        points[i].y = centroids[c].y + ((float)rand() / (float)RAND_MAX) * diameter - (diameter/2);
        points[i].cluster = rand() % nClusters;
    }

    for(int i = 0; i < nClusters; i++){
        centroids[i] = create_random_centroid();
    }
}


// Print all points and centroids to standard output
void print_data(){
    for(int i = 0; i < nPoints; i++){
        printf("%f\t%f\t%d\t\n", points[i].x, points[i].y, points[i].cluster);
    }
    printf("\n\n");
    for(int i = 0; i < nClusters; i++){
        printf("%f\t%f\t%d\t\n", centroids[i].x, centroids[i].y, i);
    }
}

// Print all points and centroids to a file
// File name will be based on input argument
// Can be used to print result after each iteration
void print_data_to_file(int i){
    char filename[15];
    sprintf(filename, "%04d.dat", i);
    FILE* f = fopen(filename, "w+");

    for(int i = 0; i < nPoints; i++){
        fprintf(f, "%f\t%f\t%d\t\n", points[i].x, points[i].y, points[i].cluster);
    }
    fprintf(f,"\n\n");
    for(int i = 0; i < nClusters; i++){
        fprintf(f,"%f\t%f\t%d\t\n", centroids[i].x, centroids[i].y, i);
    }

    fclose(f);
}


// Computing distance between point and centroid
float distance(Point a, Centroid b){
    float dx = a.x - b.x;
    float dy = a.y - b.y;

    return sqrt(dx*dx + dy*dy);
}

// Cuda variables
Point *input_points;
Centroid *input_centroids;
int *cuda_updated;
int *cuda_nClusters;
int *cuda_nPoints;
int *cuda_nthreads;


__global__ void device_compute_centroids1(Point *d_points, Centroid *d_centroids, 
    int *d_nClusters, int *d_nPoints, int *d_nthreads);

__global__ void device_compute_centroids2(Point *d_points, Centroid *d_centroids, 
    int *d_nClusters, int *d_nPoints);

__global__ void device_reassign_points(Point *d_points, Centroid *d_centroids, 
    int *d_updated, int *d_nClusters, int *d_nPoints, int *d_nthreads);

int main(int argc, char** argv) {
    srand(0);
    parse_args(argc, argv);

    // Create random data, either function can be used.
    //init_clustered_data();
    init_data();

    int nThreadsPerBlock = 64;

    dim3 numBlocks, threadsPerBlock;
    numBlocks.x = nPoints / nThreadsPerBlock;
    threadsPerBlock.x = nThreadsPerBlock;

    // 1. Allocate buffers for the points and clusters
    hipMalloc((void**) &input_points, sizeof(Point) * nPoints);
    hipMalloc((void**) &input_centroids, sizeof(Centroid) * nClusters);
    hipMalloc((void**) &cuda_updated, sizeof(int));
    hipMalloc((void**) &cuda_nClusters, sizeof(int));
    hipMalloc((void**) &cuda_nPoints, sizeof(int));
    hipMalloc((void**) &cuda_nthreads, sizeof(int));

    hipMemcpy(cuda_nClusters, &nClusters, sizeof(int), hipMemcpyHostToDevice);
    hipMemcpy(cuda_nPoints, &nPoints, sizeof(int), hipMemcpyHostToDevice);
    hipMemcpy(cuda_nthreads, &nThreadsPerBlock, sizeof(int), hipMemcpyHostToDevice);

    // Iterate until no points are updated
    int updated = 1;
    
    hipMemcpy(input_points, points, sizeof(Point) * nPoints, hipMemcpyHostToDevice);
    hipMemcpy(input_centroids, centroids, sizeof(Centroid) * nClusters, hipMemcpyHostToDevice);

    size_t smem_size = sizeof(Point) * nThreadsPerBlock + sizeof(Centroid) * nClusters;

    // Because the 'device_compute_centroids1' function does not work correctly,
    // this variable is set to 0 to go for more serial appreach that works, 
    // but is slower (maybe even than a serial approach running on the host, 
    // because of the data movement between host and device. This of course, 
    // depends on the amount of Centroids.)
    int use_function1 = 0;

    while(updated) {
        updated = 0;

        if (use_function1) {
            // Transfer the points and clusters to device
            hipMemcpy(input_points, points, sizeof(Point) * nPoints, hipMemcpyHostToDevice);
            size_t size = sizeof(Centroid) * nThreadsPerBlock + sizeof(Point) * nPoints;
            // Reset centroid positions
            device_compute_centroids1<<<nClusters, threadsPerBlock, size>>>(input_points, 
                input_centroids, cuda_nClusters, cuda_nPoints, cuda_nthreads);
            // Transfer data to host
            hipMemcpy(centroids, input_centroids, sizeof(Centroid) * nClusters, 
                hipMemcpyDeviceToHost);
        } else {
            // Transfer the points and clusters to device
            hipMemcpy(input_points, points, sizeof(Point) * nPoints, hipMemcpyHostToDevice);
            // Reset centroid positions
            device_compute_centroids2<<<nClusters, 1>>>(input_points, input_centroids, 
                cuda_nClusters, cuda_nPoints);
            // Transfer data to host
            hipMemcpy(centroids, input_centroids, sizeof(Centroid) * nClusters, 
                hipMemcpyDeviceToHost);
        }

        // Because this function involes MATH rand(), it cannot be called from the kernel
        // By using the cuRand(), random numbers could have been generated on the device as well,
        // but it results in different results on host and device, and is thus hard to debug.
        for(int i = 0; i < nClusters; i++) {
            // If a centroid lost all its points, we give it a random position
            // (to avoid dividing by 0)
            if(centroids[i].nPoints == 0) {
                centroids[i] = create_random_centroid();
            }
            else {
                centroids[i].x /= centroids[i].nPoints;
                centroids[i].y /= centroids[i].nPoints;
            }
        }

        // Transfer the Centroids to the device, 
        // the Points is unchanged from the last time this function was called
        hipMemcpy(input_centroids, centroids, sizeof(Centroid) * nClusters, 
            hipMemcpyHostToDevice);
        // Reassign points
        device_reassign_points<<<numBlocks, threadsPerBlock, smem_size>>>(input_points, 
            input_centroids, cuda_updated, cuda_nClusters, cuda_nPoints, cuda_nthreads);
        // Transfer the points back to the host, the Centroids remains unchanged
        hipMemcpy(points, input_points, sizeof(Point) * nPoints, hipMemcpyDeviceToHost);
        hipMemcpy(&updated, cuda_updated, sizeof(int), hipMemcpyDeviceToHost);
    }

    hipFree(input_points);
    hipFree(input_centroids);
    hipFree(cuda_updated);
    hipFree(cuda_nClusters);
    hipFree(cuda_nPoints);
    hipFree(cuda_nthreads);

    print_data();
}

// A quite naive approach, without any use of reduction for the Points
// Some kind of reduction is tried implemented in the _next_ function, but the results
// is not completely satisfactory, thus this function is included as well.
// Note: set the variable 'use_function1' to 0 to call this function
__global__ void device_compute_centroids2(Point *d_points, Centroid *d_centroids, 
    int *d_nClusters, int *d_nPoints) 
{
    // extern __shared__ Centroid shared[];
    __shared__ Centroid s_centroid[1];

    int gid = blockIdx.x * blockDim.x; // + threadIdx.x
    
    int tid = threadIdx.x;

    // Reset centroid to 0
    s_centroid[tid] = (Centroid) {0.0, 0.0, 0};

    // Compute new centroids positions
    for (int i = 0; i < *d_nPoints; i++) {
        if (gid == d_points[i].cluster) {
            s_centroid[tid].x += d_points[i].x;
            s_centroid[tid].y += d_points[i].y;
            s_centroid[tid].nPoints++;
        }
    }
    // Transfer computed centroid back to global memory
    d_centroids[gid] = s_centroid[tid];
}

// This function is called for each of the Clusters, 64 threads run in parallel
// reducing all the points connected to the Cluster (identified by the block id)
// It does not seam to produce a 100% correct output, but sometimes look all right
// Note: set the variable 'use_function1' to 1 to call this function
__global__ void device_compute_centroids1(Point *d_points, Centroid *d_centroids, 
    int *d_nClusters, int *d_nPoints, int *d_nthreads) 
{
    extern __shared__ Centroid s_compute_centroids[];
    Centroid *s_centroid = s_compute_centroids;
    Point *s_points = (Point *) &s_centroid[*d_nthreads];

    int bid = blockIdx.x;
    int tid = threadIdx.x;

    // Reset centroid to 0
    s_centroid[tid] = (Centroid) {0.0, 0.0, 0};

    int length = *d_nPoints / *d_nthreads;
    int start = tid * length;
    int end = start + length;

    if (tid == 0 && length < 0) {
        for (int i = 0; i < *d_nPoints; i++) {
            s_points[i] = d_points[i];
        }
    } else {
        for (int i = start; i < end; i++) {
            s_points[i] = d_points[i];
        }
    }
    __syncthreads();

    // If the length is small (i.e. there is fewer points than 64),
    // thread 0 does all the work
    if (tid == 0 && length < 0) {
        for (int i = 0; i < *d_nPoints; i++) {
            int cluster_id = d_points[i].cluster;

            if (cluster_id == bid) {
                s_centroid[0].x += d_points[i].x;
                s_centroid[0].y += d_points[i].y;
                s_centroid[0].nPoints++;
            }
        }
    } else {
        // A kind of reduction, where each thread runs through it's dedicated part
        // of the Points array and checks to see if the points is connected to the 
        // corresponding block. If it is, each thread updates it's own centroid
        // in shared memory
        for (int i = start; i < end; i++) {
            int cluster_id = d_points[i].cluster;

            if (cluster_id == bid) {
                s_centroid[tid].x += d_points[i].x;
                s_centroid[tid].y += d_points[i].y;
                s_centroid[tid].nPoints += 1;
            }
        }
        __syncthreads();

        // Thread 0 goes over the centroids in shared memory, and sums them together
        if (tid == 0) {
            for (int i = 0; i < 64; i++) {
                s_centroid[0].x += s_centroid[i].x;
                s_centroid[0].y += s_centroid[i].y;
                s_centroid[0].nPoints += s_centroid[i].nPoints;
            }
        }
    }

    // Transfer computed centroid back to global memory
    if (tid == 0) {
        d_centroids[bid] = s_centroid[0];
    }
}

// This function is runs with one thread for every point, calculating what
// centroid the respective point belongs to
__global__ void device_reassign_points(Point *d_points, Centroid *d_centroids, 
    int *d_updated, int *d_nClusters, int *d_nPoints, int *d_nthreads) 
{
    // The shared memory consists of 64 points (1 for each thread per block), and 'd_nClusters' Centroids
    extern __shared__ Point s_reassign_points[];
    Point *s_points = s_reassign_points;
    Centroid *s_centroids = (Centroid *) &s_points[*d_nthreads];

    int gid = blockIdx.x * blockDim.x + threadIdx.x;
    int tid = threadIdx.x;

    // Make sure that updated is 0
    if (tid == 0) {
        *d_updated = 0;
    }

    // Init shared Points
    s_points[tid] = d_points[gid];

    // Init shared Centroids
    int length = *d_nClusters / *d_nthreads;
    int start = tid * length;
    int end = start + length;

    // If number of clusters is small, let thread 0 do all the work.
    // For some reason this initialization does not work in parallel, so thread 0 does all the work.
    if (tid == 0) {
        for (int i = 0; i < *d_nClusters; i++) {
            s_centroids[i] = d_centroids[i];
        }
    } 
    else if (length > 1 && 0) {
        for (int i = start; i < end; i++) {
            s_centroids[i] = d_centroids[i];
        }
    }
    __syncthreads();

    //Reassign points to closest centroid
    float bestDistance = DBL_MAX;
    int bestCluster = -1;

    for(int i = 0; i < *d_nClusters; i++) {
        Point a = s_points[tid];
        Centroid b = s_centroids[i];
        float dx = a.x - b.x;
        float dy = a.y - b.y;
        float d = sqrt(dx*dx + dy*dy);

        if(d < bestDistance) {
            bestDistance = d;
            bestCluster = i;
        }
    }

    // If one point got reassigned to a new cluster, we have to do another iteration
    if(bestCluster != s_points[tid].cluster) {
        *d_updated = 1;
    }

    // Update the points in the global memory
    d_points[gid].cluster = bestCluster;
}

	.text
	.file	"kmeans_cuda.hip"
	.globl	_Z10parse_argsiPPc              # -- Begin function _Z10parse_argsiPPc
	.type	_Z10parse_argsiPPc,@function
_Z10parse_argsiPPc:                     # @_Z10parse_argsiPPc
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	pushq	%rax
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -24
	.cfi_offset %rbp, -16
	cmpl	$3, %edi
	jne	.LBB0_4
# %bb.1:
	movq	%rsi, %rbx
	movq	8(%rsi), %rdi
	callq	atoi
	movl	%eax, %ebp
	movl	%eax, nClusters(%rip)
	movq	16(%rbx), %rdi
	callq	atoi
	movl	%eax, nPoints(%rip)
	cmpl	$64, %eax
	jl	.LBB0_5
# %bb.2:
	testl	%ebp, %ebp
	jle	.LBB0_5
# %bb.3:
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.LBB0_4:
	.cfi_def_cfa_offset 32
	movl	$.Lstr.1, %edi
	callq	puts@PLT
	movl	$-1, %edi
	callq	exit
.LBB0_5:
	movl	$.Lstr, %edi
	callq	puts@PLT
	movl	$1, %edi
	callq	exit
.Lfunc_end0:
	.size	_Z10parse_argsiPPc, .Lfunc_end0-_Z10parse_argsiPPc
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function _Z19create_random_pointv
.LCPI1_0:
	.long	0x30000000                      # float 4.65661287E-10
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0
.LCPI1_1:
	.quad	0x408f400000000000              # double 1000
.LCPI1_2:
	.quad	0xc07f400000000000              # double -500
	.text
	.globl	_Z19create_random_pointv
	.type	_Z19create_random_pointv,@function
_Z19create_random_pointv:               # @_Z19create_random_pointv
	.cfi_startproc
# %bb.0:
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	callq	rand
	cvtsi2ss	%eax, %xmm0
	mulss	.LCPI1_0(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	mulsd	.LCPI1_1(%rip), %xmm0
	addsd	.LCPI1_2(%rip), %xmm0
	cvtsd2ss	%xmm0, %xmm0
	movaps	%xmm0, 16(%rsp)                 # 16-byte Spill
	callq	rand
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	mulss	.LCPI1_0(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	mulsd	.LCPI1_1(%rip), %xmm0
	addsd	.LCPI1_2(%rip), %xmm0
	cvtsd2ss	%xmm0, %xmm0
	movaps	%xmm0, (%rsp)                   # 16-byte Spill
	callq	rand
	cltd
	idivl	nClusters(%rip)
	movl	%edx, %eax
	movaps	16(%rsp), %xmm0                 # 16-byte Reload
	unpcklps	(%rsp), %xmm0                   # 16-byte Folded Reload
                                        # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
	addq	$40, %rsp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end1:
	.size	_Z19create_random_pointv, .Lfunc_end1-_Z19create_random_pointv
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function _Z22create_random_centroidv
.LCPI2_0:
	.long	0x30000000                      # float 4.65661287E-10
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0
.LCPI2_1:
	.quad	0x408f400000000000              # double 1000
.LCPI2_2:
	.quad	0xc07f400000000000              # double -500
	.text
	.globl	_Z22create_random_centroidv
	.type	_Z22create_random_centroidv,@function
_Z22create_random_centroidv:            # @_Z22create_random_centroidv
	.cfi_startproc
# %bb.0:
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	callq	rand
	cvtsi2ss	%eax, %xmm0
	mulss	.LCPI2_0(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	mulsd	.LCPI2_1(%rip), %xmm0
	addsd	.LCPI2_2(%rip), %xmm0
	cvtsd2ss	%xmm0, %xmm0
	movaps	%xmm0, (%rsp)                   # 16-byte Spill
	callq	rand
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	mulss	.LCPI2_0(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	mulsd	.LCPI2_1(%rip), %xmm0
	addsd	.LCPI2_2(%rip), %xmm0
	cvtsd2ss	%xmm0, %xmm1
	movaps	(%rsp), %xmm0                   # 16-byte Reload
	unpcklps	%xmm1, %xmm0                    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
	xorl	%eax, %eax
	addq	$24, %rsp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end2:
	.size	_Z22create_random_centroidv, .Lfunc_end2-_Z22create_random_centroidv
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function _Z29device_create_random_centroidv
.LCPI3_0:
	.long	0x30000000                      # float 4.65661287E-10
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0
.LCPI3_1:
	.quad	0x408f400000000000              # double 1000
.LCPI3_2:
	.quad	0xc07f400000000000              # double -500
	.text
	.globl	_Z29device_create_random_centroidv
	.type	_Z29device_create_random_centroidv,@function
_Z29device_create_random_centroidv:     # @_Z29device_create_random_centroidv
	.cfi_startproc
# %bb.0:
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	callq	rand
	cvtsi2ss	%eax, %xmm0
	mulss	.LCPI3_0(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	mulsd	.LCPI3_1(%rip), %xmm0
	addsd	.LCPI3_2(%rip), %xmm0
	cvtsd2ss	%xmm0, %xmm0
	movaps	%xmm0, (%rsp)                   # 16-byte Spill
	callq	rand
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	mulss	.LCPI3_0(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	mulsd	.LCPI3_1(%rip), %xmm0
	addsd	.LCPI3_2(%rip), %xmm0
	cvtsd2ss	%xmm0, %xmm1
	movaps	(%rsp), %xmm0                   # 16-byte Reload
	unpcklps	%xmm1, %xmm0                    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
	xorl	%eax, %eax
	addq	$24, %rsp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end3:
	.size	_Z29device_create_random_centroidv, .Lfunc_end3-_Z29device_create_random_centroidv
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function _Z9init_datav
.LCPI4_0:
	.long	0x30000000                      # float 4.65661287E-10
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0
.LCPI4_1:
	.quad	0x408f400000000000              # double 1000
.LCPI4_2:
	.quad	0xc07f400000000000              # double -500
	.text
	.globl	_Z9init_datav
	.type	_Z9init_datav,@function
_Z9init_datav:                          # @_Z9init_datav
	.cfi_startproc
# %bb.0:
	pushq	%r14
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	subq	$24, %rsp
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -24
	.cfi_offset %r14, -16
	movslq	nPoints(%rip), %rbx
	leaq	(,%rbx,4), %rax
	leaq	(%rax,%rax,2), %rdi
	callq	malloc
	movq	%rax, points(%rip)
	testq	%rbx, %rbx
	jle	.LBB4_5
# %bb.1:                                # %.lr.ph.preheader
	movl	$8, %ebx
	xorl	%r14d, %r14d
.LBB4_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	callq	_Z19create_random_pointv
	movq	points(%rip), %rcx
	movlps	%xmm0, -8(%rcx,%rbx)
	movl	%eax, (%rcx,%rbx)
	movslq	nClusters(%rip), %rax
	cmpq	%rax, %r14
	jge	.LBB4_4
# %bb.3:                                #   in Loop: Header=BB4_2 Depth=1
	movq	points(%rip), %rax
	movl	%r14d, (%rax,%rbx)
.LBB4_4:                                #   in Loop: Header=BB4_2 Depth=1
	incq	%r14
	movslq	nPoints(%rip), %rax
	addq	$12, %rbx
	cmpq	%rax, %r14
	jl	.LBB4_2
.LBB4_5:                                # %._crit_edge
	movslq	nClusters(%rip), %rbx
	leaq	(,%rbx,4), %rax
	leaq	(%rax,%rax,2), %rdi
	callq	malloc
	movq	%rax, centroids(%rip)
	testq	%rbx, %rbx
	jle	.LBB4_8
# %bb.6:                                # %.lr.ph20.preheader
	movl	$8, %ebx
	xorl	%r14d, %r14d
.LBB4_7:                                # %.lr.ph20
                                        # =>This Inner Loop Header: Depth=1
	callq	rand
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	movss	.LCPI4_0(%rip), %xmm1           # xmm1 = mem[0],zero,zero,zero
	mulss	%xmm1, %xmm0
	cvtss2sd	%xmm0, %xmm0
	movsd	.LCPI4_1(%rip), %xmm1           # xmm1 = mem[0],zero
	mulsd	%xmm1, %xmm0
	movsd	.LCPI4_2(%rip), %xmm1           # xmm1 = mem[0],zero
	addsd	%xmm1, %xmm0
	cvtsd2ss	%xmm0, %xmm0
	movaps	%xmm0, (%rsp)                   # 16-byte Spill
	callq	rand
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	mulss	.LCPI4_0(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	mulsd	.LCPI4_1(%rip), %xmm0
	addsd	.LCPI4_2(%rip), %xmm0
	cvtsd2ss	%xmm0, %xmm0
	movaps	(%rsp), %xmm1                   # 16-byte Reload
	unpcklps	%xmm0, %xmm1                    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
	movq	centroids(%rip), %rax
	movlps	%xmm1, -8(%rax,%rbx)
	movl	$0, (%rax,%rbx)
	incq	%r14
	movslq	nClusters(%rip), %rax
	addq	$12, %rbx
	cmpq	%rax, %r14
	jl	.LBB4_7
.LBB4_8:                                # %._crit_edge21
	addq	$24, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end4:
	.size	_Z9init_datav, .Lfunc_end4-_Z9init_datav
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z19init_clustered_datav
.LCPI5_0:
	.quad	0x407f400000000000              # double 500
.LCPI5_2:
	.quad	0x408f400000000000              # double 1000
.LCPI5_3:
	.quad	0xc07f400000000000              # double -500
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0
.LCPI5_1:
	.long	0x30000000                      # float 4.65661287E-10
.LCPI5_4:
	.long	0x3f000000                      # float 0.5
	.text
	.globl	_Z19init_clustered_datav
	.type	_Z19init_clustered_datav,@function
_Z19init_clustered_datav:               # @_Z19init_clustered_datav
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	subq	$32, %rsp
	.cfi_def_cfa_offset 64
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	cvtsi2sdl	nClusters(%rip), %xmm0
	xorpd	%xmm1, %xmm1
	ucomisd	%xmm1, %xmm0
	jb	.LBB5_2
# %bb.1:
	sqrtsd	%xmm0, %xmm0
	jmp	.LBB5_3
.LBB5_2:                                # %call.sqrt
	callq	sqrt
.LBB5_3:                                # %.split
	movsd	%xmm0, 8(%rsp)                  # 8-byte Spill
	movslq	nClusters(%rip), %rbx
	leaq	(,%rbx,4), %rax
	leaq	(%rax,%rax,2), %rdi
	callq	malloc
	movq	%rax, centroids(%rip)
	testq	%rbx, %rbx
	jle	.LBB5_6
# %bb.4:                                # %.lr.ph.preheader
	movl	$8, %ebx
	xorl	%r14d, %r14d
.LBB5_5:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	callq	rand
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	movss	.LCPI5_1(%rip), %xmm1           # xmm1 = mem[0],zero,zero,zero
	mulss	%xmm1, %xmm0
	cvtss2sd	%xmm0, %xmm0
	movsd	.LCPI5_2(%rip), %xmm1           # xmm1 = mem[0],zero
	mulsd	%xmm1, %xmm0
	movsd	.LCPI5_3(%rip), %xmm1           # xmm1 = mem[0],zero
	addsd	%xmm1, %xmm0
	cvtsd2ss	%xmm0, %xmm0
	movaps	%xmm0, 16(%rsp)                 # 16-byte Spill
	callq	rand
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	mulss	.LCPI5_1(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	mulsd	.LCPI5_2(%rip), %xmm0
	addsd	.LCPI5_3(%rip), %xmm0
	cvtsd2ss	%xmm0, %xmm0
	movaps	16(%rsp), %xmm1                 # 16-byte Reload
	unpcklps	%xmm0, %xmm1                    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
	movq	centroids(%rip), %rax
	movlps	%xmm1, -8(%rax,%rbx)
	movl	$0, (%rax,%rbx)
	incq	%r14
	movslq	nClusters(%rip), %rax
	addq	$12, %rbx
	cmpq	%rax, %r14
	jl	.LBB5_5
.LBB5_6:                                # %._crit_edge
	movslq	nPoints(%rip), %rbx
	leaq	(,%rbx,4), %rax
	leaq	(%rax,%rax,2), %rdi
	callq	malloc
	movq	%rax, points(%rip)
	testq	%rbx, %rbx
	jle	.LBB5_14
# %bb.7:                                # %.lr.ph47.preheader
	movsd	.LCPI5_0(%rip), %xmm0           # xmm0 = mem[0],zero
	divsd	8(%rsp), %xmm0                  # 8-byte Folded Reload
	cvtsd2ss	%xmm0, %xmm0
	movss	%xmm0, 16(%rsp)                 # 4-byte Spill
	movl	$8, %ebx
	xorl	%r14d, %r14d
.LBB5_8:                                # %.lr.ph47
                                        # =>This Inner Loop Header: Depth=1
	callq	_Z19create_random_pointv
	movq	points(%rip), %rcx
	movlps	%xmm0, -8(%rcx,%rbx)
	movl	%eax, (%rcx,%rbx)
	movslq	nClusters(%rip), %rax
	cmpq	%rax, %r14
	jge	.LBB5_10
# %bb.9:                                #   in Loop: Header=BB5_8 Depth=1
	movq	points(%rip), %rax
	movl	%r14d, (%rax,%rbx)
.LBB5_10:                               #   in Loop: Header=BB5_8 Depth=1
	incq	%r14
	movslq	nPoints(%rip), %rax
	addq	$12, %rbx
	cmpq	%rax, %r14
	jl	.LBB5_8
# %bb.11:                               # %.preheader43
	testl	%eax, %eax
	jle	.LBB5_14
# %bb.12:                               # %.lr.ph49
	movss	.LCPI5_4(%rip), %xmm0           # xmm0 = mem[0],zero,zero,zero
	mulss	16(%rsp), %xmm0                 # 4-byte Folded Reload
	movss	%xmm0, 8(%rsp)                  # 4-byte Spill
	movq	points(%rip), %rax
	xorl	%ebx, %ebx
	xorl	%r14d, %r14d
.LBB5_13:                               # =>This Inner Loop Header: Depth=1
	movslq	8(%rax,%rbx), %rax
	movq	centroids(%rip), %rcx
	shlq	$2, %rax
	leaq	(%rax,%rax,2), %r15
	movss	(%rcx,%r15), %xmm0              # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, 4(%rsp)                  # 4-byte Spill
	callq	rand
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	movss	.LCPI5_1(%rip), %xmm1           # xmm1 = mem[0],zero,zero,zero
	mulss	%xmm1, %xmm0
	mulss	16(%rsp), %xmm0                 # 4-byte Folded Reload
	addss	4(%rsp), %xmm0                  # 4-byte Folded Reload
	subss	8(%rsp), %xmm0                  # 4-byte Folded Reload
	movq	points(%rip), %rax
	movss	%xmm0, (%rax,%rbx)
	movq	centroids(%rip), %rax
	movss	4(%rax,%r15), %xmm0             # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, 4(%rsp)                  # 4-byte Spill
	callq	rand
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	mulss	.LCPI5_1(%rip), %xmm0
	mulss	16(%rsp), %xmm0                 # 4-byte Folded Reload
	addss	4(%rsp), %xmm0                  # 4-byte Folded Reload
	subss	8(%rsp), %xmm0                  # 4-byte Folded Reload
	movq	points(%rip), %rax
	movss	%xmm0, 4(%rax,%rbx)
	callq	rand
	cltd
	idivl	nClusters(%rip)
	movq	points(%rip), %rax
	movl	%edx, 8(%rax,%rbx)
	incq	%r14
	movslq	nPoints(%rip), %rcx
	addq	$12, %rbx
	cmpq	%rcx, %r14
	jl	.LBB5_13
.LBB5_14:                               # %.preheader
	cmpl	$0, nClusters(%rip)
	jle	.LBB5_17
# %bb.15:                               # %.lr.ph51.preheader
	movl	$8, %ebx
	xorl	%r14d, %r14d
.LBB5_16:                               # %.lr.ph51
                                        # =>This Inner Loop Header: Depth=1
	callq	rand
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	movss	.LCPI5_1(%rip), %xmm1           # xmm1 = mem[0],zero,zero,zero
	mulss	%xmm1, %xmm0
	cvtss2sd	%xmm0, %xmm0
	movsd	.LCPI5_2(%rip), %xmm1           # xmm1 = mem[0],zero
	mulsd	%xmm1, %xmm0
	movsd	.LCPI5_3(%rip), %xmm1           # xmm1 = mem[0],zero
	addsd	%xmm1, %xmm0
	cvtsd2ss	%xmm0, %xmm0
	movaps	%xmm0, 16(%rsp)                 # 16-byte Spill
	callq	rand
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	mulss	.LCPI5_1(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	mulsd	.LCPI5_2(%rip), %xmm0
	addsd	.LCPI5_3(%rip), %xmm0
	cvtsd2ss	%xmm0, %xmm0
	movaps	16(%rsp), %xmm1                 # 16-byte Reload
	unpcklps	%xmm0, %xmm1                    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
	movq	centroids(%rip), %rax
	movlps	%xmm1, -8(%rax,%rbx)
	movl	$0, (%rax,%rbx)
	incq	%r14
	movslq	nClusters(%rip), %rax
	addq	$12, %rbx
	cmpq	%rax, %r14
	jl	.LBB5_16
.LBB5_17:                               # %._crit_edge52
	addq	$32, %rsp
	.cfi_def_cfa_offset 32
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end5:
	.size	_Z19init_clustered_datav, .Lfunc_end5-_Z19init_clustered_datav
	.cfi_endproc
                                        # -- End function
	.globl	_Z10print_datav                 # -- Begin function _Z10print_datav
	.type	_Z10print_datav,@function
_Z10print_datav:                        # @_Z10print_datav
	.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
	cmpl	$0, nPoints(%rip)
	jle	.LBB6_3
# %bb.1:                                # %.lr.ph.preheader
	movl	$8, %ebx
	xorl	%r14d, %r14d
.LBB6_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movq	points(%rip), %rax
	xorps	%xmm0, %xmm0
	cvtss2sd	-8(%rax,%rbx), %xmm0
	xorps	%xmm1, %xmm1
	cvtss2sd	-4(%rax,%rbx), %xmm1
	movl	(%rax,%rbx), %esi
	movl	$.L.str.2, %edi
	movb	$2, %al
	callq	printf
	incq	%r14
	movslq	nPoints(%rip), %rax
	addq	$12, %rbx
	cmpq	%rax, %r14
	jl	.LBB6_2
.LBB6_3:                                # %._crit_edge
	movl	$.Lstr.2, %edi
	callq	puts@PLT
	cmpl	$0, nClusters(%rip)
	jle	.LBB6_6
# %bb.4:                                # %.lr.ph14.preheader
	movl	$4, %r14d
	xorl	%ebx, %ebx
.LBB6_5:                                # %.lr.ph14
                                        # =>This Inner Loop Header: Depth=1
	movq	centroids(%rip), %rax
	xorps	%xmm0, %xmm0
	cvtss2sd	-4(%rax,%r14), %xmm0
	xorps	%xmm1, %xmm1
	cvtss2sd	(%rax,%r14), %xmm1
	movl	$.L.str.2, %edi
	movl	%ebx, %esi
	movb	$2, %al
	callq	printf
	incq	%rbx
	movslq	nClusters(%rip), %rax
	addq	$12, %r14
	cmpq	%rax, %rbx
	jl	.LBB6_5
.LBB6_6:                                # %._crit_edge15
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end6:
	.size	_Z10print_datav, .Lfunc_end6-_Z10print_datav
	.cfi_endproc
                                        # -- End function
	.globl	_Z18print_data_to_filei         # -- Begin function _Z18print_data_to_filei
	.type	_Z18print_data_to_filei,@function
_Z18print_data_to_filei:                # @_Z18print_data_to_filei
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	subq	$16, %rsp
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movl	%edi, %edx
	leaq	1(%rsp), %rbx
	movl	$.L.str.4, %esi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	callq	sprintf
	movl	$.L.str.5, %esi
	movq	%rbx, %rdi
	callq	fopen
	movq	%rax, %rbx
	cmpl	$0, nPoints(%rip)
	jle	.LBB7_3
# %bb.1:                                # %.lr.ph.preheader
	movl	$8, %r14d
	xorl	%r15d, %r15d
.LBB7_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movq	points(%rip), %rax
	xorps	%xmm0, %xmm0
	cvtss2sd	-8(%rax,%r14), %xmm0
	xorps	%xmm1, %xmm1
	cvtss2sd	-4(%rax,%r14), %xmm1
	movl	(%rax,%r14), %edx
	movl	$.L.str.2, %esi
	movq	%rbx, %rdi
	movb	$2, %al
	callq	fprintf
	incq	%r15
	movslq	nPoints(%rip), %rax
	addq	$12, %r14
	cmpq	%rax, %r15
	jl	.LBB7_2
.LBB7_3:                                # %._crit_edge
	movl	$.L.str.3, %edi
	movl	$2, %esi
	movl	$1, %edx
	movq	%rbx, %rcx
	callq	fwrite@PLT
	cmpl	$0, nClusters(%rip)
	jle	.LBB7_6
# %bb.4:                                # %.lr.ph18.preheader
	movl	$4, %r15d
	xorl	%r14d, %r14d
.LBB7_5:                                # %.lr.ph18
                                        # =>This Inner Loop Header: Depth=1
	movq	centroids(%rip), %rax
	xorps	%xmm0, %xmm0
	cvtss2sd	-4(%rax,%r15), %xmm0
	xorps	%xmm1, %xmm1
	cvtss2sd	(%rax,%r15), %xmm1
	movl	$.L.str.2, %esi
	movq	%rbx, %rdi
	movl	%r14d, %edx
	movb	$2, %al
	callq	fprintf
	incq	%r14
	movslq	nClusters(%rip), %rax
	addq	$12, %r15
	cmpq	%rax, %r14
	jl	.LBB7_5
.LBB7_6:                                # %._crit_edge19
	movq	%rbx, %rdi
	addq	$16, %rsp
	.cfi_def_cfa_offset 32
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	jmp	fclose                          # TAILCALL
.Lfunc_end7:
	.size	_Z18print_data_to_filei, .Lfunc_end7-_Z18print_data_to_filei
	.cfi_endproc
                                        # -- End function
	.globl	_Z8distance5Point8Centroid      # -- Begin function _Z8distance5Point8Centroid
	.type	_Z8distance5Point8Centroid,@function
_Z8distance5Point8Centroid:             # @_Z8distance5Point8Centroid
	.cfi_startproc
# %bb.0:
	subps	%xmm1, %xmm0
	mulps	%xmm0, %xmm0
	movaps	%xmm0, %xmm1
	shufps	$85, %xmm0, %xmm1               # xmm1 = xmm1[1,1],xmm0[1,1]
	addss	%xmm0, %xmm1
	xorps	%xmm0, %xmm0
	sqrtss	%xmm1, %xmm0
	retq
.Lfunc_end8:
	.size	_Z8distance5Point8Centroid, .Lfunc_end8-_Z8distance5Point8Centroid
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function main
.LCPI9_0:
	.long	0x30000000                      # float 4.65661287E-10
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0
.LCPI9_1:
	.quad	0x408f400000000000              # double 1000
.LCPI9_2:
	.quad	0xc07f400000000000              # double -500
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:                                # %.lr.ph51.preheader
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rsi, %rbx
	movl	%edi, %ebp
	movabsq	$4294967296, %r13               # imm = 0x100000000
	xorl	%edi, %edi
	callq	srand
	movl	%ebp, %edi
	movq	%rbx, %rsi
	callq	_Z10parse_argsiPPc
	callq	_Z9init_datav
	leaq	12(%rsp), %r14
	movl	$64, (%r14)
	movslq	nPoints(%rip), %rax
	leal	63(%rax), %ebx
	testl	%eax, %eax
	cmovnsl	%eax, %ebx
	sarl	$6, %ebx
	btsq	$32, %rbx
	shlq	$2, %rax
	leaq	(%rax,%rax,2), %rsi
	movl	$input_points, %edi
	callq	hipMalloc
	movslq	nClusters(%rip), %rax
	shlq	$2, %rax
	leaq	(%rax,%rax,2), %rsi
	movl	$input_centroids, %edi
	callq	hipMalloc
	movl	$cuda_updated, %edi
	movl	$4, %esi
	callq	hipMalloc
	movl	$cuda_nClusters, %edi
	movl	$4, %esi
	callq	hipMalloc
	movl	$cuda_nPoints, %edi
	movl	$4, %esi
	callq	hipMalloc
	movl	$cuda_nthreads, %edi
	movl	$4, %esi
	callq	hipMalloc
	movq	cuda_nClusters(%rip), %rdi
	movl	$nClusters, %esi
	movl	$4, %edx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	cuda_nPoints(%rip), %rdi
	movl	$nPoints, %esi
	movl	$4, %edx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	cuda_nthreads(%rip), %rdi
	movl	$4, %edx
	movq	%r14, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	movq	input_points(%rip), %rdi
	movq	points(%rip), %rsi
	movslq	nPoints(%rip), %rax
	shlq	$2, %rax
	leaq	(%rax,%rax,2), %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	input_centroids(%rip), %rdi
	movq	centroids(%rip), %rsi
	movslq	nClusters(%rip), %rax
	shlq	$2, %rax
	leaq	(%rax,%rax,2), %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movslq	(%r14), %rax
	movslq	nClusters(%rip), %rcx
	addq	%rax, %rcx
	shlq	$2, %rcx
	leaq	(%rcx,%rcx,2), %r14
	leaq	1(%r13), %r15
.LBB9_1:                                # %.lr.ph51
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB9_5 Depth 2
	movl	$0, 8(%rsp)
	movq	input_points(%rip), %rdi
	movq	points(%rip), %rsi
	movslq	nPoints(%rip), %rax
	shlq	$2, %rax
	leaq	(%rax,%rax,2), %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movl	nClusters(%rip), %edi
	orq	%r13, %rdi
	movl	$1, %esi
	movq	%r15, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB9_3
# %bb.2:                                #   in Loop: Header=BB9_1 Depth=1
	movq	input_points(%rip), %rdi
	movq	input_centroids(%rip), %rsi
	movq	cuda_nClusters(%rip), %rdx
	movq	cuda_nPoints(%rip), %rcx
	callq	_Z40__device_stub__device_compute_centroids2P5PointP8CentroidPiS3_
.LBB9_3:                                #   in Loop: Header=BB9_1 Depth=1
	movq	centroids(%rip), %rdi
	movq	input_centroids(%rip), %rsi
	movslq	nClusters(%rip), %rax
	shlq	$2, %rax
	leaq	(%rax,%rax,2), %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	movslq	nClusters(%rip), %rcx
	movq	centroids(%rip), %rsi
	testq	%rcx, %rcx
	jle	.LBB9_9
# %bb.4:                                # %.lr.ph.preheader
                                        #   in Loop: Header=BB9_1 Depth=1
	xorl	%ebp, %ebp
	movl	%ecx, %eax
	xorl	%r12d, %r12d
.LBB9_5:                                # %.lr.ph
                                        #   Parent Loop BB9_1 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	8(%rsi,%rbp), %ecx
	testl	%ecx, %ecx
	je	.LBB9_6
# %bb.7:                                #   in Loop: Header=BB9_5 Depth=2
	xorps	%xmm0, %xmm0
	cvtsi2ss	%ecx, %xmm0
	movss	(%rsi,%rbp), %xmm1              # xmm1 = mem[0],zero,zero,zero
	movss	4(%rsi,%rbp), %xmm2             # xmm2 = mem[0],zero,zero,zero
	divss	%xmm0, %xmm1
	movss	%xmm1, (%rsi,%rbp)
	divss	%xmm0, %xmm2
	movss	%xmm2, 4(%rsi,%rbp)
	jmp	.LBB9_8
.LBB9_6:                                #   in Loop: Header=BB9_5 Depth=2
	callq	rand
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	movss	.LCPI9_0(%rip), %xmm1           # xmm1 = mem[0],zero,zero,zero
	mulss	%xmm1, %xmm0
	cvtss2sd	%xmm0, %xmm0
	movsd	.LCPI9_1(%rip), %xmm1           # xmm1 = mem[0],zero
	mulsd	%xmm1, %xmm0
	movsd	.LCPI9_2(%rip), %xmm1           # xmm1 = mem[0],zero
	addsd	%xmm1, %xmm0
	cvtsd2ss	%xmm0, %xmm0
	movaps	%xmm0, 16(%rsp)                 # 16-byte Spill
	callq	rand
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	mulss	.LCPI9_0(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	mulsd	.LCPI9_1(%rip), %xmm0
	addsd	.LCPI9_2(%rip), %xmm0
	cvtsd2ss	%xmm0, %xmm0
	movaps	16(%rsp), %xmm1                 # 16-byte Reload
	unpcklps	%xmm0, %xmm1                    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
	movq	centroids(%rip), %rax
	movlps	%xmm1, (%rax,%rbp)
	movl	$0, 8(%rax,%rbp)
	movq	centroids(%rip), %rsi
	movl	nClusters(%rip), %eax
.LBB9_8:                                #   in Loop: Header=BB9_5 Depth=2
	incq	%r12
	movslq	%eax, %rcx
	addq	$12, %rbp
	cmpq	%rcx, %r12
	jl	.LBB9_5
.LBB9_9:                                # %._crit_edge
                                        #   in Loop: Header=BB9_1 Depth=1
	movq	input_centroids(%rip), %rdi
	shlq	$2, %rcx
	leaq	(%rcx,%rcx,2), %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	leaq	64(%r13), %rdx
	movq	%rbx, %rdi
	movl	$1, %esi
	movl	$1, %ecx
	movq	%r14, %r8
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB9_11
# %bb.10:                               #   in Loop: Header=BB9_1 Depth=1
	movq	input_points(%rip), %rdi
	movq	input_centroids(%rip), %rsi
	movq	cuda_updated(%rip), %rdx
	movq	cuda_nClusters(%rip), %rcx
	movq	cuda_nPoints(%rip), %r8
	movq	cuda_nthreads(%rip), %r9
	callq	_Z37__device_stub__device_reassign_pointsP5PointP8CentroidPiS3_S3_S3_
.LBB9_11:                               #   in Loop: Header=BB9_1 Depth=1
	movq	points(%rip), %rdi
	movq	input_points(%rip), %rsi
	movslq	nPoints(%rip), %rax
	shlq	$2, %rax
	leaq	(%rax,%rax,2), %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	movq	cuda_updated(%rip), %rsi
	movl	$4, %edx
	leaq	8(%rsp), %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	cmpl	$0, 8(%rsp)
	jne	.LBB9_1
# %bb.12:                               # %._crit_edge52
	movq	input_points(%rip), %rdi
	callq	hipFree
	movq	input_centroids(%rip), %rdi
	callq	hipFree
	movq	cuda_updated(%rip), %rdi
	callq	hipFree
	movq	cuda_nClusters(%rip), %rdi
	callq	hipFree
	movq	cuda_nPoints(%rip), %rdi
	callq	hipFree
	movq	cuda_nthreads(%rip), %rdi
	callq	hipFree
	callq	_Z10print_datav
	xorl	%eax, %eax
	addq	$40, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end9:
	.size	main, .Lfunc_end9-main
	.cfi_endproc
                                        # -- End function
	.globl	_Z40__device_stub__device_compute_centroids1P5PointP8CentroidPiS3_S3_ # -- Begin function _Z40__device_stub__device_compute_centroids1P5PointP8CentroidPiS3_S3_
	.type	_Z40__device_stub__device_compute_centroids1P5PointP8CentroidPiS3_S3_,@function
_Z40__device_stub__device_compute_centroids1P5PointP8CentroidPiS3_S3_: # @_Z40__device_stub__device_compute_centroids1P5PointP8CentroidPiS3_S3_
	.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	$_Z25device_compute_centroids1P5PointP8CentroidPiS3_S3_, %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_end10:
	.size	_Z40__device_stub__device_compute_centroids1P5PointP8CentroidPiS3_S3_, .Lfunc_end10-_Z40__device_stub__device_compute_centroids1P5PointP8CentroidPiS3_S3_
	.cfi_endproc
                                        # -- End function
	.globl	_Z40__device_stub__device_compute_centroids2P5PointP8CentroidPiS3_ # -- Begin function _Z40__device_stub__device_compute_centroids2P5PointP8CentroidPiS3_
	.type	_Z40__device_stub__device_compute_centroids2P5PointP8CentroidPiS3_,@function
_Z40__device_stub__device_compute_centroids2P5PointP8CentroidPiS3_: # @_Z40__device_stub__device_compute_centroids2P5PointP8CentroidPiS3_
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$112, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	32(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	24(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	16(%rsp), %rdx
	movq	%rcx, (%rdx)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	8(%rsp), %r12
	movq	%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	$_Z25device_compute_centroids2P5PointP8CentroidPiS3_, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$128, %rsp
	.cfi_adjust_cfa_offset -128
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end11:
	.size	_Z40__device_stub__device_compute_centroids2P5PointP8CentroidPiS3_, .Lfunc_end11-_Z40__device_stub__device_compute_centroids2P5PointP8CentroidPiS3_
	.cfi_endproc
                                        # -- End function
	.globl	_Z37__device_stub__device_reassign_pointsP5PointP8CentroidPiS3_S3_S3_ # -- Begin function _Z37__device_stub__device_reassign_pointsP5PointP8CentroidPiS3_S3_S3_
	.type	_Z37__device_stub__device_reassign_pointsP5PointP8CentroidPiS3_S3_S3_,@function
_Z37__device_stub__device_reassign_pointsP5PointP8CentroidPiS3_S3_S3_: # @_Z37__device_stub__device_reassign_pointsP5PointP8CentroidPiS3_S3_S3_
	.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	16(%rsp), %r8
	movq	%r9, (%r8)
	leaq	96(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	movq	%rcx, 32(%rbx)
	movq	%r8, 40(%rbx)
	leaq	80(%rsp), %r14
	leaq	64(%rsp), %r15
	leaq	8(%rsp), %r12
	movq	%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	$_Z22device_reassign_pointsP5PointP8CentroidPiS3_S3_S3_, %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_end12:
	.size	_Z37__device_stub__device_reassign_pointsP5PointP8CentroidPiS3_S3_S3_, .Lfunc_end12-_Z37__device_stub__device_reassign_pointsP5PointP8CentroidPiS3_S3_S3_
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$32, %rsp
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -16
	movq	__hip_gpubin_handle(%rip), %rbx
	testq	%rbx, %rbx
	jne	.LBB13_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB13_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z25device_compute_centroids2P5PointP8CentroidPiS3_, %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	$_Z25device_compute_centroids1P5PointP8CentroidPiS3_S3_, %esi
	movl	$.L__unnamed_2, %edx
	movl	$.L__unnamed_2, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z22device_reassign_pointsP5PointP8CentroidPiS3_S3_S3_, %esi
	movl	$.L__unnamed_3, %edx
	movl	$.L__unnamed_3, %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_end13:
	.size	__hip_module_ctor, .Lfunc_end13-__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	.LBB14_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
.LBB14_2:
	retq
.Lfunc_end14:
	.size	__hip_module_dtor, .Lfunc_end14-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	nPoints,@object                 # @nPoints
	.bss
	.globl	nPoints
	.p2align	2, 0x0
nPoints:
	.long	0                               # 0x0
	.size	nPoints, 4

	.type	nClusters,@object               # @nClusters
	.globl	nClusters
	.p2align	2, 0x0
nClusters:
	.long	0                               # 0x0
	.size	nClusters, 4

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

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

	.type	.L.str.2,@object                # @.str.2
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.2:
	.asciz	"%f\t%f\t%d\t\n"
	.size	.L.str.2, 11

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

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"%04d.dat"
	.size	.L.str.4, 9

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"w+"
	.size	.L.str.5, 3

	.type	input_points,@object            # @input_points
	.bss
	.globl	input_points
	.p2align	3, 0x0
input_points:
	.quad	0
	.size	input_points, 8

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

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

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

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

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

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

	.type	_Z25device_compute_centroids2P5PointP8CentroidPiS3_,@object # @_Z25device_compute_centroids2P5PointP8CentroidPiS3_
	.globl	_Z25device_compute_centroids2P5PointP8CentroidPiS3_
	.p2align	3, 0x0
_Z25device_compute_centroids2P5PointP8CentroidPiS3_:
	.quad	_Z40__device_stub__device_compute_centroids2P5PointP8CentroidPiS3_
	.size	_Z25device_compute_centroids2P5PointP8CentroidPiS3_, 8

	.type	_Z22device_reassign_pointsP5PointP8CentroidPiS3_S3_S3_,@object # @_Z22device_reassign_pointsP5PointP8CentroidPiS3_S3_S3_
	.globl	_Z22device_reassign_pointsP5PointP8CentroidPiS3_S3_S3_
	.p2align	3, 0x0
_Z22device_reassign_pointsP5PointP8CentroidPiS3_S3_S3_:
	.quad	_Z37__device_stub__device_reassign_pointsP5PointP8CentroidPiS3_S3_S3_
	.size	_Z22device_reassign_pointsP5PointP8CentroidPiS3_S3_S3_, 8

	.type	.L__unnamed_1,@object           # @0
	.section	.rodata.str1.1,"aMS",@progbits,1
.L__unnamed_1:
	.asciz	"_Z25device_compute_centroids2P5PointP8CentroidPiS3_"
	.size	.L__unnamed_1, 52

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z25device_compute_centroids1P5PointP8CentroidPiS3_S3_"
	.size	.L__unnamed_2, 55

	.type	.L__unnamed_3,@object           # @2
.L__unnamed_3:
	.asciz	"_Z22device_reassign_pointsP5PointP8CentroidPiS3_S3_S3_"
	.size	.L__unnamed_3, 55

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

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

	.type	.Lstr,@object                   # @str
	.section	.rodata.str1.1,"aMS",@progbits,1
.Lstr:
	.asciz	"nClusters must be greater than 0\nnPoints must be greater than or equal to 64"
	.size	.Lstr, 77

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"Useage: kmeans nClusters nPoints"
	.size	.Lstr.1, 33

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

	.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 _Z40__device_stub__device_compute_centroids1P5PointP8CentroidPiS3_S3_
	.addrsig_sym _Z40__device_stub__device_compute_centroids2P5PointP8CentroidPiS3_
	.addrsig_sym _Z37__device_stub__device_reassign_pointsP5PointP8CentroidPiS3_S3_S3_
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym nPoints
	.addrsig_sym nClusters
	.addrsig_sym input_points
	.addrsig_sym input_centroids
	.addrsig_sym cuda_updated
	.addrsig_sym cuda_nClusters
	.addrsig_sym cuda_nPoints
	.addrsig_sym cuda_nthreads
	.addrsig_sym _Z25device_compute_centroids1P5PointP8CentroidPiS3_S3_
	.addrsig_sym _Z25device_compute_centroids2P5PointP8CentroidPiS3_
	.addrsig_sym _Z22device_reassign_pointsP5PointP8CentroidPiS3_S3_S3_
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z25device_compute_centroids2P5PointP8CentroidPiS3_ ; -- Begin function _Z25device_compute_centroids2P5PointP8CentroidPiS3_
	.globl	_Z25device_compute_centroids2P5PointP8CentroidPiS3_
	.p2align	8
	.type	_Z25device_compute_centroids2P5PointP8CentroidPiS3_,@function
_Z25device_compute_centroids2P5PointP8CentroidPiS3_: ; @_Z25device_compute_centroids2P5PointP8CentroidPiS3_
; %bb.0:
	s_clause 0x1
	s_load_b64 s[2:3], s[0:1], 0x18
	s_load_b32 s4, s[0:1], 0x2c
	v_mul_u32_u24_e32 v1, 12, v0
	v_mov_b32_e32 v0, 0
	s_mov_b32 s6, 0
	s_waitcnt lgkmcnt(0)
	s_load_b32 s5, s[2:3], 0x0
	s_load_b128 s[0:3], s[0:1], 0x0
	s_and_b32 s4, s4, 0xffff
	ds_store_2addr_b32 v1, v0, v0 offset1:1
	ds_store_b32 v1, v0 offset:8
	s_mul_i32 s4, s15, s4
	s_waitcnt lgkmcnt(0)
	s_cmp_lt_i32 s5, 1
	s_cbranch_scc1 .LBB0_5
; %bb.1:                                ; %.lr.ph.preheader
	v_dual_mov_b32 v2, 0 :: v_dual_mov_b32 v3, 0
	s_add_u32 s0, s0, 4
	s_addc_u32 s1, s1, 0
.LBB0_2:                                ; %.lr.ph
                                        ; =>This Inner Loop Header: Depth=1
	s_load_b32 s7, s[0:1], 0x4
	s_waitcnt lgkmcnt(0)
	s_cmp_lg_u32 s4, s7
	s_cbranch_scc1 .LBB0_4
; %bb.3:                                ;   in Loop: Header=BB0_2 Depth=1
	s_add_u32 s8, s0, -4
	s_addc_u32 s9, s1, -1
	s_add_i32 s6, s6, 1
	s_load_b64 s[8:9], s[8:9], 0x0
	s_waitcnt lgkmcnt(0)
	v_dual_mov_b32 v4, s6 :: v_dual_add_f32 v3, s8, v3
	v_add_f32_e32 v2, s9, v2
	ds_store_2addr_b32 v1, v3, v2 offset1:1
	ds_store_b32 v1, v4 offset:8
.LBB0_4:                                ;   in Loop: Header=BB0_2 Depth=1
	s_add_i32 s5, s5, -1
	s_add_u32 s0, s0, 12
	s_addc_u32 s1, s1, 0
	s_cmp_eq_u32 s5, 0
	s_cbranch_scc0 .LBB0_2
.LBB0_5:                                ; %._crit_edge
	ds_load_b32 v3, v1 offset:8
	ds_load_2addr_b32 v[1:2], v1 offset1:1
	s_mul_i32 s0, s4, 12
	s_mul_hi_i32 s1, s4, 12
	s_add_u32 s0, s2, s0
	s_addc_u32 s1, s3, s1
	s_waitcnt lgkmcnt(0)
	global_store_b96 v0, v[1:3], s[0:1]
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z25device_compute_centroids2P5PointP8CentroidPiS3_
		.amdhsa_group_segment_fixed_size 12
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 288
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 5
		.amdhsa_next_free_sgpr 16
		.amdhsa_reserve_vcc 0
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end0:
	.size	_Z25device_compute_centroids2P5PointP8CentroidPiS3_, .Lfunc_end0-_Z25device_compute_centroids2P5PointP8CentroidPiS3_
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 256
; NumSgprs: 16
; NumVgprs: 5
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 12 bytes/workgroup (compile time only)
; SGPRBlocks: 1
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 16
; NumVGPRsForWavesPerEU: 5
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.protected	_Z25device_compute_centroids1P5PointP8CentroidPiS3_S3_ ; -- Begin function _Z25device_compute_centroids1P5PointP8CentroidPiS3_S3_
	.globl	_Z25device_compute_centroids1P5PointP8CentroidPiS3_S3_
	.p2align	8
	.type	_Z25device_compute_centroids1P5PointP8CentroidPiS3_S3_,@function
_Z25device_compute_centroids1P5PointP8CentroidPiS3_S3_: ; @_Z25device_compute_centroids1P5PointP8CentroidPiS3_S3_
; %bb.0:
	s_load_b128 s[8:11], s[0:1], 0x18
	v_mad_u32_u24 v3, v0, 12, 0
	v_cmp_eq_u32_e32 vcc_lo, 0, v0
	s_waitcnt lgkmcnt(0)
	s_load_b32 s10, s[10:11], 0x0
	s_waitcnt lgkmcnt(0)
	s_ashr_i32 s3, s10, 31
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_add_i32 s2, s10, s3
	s_xor_b32 s4, s2, s3
	s_load_b32 s2, s[8:9], 0x0
	v_cvt_f32_u32_e32 v1, s4
	s_sub_i32 s6, 0, s4
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_4) | instid1(VALU_DEP_1)
	v_rcp_iflag_f32_e32 v1, v1
	s_waitcnt_depctr 0xfff
	v_mul_f32_e32 v1, 0x4f7ffffe, v1
	s_waitcnt lgkmcnt(0)
	s_ashr_i32 s7, s2, 31
	v_cvt_u32_f32_e32 v1, v1
	s_add_i32 s11, s2, s7
	s_xor_b32 s3, s7, s3
	s_xor_b32 s11, s11, s7
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_4) | instid1(SALU_CYCLE_1)
	v_readfirstlane_b32 s5, v1
	v_mov_b32_e32 v1, 0
	ds_store_2addr_b32 v3, v1, v1 offset1:1
	ds_store_b32 v3, v1 offset:8
	s_mul_i32 s6, s6, s5
	s_mul_hi_u32 s6, s5, s6
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_add_i32 s5, s5, s6
	s_mul_hi_u32 s5, s11, s5
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_2) | instid1(SALU_CYCLE_1)
	s_mul_i32 s6, s5, s4
	s_add_i32 s7, s5, 1
	s_sub_i32 s6, s11, s6
	s_sub_i32 s11, s6, s4
	s_cmp_ge_u32 s6, s4
	s_cselect_b32 s12, s7, s5
	s_cselect_b32 s5, s11, s6
	s_add_i32 s11, s12, 1
	s_cmp_ge_u32 s5, s4
	s_load_b128 s[4:7], s[0:1], 0x0
	s_cselect_b32 s0, s11, s12
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_xor_b32 s0, s0, s3
	s_sub_i32 s3, s0, s3
	v_cmp_ne_u32_e64 s0, 0, v0
	v_mul_lo_u32 v2, s3, v0
	s_cmp_gt_i32 s3, -1
	s_cselect_b32 s1, -1, 0
	s_delay_alu instid0(VALU_DEP_2) | instid1(SALU_CYCLE_1)
	s_or_b32 s11, s0, s1
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(SALU_CYCLE_1)
	v_add_nc_u32_e32 v4, s3, v2
	s_and_saveexec_b32 s0, s11
	s_xor_b32 s1, exec_lo, s0
	s_cbranch_execz .LBB1_5
; %bb.1:                                ; %.preheader93
	s_cmp_lt_i32 s3, 1
	s_cbranch_scc1 .LBB1_5
; %bb.2:                                ; %.lr.ph.preheader
	v_mul_lo_u32 v5, v2, 12
	s_waitcnt lgkmcnt(0)
	v_mad_u64_u32 v[0:1], null, v2, 12, s[4:5]
	s_mul_i32 s0, s10, 12
	v_mov_b32_e32 v6, v2
	s_mov_b32 s12, 0
	s_delay_alu instid0(VALU_DEP_3)
	v_add3_u32 v5, 0, s0, v5
.LBB1_3:                                ; %.lr.ph
                                        ; =>This Inner Loop Header: Depth=1
	global_load_b96 v[7:9], v[0:1], off
	v_add_nc_u32_e32 v6, 1, v6
	v_add_co_u32 v0, s0, v0, 12
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_co_ci_u32_e64 v1, s0, 0, v1, s0
	v_cmp_ge_i32_e64 s0, v6, v4
	s_waitcnt vmcnt(0)
	ds_store_2addr_b32 v5, v7, v8 offset1:1
	ds_store_b32 v5, v9 offset:8
	v_add_nc_u32_e32 v5, 12, v5
	s_or_b32 s12, s0, s12
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_not1_b32 exec_lo, exec_lo, s12
	s_cbranch_execnz .LBB1_3
; %bb.4:                                ; %Flow163
	s_or_b32 exec_lo, exec_lo, s12
.LBB1_5:                                ; %Flow167
	s_and_not1_saveexec_b32 s12, s1
	s_cbranch_execz .LBB1_9
; %bb.6:                                ; %.preheader91
	s_cmp_lt_i32 s2, 1
	s_cbranch_scc1 .LBB1_9
; %bb.7:                                ; %.lr.ph97.preheader
	v_mov_b32_e32 v0, 0
	s_mul_i32 s10, s10, 12
	s_waitcnt lgkmcnt(0)
	s_mov_b64 s[0:1], s[4:5]
	s_add_i32 s10, s10, 0
.LBB1_8:                                ; %.lr.ph97
                                        ; =>This Inner Loop Header: Depth=1
	global_load_b96 v[5:7], v0, s[0:1]
	v_mov_b32_e32 v1, s10
	s_add_i32 s2, s2, -1
	s_add_u32 s0, s0, 12
	s_addc_u32 s1, s1, 0
	s_add_i32 s10, s10, 12
	s_cmp_eq_u32 s2, 0
	s_waitcnt vmcnt(0)
	ds_store_2addr_b32 v1, v5, v6 offset1:1
	ds_store_b32 v1, v7 offset:8
	s_cbranch_scc0 .LBB1_8
.LBB1_9:                                ; %.loopexit92
	s_or_b32 exec_lo, exec_lo, s12
	s_mov_b32 s10, 0
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	s_and_saveexec_b32 s0, s11
	s_delay_alu instid0(SALU_CYCLE_1)
	s_xor_b32 s2, exec_lo, s0
	s_cbranch_execz .LBB1_21
; %bb.10:                               ; %.preheader90
	s_cmp_lt_i32 s3, 1
	s_cbranch_scc1 .LBB1_16
; %bb.11:                               ; %.lr.ph99.preheader
	v_mad_u64_u32 v[0:1], null, v2, 12, s[4:5]
	s_mov_b32 s3, 0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_co_u32 v0, s0, v0, 4
	v_add_co_ci_u32_e64 v1, s0, 0, v1, s0
.LBB1_12:                               ; %.lr.ph99
                                        ; =>This Inner Loop Header: Depth=1
	global_load_b32 v5, v[0:1], off offset:4
	s_mov_b32 s1, exec_lo
	s_waitcnt vmcnt(0)
	v_cmpx_eq_u32_e64 s15, v5
	s_cbranch_execz .LBB1_14
; %bb.13:                               ;   in Loop: Header=BB1_12 Depth=1
	global_load_b64 v[5:6], v[0:1], off offset:-4
	ds_load_2addr_b32 v[7:8], v3 offset1:1
	ds_load_b32 v9, v3 offset:8
	s_waitcnt vmcnt(0) lgkmcnt(1)
	v_dual_add_f32 v5, v5, v7 :: v_dual_add_f32 v6, v6, v8
	s_waitcnt lgkmcnt(0)
	v_add_nc_u32_e32 v7, 1, v9
	ds_store_2addr_b32 v3, v5, v6 offset1:1
	ds_store_b32 v3, v7 offset:8
.LBB1_14:                               ;   in Loop: Header=BB1_12 Depth=1
	s_or_b32 exec_lo, exec_lo, s1
	v_add_nc_u32_e32 v2, 1, v2
	v_add_co_u32 v0, s1, v0, 12
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_co_ci_u32_e64 v1, s1, 0, v1, s1
	v_cmp_ge_i32_e64 s0, v2, v4
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_or_b32 s3, s0, s3
	s_and_not1_b32 exec_lo, exec_lo, s3
	s_cbranch_execnz .LBB1_12
; %bb.15:                               ; %Flow155
	s_or_b32 exec_lo, exec_lo, s3
.LBB1_16:                               ; %._crit_edge
	s_mov_b32 s1, 0
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	s_and_saveexec_b32 s0, vcc_lo
	s_cbranch_execz .LBB1_20
; %bb.17:                               ; %.preheader88
	v_mov_b32_e32 v2, 0
	ds_load_2addr_b32 v[0:1], v2 offset1:1
	ds_load_b32 v3, v2 offset:8
.LBB1_18:                               ; =>This Inner Loop Header: Depth=1
	s_add_i32 s3, s1, 0
	s_add_i32 s1, s1, 12
	v_mov_b32_e32 v6, s3
	s_cmpk_lg_i32 s1, 0x300
	ds_load_2addr_b32 v[4:5], v6 offset1:1
	ds_load_b32 v6, v6 offset:8
	s_waitcnt lgkmcnt(1)
	v_dual_add_f32 v1, v5, v1 :: v_dual_add_f32 v0, v4, v0
	s_waitcnt lgkmcnt(0)
	v_add_nc_u32_e32 v3, v3, v6
	ds_store_2addr_b32 v2, v0, v1 offset1:1
	ds_store_b32 v2, v3 offset:8
	s_cbranch_scc1 .LBB1_18
; %bb.19:                               ; %Flow
	s_mov_b32 s1, exec_lo
.LBB1_20:                               ; %Flow161
	s_or_b32 exec_lo, exec_lo, s0
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_b32 s10, s1, exec_lo
.LBB1_21:                               ; %Flow160
	s_and_not1_saveexec_b32 s2, s2
	s_cbranch_execz .LBB1_28
; %bb.22:                               ; %.preheader
	s_load_b32 s3, s[8:9], 0x0
	s_waitcnt lgkmcnt(0)
	s_cmp_lt_i32 s3, 1
	s_cbranch_scc1 .LBB1_27
; %bb.23:                               ; %.lr.ph103.preheader
	v_mov_b32_e32 v0, 0
	s_add_u32 s0, s4, 4
	s_addc_u32 s1, s5, 0
.LBB1_24:                               ; %.lr.ph103
                                        ; =>This Inner Loop Header: Depth=1
	s_load_b32 s4, s[0:1], 0x4
	s_waitcnt lgkmcnt(0)
	s_cmp_lg_u32 s4, s15
	s_cbranch_scc1 .LBB1_26
; %bb.25:                               ;   in Loop: Header=BB1_24 Depth=1
	global_load_b64 v[1:2], v0, s[0:1] offset:-4
	ds_load_2addr_b32 v[3:4], v0 offset1:1
	ds_load_b32 v5, v0 offset:8
	s_waitcnt vmcnt(0) lgkmcnt(1)
	v_dual_add_f32 v1, v1, v3 :: v_dual_add_f32 v2, v2, v4
	s_waitcnt lgkmcnt(0)
	v_add_nc_u32_e32 v3, 1, v5
	ds_store_2addr_b32 v0, v1, v2 offset1:1
	ds_store_b32 v0, v3 offset:8
.LBB1_26:                               ;   in Loop: Header=BB1_24 Depth=1
	s_add_i32 s3, s3, -1
	s_add_u32 s0, s0, 12
	s_addc_u32 s1, s1, 0
	s_cmp_eq_u32 s3, 0
	s_cbranch_scc0 .LBB1_24
.LBB1_27:                               ; %Flow159
	s_or_b32 s10, s10, exec_lo
.LBB1_28:                               ; %Flow162
	s_or_b32 exec_lo, exec_lo, s2
	s_and_saveexec_b32 s0, s10
	s_cbranch_execz .LBB1_31
; %bb.29:                               ; %.loopexit
	s_and_b32 exec_lo, exec_lo, vcc_lo
	s_cbranch_execz .LBB1_31
; %bb.30:
	v_mov_b32_e32 v3, 0
	s_mul_i32 s0, s15, 12
	s_mul_hi_i32 s1, s15, 12
	s_add_u32 s0, s6, s0
	s_addc_u32 s1, s7, s1
	ds_load_b32 v2, v3 offset:8
	ds_load_2addr_b32 v[0:1], v3 offset1:1
	s_waitcnt lgkmcnt(0)
	global_store_b96 v3, v[0:2], s[0:1]
.LBB1_31:                               ; %.critedge
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z25device_compute_centroids1P5PointP8CentroidPiS3_S3_
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 40
		.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 10
		.amdhsa_next_free_sgpr 16
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end1:
	.size	_Z25device_compute_centroids1P5PointP8CentroidPiS3_S3_, .Lfunc_end1-_Z25device_compute_centroids1P5PointP8CentroidPiS3_S3_
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 1088
; NumSgprs: 18
; NumVgprs: 10
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 10
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.protected	_Z22device_reassign_pointsP5PointP8CentroidPiS3_S3_S3_ ; -- Begin function _Z22device_reassign_pointsP5PointP8CentroidPiS3_S3_S3_
	.globl	_Z22device_reassign_pointsP5PointP8CentroidPiS3_S3_S3_
	.p2align	8
	.type	_Z22device_reassign_pointsP5PointP8CentroidPiS3_S3_S3_,@function
_Z22device_reassign_pointsP5PointP8CentroidPiS3_S3_S3_: ; @_Z22device_reassign_pointsP5PointP8CentroidPiS3_S3_S3_
; %bb.0:
	s_clause 0x2
	s_load_b64 s[2:3], s[0:1], 0x28
	s_load_b256 s[4:11], s[0:1], 0x0
	s_load_b32 s1, s[0:1], 0x3c
	v_cmp_eq_u32_e32 vcc_lo, 0, v0
	s_waitcnt lgkmcnt(0)
	s_load_b32 s0, s[2:3], 0x0
	s_and_saveexec_b32 s2, vcc_lo
	s_cbranch_execz .LBB2_2
; %bb.1:
	v_mov_b32_e32 v1, 0
	global_store_b32 v1, v1, s[8:9]
.LBB2_2:
	s_or_b32 exec_lo, exec_lo, s2
	s_and_b32 s1, 0xffff, s1
	s_waitcnt lgkmcnt(0)
	s_mul_i32 s0, s0, 12
	v_mad_u64_u32 v[1:2], null, s15, s1, v[0:1]
	v_mad_u32_u24 v0, v0, 12, 0
	s_add_i32 s1, s0, 0
	s_delay_alu instid0(VALU_DEP_2)
	v_mad_i64_i32 v[2:3], null, v1, 12, s[4:5]
	global_load_b96 v[2:4], v[2:3], off
	s_waitcnt vmcnt(0)
	ds_store_2addr_b32 v0, v2, v3 offset1:1
	ds_store_b32 v0, v4 offset:8
	s_and_saveexec_b32 s0, vcc_lo
	s_cbranch_execz .LBB2_6
; %bb.3:                                ; %.preheader
	v_mov_b32_e32 v2, 0
	global_load_b32 v3, v2, s[10:11]
	s_waitcnt vmcnt(0)
	v_cmp_gt_i32_e32 vcc_lo, 1, v3
	s_cbranch_vccnz .LBB2_6
; %bb.4:                                ; %.lr.ph.preheader
	s_mov_b32 s2, s1
.LBB2_5:                                ; %.lr.ph
                                        ; =>This Inner Loop Header: Depth=1
	global_load_b96 v[4:6], v2, s[6:7]
	v_add_nc_u32_e32 v3, -1, v3
	v_mov_b32_e32 v7, s2
	s_add_u32 s6, s6, 12
	s_addc_u32 s7, s7, 0
	s_add_i32 s2, s2, 12
	v_cmp_ne_u32_e32 vcc_lo, 0, v3
	s_waitcnt vmcnt(0)
	ds_store_2addr_b32 v7, v4, v5 offset1:1
	ds_store_b32 v7, v6 offset:8
	s_cbranch_vccnz .LBB2_5
.LBB2_6:                                ; %.loopexit
	s_or_b32 exec_lo, exec_lo, s0
	v_mov_b32_e32 v2, 0
	s_waitcnt lgkmcnt(0)
	s_waitcnt_vscnt null, 0x0
	s_barrier
	buffer_gl0_inv
	global_load_b32 v5, v2, s[10:11]
	s_waitcnt vmcnt(0)
	v_cmp_gt_i32_e32 vcc_lo, 1, v5
	s_cbranch_vccnz .LBB2_9
; %bb.7:                                ; %.lr.ph62
	ds_load_2addr_b32 v[2:3], v0 offset1:1
	v_mov_b32_e32 v6, 0x7f800000
	v_mov_b32_e32 v4, -1
	s_mov_b32 s2, 0
.LBB2_8:                                ; =>This Inner Loop Header: Depth=1
	v_mov_b32_e32 v7, s1
	s_add_i32 s1, s1, 12
	ds_load_2addr_b32 v[7:8], v7 offset1:1
	s_waitcnt lgkmcnt(0)
	v_dual_sub_f32 v8, v3, v8 :: v_dual_sub_f32 v7, v2, v7
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_f32_e32 v8, v8, v8
	v_fmac_f32_e32 v8, v7, v7
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_cmp_gt_f32_e32 vcc_lo, 0xf800000, v8
	v_mul_f32_e32 v7, 0x4f800000, v8
	v_cndmask_b32_e32 v7, v8, v7, vcc_lo
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_3) | instid1(VALU_DEP_2)
	v_sqrt_f32_e32 v8, v7
	s_waitcnt_depctr 0xfff
	v_add_nc_u32_e32 v10, 1, v8
	v_add_nc_u32_e32 v9, -1, v8
	v_fma_f32 v12, -v10, v8, v7
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f32 v11, -v9, v8, v7
	v_cmp_ge_f32_e64 s0, 0, v11
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_cndmask_b32_e64 v8, v8, v9, s0
	v_cmp_lt_f32_e64 s0, 0, v12
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cndmask_b32_e64 v8, v8, v10, s0
	v_mul_f32_e32 v9, 0x37800000, v8
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_cndmask_b32_e32 v8, v8, v9, vcc_lo
	v_cmp_class_f32_e64 vcc_lo, v7, 0x260
	v_cndmask_b32_e32 v7, v8, v7, vcc_lo
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_4)
	v_cmp_lt_f32_e32 vcc_lo, v7, v6
	v_cndmask_b32_e32 v6, v6, v7, vcc_lo
	v_cndmask_b32_e64 v4, v4, s2, vcc_lo
	s_add_i32 s2, s2, 1
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cmp_eq_u32_e64 s0, s2, v5
	s_and_b32 vcc_lo, exec_lo, s0
	s_cbranch_vccz .LBB2_8
	s_branch .LBB2_10
.LBB2_9:
	v_mov_b32_e32 v4, -1
.LBB2_10:                               ; %Flow87
	ds_load_b32 v0, v0 offset:8
	s_mov_b32 s0, exec_lo
	s_waitcnt lgkmcnt(0)
	v_cmpx_ne_u32_e64 v4, v0
	s_cbranch_execz .LBB2_12
; %bb.11:
	v_mov_b32_e32 v0, 0
	v_mov_b32_e32 v2, 1
	global_store_b32 v0, v2, s[8:9]
.LBB2_12:
	s_or_b32 exec_lo, exec_lo, s0
	v_mad_i64_i32 v[2:3], null, v1, 12, s[4:5]
	global_store_b32 v[2:3], v4, off offset:8
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z22device_reassign_pointsP5PointP8CentroidPiS3_S3_S3_
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 304
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 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 13
		.amdhsa_next_free_sgpr 16
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end2:
	.size	_Z22device_reassign_pointsP5PointP8CentroidPiS3_S3_S3_, .Lfunc_end2-_Z22device_reassign_pointsP5PointP8CentroidPiS3_S3_S3_
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 612
; NumSgprs: 18
; NumVgprs: 13
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 13
; 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
      - .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
      - .offset:         32
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         36
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         40
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         44
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         46
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         48
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         50
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         52
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         54
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         88
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         96
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 12
    .kernarg_segment_align: 8
    .kernarg_segment_size: 288
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z25device_compute_centroids2P5PointP8CentroidPiS3_
    .private_segment_fixed_size: 0
    .sgpr_count:     16
    .sgpr_spill_count: 0
    .symbol:         _Z25device_compute_centroids2P5PointP8CentroidPiS3_.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     5
    .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
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 40
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z25device_compute_centroids1P5PointP8CentroidPiS3_S3_
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z25device_compute_centroids1P5PointP8CentroidPiS3_S3_.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     10
    .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
      - .address_space:  global
        .offset:         40
        .size:           8
        .value_kind:     global_buffer
      - .offset:         48
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         52
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         56
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         60
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         62
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         64
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         66
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         68
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         70
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         88
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         96
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         104
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         112
        .size:           2
        .value_kind:     hidden_grid_dims
      - .offset:         168
        .size:           4
        .value_kind:     hidden_dynamic_lds_size
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 304
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z22device_reassign_pointsP5PointP8CentroidPiS3_S3_S3_
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z22device_reassign_pointsP5PointP8CentroidPiS3_S3_S3_.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     13
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
