
#include <stdio.h>
#include <cuda.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
//use high as x value low as y for clustering
typedef struct day{
	int month;
	int date;
	int year;
	double high;
	double low;
	int cluster;
}day;

typedef struct center{
	double x;
	double y;
}center;


__global__ void setCenters(day* data, center* centers, int k, int numDays) {
	__shared__ int nums[3];

	int * avgx =nums;
	int * avgy =&nums[1];
	int * n=&nums[2];
	*avgx=0;
	*avgy=0;
	*n=0;
	int i =0;
	int index;	
	while((index=threadIdx.x + blockDim.x*i) < numDays){
		if(data[index].cluster==blockIdx.x){
			atomicAdd(n, 1);
			atomicAdd(avgx, (int)data[index].high);
			atomicAdd(avgy, (int)data[index].low);
			
		}
		
		i++;
	}
	__syncthreads();
	if(threadIdx.x ==0){
		centers[blockIdx.x].x=(double)(*avgx)/(double)(*n);
		centers[blockIdx.x].y=(double)(*avgy)/(double)(*n);
	}
	
}

__global__ void cluster(day* data, center* centers, int k, int numDays, int * s){
	int numT=gridDim.x*blockDim.x;
	int i=0;
	int index;
	int cluster;
	*s=0;
	while((index=threadIdx.x +blockIdx.x * blockDim.x+ numT*i) < numDays){
		double min=1000;
		for( int j=0; j< k; j++){
			double x=data[index].high-centers[j].x;
			x=x*x;
			double y=data[index].low-centers[j].y;
			y=y*y;
			double dist=sqrt(x+y);
			if(dist< min){
				min=dist;
				cluster=j;
				
			}		
		}
		if(data[index].cluster!=cluster){
			atomicAdd(s, 1);
			data[index].cluster=cluster;
		}
		i++;
	} 
}
__global__ void processData(day* data, int * month_data, int k, int numDays){
	int i=0;
	int month_index = blockIdx.x * 12 + threadIdx.x; //index for month_data
	int data_index;//index for data
	int month = threadIdx.x + 1;//month to look for
	int cluster = blockIdx.x;//cluster to look for
	
	while((data_index = threadIdx.y + blockDim.y * gridDim.y *i++) < numDays){
	
		if((data[data_index].cluster == cluster) && (data[data_index].month == month) ){
			atomicAdd(&month_data[month_index], 1);
		}
		
	}
}
int main(int  argc, char *argv[]) {
	printf("begin checks\n");
    	if(argc < 3){ //checcks for proper number of Args
		printf("Missing Arguments");
		return 1;
    	}
    	int k=atoi(argv[1]);
    	if(k <1){ //checks that k value is greater than 1
		printf("invalid number of Clusters");
		return 1;
  	}
    	FILE *fp;
    	fp=fopen(argv[2], "r");
    	if(fp==NULL){ //chechs that the file opened properly
		perror("Failed to open file:");
		return 1;
    	}
    	day * data;
    	data=(day*)malloc(sizeof(struct day));
    	while((fgetc(fp))!='\n'){}//getting rid of the title line of the file
    
    	int numDays=0;
    	int high=-1;
    	int low;
    	int date;
    	int month;
    	int year;
    	char  station[15];
    	while(fscanf(fp,"%[^,],%d/%d/%d,%d,%d",station,&month, &date, &year, &high, &low)==6){//populates data from file
		numDays++;
		data=(day*)realloc(data, sizeof(struct day) * numDays);
		data[numDays-1].date=date;
		data[numDays-1].high=high;
		data[numDays-1].low=low;
		data[numDays-1].month=month;
		data[numDays-1].year=year;
		data[numDays-1].cluster=-1;
	}
		
	fclose(fp);//close file
		
    	//declares data for device
    	day * d_data;
    	cudaMalloc((void **)&d_data, sizeof(struct day)*numDays);
    	cudaMemcpy(d_data, data, sizeof(struct day)*numDays, cudaMemcpyHostToDevice);
    
    	//create centers 
    	center * centers;
    	centers=(center*)malloc(sizeof(struct center)* k);
    	for(int i=0; i<k; i++){//initilize centers to random data points
		centers[i].x=data[numDays/(i+2)].high;
		centers[i].y=data[numDays/(i+2)].low;

    	} 
    
    	//create centers for device
    	center * d_centers;
    	cudaMalloc((void **)&d_centers, sizeof(struct center) *k);
    	cudaMemcpy(d_centers, centers, sizeof(struct center) *k, cudaMemcpyHostToDevice);
    
    	int temp = 1093; //random number non zero number
    	int * s=&temp;

    	int * d_s;//variable to count how many data points change clusters between iterations
    	cudaMalloc((void **)&d_s, sizeof(int));
    
    
    	while(*s>0 ){
		*s=0;//reset s value
		int numB=numDays/512;

		cluster<<<numB, 512>>>(d_data, d_centers, k, numDays, d_s);//cluster data
		
		cudaMemcpy(s, d_s, sizeof(int), cudaMemcpyDeviceToHost);//retrieve d_S value from device
			
		if(*s>0){//compute new centers if any clusters changed
			int numT=((numDays/k)/32)*32; //assigns highest 
			numT>512 ? numT=512 : numT=numT;//checks that numt doesn't exceed 512
				
			setCenters<<<k, numT>>>(d_data, d_centers, k, numDays);
				
		}	
	}
		//copy data back to device for printing
    	cudaMemcpy(data, d_data, sizeof(struct day)*numDays, cudaMemcpyDeviceToHost);
	//open file for output
	fp=fopen("output.csv", "w");
		
	//print data to output in csv format
	for(int i=0; i<k; i++){
		fprintf(fp, "Cluster %d,Center,x=%f, y=%f\nDate,High,Low\n", i+1, centers[i].x, centers[i].y);
		for(int j=0; j<numDays; j++){
			if(i==data[j].cluster){
				fprintf(fp, "%d/%d/%d,%f,%f,%d\n", data[j].month, data[j].date, data[j].year, data[j].high,data[j].low, data[j].cluster);
			}
		}
		fprintf(fp,"\n\n");
    	}
	//pointer to single dimensional array that is to 
	//hold summary of many days of each month are in each
	int * month_data;
	month_data=(int*)malloc(k*12*sizeof(int));
	int * d_month_data;//device copy
	cudaMalloc((void **)&d_month_data, k*12*sizeof(int) );
		
	dim3 threads(12, 32);
	processData<<<k, threads>>>(d_data, d_month_data, k, numDays );
	cudaMemcpy(month_data, d_month_data, k * 12 *sizeof(int), cudaMemcpyDeviceToHost);
	
	fprintf(fp, "Cluster,JAN,FEB,MAR,APR,MAY,JUN,JUL,AUG,SEP,OCT,NOV,DEC\n");
	printf("%6s%5s%5s%5s%5s%5s%5s%5s%5s%5s%5s%5s%5s\n","Cluster","JAN", "FEB", "MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC");
		
	for( int i = 0; i< k; i++){
		fprintf(fp, "%d", i+1);
		printf("%6d", i+1);
		
		for( int j = 0; j < 12; j++){
			fprintf(fp, ",%d",month_data[i * 12 + j]);
			printf("%5d",month_data[i * 12 + j]);
		}
		fprintf(fp, "\n");
		printf("\n");
	}

    	// Cleanup
    	cudaFree(d_centers);
   	cudaFree(d_s); 
	cudaFree(d_data);
	cudaFree(d_month_data);
    	free(data); 
    	free(centers);
	free(month_data);
    	return 0;
}

	.file	"tmpxft_00204b07_00000000-6_main.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2030:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2030:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z43__device_stub__Z10setCentersP3dayP6centeriiP3dayP6centerii
	.type	_Z43__device_stub__Z10setCentersP3dayP6centeriiP3dayP6centerii, @function
_Z43__device_stub__Z10setCentersP3dayP6centeriiP3dayP6centerii:
.LFB2052:
	.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
	movl	%edx, 12(%rsp)
	leaq	40(%rsp), %rdx
	movl	%ecx, 8(%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	12(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	8(%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	.L2
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z10setCentersP3dayP6centerii(%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
.L2:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L4
	call	__stack_chk_fail@PLT
.L4:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2052:
	.size	_Z43__device_stub__Z10setCentersP3dayP6centeriiP3dayP6centerii, .-_Z43__device_stub__Z10setCentersP3dayP6centeriiP3dayP6centerii
	.globl	_Z10setCentersP3dayP6centerii
	.type	_Z10setCentersP3dayP6centerii, @function
_Z10setCentersP3dayP6centerii:
.LFB2053:
	.cfi_startproc
	endbr64
	jmp	_Z43__device_stub__Z10setCentersP3dayP6centeriiP3dayP6centerii
	.cfi_endproc
.LFE2053:
	.size	_Z10setCentersP3dayP6centerii, .-_Z10setCentersP3dayP6centerii
	.globl	_Z41__device_stub__Z7clusterP3dayP6centeriiPiP3dayP6centeriiPi
	.type	_Z41__device_stub__Z7clusterP3dayP6centeriiPiP3dayP6centeriiPi, @function
_Z41__device_stub__Z7clusterP3dayP6centeriiPiP3dayP6centeriiPi:
.LFB2054:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdi, 24(%rsp)
	leaq	48(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	60(%rsp), %rsi
	movl	%edx, 12(%rsp)
	leaq	32(%rsp), %rdx
	movl	%ecx, 8(%rsp)
	leaq	40(%rsp), %rcx
	movq	%r8, (%rsp)
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 56(%rsp)
	movq	%rax, 96(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 104(%rsp)
	leaq	12(%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, 48(%rsp)
	movq	%rax, 60(%rsp)
	movl	$1, 68(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L8
	pushq	40(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z7clusterP3dayP6centeriiPi(%rip), %rdi
	pushq	40(%rsp)
	.cfi_def_cfa_offset 176
	movq	76(%rsp), %rcx
	movl	84(%rsp), %r8d
	movq	64(%rsp), %rsi
	movl	72(%rsp), %edx
	leaq	112(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 168
	popq	%rdx
	.cfi_def_cfa_offset 160
.L8:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L10
	call	__stack_chk_fail@PLT
.L10:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2054:
	.size	_Z41__device_stub__Z7clusterP3dayP6centeriiPiP3dayP6centeriiPi, .-_Z41__device_stub__Z7clusterP3dayP6centeriiPiP3dayP6centeriiPi
	.globl	_Z7clusterP3dayP6centeriiPi
	.type	_Z7clusterP3dayP6centeriiPi, @function
_Z7clusterP3dayP6centeriiPi:
.LFB2055:
	.cfi_startproc
	endbr64
	jmp	_Z41__device_stub__Z7clusterP3dayP6centeriiPiP3dayP6centeriiPi
	.cfi_endproc
.LFE2055:
	.size	_Z7clusterP3dayP6centeriiPi, .-_Z7clusterP3dayP6centeriiPi
	.globl	_Z38__device_stub__Z11processDataP3dayPiiiP3dayPiii
	.type	_Z38__device_stub__Z11processDataP3dayPiiiP3dayPiii, @function
_Z38__device_stub__Z11processDataP3dayPiiiP3dayPiii:
.LFB2056:
	.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
	movl	%edx, 12(%rsp)
	leaq	40(%rsp), %rdx
	movl	%ecx, 8(%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	12(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	8(%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	.L13
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z11processDataP3dayPiii(%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
.L13:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L15
	call	__stack_chk_fail@PLT
.L15:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2056:
	.size	_Z38__device_stub__Z11processDataP3dayPiiiP3dayPiii, .-_Z38__device_stub__Z11processDataP3dayPiiiP3dayPiii
	.globl	_Z11processDataP3dayPiii
	.type	_Z11processDataP3dayPiii, @function
_Z11processDataP3dayPiii:
.LFB2057:
	.cfi_startproc
	endbr64
	jmp	_Z38__device_stub__Z11processDataP3dayPiiiP3dayPiii
	.cfi_endproc
.LFE2057:
	.size	_Z11processDataP3dayPiii, .-_Z11processDataP3dayPiii
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"begin checks\n"
.LC1:
	.string	"Missing Arguments"
.LC2:
	.string	"invalid number of Clusters"
.LC3:
	.string	"r"
.LC4:
	.string	"Failed to open file:"
.LC5:
	.string	"%[^,],%d/%d/%d,%d,%d"
.LC6:
	.string	"w"
.LC7:
	.string	"output.csv"
.LC8:
	.string	"Cluster %d,Center,x=%f, y=%f\nDate,High,Low\n"
.LC9:
	.string	"%d/%d/%d,%f,%f,%d\n"
.LC10:
	.string	"\n\n"
.LC11:
	.string	"Cluster,JAN,FEB,MAR,APR,MAY,JUN,JUL,AUG,SEP,OCT,NOV,DEC\n"
.LC12:
	.string	"MAR"
.LC13:
	.string	"FEB"
.LC14:
	.string	"JAN"
.LC15:
	.string	"Cluster"
.LC16:
	.string	"%6s%5s%5s%5s%5s%5s%5s%5s%5s%5s%5s%5s%5s\n"
.LC17:
	.string	"DEC"
.LC18:
	.string	"NOV"
.LC19:
	.string	"OCT"
.LC20:
	.string	"SEP"
.LC21:
	.string	"AUG"
.LC22:
	.string	"JUL"
.LC23:
	.string	"JUN"
.LC24:
	.string	"MAY"
.LC25:
	.string	"APR"
.LC26:
	.string	"%d"
.LC27:
	.string	"%6d"
.LC28:
	.string	",%d"
.LC29:
	.string	"%5d"
.LC30:
	.string	"\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2027:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movl	%edi, %ebp
	movl	$2, %edi
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%rsi, %rbx
	leaq	.LC0(%rip), %rsi
	subq	$152, %rsp
	.cfi_def_cfa_offset 208
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	.LC1(%rip), %rsi
	cmpl	$2, %ebp
	jle	.L48
	movq	8(%rbx), %rdi
	call	atoi@PLT
	movl	%eax, %r14d
	testl	%eax, %eax
	jg	.L21
	leaq	.LC2(%rip), %rsi
.L48:
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L20:
	movl	$1, %eax
	jmp	.L18
.L21:
	movq	16(%rbx), %rdi
	leaq	.LC3(%rip), %rsi
	call	fopen@PLT
	movq	%rax, %rbx
	testq	%rax, %rax
	jne	.L23
	leaq	.LC4(%rip), %rdi
	call	perror@PLT
	jmp	.L20
.L23:
	movl	$40, %edi
	call	malloc@PLT
	movq	%rax, %r15
.L24:
	movq	%rbx, %rdi
	call	fgetc@PLT
	cmpl	$10, %eax
	jne	.L24
	movl	$-1, 40(%rsp)
	xorl	%ebp, %ebp
	leaq	.LC5(%rip), %r12
.L25:
	leaq	44(%rsp), %rax
	leaq	52(%rsp), %rcx
	movq	%r12, %rsi
	movq	%rbx, %rdi
	leaq	121(%rsp), %rdx
	pushq	%rax
	.cfi_def_cfa_offset 216
	leaq	48(%rsp), %rax
	pushq	%rax
	.cfi_def_cfa_offset 224
	xorl	%eax, %eax
	leaq	72(%rsp), %r9
	leaq	64(%rsp), %r8
	call	__isoc23_fscanf@PLT
	popq	%r8
	.cfi_def_cfa_offset 216
	popq	%r9
	.cfi_def_cfa_offset 208
	cmpl	$6, %eax
	jne	.L49
	imulq	$40, %rbp, %r13
	movq	%r15, %rdi
	incq	%rbp
	leaq	40(%r13), %rsi
	call	realloc@PLT
	cvtsi2sdl	40(%rsp), %xmm0
	movl	48(%rsp), %edx
	movq	%rax, %r15
	leaq	(%rax,%r13), %rax
	movl	%edx, 4(%rax)
	movl	52(%rsp), %edx
	movl	$-1, 32(%rax)
	movsd	%xmm0, 16(%rax)
	cvtsi2sdl	44(%rsp), %xmm0
	movl	%edx, (%rax)
	movl	56(%rsp), %edx
	movl	%edx, 8(%rax)
	movsd	%xmm0, 24(%rax)
	jmp	.L25
.L49:
	movslq	%ebp, %r12
	movq	%rbx, %rdi
	movl	%ebp, 24(%rsp)
	movslq	%r14d, %r13
	call	fclose@PLT
	imulq	$40, %r12, %r12
	leaq	64(%rsp), %rdi
	xorl	%ebx, %ebx
	salq	$4, %r13
	movq	%r12, %rsi
	call	cudaMalloc@PLT
	movq	64(%rsp), %rdi
	movq	%r12, %rdx
	movq	%r15, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movq	%r13, %rdi
	call	malloc@PLT
	movq	%rax, 8(%rsp)
	movq	%rax, %rcx
	movq	%rax, 16(%rsp)
.L27:
	movl	24(%rsp), %eax
	leal	2(%rbx), %esi
	movl	%ebx, 28(%rsp)
	incl	%ebx
	addq	$16, %rcx
	cltd
	idivl	%esi
	cltq
	imulq	$40, %rax, %rax
	addq	%r15, %rax
	movsd	16(%rax), %xmm0
	movsd	%xmm0, -16(%rcx)
	movsd	24(%rax), %xmm0
	movsd	%xmm0, -8(%rcx)
	cmpl	%ebx, %r14d
	jne	.L27
	movq	%r13, %rsi
	leaq	72(%rsp), %rdi
	call	cudaMalloc@PLT
	movq	8(%rsp), %rsi
	movq	72(%rsp), %rdi
	movq	%r13, %rdx
	movabsq	$4294967808, %r13
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	leaq	80(%rsp), %rdi
	movl	$4, %esi
	movl	$1093, 60(%rsp)
	call	cudaMalloc@PLT
	movl	24(%rsp), %r14d
	sarl	$9, %r14d
.L30:
	cmpl	$0, 60(%rsp)
	jle	.L50
	xorl	%edi, %edi
	movl	%r14d, 96(%rsp)
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	%edi, 60(%rsp)
	movq	%r13, %rdx
	movl	$1, %ecx
	movabsq	$4294967297, %rax
	movq	%rax, 100(%rsp)
	movq	96(%rsp), %rdi
	movl	104(%rsp), %esi
	movq	%r13, 108(%rsp)
	movl	$1, 116(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L29
	movq	80(%rsp), %r8
	movl	24(%rsp), %ecx
	movl	%ebx, %edx
	movq	72(%rsp), %rsi
	movq	64(%rsp), %rdi
	call	_Z41__device_stub__Z7clusterP3dayP6centeriiPiP3dayP6centeriiPi
.L29:
	movq	80(%rsp), %rsi
	leaq	60(%rsp), %rdi
	movl	$2, %ecx
	movl	$4, %edx
	call	cudaMemcpy@PLT
	cmpl	$0, 60(%rsp)
	jle	.L30
	movl	24(%rsp), %eax
	movl	%ebx, 96(%rsp)
	cltd
	idivl	%ebx
	movl	$512, %edx
	andl	$-32, %eax
	cmpl	%edx, %eax
	cmovg	%edx, %eax
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	%eax, 108(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 112(%rsp)
	movl	116(%rsp), %ecx
	movq	%rax, 100(%rsp)
	movq	108(%rsp), %rdx
	movq	96(%rsp), %rdi
	movl	104(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L30
	movl	24(%rsp), %ecx
	movq	72(%rsp), %rsi
	movl	%ebx, %edx
	movq	64(%rsp), %rdi
	call	_Z43__device_stub__Z10setCentersP3dayP6centeriiP3dayP6centerii
	jmp	.L30
.L50:
	movq	64(%rsp), %rsi
	movl	$2, %ecx
	movq	%r12, %rdx
	movq	%r15, %rdi
	imulq	$40, %rbp, %rbp
	call	cudaMemcpy@PLT
	leaq	.LC6(%rip), %rsi
	leaq	.LC7(%rip), %rdi
	call	fopen@PLT
	movq	%rax, (%rsp)
	leaq	0(%rbp,%r15), %r13
	xorl	%ebp, %ebp
.L36:
	movq	16(%rsp), %rax
	movq	(%rsp), %rdi
	movl	%ebp, %r12d
	incl	%ebp
	movl	%ebp, %ecx
	leaq	.LC8(%rip), %rdx
	movl	$2, %esi
	movq	%r15, %r14
	movsd	8(%rax), %xmm1
	movsd	(%rax), %xmm0
	movb	$2, %al
	call	__fprintf_chk@PLT
.L33:
	cmpq	%r13, %r14
	je	.L51
	cmpl	%r12d, 32(%r14)
	jne	.L34
	movl	8(%r14), %r9d
	movl	4(%r14), %r8d
	movl	$2, %esi
	movb	$2, %al
	movsd	24(%r14), %xmm1
	movsd	16(%r14), %xmm0
	pushq	%rdx
	.cfi_def_cfa_offset 216
	leaq	.LC9(%rip), %rdx
	pushq	%r12
	.cfi_def_cfa_offset 224
	movq	16(%rsp), %rdi
	movl	(%r14), %ecx
	call	__fprintf_chk@PLT
	popq	%rcx
	.cfi_def_cfa_offset 216
	popq	%rsi
	.cfi_def_cfa_offset 208
.L34:
	addq	$40, %r14
	jmp	.L33
.L51:
	movq	(%rsp), %rdi
	leaq	.LC10(%rip), %rdx
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	movl	28(%rsp), %eax
	addq	$16, 16(%rsp)
	cmpl	%eax, %r12d
	jne	.L36
	imull	$12, %ebx, %ebp
	movslq	%ebp, %rbp
	salq	$2, %rbp
	movq	%rbp, %rdi
	call	malloc@PLT
	leaq	88(%rsp), %rdi
	movq	%rbp, %rsi
	movq	%rax, %r12
	call	cudaMalloc@PLT
	movl	%ebx, 108(%rsp)
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movabsq	$4294967297, %rax
	movl	$1, %ecx
	movabsq	$137438953484, %rdx
	movl	$1, 104(%rsp)
	movq	%rax, 112(%rsp)
	movq	108(%rsp), %rdi
	movl	116(%rsp), %esi
	movq	%rdx, 96(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L37
	movl	24(%rsp), %ecx
	movq	88(%rsp), %rsi
	movl	%ebx, %edx
	movq	64(%rsp), %rdi
	call	_Z38__device_stub__Z11processDataP3dayPiiiP3dayPiii
.L37:
	movq	88(%rsp), %rsi
	movl	$2, %ecx
	movq	%rbp, %rdx
	movq	%r12, %rdi
	xorl	%r13d, %r13d
	call	cudaMemcpy@PLT
	movq	(%rsp), %rdi
	movl	$2, %esi
	xorl	%eax, %eax
	leaq	.LC11(%rip), %rdx
	call	__fprintf_chk@PLT
	leaq	.LC12(%rip), %r9
	leaq	.LC13(%rip), %r8
	movl	$2, %edi
	pushq	%rax
	.cfi_def_cfa_offset 216
	leaq	.LC17(%rip), %rax
	leaq	.LC14(%rip), %rcx
	pushq	%rax
	.cfi_def_cfa_offset 224
	leaq	.LC18(%rip), %rax
	leaq	.LC15(%rip), %rdx
	pushq	%rax
	.cfi_def_cfa_offset 232
	leaq	.LC19(%rip), %rax
	leaq	.LC16(%rip), %rsi
	pushq	%rax
	.cfi_def_cfa_offset 240
	leaq	.LC20(%rip), %rax
	pushq	%rax
	.cfi_def_cfa_offset 248
	leaq	.LC21(%rip), %rax
	pushq	%rax
	.cfi_def_cfa_offset 256
	leaq	.LC22(%rip), %rax
	pushq	%rax
	.cfi_def_cfa_offset 264
	leaq	.LC23(%rip), %rax
	pushq	%rax
	.cfi_def_cfa_offset 272
	leaq	.LC24(%rip), %rax
	pushq	%rax
	.cfi_def_cfa_offset 280
	leaq	.LC25(%rip), %rax
	pushq	%rax
	.cfi_def_cfa_offset 288
	xorl	%eax, %eax
	call	__printf_chk@PLT
	addq	$80, %rsp
	.cfi_def_cfa_offset 208
.L39:
	leal	1(%r13), %ebp
	movq	(%rsp), %rdi
	movl	$2, %esi
	xorl	%eax, %eax
	movl	%ebp, %ecx
	leaq	.LC26(%rip), %rdx
	movl	$12, %r14d
	call	__fprintf_chk@PLT
	movl	%ebp, %edx
	imulq	$48, %r13, %rbp
	movl	$2, %edi
	leaq	.LC27(%rip), %rsi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	addq	%r12, %rbp
.L38:
	movl	0(%rbp), %ecx
	movq	(%rsp), %rdi
	leaq	.LC28(%rip), %rdx
	xorl	%eax, %eax
	movl	$2, %esi
	addq	$4, %rbp
	call	__fprintf_chk@PLT
	movl	-4(%rbp), %edx
	movl	$2, %edi
	xorl	%eax, %eax
	leaq	.LC29(%rip), %rsi
	call	__printf_chk@PLT
	decl	%r14d
	jne	.L38
	movq	(%rsp), %rdi
	leaq	.LC30(%rip), %rbp
	xorl	%eax, %eax
	incq	%r13
	movq	%rbp, %rdx
	movl	$2, %esi
	call	__fprintf_chk@PLT
	movq	%rbp, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	cmpl	%r13d, %ebx
	jg	.L39
	movq	72(%rsp), %rdi
	call	cudaFree@PLT
	movq	80(%rsp), %rdi
	call	cudaFree@PLT
	movq	64(%rsp), %rdi
	call	cudaFree@PLT
	movq	88(%rsp), %rdi
	call	cudaFree@PLT
	movq	%r15, %rdi
	call	free@PLT
	movq	8(%rsp), %rdi
	call	free@PLT
	movq	%r12, %rdi
	call	free@PLT
	xorl	%eax, %eax
.L18:
	movq	136(%rsp), %rdx
	subq	%fs:40, %rdx
	je	.L40
	call	__stack_chk_fail@PLT
.L40:
	addq	$152, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2027:
	.size	main, .-main
	.section	.rodata.str1.1
.LC31:
	.string	"_Z11processDataP3dayPiii"
.LC32:
	.string	"_Z7clusterP3dayP6centeriiPi"
.LC33:
	.string	"_Z10setCentersP3dayP6centerii"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2059:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	pushq	$0
	.cfi_def_cfa_offset 24
	xorl	%r9d, %r9d
	orl	$-1, %r8d
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC31(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z11processDataP3dayPiii(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r9d, %r9d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC32(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z7clusterP3dayP6centeriiPi(%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	.LC33(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z10setCentersP3dayP6centerii(%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
.LFE2059:
	.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
	.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 <hip/hip_runtime.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
//use high as x value low as y for clustering
typedef struct day{
	int month;
	int date;
	int year;
	double high;
	double low;
	int cluster;
}day;

typedef struct center{
	double x;
	double y;
}center;


__global__ void setCenters(day* data, center* centers, int k, int numDays) {
	__shared__ int nums[3];

	int * avgx =nums;
	int * avgy =&nums[1];
	int * n=&nums[2];
	*avgx=0;
	*avgy=0;
	*n=0;
	int i =0;
	int index;	
	while((index=threadIdx.x + blockDim.x*i) < numDays){
		if(data[index].cluster==blockIdx.x){
			atomicAdd(n, 1);
			atomicAdd(avgx, (int)data[index].high);
			atomicAdd(avgy, (int)data[index].low);
			
		}
		
		i++;
	}
	__syncthreads();
	if(threadIdx.x ==0){
		centers[blockIdx.x].x=(double)(*avgx)/(double)(*n);
		centers[blockIdx.x].y=(double)(*avgy)/(double)(*n);
	}
	
}

__global__ void cluster(day* data, center* centers, int k, int numDays, int * s){
	int numT=gridDim.x*blockDim.x;
	int i=0;
	int index;
	int cluster;
	*s=0;
	while((index=threadIdx.x +blockIdx.x * blockDim.x+ numT*i) < numDays){
		double min=1000;
		for( int j=0; j< k; j++){
			double x=data[index].high-centers[j].x;
			x=x*x;
			double y=data[index].low-centers[j].y;
			y=y*y;
			double dist=sqrt(x+y);
			if(dist< min){
				min=dist;
				cluster=j;
				
			}		
		}
		if(data[index].cluster!=cluster){
			atomicAdd(s, 1);
			data[index].cluster=cluster;
		}
		i++;
	} 
}
__global__ void processData(day* data, int * month_data, int k, int numDays){
	int i=0;
	int month_index = blockIdx.x * 12 + threadIdx.x; //index for month_data
	int data_index;//index for data
	int month = threadIdx.x + 1;//month to look for
	int cluster = blockIdx.x;//cluster to look for
	
	while((data_index = threadIdx.y + blockDim.y * gridDim.y *i++) < numDays){
	
		if((data[data_index].cluster == cluster) && (data[data_index].month == month) ){
			atomicAdd(&month_data[month_index], 1);
		}
		
	}
}
int main(int  argc, char *argv[]) {
	printf("begin checks\n");
    	if(argc < 3){ //checcks for proper number of Args
		printf("Missing Arguments");
		return 1;
    	}
    	int k=atoi(argv[1]);
    	if(k <1){ //checks that k value is greater than 1
		printf("invalid number of Clusters");
		return 1;
  	}
    	FILE *fp;
    	fp=fopen(argv[2], "r");
    	if(fp==NULL){ //chechs that the file opened properly
		perror("Failed to open file:");
		return 1;
    	}
    	day * data;
    	data=(day*)malloc(sizeof(struct day));
    	while((fgetc(fp))!='\n'){}//getting rid of the title line of the file
    
    	int numDays=0;
    	int high=-1;
    	int low;
    	int date;
    	int month;
    	int year;
    	char  station[15];
    	while(fscanf(fp,"%[^,],%d/%d/%d,%d,%d",station,&month, &date, &year, &high, &low)==6){//populates data from file
		numDays++;
		data=(day*)realloc(data, sizeof(struct day) * numDays);
		data[numDays-1].date=date;
		data[numDays-1].high=high;
		data[numDays-1].low=low;
		data[numDays-1].month=month;
		data[numDays-1].year=year;
		data[numDays-1].cluster=-1;
	}
		
	fclose(fp);//close file
		
    	//declares data for device
    	day * d_data;
    	hipMalloc((void **)&d_data, sizeof(struct day)*numDays);
    	hipMemcpy(d_data, data, sizeof(struct day)*numDays, hipMemcpyHostToDevice);
    
    	//create centers 
    	center * centers;
    	centers=(center*)malloc(sizeof(struct center)* k);
    	for(int i=0; i<k; i++){//initilize centers to random data points
		centers[i].x=data[numDays/(i+2)].high;
		centers[i].y=data[numDays/(i+2)].low;

    	} 
    
    	//create centers for device
    	center * d_centers;
    	hipMalloc((void **)&d_centers, sizeof(struct center) *k);
    	hipMemcpy(d_centers, centers, sizeof(struct center) *k, hipMemcpyHostToDevice);
    
    	int temp = 1093; //random number non zero number
    	int * s=&temp;

    	int * d_s;//variable to count how many data points change clusters between iterations
    	hipMalloc((void **)&d_s, sizeof(int));
    
    
    	while(*s>0 ){
		*s=0;//reset s value
		int numB=numDays/512;

		cluster<<<numB, 512>>>(d_data, d_centers, k, numDays, d_s);//cluster data
		
		hipMemcpy(s, d_s, sizeof(int), hipMemcpyDeviceToHost);//retrieve d_S value from device
			
		if(*s>0){//compute new centers if any clusters changed
			int numT=((numDays/k)/32)*32; //assigns highest 
			numT>512 ? numT=512 : numT=numT;//checks that numt doesn't exceed 512
				
			setCenters<<<k, numT>>>(d_data, d_centers, k, numDays);
				
		}	
	}
		//copy data back to device for printing
    	hipMemcpy(data, d_data, sizeof(struct day)*numDays, hipMemcpyDeviceToHost);
	//open file for output
	fp=fopen("output.csv", "w");
		
	//print data to output in csv format
	for(int i=0; i<k; i++){
		fprintf(fp, "Cluster %d,Center,x=%f, y=%f\nDate,High,Low\n", i+1, centers[i].x, centers[i].y);
		for(int j=0; j<numDays; j++){
			if(i==data[j].cluster){
				fprintf(fp, "%d/%d/%d,%f,%f,%d\n", data[j].month, data[j].date, data[j].year, data[j].high,data[j].low, data[j].cluster);
			}
		}
		fprintf(fp,"\n\n");
    	}
	//pointer to single dimensional array that is to 
	//hold summary of many days of each month are in each
	int * month_data;
	month_data=(int*)malloc(k*12*sizeof(int));
	int * d_month_data;//device copy
	hipMalloc((void **)&d_month_data, k*12*sizeof(int) );
		
	dim3 threads(12, 32);
	processData<<<k, threads>>>(d_data, d_month_data, k, numDays );
	hipMemcpy(month_data, d_month_data, k * 12 *sizeof(int), hipMemcpyDeviceToHost);
	
	fprintf(fp, "Cluster,JAN,FEB,MAR,APR,MAY,JUN,JUL,AUG,SEP,OCT,NOV,DEC\n");
	printf("%6s%5s%5s%5s%5s%5s%5s%5s%5s%5s%5s%5s%5s\n","Cluster","JAN", "FEB", "MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC");
		
	for( int i = 0; i< k; i++){
		fprintf(fp, "%d", i+1);
		printf("%6d", i+1);
		
		for( int j = 0; j < 12; j++){
			fprintf(fp, ",%d",month_data[i * 12 + j]);
			printf("%5d",month_data[i * 12 + j]);
		}
		fprintf(fp, "\n");
		printf("\n");
	}

    	// Cleanup
    	hipFree(d_centers);
   	hipFree(d_s); 
	hipFree(d_data);
	hipFree(d_month_data);
    	free(data); 
    	free(centers);
	free(month_data);
    	return 0;
}

	.text
	.file	"main.hip"
	.globl	_Z25__device_stub__setCentersP3dayP6centerii # -- Begin function _Z25__device_stub__setCentersP3dayP6centerii
	.type	_Z25__device_stub__setCentersP3dayP6centerii,@function
_Z25__device_stub__setCentersP3dayP6centerii: # @_Z25__device_stub__setCentersP3dayP6centerii
	.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	12(%rsp), %rsi
	movl	%edx, (%rsi)
	leaq	8(%rsp), %rdx
	movl	%ecx, (%rdx)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	24(%rsp), %r12
	leaq	16(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z10setCentersP3dayP6centerii, %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_end0:
	.size	_Z25__device_stub__setCentersP3dayP6centerii, .Lfunc_end0-_Z25__device_stub__setCentersP3dayP6centerii
	.cfi_endproc
                                        # -- End function
	.globl	_Z22__device_stub__clusterP3dayP6centeriiPi # -- Begin function _Z22__device_stub__clusterP3dayP6centeriiPi
	.type	_Z22__device_stub__clusterP3dayP6centeriiPi,@function
_Z22__device_stub__clusterP3dayP6centeriiPi: # @_Z22__device_stub__clusterP3dayP6centeriiPi
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$128, %rsp
	.cfi_def_cfa_offset 176
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	32(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	4(%rsp), %rsi
	movl	%edx, (%rsi)
	movq	%rsp, %rdx
	movl	%ecx, (%rdx)
	leaq	24(%rsp), %rcx
	movq	%r8, (%rcx)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	movq	%rcx, 32(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	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	$_Z7clusterP3dayP6centeriiPi, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$144, %rsp
	.cfi_adjust_cfa_offset -144
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end1:
	.size	_Z22__device_stub__clusterP3dayP6centeriiPi, .Lfunc_end1-_Z22__device_stub__clusterP3dayP6centeriiPi
	.cfi_endproc
                                        # -- End function
	.globl	_Z26__device_stub__processDataP3dayPiii # -- Begin function _Z26__device_stub__processDataP3dayPiii
	.type	_Z26__device_stub__processDataP3dayPiii,@function
_Z26__device_stub__processDataP3dayPiii: # @_Z26__device_stub__processDataP3dayPiii
	.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	12(%rsp), %rsi
	movl	%edx, (%rsi)
	leaq	8(%rsp), %rdx
	movl	%ecx, (%rdx)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	24(%rsp), %r12
	leaq	16(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z11processDataP3dayPiii, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$128, %rsp
	.cfi_adjust_cfa_offset -128
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end2:
	.size	_Z26__device_stub__processDataP3dayPiii, .Lfunc_end2-_Z26__device_stub__processDataP3dayPiii
	.cfi_endproc
                                        # -- End function
	.globl	main                            # -- Begin function main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$120, %rsp
	.cfi_def_cfa_offset 176
	.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
	movl	$.Lstr, %edi
	callq	puts@PLT
	cmpl	$2, %ebp
	jg	.LBB3_2
# %bb.1:
	movl	$.L.str.1, %edi
	jmp	.LBB3_33
.LBB3_2:
	movq	8(%rbx), %rdi
	callq	atoi
                                        # kill: def $eax killed $eax def $rax
	testl	%eax, %eax
	jle	.LBB3_32
# %bb.3:
	movq	%rax, 48(%rsp)                  # 8-byte Spill
	movq	16(%rbx), %rdi
	movl	$.L.str.3, %esi
	callq	fopen
	testq	%rax, %rax
	je	.LBB3_36
# %bb.4:
	movq	%rax, %r15
	movl	$40, %edi
	callq	malloc
	movq	%rax, %rbx
.LBB3_5:                                # =>This Inner Loop Header: Depth=1
	movq	%r15, %rdi
	callq	fgetc
	cmpl	$10, %eax
	jne	.LBB3_5
# %bb.6:
	leaq	44(%rsp), %r10
	movl	$-1, (%r10)
	leaq	84(%rsp), %rbp
	xorl	%r13d, %r13d
	leaq	105(%rsp), %rdx
	leaq	36(%rsp), %rcx
	leaq	40(%rsp), %r8
	leaq	32(%rsp), %r9
	movl	$.L.str.5, %esi
	movq	%r15, %rdi
	xorl	%eax, %eax
	pushq	%rbp
	.cfi_adjust_cfa_offset 8
	pushq	%r10
	.cfi_adjust_cfa_offset 8
	callq	__isoc23_fscanf
	addq	$16, %rsp
	.cfi_adjust_cfa_offset -16
	cmpl	$6, %eax
	jne	.LBB3_9
# %bb.7:                                # %.lr.ph.preheader
	movl	$40, %r14d
	leaq	32(%rsp), %r12
	xorl	%r13d, %r13d
.LBB3_8:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movq	%rbx, %rdi
	movq	%r14, %rsi
	callq	realloc
	movq	%rax, %rbx
	movl	40(%rsp), %eax
	movl	%eax, -36(%rbx,%r14)
	xorps	%xmm0, %xmm0
	cvtsi2sdl	44(%rsp), %xmm0
	movsd	%xmm0, -24(%rbx,%r14)
	xorps	%xmm0, %xmm0
	cvtsi2sdl	84(%rsp), %xmm0
	movsd	%xmm0, -16(%rbx,%r14)
	movl	36(%rsp), %eax
	movl	%eax, -40(%rbx,%r14)
	movl	32(%rsp), %eax
	movl	%eax, -32(%rbx,%r14)
	movl	$-1, -8(%rbx,%r14)
	movl	$.L.str.5, %esi
	movq	%r15, %rdi
	leaq	105(%rsp), %rdx
	leaq	36(%rsp), %rcx
	leaq	40(%rsp), %r8
	movq	%r12, %r9
	xorl	%eax, %eax
	pushq	%rbp
	.cfi_adjust_cfa_offset 8
	leaq	52(%rsp), %r10
	pushq	%r10
	.cfi_adjust_cfa_offset 8
	callq	__isoc23_fscanf
	addq	$16, %rsp
	.cfi_adjust_cfa_offset -16
	addq	$40, %r14
	incl	%r13d
	cmpl	$6, %eax
	je	.LBB3_8
.LBB3_9:                                # %.lr.ph162.preheader
	movq	%r15, %rdi
	callq	fclose
	movl	%r13d, %r13d
	leaq	(,%r13,8), %rax
	leaq	(%rax,%rax,4), %rbp
	leaq	24(%rsp), %r14
	movq	%r14, %rdi
	movq	%rbp, %rsi
	callq	hipMalloc
	movq	(%r14), %rdi
	movl	$1, %r15d
	movq	%rbx, %rsi
	movq	%rbp, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	48(%rsp), %r12                  # 8-byte Reload
	movl	%r12d, %r14d
	movq	%r14, 88(%rsp)                  # 8-byte Spill
	shlq	$4, %r14
	movq	%r14, %rdi
	callq	malloc
	cmpl	$2, %r12d
	cmovgel	%r12d, %r15d
	movq	%rax, %r12
	shlq	$4, %r15
	movl	$2, %ecx
	xorl	%esi, %esi
.LBB3_10:                               # %.lr.ph162
                                        # =>This Inner Loop Header: Depth=1
	movl	%r13d, %eax
	xorl	%edx, %edx
	divl	%ecx
                                        # kill: def $eax killed $eax def $rax
	leaq	(%rax,%rax,4), %rax
	movsd	16(%rbx,%rax,8), %xmm0          # xmm0 = mem[0],zero
	movsd	%xmm0, (%r12,%rsi)
	movsd	24(%rbx,%rax,8), %xmm0          # xmm0 = mem[0],zero
	movsd	%xmm0, 8(%r12,%rsi)
	incl	%ecx
	addq	$16, %rsi
	cmpq	%rsi, %r15
	jne	.LBB3_10
# %bb.11:                               # %.lr.ph165
	movq	%r13, %r15
	leaq	72(%rsp), %r13
	movq	%r13, %rdi
	movq	%r14, %rsi
	callq	hipMalloc
	movq	(%r13), %rdi
	movq	%r12, 96(%rsp)                  # 8-byte Spill
	movq	%r12, %rsi
	movq	%r14, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	leaq	64(%rsp), %rdi
	movl	$4, %esi
	callq	hipMalloc
	movq	%r15, %rax
	movq	%r15, (%rsp)                    # 8-byte Spill
	movl	%r15d, %r13d
	shrl	$9, %r13d
	btsq	$32, %r13
	movq	88(%rsp), %r14                  # 8-byte Reload
	btsq	$32, %r14
	movabsq	$4294967296, %rax               # imm = 0x100000000
	addq	$512, %rax                      # imm = 0x200
	movq	%rax, 16(%rsp)                  # 8-byte Spill
	movl	$512, %r12d                     # imm = 0x200
	movq	48(%rsp), %r15                  # 8-byte Reload
.LBB3_12:                               # =>This Inner Loop Header: Depth=1
	movl	$0, 12(%rsp)
	movq	%r13, %rdi
	movl	$1, %esi
	movq	16(%rsp), %rdx                  # 8-byte Reload
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB3_14
# %bb.13:                               #   in Loop: Header=BB3_12 Depth=1
	movq	24(%rsp), %rdi
	movq	72(%rsp), %rsi
	movq	64(%rsp), %r8
	movl	%r15d, %edx
	movq	(%rsp), %rcx                    # 8-byte Reload
                                        # kill: def $ecx killed $ecx killed $rcx
	callq	_Z22__device_stub__clusterP3dayP6centeriiPi
.LBB3_14:                               #   in Loop: Header=BB3_12 Depth=1
	movq	64(%rsp), %rsi
	movl	$4, %edx
	leaq	12(%rsp), %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	cmpl	$0, 12(%rsp)
	jle	.LBB3_18
# %bb.15:                               #   in Loop: Header=BB3_12 Depth=1
	movq	(%rsp), %rax                    # 8-byte Reload
                                        # kill: def $eax killed $eax killed $rax
	xorl	%edx, %edx
	divl	%r15d
                                        # kill: def $eax killed $eax def $rax
	andl	$2147483616, %eax               # imm = 0x7FFFFFE0
	cmpl	%r12d, %eax
	cmovael	%r12d, %eax
	movabsq	$4294967296, %rcx               # imm = 0x100000000
	orq	%rcx, %rax
	movq	%r14, %rdi
	movl	$1, %esi
	movq	%rax, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB3_17
# %bb.16:                               #   in Loop: Header=BB3_12 Depth=1
	movq	24(%rsp), %rdi
	movq	72(%rsp), %rsi
	movl	%r15d, %edx
	movq	(%rsp), %rcx                    # 8-byte Reload
                                        # kill: def $ecx killed $ecx killed $rcx
	callq	_Z25__device_stub__setCentersP3dayP6centerii
.LBB3_17:                               #   in Loop: Header=BB3_12 Depth=1
	cmpl	$0, 12(%rsp)
	jg	.LBB3_12
.LBB3_18:                               # %.lr.ph173
	movq	24(%rsp), %rsi
	movq	%rbx, %rdi
	movq	%rbp, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	movl	$.L.str.6, %edi
	movl	$.L.str.7, %esi
	callq	fopen
	movq	%rax, %r13
	cmpl	$2, %r15d
	movl	$1, %eax
	cmovgel	%r15d, %eax
	movq	%rax, 16(%rsp)                  # 8-byte Spill
	xorl	%r14d, %r14d
.LBB3_19:                               # =>This Loop Header: Depth=1
                                        #     Child Loop BB3_21 Depth 2
	leaq	1(%r14), %r15
	movq	%r14, %rax
	shlq	$4, %rax
	movq	96(%rsp), %rcx                  # 8-byte Reload
	movsd	(%rcx,%rax), %xmm0              # xmm0 = mem[0],zero
	movsd	8(%rcx,%rax), %xmm1             # xmm1 = mem[0],zero
	movl	$.L.str.8, %esi
	movq	%r13, %rdi
	movl	%r15d, %edx
	movb	$2, %al
	callq	fprintf
	cmpl	$0, (%rsp)                      # 4-byte Folded Reload
	je	.LBB3_24
# %bb.20:                               # %.lr.ph169.preheader
                                        #   in Loop: Header=BB3_19 Depth=1
	xorl	%r12d, %r12d
.LBB3_21:                               # %.lr.ph169
                                        #   Parent Loop BB3_19 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	32(%rbx,%r12), %r9d
	cmpq	%r9, %r14
	jne	.LBB3_23
# %bb.22:                               #   in Loop: Header=BB3_21 Depth=2
	movl	(%rbx,%r12), %edx
	movl	4(%rbx,%r12), %ecx
	movl	8(%rbx,%r12), %r8d
	movsd	16(%rbx,%r12), %xmm0            # xmm0 = mem[0],zero
	movsd	24(%rbx,%r12), %xmm1            # xmm1 = mem[0],zero
	movl	$.L.str.9, %esi
	movq	%r13, %rdi
                                        # kill: def $r9d killed $r9d killed $r9
	movb	$2, %al
	callq	fprintf
.LBB3_23:                               #   in Loop: Header=BB3_21 Depth=2
	addq	$40, %r12
	cmpq	%r12, %rbp
	jne	.LBB3_21
.LBB3_24:                               # %._crit_edge170
                                        #   in Loop: Header=BB3_19 Depth=1
	movl	$.L.str.10, %edi
	movl	$2, %esi
	movl	$1, %edx
	movq	%r13, %rcx
	callq	fwrite@PLT
	movq	%r15, %r14
	cmpq	16(%rsp), %r15                  # 8-byte Folded Reload
	jne	.LBB3_19
# %bb.25:                               # %._crit_edge174
	movq	48(%rsp), %r15                  # 8-byte Reload
	leal	(,%r15,4), %eax
	leal	(%rax,%rax,2), %r14d
	shlq	$2, %r14
	movq	%r14, %rdi
	callq	malloc
	movq	%rax, %rbp
	leaq	56(%rsp), %rdi
	movq	%r14, %rsi
	callq	hipMalloc
	movq	88(%rsp), %rdi                  # 8-byte Reload
	movabsq	$4294967296, %rax               # imm = 0x100000000
	orq	%rax, %rdi
	movabsq	$137438953484, %rdx             # imm = 0x200000000C
	movl	$1, %r12d
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB3_27
# %bb.26:
	movq	24(%rsp), %rdi
	movq	56(%rsp), %rsi
	movl	%r15d, %edx
	movq	(%rsp), %rcx                    # 8-byte Reload
                                        # kill: def $ecx killed $ecx killed $rcx
	callq	_Z26__device_stub__processDataP3dayPiii
.LBB3_27:                               # %.lr.ph178.preheader
	movq	56(%rsp), %rsi
	movq	%rbp, %rdi
	movq	%r14, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	movl	$.L.str.11, %edi
	movl	$56, %esi
	movl	$1, %edx
	movq	%r13, %rcx
	callq	fwrite@PLT
	movl	$.L.str.12, %edi
	movl	$.L.str.13, %esi
	movl	$.L.str.14, %edx
	movl	$.L.str.15, %ecx
	movl	$.L.str.16, %r8d
	movl	$.L.str.17, %r9d
	xorl	%eax, %eax
	pushq	$.L.str.25
	.cfi_adjust_cfa_offset 8
	pushq	$.L.str.24
	.cfi_adjust_cfa_offset 8
	pushq	$.L.str.23
	.cfi_adjust_cfa_offset 8
	pushq	$.L.str.22
	.cfi_adjust_cfa_offset 8
	pushq	$.L.str.21
	.cfi_adjust_cfa_offset 8
	pushq	$.L.str.20
	.cfi_adjust_cfa_offset 8
	pushq	$.L.str.19
	.cfi_adjust_cfa_offset 8
	pushq	$.L.str.18
	.cfi_adjust_cfa_offset 8
	callq	printf
	addq	$64, %rsp
	.cfi_adjust_cfa_offset -64
	cmpl	$2, %r15d
	cmovgel	%r15d, %r12d
	movq	%r12, (%rsp)                    # 8-byte Spill
	xorl	%r12d, %r12d
	xorl	%r14d, %r14d
	movq	%rbp, 16(%rsp)                  # 8-byte Spill
.LBB3_28:                               # %.lr.ph178
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB3_29 Depth 2
	movl	%r12d, %r15d
	andl	$1073741823, %r15d              # imm = 0x3FFFFFFF
	shlq	$4, %r15
	addq	%rbp, %r15
	incq	%r14
	movl	$.L.str.26, %esi
	movq	%r13, %rdi
	movl	%r14d, %edx
	xorl	%eax, %eax
	callq	fprintf
	movl	$.L.str.27, %edi
	movl	%r14d, %esi
	xorl	%eax, %eax
	callq	printf
	xorl	%ebp, %ebp
.LBB3_29:                               #   Parent Loop BB3_28 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	(%r15,%rbp,4), %edx
	movl	$.L.str.28, %esi
	movq	%r13, %rdi
	xorl	%eax, %eax
	callq	fprintf
	movl	(%r15,%rbp,4), %esi
	movl	$.L.str.29, %edi
	xorl	%eax, %eax
	callq	printf
	incq	%rbp
	cmpq	$12, %rbp
	jne	.LBB3_29
# %bb.30:                               #   in Loop: Header=BB3_28 Depth=1
	movl	$10, %edi
	movq	%r13, %rsi
	callq	fputc@PLT
	movl	$10, %edi
	callq	putchar@PLT
	addl	$3, %r12d
	cmpq	(%rsp), %r14                    # 8-byte Folded Reload
	movq	16(%rsp), %rbp                  # 8-byte Reload
	jne	.LBB3_28
# %bb.31:                               # %._crit_edge179
	movq	72(%rsp), %rdi
	callq	hipFree
	movq	64(%rsp), %rdi
	callq	hipFree
	movq	24(%rsp), %rdi
	callq	hipFree
	movq	56(%rsp), %rdi
	callq	hipFree
	movq	%rbx, %rdi
	callq	free
	movq	96(%rsp), %rdi                  # 8-byte Reload
	callq	free
	movq	%rbp, %rdi
	callq	free
	xorl	%eax, %eax
	jmp	.LBB3_35
.LBB3_32:
	movl	$.L.str.2, %edi
.LBB3_33:
	xorl	%eax, %eax
	callq	printf
.LBB3_34:
	movl	$1, %eax
.LBB3_35:
	addq	$120, %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
.LBB3_36:
	.cfi_def_cfa_offset 176
	movl	$.L.str.4, %edi
	callq	perror
	jmp	.LBB3_34
.Lfunc_end3:
	.size	main, .Lfunc_end3-main
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$32, %rsp
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -16
	movq	__hip_gpubin_handle(%rip), %rbx
	testq	%rbx, %rbx
	jne	.LBB4_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB4_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z10setCentersP3dayP6centerii, %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	$_Z7clusterP3dayP6centeriiPi, %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	$_Z11processDataP3dayPiii, %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_end4:
	.size	__hip_module_ctor, .Lfunc_end4-__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	.LBB5_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
.LBB5_2:
	retq
.Lfunc_end5:
	.size	__hip_module_dtor, .Lfunc_end5-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	_Z10setCentersP3dayP6centerii,@object # @_Z10setCentersP3dayP6centerii
	.section	.rodata,"a",@progbits
	.globl	_Z10setCentersP3dayP6centerii
	.p2align	3, 0x0
_Z10setCentersP3dayP6centerii:
	.quad	_Z25__device_stub__setCentersP3dayP6centerii
	.size	_Z10setCentersP3dayP6centerii, 8

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

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

	.type	.L.str.1,@object                # @.str.1
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.1:
	.asciz	"Missing Arguments"
	.size	.L.str.1, 18

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"invalid number of Clusters"
	.size	.L.str.2, 27

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

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"Failed to open file:"
	.size	.L.str.4, 21

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"%[^,],%d/%d/%d,%d,%d"
	.size	.L.str.5, 21

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"output.csv"
	.size	.L.str.6, 11

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

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"Cluster %d,Center,x=%f, y=%f\nDate,High,Low\n"
	.size	.L.str.8, 44

	.type	.L.str.9,@object                # @.str.9
.L.str.9:
	.asciz	"%d/%d/%d,%f,%f,%d\n"
	.size	.L.str.9, 19

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

	.type	.L.str.11,@object               # @.str.11
.L.str.11:
	.asciz	"Cluster,JAN,FEB,MAR,APR,MAY,JUN,JUL,AUG,SEP,OCT,NOV,DEC\n"
	.size	.L.str.11, 57

	.type	.L.str.12,@object               # @.str.12
.L.str.12:
	.asciz	"%6s%5s%5s%5s%5s%5s%5s%5s%5s%5s%5s%5s%5s\n"
	.size	.L.str.12, 41

	.type	.L.str.13,@object               # @.str.13
.L.str.13:
	.asciz	"Cluster"
	.size	.L.str.13, 8

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

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

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

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

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

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

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

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

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

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

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

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

	.type	.L.str.26,@object               # @.str.26
.L.str.26:
	.asciz	"%d"
	.size	.L.str.26, 3

	.type	.L.str.27,@object               # @.str.27
.L.str.27:
	.asciz	"%6d"
	.size	.L.str.27, 4

	.type	.L.str.28,@object               # @.str.28
.L.str.28:
	.asciz	",%d"
	.size	.L.str.28, 4

	.type	.L.str.29,@object               # @.str.29
.L.str.29:
	.asciz	"%5d"
	.size	.L.str.29, 4

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z10setCentersP3dayP6centerii"
	.size	.L__unnamed_1, 30

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z7clusterP3dayP6centeriiPi"
	.size	.L__unnamed_2, 28

	.type	.L__unnamed_3,@object           # @2
.L__unnamed_3:
	.asciz	"_Z11processDataP3dayPiii"
	.size	.L__unnamed_3, 25

	.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	"begin checks"
	.size	.Lstr, 13

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym _Z25__device_stub__setCentersP3dayP6centerii
	.addrsig_sym _Z22__device_stub__clusterP3dayP6centeriiPi
	.addrsig_sym _Z26__device_stub__processDataP3dayPiii
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z10setCentersP3dayP6centerii
	.addrsig_sym _Z7clusterP3dayP6centeriiPi
	.addrsig_sym _Z11processDataP3dayPiii
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z10setCentersP3dayP6centerii ; -- Begin function _Z10setCentersP3dayP6centerii
	.globl	_Z10setCentersP3dayP6centerii
	.p2align	8
	.type	_Z10setCentersP3dayP6centerii,@function
_Z10setCentersP3dayP6centerii:          ; @_Z10setCentersP3dayP6centerii
; %bb.0:
	s_clause 0x1
	s_load_b32 s3, s[0:1], 0x14
	s_load_b128 s[4:7], s[0:1], 0x0
	v_mov_b32_e32 v1, 0
	s_mov_b32 s2, s15
	s_mov_b32 s8, 0
	s_mov_b32 s9, exec_lo
	s_delay_alu instid0(VALU_DEP_1)
	v_mov_b32_e32 v2, v1
	v_mov_b32_e32 v3, v1
	ds_store_b96 v1, v[1:3]
	s_waitcnt lgkmcnt(0)
	v_cmpx_gt_i32_e64 s3, v0
	s_cbranch_execz .LBB0_14
; %bb.1:                                ; %.lr.ph
	s_load_b32 s0, s[0:1], 0x24
	v_mov_b32_e32 v4, v0
	s_mov_b32 s1, 0
	s_waitcnt lgkmcnt(0)
	s_and_b32 s0, s0, 0xffff
.LBB0_2:                                ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_6 Depth 2
                                        ;     Child Loop BB0_10 Depth 2
	s_delay_alu instid0(VALU_DEP_1)
	v_mad_i64_i32 v[2:3], null, v4, 40, s[4:5]
	s_mov_b32 s10, exec_lo
	global_load_b32 v4, v[2:3], off offset:32
	s_waitcnt vmcnt(0)
	v_cmpx_eq_u32_e64 s2, v4
	s_cbranch_execz .LBB0_13
; %bb.3:                                ;   in Loop: Header=BB0_2 Depth=1
	s_mov_b32 s12, exec_lo
	s_mov_b32 s11, exec_lo
	v_mbcnt_lo_u32_b32 v4, s12, 0
	s_delay_alu instid0(VALU_DEP_1)
	v_cmpx_eq_u32_e32 0, v4
	s_cbranch_execz .LBB0_5
; %bb.4:                                ;   in Loop: Header=BB0_2 Depth=1
	s_bcnt1_i32_b32 s12, s12
	s_delay_alu instid0(SALU_CYCLE_1)
	v_mov_b32_e32 v4, s12
	ds_add_u32 v1, v4 offset:8
.LBB0_5:                                ;   in Loop: Header=BB0_2 Depth=1
	s_or_b32 exec_lo, exec_lo, s11
	global_load_b64 v[4:5], v[2:3], off offset:16
	s_mov_b32 s12, exec_lo
	s_mov_b32 s11, 0
	s_waitcnt vmcnt(0)
	v_cvt_i32_f64_e32 v4, v[4:5]
.LBB0_6:                                ; %ComputeLoop
                                        ;   Parent Loop BB0_2 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	s_ctz_i32_b32 s13, s12
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	v_readlane_b32 s14, v4, s13
	s_lshl_b32 s13, 1, s13
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	s_and_not1_b32 s12, s12, s13
	s_add_i32 s11, s11, s14
	s_cmp_lg_u32 s12, 0
	s_cbranch_scc1 .LBB0_6
; %bb.7:                                ; %ComputeEnd
                                        ;   in Loop: Header=BB0_2 Depth=1
	v_mbcnt_lo_u32_b32 v4, exec_lo, 0
	s_mov_b32 s12, exec_lo
	s_delay_alu instid0(VALU_DEP_1)
	v_cmpx_eq_u32_e32 0, v4
	s_xor_b32 s12, exec_lo, s12
	s_cbranch_execz .LBB0_9
; %bb.8:                                ;   in Loop: Header=BB0_2 Depth=1
	v_mov_b32_e32 v4, s11
	ds_add_u32 v1, v4
.LBB0_9:                                ;   in Loop: Header=BB0_2 Depth=1
	s_or_b32 exec_lo, exec_lo, s12
	global_load_b64 v[2:3], v[2:3], off offset:24
	s_mov_b32 s12, exec_lo
	s_mov_b32 s11, 0
	s_waitcnt vmcnt(0)
	v_cvt_i32_f64_e32 v2, v[2:3]
.LBB0_10:                               ; %ComputeLoop24
                                        ;   Parent Loop BB0_2 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	s_ctz_i32_b32 s13, s12
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	v_readlane_b32 s14, v2, s13
	s_lshl_b32 s13, 1, s13
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	s_and_not1_b32 s12, s12, s13
	s_add_i32 s11, s11, s14
	s_cmp_lg_u32 s12, 0
	s_cbranch_scc1 .LBB0_10
; %bb.11:                               ; %ComputeEnd25
                                        ;   in Loop: Header=BB0_2 Depth=1
	v_mbcnt_lo_u32_b32 v2, exec_lo, 0
	s_mov_b32 s12, exec_lo
	s_delay_alu instid0(VALU_DEP_1)
	v_cmpx_eq_u32_e32 0, v2
	s_xor_b32 s12, exec_lo, s12
	s_cbranch_execz .LBB0_13
; %bb.12:                               ;   in Loop: Header=BB0_2 Depth=1
	v_mov_b32_e32 v2, s11
	ds_add_u32 v1, v2 offset:4
.LBB0_13:                               ; %Flow36
                                        ;   in Loop: Header=BB0_2 Depth=1
	s_or_b32 exec_lo, exec_lo, s10
	s_add_i32 s1, s1, 1
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[4:5], null, s1, s0, v[0:1]
	v_cmp_le_i32_e32 vcc_lo, s3, v4
	s_or_b32 s8, vcc_lo, s8
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_not1_b32 exec_lo, exec_lo, s8
	s_cbranch_execnz .LBB0_2
.LBB0_14:                               ; %Flow38
	s_or_b32 exec_lo, exec_lo, s9
	s_mov_b32 s3, 0
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	s_mov_b32 s0, exec_lo
	v_cmpx_eq_u32_e32 0, v0
	s_cbranch_execz .LBB0_16
; %bb.15:
	v_mov_b32_e32 v23, 0
	ds_load_b96 v[0:2], v23
	s_waitcnt lgkmcnt(0)
	v_cvt_f64_i32_e32 v[3:4], v0
	v_cvt_f64_i32_e32 v[5:6], v2
	v_cvt_f64_i32_e32 v[7:8], v1
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_div_scale_f64 v[0:1], null, v[5:6], v[5:6], v[3:4]
	v_div_scale_f64 v[9:10], null, v[5:6], v[5:6], v[7:8]
	v_div_scale_f64 v[19:20], vcc_lo, v[3:4], v[5:6], v[3:4]
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_rcp_f64_e32 v[11:12], v[0:1]
	v_rcp_f64_e32 v[13:14], v[9:10]
	s_waitcnt_depctr 0xfff
	v_fma_f64 v[15:16], -v[0:1], v[11:12], 1.0
	v_fma_f64 v[17:18], -v[9:10], v[13:14], 1.0
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_fma_f64 v[11:12], v[11:12], v[15:16], v[11:12]
	v_fma_f64 v[13:14], v[13:14], v[17:18], v[13:14]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_fma_f64 v[15:16], -v[0:1], v[11:12], 1.0
	v_fma_f64 v[17:18], -v[9:10], v[13:14], 1.0
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_3)
	v_fma_f64 v[11:12], v[11:12], v[15:16], v[11:12]
	v_div_scale_f64 v[15:16], s0, v[7:8], v[5:6], v[7:8]
	v_fma_f64 v[13:14], v[13:14], v[17:18], v[13:14]
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_mul_f64 v[17:18], v[19:20], v[11:12]
	v_mul_f64 v[21:22], v[15:16], v[13:14]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_fma_f64 v[0:1], -v[0:1], v[17:18], v[19:20]
	v_fma_f64 v[9:10], -v[9:10], v[21:22], v[15:16]
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_2) | instid1(VALU_DEP_2)
	v_div_fmas_f64 v[0:1], v[0:1], v[11:12], v[17:18]
	s_mov_b32 vcc_lo, s0
	s_lshl_b64 s[0:1], s[2:3], 4
	v_div_fmas_f64 v[9:10], v[9:10], v[13:14], v[21:22]
	s_add_u32 s0, s6, s0
	s_addc_u32 s1, s7, s1
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_div_fixup_f64 v[0:1], v[0:1], v[5:6], v[3:4]
	v_div_fixup_f64 v[2:3], v[9:10], v[5:6], v[7:8]
	global_store_b128 v23, v[0:3], s[0:1]
.LBB0_16:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z10setCentersP3dayP6centerii
		.amdhsa_group_segment_fixed_size 12
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 280
		.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 24
		.amdhsa_next_free_sgpr 16
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end0:
	.size	_Z10setCentersP3dayP6centerii, .Lfunc_end0-_Z10setCentersP3dayP6centerii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 752
; NumSgprs: 18
; NumVgprs: 24
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 12 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 2
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 24
; 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	_Z7clusterP3dayP6centeriiPi ; -- Begin function _Z7clusterP3dayP6centeriiPi
	.globl	_Z7clusterP3dayP6centeriiPi
	.p2align	8
	.type	_Z7clusterP3dayP6centeriiPi,@function
_Z7clusterP3dayP6centeriiPi:            ; @_Z7clusterP3dayP6centeriiPi
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x2c
	s_load_b128 s[4:7], s[0:1], 0x10
	s_add_u32 s8, s0, 32
	s_addc_u32 s9, s1, 0
	v_mov_b32_e32 v8, 0
	s_waitcnt lgkmcnt(0)
	s_and_b32 s10, s2, 0xffff
	global_store_b32 v8, v8, s[6:7]
	v_mad_u64_u32 v[5:6], null, s15, s10, v[0:1]
	s_mov_b32 s2, exec_lo
	s_delay_alu instid0(VALU_DEP_1)
	v_cmpx_gt_i32_e64 s5, v5
	s_cbranch_execz .LBB1_10
; %bb.1:                                ; %.preheader.lr.ph
	s_load_b128 s[0:3], s[0:1], 0x0
	s_load_b32 s11, s[8:9], 0x0
	s_cmp_gt_i32 s4, 0
	s_mov_b32 s12, 0
	s_cselect_b32 s13, -1, 0
	s_mov_b32 s14, 0
                                        ; implicit-def: $vgpr9
	s_waitcnt lgkmcnt(0)
	s_add_u32 s2, s2, 8
	s_addc_u32 s3, s3, 0
.LBB1_2:                                ; %.preheader
                                        ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB1_4 Depth 2
	s_and_not1_b32 vcc_lo, exec_lo, s13
	s_cbranch_vccnz .LBB1_5
; %bb.3:                                ; %.lr.ph
                                        ;   in Loop: Header=BB1_2 Depth=1
	v_mad_i64_i32 v[1:2], null, v5, 40, s[0:1]
	v_mov_b32_e32 v6, 0
	v_mov_b32_e32 v7, 0x408f4000
	s_mov_b32 s16, 0
	s_mov_b64 s[8:9], s[2:3]
	global_load_b128 v[1:4], v[1:2], off offset:16
.LBB1_4:                                ;   Parent Loop BB1_2 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	global_load_b128 v[10:13], v8, s[8:9] offset:-8
	s_waitcnt vmcnt(0)
	v_add_f64 v[12:13], v[3:4], -v[12:13]
	v_add_f64 v[10:11], v[1:2], -v[10:11]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_f64 v[12:13], v[12:13], v[12:13]
	v_fma_f64 v[10:11], v[10:11], v[10:11], v[12:13]
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_cmp_gt_f64_e32 vcc_lo, 0x10000000, v[10:11]
	v_cndmask_b32_e64 v12, 0, 1, vcc_lo
	v_lshlrev_b32_e32 v12, 8, v12
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ldexp_f64 v[10:11], v[10:11], v12
	v_rsq_f64_e32 v[12:13], v[10:11]
	s_waitcnt_depctr 0xfff
	v_mul_f64 v[14:15], v[10:11], v[12:13]
	v_mul_f64 v[12:13], v[12:13], 0.5
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[16:17], -v[12:13], v[14:15], 0.5
	v_fma_f64 v[14:15], v[14:15], v[16:17], v[14:15]
	v_fma_f64 v[12:13], v[12:13], v[16:17], v[12:13]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[16:17], -v[14:15], v[14:15], v[10:11]
	v_fma_f64 v[14:15], v[16:17], v[12:13], v[14:15]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[16:17], -v[14:15], v[14:15], v[10:11]
	v_fma_f64 v[12:13], v[16:17], v[12:13], v[14:15]
	v_cndmask_b32_e64 v14, 0, 0xffffff80, vcc_lo
	v_cmp_class_f64_e64 vcc_lo, v[10:11], 0x260
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ldexp_f64 v[12:13], v[12:13], v14
	v_dual_cndmask_b32 v11, v13, v11 :: v_dual_cndmask_b32 v10, v12, v10
	s_delay_alu instid0(VALU_DEP_1)
	v_cmp_lt_f64_e32 vcc_lo, v[10:11], v[6:7]
	v_dual_cndmask_b32 v7, v7, v11 :: v_dual_cndmask_b32 v6, v6, v10
	v_cndmask_b32_e64 v9, v9, s16, vcc_lo
	s_add_i32 s16, s16, 1
	s_add_u32 s8, s8, 16
	s_addc_u32 s9, s9, 0
	s_cmp_eq_u32 s4, s16
	s_cbranch_scc0 .LBB1_4
.LBB1_5:                                ; %Flow65
                                        ;   in Loop: Header=BB1_2 Depth=1
	v_mad_i64_i32 v[1:2], null, v5, 40, s[0:1]
	s_mov_b32 s8, exec_lo
	global_load_b32 v3, v[1:2], off offset:32
	s_waitcnt vmcnt(0)
	v_cmpx_ne_u32_e64 v3, v9
	s_cbranch_execz .LBB1_9
; %bb.6:                                ;   in Loop: Header=BB1_2 Depth=1
	s_mov_b32 s16, exec_lo
	s_mov_b32 s9, exec_lo
	v_mbcnt_lo_u32_b32 v3, s16, 0
	s_delay_alu instid0(VALU_DEP_1)
	v_cmpx_eq_u32_e32 0, v3
	s_cbranch_execz .LBB1_8
; %bb.7:                                ;   in Loop: Header=BB1_2 Depth=1
	s_bcnt1_i32_b32 s16, s16
	s_delay_alu instid0(SALU_CYCLE_1)
	v_mov_b32_e32 v3, s16
	global_atomic_add_u32 v8, v3, s[6:7]
.LBB1_8:                                ;   in Loop: Header=BB1_2 Depth=1
	s_or_b32 exec_lo, exec_lo, s9
	v_add_co_u32 v1, vcc_lo, v1, 32
	v_add_co_ci_u32_e32 v2, vcc_lo, 0, v2, vcc_lo
	global_store_b32 v[1:2], v9, off
.LBB1_9:                                ; %Flow
                                        ;   in Loop: Header=BB1_2 Depth=1
	s_or_b32 exec_lo, exec_lo, s8
	s_add_i32 s14, s14, 1
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_mul_i32 s8, s14, s11
	s_add_i32 s8, s8, s15
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[5:6], null, s8, s10, v[0:1]
	v_cmp_le_i32_e32 vcc_lo, s5, v5
	s_or_b32 s12, vcc_lo, s12
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_not1_b32 exec_lo, exec_lo, s12
	s_cbranch_execnz .LBB1_2
.LBB1_10:                               ; %._crit_edge48
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z7clusterP3dayP6centeriiPi
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 288
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 18
		.amdhsa_next_free_sgpr 17
		.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	_Z7clusterP3dayP6centeriiPi, .Lfunc_end1-_Z7clusterP3dayP6centeriiPi
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 604
; NumSgprs: 19
; NumVgprs: 18
; ScratchSize: 0
; MemoryBound: 1
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 2
; NumSGPRsForWavesPerEU: 19
; NumVGPRsForWavesPerEU: 18
; 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	_Z11processDataP3dayPiii ; -- Begin function _Z11processDataP3dayPiii
	.globl	_Z11processDataP3dayPiii
	.p2align	8
	.type	_Z11processDataP3dayPiii,@function
_Z11processDataP3dayPiii:               ; @_Z11processDataP3dayPiii
; %bb.0:
	s_load_b32 s2, s[0:1], 0x14
	v_bfe_u32 v4, v0, 10, 10
	s_mov_b32 s3, exec_lo
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_1)
	v_cmpx_gt_i32_e64 s2, v4
	s_cbranch_execz .LBB2_6
; %bb.1:                                ; %.lr.ph
	v_and_b32_e32 v0, 0x3ff, v0
	s_clause 0x2
	s_load_b32 s3, s[0:1], 0x24
	s_load_b128 s[4:7], s[0:1], 0x0
	s_load_b32 s0, s[0:1], 0x1c
	v_mov_b32_e32 v6, 1
	v_mad_u64_u32 v[1:2], null, s15, 12, v[0:1]
	v_add_nc_u32_e32 v5, 1, v0
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v2, 31, v1
	v_lshlrev_b64 v[1:2], 2, v[1:2]
	s_waitcnt lgkmcnt(0)
	s_lshr_b32 s1, s3, 16
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	s_mul_i32 s0, s0, s1
	s_mov_b32 s1, 0
	v_add_co_u32 v0, vcc_lo, s6, v1
	v_add_co_ci_u32_e32 v1, vcc_lo, s7, v2, vcc_lo
.LBB2_2:                                ; =>This Inner Loop Header: Depth=1
	v_mad_i64_i32 v[2:3], null, v4, 40, s[4:5]
	s_mov_b32 s3, exec_lo
	global_load_b32 v7, v[2:3], off offset:32
	s_waitcnt vmcnt(0)
	v_cmpx_eq_u32_e64 s15, v7
	s_cbranch_execz .LBB2_5
; %bb.3:                                ;   in Loop: Header=BB2_2 Depth=1
	global_load_b32 v2, v[2:3], off
	s_waitcnt vmcnt(0)
	v_cmp_eq_u32_e32 vcc_lo, v2, v5
	s_and_b32 exec_lo, exec_lo, vcc_lo
	s_cbranch_execz .LBB2_5
; %bb.4:                                ;   in Loop: Header=BB2_2 Depth=1
	global_atomic_add_u32 v[0:1], v6, off
.LBB2_5:                                ;   in Loop: Header=BB2_2 Depth=1
	s_or_b32 exec_lo, exec_lo, s3
	v_add_nc_u32_e32 v4, s0, v4
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(SALU_CYCLE_1)
	v_cmp_le_i32_e32 vcc_lo, s2, v4
	s_or_b32 s1, vcc_lo, s1
	s_and_not1_b32 exec_lo, exec_lo, s1
	s_cbranch_execnz .LBB2_2
.LBB2_6:                                ; %._crit_edge
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z11processDataP3dayPiii
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 280
		.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 1
		.amdhsa_next_free_vgpr 8
		.amdhsa_next_free_sgpr 16
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end2:
	.size	_Z11processDataP3dayPiii, .Lfunc_end2-_Z11processDataP3dayPiii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 248
; NumSgprs: 18
; NumVgprs: 8
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 8
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 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: 1
	.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
      - .offset:         16
        .size:           4
        .value_kind:     by_value
      - .offset:         20
        .size:           4
        .value_kind:     by_value
      - .offset:         24
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         28
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         32
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         36
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         38
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         40
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         42
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         44
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         46
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         64
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         88
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 12
    .kernarg_segment_align: 8
    .kernarg_segment_size: 280
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z10setCentersP3dayP6centerii
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z10setCentersP3dayP6centerii.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     24
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .offset:         16
        .size:           4
        .value_kind:     by_value
      - .offset:         20
        .size:           4
        .value_kind:     by_value
      - .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: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 288
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z7clusterP3dayP6centeriiPi
    .private_segment_fixed_size: 0
    .sgpr_count:     19
    .sgpr_spill_count: 0
    .symbol:         _Z7clusterP3dayP6centeriiPi.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     18
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .offset:         16
        .size:           4
        .value_kind:     by_value
      - .offset:         20
        .size:           4
        .value_kind:     by_value
      - .offset:         24
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         28
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         32
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         36
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         38
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         40
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         42
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         44
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         46
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         64
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         88
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 280
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z11processDataP3dayPiii
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z11processDataP3dayPiii.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     8
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
