#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <sys/time.h>
#include <float.h>
#include <time.h>
#include <cuda.h>

struct timeval startwtime,endwtime;
double seq_time;

__device__ double kernel(double a,double *d_sigma);
__device__ double distance(int l,int q,double *a, double *b, int *d_d);
void printmatrixd(int a, int b, double *matrix);
void printmatrixi(int a,int b, int *matrix);
void printsolution(int a, int b, double *point, int *kmatrix);
void checkfunction(void);

__global__ void devMain(double *d_m,int *d_kmatrix,double *d_x,double *d_y,double *d_y2, double *d_epsilon, double *d_sigma, int *d_n, int *d_d, int *d_count, double *d_xtemp, double *d_sum2, int *d_numthreads, double *d_sum);

int i,j,s,n,d,len,h,numthreads;
int *d_n, *d_d;

double *sum2,*m, *xtemp, *sum;
double *d_sum2, *d_m, *d_xtemp, *d_sum;

int *kmatrix, *count;
int *d_kmatrix, *d_count, *d_numthreads;

FILE *myfile;

double *x, *y, *y2;
double *d_x, *d_y, *d_y2;

double sigma,epsilon,p; //only use sigma and epsilon
double *d_sigma, *d_epsilon;

int main(int argc, char **argv){
	numthreads=6 ;// you can change this if you want
	if (argc!=5) {
		printf("Usage: %s, s, n, d, file.bin, \nwhere s is sigma*0.1, e is sigma*0.0001, \nn is the number of elements, \nd its dimension and file.bin\nthe binary file with the elements \n",argv[0]);
	    exit(1);
	}
	s=atoi(argv[1]);
	sigma=s*0.1;
	cudaMalloc((void **)&d_sigma,sizeof(double));
	cudaMemcpy(d_sigma,&sigma,sizeof(double),cudaMemcpyHostToDevice);

	
	cudaMalloc((void **)&d_numthreads,sizeof(int));
	cudaMemcpy(d_numthreads,&numthreads,sizeof(int),cudaMemcpyHostToDevice);



	epsilon=sigma*0.0001;
	cudaMalloc((void **)&d_epsilon,sizeof(double));
	cudaMemcpy(d_epsilon,&epsilon,sizeof(double),cudaMemcpyHostToDevice);

	n=atoi(argv[2]);
	cudaMalloc((void **)&d_n,sizeof(int));
	cudaMemcpy(d_n,&n,sizeof(int),cudaMemcpyHostToDevice);

	d=atoi(argv[3]);
	cudaMalloc((void **)&d_d,sizeof(int));
	cudaMemcpy(d_d,&d,sizeof(int),cudaMemcpyHostToDevice);

	xtemp=(double*)malloc(n*numthreads*sizeof(double));
	cudaMalloc((void **)&d_xtemp,n*numthreads*sizeof(double));

	m=(double*)malloc(n*sizeof(double));
	cudaMalloc((void **)&d_m,n*sizeof(double));

	sum2=(double*)malloc(n*numthreads*sizeof(double));
	cudaMalloc((void **)&d_sum2,n*numthreads*sizeof(double));

	sum=(double*)malloc(n*sizeof(double));
	cudaMalloc((void **)&d_sum,n*sizeof(double));

	kmatrix=(int*)malloc(n*sizeof(int));
	cudaMalloc((void **)&d_kmatrix,n*sizeof(int));

	count=(int*)malloc(n*sizeof(int));
	cudaMalloc((void **)&d_count,n*sizeof(int));

	x=(double*)malloc(n*d*sizeof(double));
	cudaMalloc((void **)&d_x,n*d*sizeof(double));

	y=(double*)malloc(n*d*sizeof(double));
	cudaMalloc((void **)&d_y,n*d*sizeof(double));

	y2=(double*)malloc(n*d*sizeof(double));
	cudaMalloc((void **)&d_y2,n*d*sizeof(double));

	for (i=0;i<n;i++){
		m[i]=100;
		for (j=0;j<numthreads;j++){
			xtemp[i*numthreads+j]=0;
			sum2[i*numthreads+j]=0;
		}
		sum[i]=0;
		kmatrix[i]=0;
		count[i]=0;
	}
	cudaMemcpy(d_m,m,n*sizeof(double),cudaMemcpyHostToDevice);
	cudaMemcpy(d_sum,sum,n*sizeof(double),cudaMemcpyHostToDevice);
	cudaMemcpy(d_sum2,sum2,n*numthreads*sizeof(double),cudaMemcpyHostToDevice);
	cudaMemcpy(d_kmatrix,kmatrix,n*sizeof(int),cudaMemcpyHostToDevice);
	cudaMemcpy(d_xtemp,xtemp,n*numthreads*sizeof(double),cudaMemcpyHostToDevice);
	cudaMemcpy(d_count,count,n*sizeof(int),cudaMemcpyHostToDevice);

	myfile=fopen(argv[4],"rb");
	for (i=0;i<n;i++){
		for (j=0;j<d;j++){
			len=fread(&p,8,1,myfile);
			x[i*d+j]=p;
			y[i*d+j]=0;
			y2[i*d+j]=p;
		}
	}
	fclose(myfile);

	cudaMemcpy(d_x,x,n*d*sizeof(double),cudaMemcpyHostToDevice);
	cudaMemcpy(d_y,y,n*d*sizeof(double),cudaMemcpyHostToDevice);
	cudaMemcpy(d_y2,y2,n*d*sizeof(double),cudaMemcpyHostToDevice);
	/** start of the main part of the program**/

	gettimeofday(&startwtime,NULL);

	devMain<<<n,numthreads,n*d*sizeof(double)>>>(d_m,d_kmatrix,d_x,d_y,d_y2,d_epsilon,d_sigma,d_n,d_d,d_count,d_xtemp,d_sum2,d_numthreads,d_sum);

	gettimeofday(&endwtime,NULL);
	cudaMemcpy(kmatrix,d_kmatrix,n*sizeof(int),cudaMemcpyDeviceToHost);
	cudaMemcpy(y2,d_y2,n*d*sizeof(double),cudaMemcpyDeviceToHost);

	printsolution(n,d,y2,kmatrix);
	//checkfunction();

	seq_time = (double)((endwtime.tv_usec - startwtime.tv_usec)/1.0e6
		      + endwtime.tv_sec - startwtime.tv_sec);
	printf("total time: %f secs\n",seq_time);

    free(x);
    free(y);
    free(y2);
    free(count);
    free(kmatrix);
    free (sum);
    free (sum2);
    free(m);

    cudaFree(d_x);
    cudaFree(d_y);
    cudaFree(d_y2);
    cudaFree(d_count);
    cudaFree(d_kmatrix);
    cudaFree(d_sum2);
    cudaFree(d_sum);
    cudaFree(m);

}

__device__ double kernel(double a, double *d_sigma){
	double result;
	result=exp(-a/(2*(*d_sigma)*(*d_sigma)));
	return result;
}

__device__ double distance(int l,int q, double *a, double *b, int *d_d){
	double sum=0;
	double root=0;
	int j;
	for (j=0;j<(*d_d);j++){
		sum+=(a[l*(*d_d)+j]-b[q*(*d_d)+j])*(a[l*(*d_d)+j]-b[q*(*d_d)+j]);
	}
	root=sqrt(sum);
	return root;
}

void printmatrixd(int a,int b, double *matrix){
	int i,j;
	for (i=0;i<a;i++){
		for (j=0;j<b;j++){
			printf("%f ",matrix[i*b+j]);
		}
		printf("\n");
	}
}

void printmatrixi(int a,int b, int *matrix){
	int i,j;
	for (i=0;i<a;i++){
		for (j=0;j<b;j++){
			printf("%d ",matrix[i*b+j]);
		}
		printf("\n");
	}
}

void printsolution(int a, int b, double *point, int *kmatrix){
	int i,j;
	for (i=0;i<a;i++){
		for (j=0;j<b;j++){
			printf("%f ",point[i*b+j]);
		}
		printf("i=%d, k=%d\n",i, kmatrix[i]);
	}
}

void checkfunction(void){
	char binary[50];
	FILE *myfile2;
	int  count,i,j;
	double *a;
	double p,dist;
	a=(double*)malloc(n*d*sizeof(double));
	printf("please give the name of the binary file \n(of double floats-8-bytes) that is a right solution\nto the mean shift problem:\n");
	dist=0;
	count=0;

	scanf("%s",binary);
	myfile2=fopen(binary,"rb");
	for (i=0;i<n;i++){
		//printf("reached here\n");
		for (int j=0;j<d;j++){
			fread(&p,8,1,myfile);
			a[i*d+j]=p;
		}
	}
	fclose(myfile2);
	for (i=0;i<n;i++){
		for (j=0;j<d;j++){
			dist+=(a[i*d+j]-y2[i*d+j])*(a[i*d+j]-y2[i*d+j]);
		}
		if (dist>sigma*sigma/100){ //distance>sigma/10
			count++;
		}
		dist=0;
	}
	free(a);
	printf("we have problem in %d out of %d points\n",count,n);



}

__global__ void devMain(double *d_m,int *d_kmatrix,double *d_x,double *d_y,double *d_y2, double *d_epsilon, double *d_sigma, int *d_n, int *d_d, int *d_count, double *d_xtemp, double *d_sum2, int *d_numthreads, double *d_sum){
	int j,i;
	int h;
	int bid=blockIdx.x;
	int tid=threadIdx.x;
	int steps=(*d_n/(*d_numthreads));
	extern __shared__ double sharedx[];
	

	for (j=0;j<(*d_d);j++){
		sharedx[bid*(*d_d)+j]=d_x[bid*(*d_d)+j];
	}
	__syncthreads();

		while ((d_m[bid]>*d_epsilon)&&(d_kmatrix[bid]<15)){
			//d_count[bid]=0;
			for (j=tid*steps;j<(tid+1)*steps;j++){
				//printf("j=%d\n",j);
				if (distance(bid,j,d_y2,d_x,d_d)<(*d_sigma)*(*d_sigma)){
					d_xtemp[bid*(*d_numthreads)+tid]=kernel(distance(bid,j,d_y2,d_x,d_d),d_sigma);
					//d_count[bid*(*d_numthreads)+tid]++;
					d_sum2[bid*(*d_numthreads)+tid]+=d_xtemp[bid*(*d_numthreads)+tid];
					for (h=0;h<(*d_d);h++){
						for (i=0;i<(*d_numthreads);i++){
						if (i==tid)	//to prevent data races
						d_y[bid*(*d_d)+h]+=d_xtemp[bid*(*d_numthreads)+tid]*d_x[j*(*d_d)+h];
					    __syncthreads();
					}
					}
				}
			}
			if (1==tid){
			for (h=0;h<(*d_numthreads);h++){
				d_sum[bid]+=d_sum2[bid*(*d_numthreads)+h];
			}
			for (h=0;h<*d_d;h++){
				d_y[bid*(*d_d)+h]/=d_sum[bid];
			}
			d_sum[bid]=0;
			d_m[bid]=distance(bid,bid,d_y,d_y2,d_d);
			d_kmatrix[bid]++;
			for (h=0;h<(*d_d);h++){
				d_y2[bid*(*d_d)+h]=d_y[bid*(*d_d)+h];
				d_y[bid*(*d_d)+h]=0;
			}
		}
		__syncthreads();
		d_sum2[bid*(*d_numthreads)+tid]=0;
		__syncthreads();
	}
	
}
	.file	"tmpxft_003af7ee_00000000-6_ergasia3_parallel_shared_double_1dmatrixes2.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2036:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2036:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z6kerneldPd
	.type	_Z6kerneldPd, @function
_Z6kerneldPd:
.LFB2028:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE2028:
	.size	_Z6kerneldPd, .-_Z6kerneldPd
	.globl	_Z8distanceiiPdS_Pi
	.type	_Z8distanceiiPdS_Pi, @function
_Z8distanceiiPdS_Pi:
.LFB2029:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE2029:
	.size	_Z8distanceiiPdS_Pi, .-_Z8distanceiiPdS_Pi
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%f "
.LC1:
	.string	"\n"
	.text
	.globl	_Z12printmatrixdiiPd
	.type	_Z12printmatrixdiiPd, @function
_Z12printmatrixdiiPd:
.LFB2030:
	.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
	movl	%edi, %r14d
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	xorl	%r13d, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	xorl	%r12d, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%rdx, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movl	%esi, %ebx
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
.L7:
	cmpl	%r14d, %r13d
	jge	.L6
	movslq	%r12d, %rax
	xorl	%r15d, %r15d
	leaq	0(%rbp,%rax,8), %rcx
.L10:
	cmpl	%r15d, %ebx
	jle	.L13
	movsd	(%rcx,%r15,8), %xmm0
	leaq	.LC0(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	movq	%rcx, 8(%rsp)
	incq	%r15
	call	__printf_chk@PLT
	movq	8(%rsp), %rcx
	jmp	.L10
.L13:
	leaq	.LC1(%rip), %rsi
	xorl	%eax, %eax
	incl	%r13d
	addl	%ebx, %r12d
	movl	$2, %edi
	call	__printf_chk@PLT
	jmp	.L7
.L6:
	addq	$24, %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
.LFE2030:
	.size	_Z12printmatrixdiiPd, .-_Z12printmatrixdiiPd
	.section	.rodata.str1.1
.LC2:
	.string	"%d "
	.text
	.globl	_Z12printmatrixiiiPi
	.type	_Z12printmatrixiiiPi, @function
_Z12printmatrixiiiPi:
.LFB2031:
	.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
	movl	%edi, %r14d
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	xorl	%r13d, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	xorl	%r12d, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%rdx, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movl	%esi, %ebx
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
.L15:
	cmpl	%r14d, %r13d
	jge	.L14
	movslq	%r12d, %rax
	xorl	%r15d, %r15d
	leaq	0(%rbp,%rax,4), %r8
.L18:
	cmpl	%r15d, %ebx
	jle	.L20
	movl	(%r8,%r15,4), %edx
	leaq	.LC2(%rip), %rsi
	xorl	%eax, %eax
	incq	%r15
	movl	$2, %edi
	movq	%r8, 8(%rsp)
	call	__printf_chk@PLT
	movq	8(%rsp), %r8
	jmp	.L18
.L20:
	leaq	.LC1(%rip), %rsi
	xorl	%eax, %eax
	incl	%r13d
	addl	%ebx, %r12d
	movl	$2, %edi
	call	__printf_chk@PLT
	jmp	.L15
.L14:
	addq	$24, %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
.LFE2031:
	.size	_Z12printmatrixiiiPi, .-_Z12printmatrixiiiPi
	.section	.rodata.str1.1
.LC3:
	.string	"i=%d, k=%d\n"
	.text
	.globl	_Z13printsolutioniiPdPi
	.type	_Z13printsolutioniiPdPi, @function
_Z13printsolutioniiPdPi:
.LFB2032:
	.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
	movq	%rcx, %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	xorl	%r12d, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	xorl	%ebp, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movl	%esi, %ebx
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	movl	%edi, 8(%rsp)
	movq	%rdx, (%rsp)
.L22:
	movl	%ebp, %edx
	cmpl	%ebp, 8(%rsp)
	jle	.L21
	movq	(%rsp), %rdi
	movslq	%r12d, %rax
	xorl	%r15d, %r15d
	leaq	(%rdi,%rax,8), %r13
.L25:
	cmpl	%r15d, %ebx
	jle	.L27
	movsd	0(%r13,%r15,8), %xmm0
	leaq	.LC0(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	movl	%edx, 12(%rsp)
	incq	%r15
	call	__printf_chk@PLT
	movl	12(%rsp), %edx
	jmp	.L25
.L27:
	movl	(%r14,%rbp,4), %ecx
	leaq	.LC3(%rip), %rsi
	xorl	%eax, %eax
	incq	%rbp
	movl	$2, %edi
	addl	%ebx, %r12d
	call	__printf_chk@PLT
	jmp	.L22
.L21:
	addq	$24, %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
.LFE2032:
	.size	_Z13printsolutioniiPdPi, .-_Z13printsolutioniiPdPi
	.section	.rodata.str1.1
.LC5:
	.string	"please give the name of the binary file \n(of double floats-8-bytes) that is a right solution\nto the mean shift problem:\n"
.LC6:
	.string	"%s"
.LC7:
	.string	"rb"
.LC9:
	.string	"we have problem in %d out of %d points\n"
	.text
	.globl	_Z13checkfunctionv
	.type	_Z13checkfunctionv, @function
_Z13checkfunctionv:
.LFB2033:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	xorl	%r13d, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	subq	$80, %rsp
	.cfi_def_cfa_offset 128
	movl	n(%rip), %edi
	imull	d(%rip), %edi
	movq	%fs:40, %rax
	movq	%rax, 72(%rsp)
	xorl	%eax, %eax
	leaq	22(%rsp), %rbp
	leaq	8(%rsp), %r12
	movslq	%edi, %rdi
	salq	$3, %rdi
	call	malloc@PLT
	leaq	.LC5(%rip), %rsi
	movl	$2, %edi
	movq	%rax, %rbx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	%rbp, %rsi
	leaq	.LC6(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc23_scanf@PLT
	movq	%rbp, %rdi
	leaq	.LC7(%rip), %rsi
	call	fopen@PLT
	movq	%rax, %rbp
.L29:
	cmpl	%r13d, n(%rip)
	jle	.L42
	xorl	%r14d, %r14d
.L31:
	cmpl	%r14d, d(%rip)
	jle	.L43
	movq	myfile(%rip), %r8
	movl	$1, %ecx
	movl	$8, %edx
	movq	%r12, %rdi
	movl	$8, %esi
	call	__fread_chk@PLT
	movl	d(%rip), %eax
	movsd	8(%rsp), %xmm0
	imull	%r13d, %eax
	addl	%r14d, %eax
	incl	%r14d
	cltq
	movsd	%xmm0, (%rbx,%rax,8)
	jmp	.L31
.L43:
	incl	%r13d
	jmp	.L29
.L42:
	movq	%rbp, %rdi
	xorl	%ebp, %ebp
	call	fclose@PLT
	movl	n(%rip), %r12d
	xorl	%ecx, %ecx
	xorl	%esi, %esi
	movl	d(%rip), %edi
	movsd	sigma(%rip), %xmm2
	movq	y2(%rip), %r8
	movsd	.LC8(%rip), %xmm3
.L32:
	cmpl	%esi, %r12d
	jle	.L36
	movslq	%ecx, %rax
	xorps	%xmm1, %xmm1
	xorl	%edx, %edx
	salq	$3, %rax
.L37:
	cmpl	%edx, %edi
	jle	.L44
	movsd	(%rbx,%rax), %xmm0
	subsd	(%r8,%rax), %xmm0
	incl	%edx
	addq	$8, %rax
	mulsd	%xmm0, %xmm0
	addsd	%xmm0, %xmm1
	jmp	.L37
.L44:
	movaps	%xmm2, %xmm0
	mulsd	%xmm2, %xmm0
	divsd	%xmm3, %xmm0
	comisd	%xmm0, %xmm1
	jbe	.L34
	incl	%ebp
.L34:
	incl	%esi
	addl	%edi, %ecx
	jmp	.L32
.L36:
	movq	%rbx, %rdi
	call	free@PLT
	xorl	%eax, %eax
	movl	%r12d, %ecx
	movl	%ebp, %edx
	leaq	.LC9(%rip), %rsi
	movl	$2, %edi
	call	__printf_chk@PLT
	movq	72(%rsp), %rax
	subq	%fs:40, %rax
	je	.L38
	call	__stack_chk_fail@PLT
.L38:
	addq	$80, %rsp
	.cfi_def_cfa_offset 48
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2033:
	.size	_Z13checkfunctionv, .-_Z13checkfunctionv
	.globl	_Z56__device_stub__Z7devMainPdPiS_S_S_S_S_S0_S0_S0_S_S_S0_S_PdPiS_S_S_S_S_S0_S0_S0_S_S_S0_S_
	.type	_Z56__device_stub__Z7devMainPdPiS_S_S_S_S_S0_S0_S0_S_S_S0_S_PdPiS_S_S_S_S_S0_S0_S0_S_S_S0_S_, @function
_Z56__device_stub__Z7devMainPdPiS_S_S_S_S_S0_S0_S0_S_S_S0_S_PdPiS_S_S_S_S_S0_S0_S0_S_S_S0_S_:
.LFB2058:
	.cfi_startproc
	endbr64
	subq	$312, %rsp
	.cfi_def_cfa_offset 320
	movq	320(%rsp), %rax
	movq	%rdi, 104(%rsp)
	leaq	136(%rsp), %rdi
	movq	%rsi, 96(%rsp)
	leaq	148(%rsp), %rsi
	movq	%rax, 56(%rsp)
	movq	328(%rsp), %rax
	movq	%rdx, 88(%rsp)
	leaq	120(%rsp), %rdx
	movq	%rax, 48(%rsp)
	movq	336(%rsp), %rax
	movq	%rcx, 80(%rsp)
	leaq	128(%rsp), %rcx
	movq	%rax, 40(%rsp)
	movq	344(%rsp), %rax
	movq	%r8, 72(%rsp)
	movq	%rax, 32(%rsp)
	movq	352(%rsp), %rax
	movq	%r9, 64(%rsp)
	movq	%rax, 24(%rsp)
	movq	360(%rsp), %rax
	movq	%rax, 16(%rsp)
	movq	368(%rsp), %rax
	movq	%rax, 8(%rsp)
	movq	376(%rsp), %rax
	movq	%rax, (%rsp)
	movq	%fs:40, %rax
	movq	%rax, 296(%rsp)
	xorl	%eax, %eax
	leaq	104(%rsp), %rax
	movq	%rax, 184(%rsp)
	leaq	96(%rsp), %rax
	movq	%rax, 192(%rsp)
	leaq	88(%rsp), %rax
	movq	%rax, 200(%rsp)
	leaq	80(%rsp), %rax
	movq	%rax, 208(%rsp)
	leaq	72(%rsp), %rax
	movq	%rax, 216(%rsp)
	leaq	64(%rsp), %rax
	movq	%rax, 224(%rsp)
	leaq	56(%rsp), %rax
	movq	%rax, 232(%rsp)
	leaq	48(%rsp), %rax
	movq	%rax, 240(%rsp)
	leaq	40(%rsp), %rax
	movq	%rax, 248(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 256(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 264(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 272(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 280(%rsp)
	movq	%rsp, %rax
	movq	%rax, 288(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 136(%rsp)
	movl	$1, 144(%rsp)
	movq	%rax, 148(%rsp)
	movl	$1, 156(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L45
	pushq	128(%rsp)
	.cfi_def_cfa_offset 328
	leaq	_Z7devMainPdPiS_S_S_S_S_S0_S0_S0_S_S_S0_S_(%rip), %rdi
	pushq	128(%rsp)
	.cfi_def_cfa_offset 336
	movq	164(%rsp), %rcx
	movl	172(%rsp), %r8d
	movq	152(%rsp), %rsi
	movl	160(%rsp), %edx
	leaq	200(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 328
	popq	%rdx
	.cfi_def_cfa_offset 320
.L45:
	movq	296(%rsp), %rax
	subq	%fs:40, %rax
	je	.L47
	call	__stack_chk_fail@PLT
.L47:
	addq	$312, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2058:
	.size	_Z56__device_stub__Z7devMainPdPiS_S_S_S_S_S0_S0_S0_S_S_S0_S_PdPiS_S_S_S_S_S0_S0_S0_S_S_S0_S_, .-_Z56__device_stub__Z7devMainPdPiS_S_S_S_S_S0_S0_S0_S_S_S0_S_PdPiS_S_S_S_S_S0_S0_S0_S_S_S0_S_
	.globl	_Z7devMainPdPiS_S_S_S_S_S0_S0_S0_S_S_S0_S_
	.type	_Z7devMainPdPiS_S_S_S_S_S0_S0_S0_S_S_S0_S_, @function
_Z7devMainPdPiS_S_S_S_S_S0_S0_S0_S_S_S0_S_:
.LFB2059:
	.cfi_startproc
	endbr64
	jmp	_Z56__device_stub__Z7devMainPdPiS_S_S_S_S_S0_S0_S0_S_S_S0_S_PdPiS_S_S_S_S_S0_S0_S0_S_S_S0_S_
	.cfi_endproc
.LFE2059:
	.size	_Z7devMainPdPiS_S_S_S_S_S0_S0_S0_S_S_S0_S_, .-_Z7devMainPdPiS_S_S_S_S_S0_S0_S0_S_S_S0_S_
	.section	.rodata.str1.1
.LC10:
	.string	"Usage: %s, s, n, d, file.bin, \nwhere s is sigma*0.1, e is sigma*0.0001, \nn is the number of elements, \nd its dimension and file.bin\nthe binary file with the elements \n"
.LC14:
	.string	"total time: %f secs\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2027:
	.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
	movq	%rsi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	subq	$32, %rsp
	.cfi_def_cfa_offset 64
	movl	$6, numthreads(%rip)
	cmpl	$5, %edi
	je	.L51
	movq	(%rsi), %rdx
	movl	$2, %edi
	xorl	%eax, %eax
	leaq	.LC10(%rip), %rsi
	call	__printf_chk@PLT
	movl	$1, %edi
	call	exit@PLT
.L51:
	movq	8(%rsi), %rdi
	call	atoi@PLT
	movl	$8, %esi
	leaq	d_sigma(%rip), %rdi
	cvtsi2sdl	%eax, %xmm0
	mulsd	.LC11(%rip), %xmm0
	movl	%eax, s(%rip)
	movsd	%xmm0, sigma(%rip)
	call	cudaMalloc@PLT
	movl	$1, %ecx
	movq	d_sigma(%rip), %rdi
	movl	$8, %edx
	leaq	sigma(%rip), %rsi
	call	cudaMemcpy@PLT
	movl	$4, %esi
	leaq	d_numthreads(%rip), %rdi
	call	cudaMalloc@PLT
	movl	$1, %ecx
	movq	d_numthreads(%rip), %rdi
	movl	$4, %edx
	leaq	numthreads(%rip), %rsi
	call	cudaMemcpy@PLT
	movsd	.LC12(%rip), %xmm0
	mulsd	sigma(%rip), %xmm0
	movl	$8, %esi
	leaq	d_epsilon(%rip), %rdi
	movsd	%xmm0, epsilon(%rip)
	call	cudaMalloc@PLT
	movl	$1, %ecx
	movq	d_epsilon(%rip), %rdi
	movl	$8, %edx
	leaq	epsilon(%rip), %rsi
	call	cudaMemcpy@PLT
	movq	16(%rbp), %rdi
	call	atoi@PLT
	movl	$4, %esi
	leaq	d_n(%rip), %rdi
	movl	%eax, n(%rip)
	call	cudaMalloc@PLT
	movl	$1, %ecx
	movq	d_n(%rip), %rdi
	movl	$4, %edx
	leaq	n(%rip), %rsi
	call	cudaMemcpy@PLT
	movq	24(%rbp), %rdi
	call	atoi@PLT
	movl	$4, %esi
	leaq	d_d(%rip), %rdi
	movl	%eax, d(%rip)
	call	cudaMalloc@PLT
	movl	$1, %ecx
	movq	d_d(%rip), %rdi
	movl	$4, %edx
	leaq	d(%rip), %rsi
	call	cudaMemcpy@PLT
	movl	n(%rip), %ebx
	imull	numthreads(%rip), %ebx
	movslq	%ebx, %rbx
	salq	$3, %rbx
	movq	%rbx, %rdi
	call	malloc@PLT
	movq	%rbx, %rsi
	leaq	d_xtemp(%rip), %rdi
	movq	%rax, xtemp(%rip)
	call	cudaMalloc@PLT
	movslq	n(%rip), %rbx
	salq	$3, %rbx
	movq	%rbx, %rdi
	call	malloc@PLT
	movq	%rbx, %rsi
	leaq	d_m(%rip), %rdi
	movq	%rax, m(%rip)
	call	cudaMalloc@PLT
	movl	n(%rip), %ebx
	imull	numthreads(%rip), %ebx
	movslq	%ebx, %rbx
	salq	$3, %rbx
	movq	%rbx, %rdi
	call	malloc@PLT
	movq	%rbx, %rsi
	leaq	d_sum2(%rip), %rdi
	movq	%rax, sum2(%rip)
	call	cudaMalloc@PLT
	movslq	n(%rip), %rbx
	salq	$3, %rbx
	movq	%rbx, %rdi
	call	malloc@PLT
	movq	%rbx, %rsi
	leaq	d_sum(%rip), %rdi
	movq	%rax, sum(%rip)
	call	cudaMalloc@PLT
	movslq	n(%rip), %rbx
	salq	$2, %rbx
	movq	%rbx, %rdi
	call	malloc@PLT
	movq	%rbx, %rsi
	leaq	d_kmatrix(%rip), %rdi
	movq	%rax, kmatrix(%rip)
	call	cudaMalloc@PLT
	movslq	n(%rip), %rbx
	salq	$2, %rbx
	movq	%rbx, %rdi
	call	malloc@PLT
	movq	%rbx, %rsi
	leaq	d_count(%rip), %rdi
	movq	%rax, count(%rip)
	call	cudaMalloc@PLT
	movl	n(%rip), %ebx
	xorl	%r12d, %r12d
	imull	d(%rip), %ebx
	movslq	%ebx, %rbx
	salq	$3, %rbx
	movq	%rbx, %rdi
	call	malloc@PLT
	movq	%rbx, %rsi
	leaq	d_x(%rip), %rdi
	movq	%rax, x(%rip)
	call	cudaMalloc@PLT
	movl	n(%rip), %ebx
	imull	d(%rip), %ebx
	movslq	%ebx, %rbx
	salq	$3, %rbx
	movq	%rbx, %rdi
	call	malloc@PLT
	movq	%rbx, %rsi
	leaq	d_y(%rip), %rdi
	movq	%rax, y(%rip)
	call	cudaMalloc@PLT
	movl	n(%rip), %ebx
	imull	d(%rip), %ebx
	movslq	%ebx, %rbx
	salq	$3, %rbx
	movq	%rbx, %rdi
	call	malloc@PLT
	movq	%rbx, %rsi
	leaq	d_y2(%rip), %rdi
	movq	%rax, y2(%rip)
	call	cudaMalloc@PLT
	movl	%r12d, i(%rip)
	movq	m(%rip), %rsi
	movq	sum(%rip), %r9
	movq	kmatrix(%rip), %r10
	movq	count(%rip), %r11
	movq	xtemp(%rip), %rdi
	movq	sum2(%rip), %r8
	movsd	.LC8(%rip), %xmm0
.L52:
	movl	i(%rip), %eax
	movslq	n(%rip), %rdx
	cmpl	%edx, %eax
	jge	.L66
	movl	numthreads(%rip), %edx
	movslq	%eax, %rcx
	xorl	%ebx, %ebx
	xorl	%r12d, %r12d
	movl	%ebx, j(%rip)
	xorl	%ebx, %ebx
	imull	%edx, %eax
	movsd	%xmm0, (%rsi,%rcx,8)
	cltq
	salq	$3, %rax
.L53:
	cmpl	%edx, %ebx
	jge	.L67
	movq	$0x000000000, (%rdi,%rax)
	incl	%ebx
	movb	$1, %r12b
	movq	$0x000000000, (%r8,%rax)
	addq	$8, %rax
	jmp	.L53
.L67:
	testb	%r12b, %r12b
	je	.L55
	xorl	%eax, %eax
	testl	%edx, %edx
	cmovs	%eax, %edx
	movl	%edx, j(%rip)
.L55:
	xorl	%eax, %eax
	movq	$0x000000000, (%r9,%rcx,8)
	xorl	%edx, %edx
	movl	%eax, (%r10,%rcx,4)
	movslq	i(%rip), %rax
	movl	%edx, (%r11,%rax,4)
	incl	i(%rip)
	jmp	.L52
.L66:
	movq	d_m(%rip), %rdi
	salq	$3, %rdx
	movl	$1, %ecx
	leaq	p(%rip), %rbx
	call	cudaMemcpy@PLT
	movslq	n(%rip), %rdx
	movl	$1, %ecx
	movq	sum(%rip), %rsi
	movq	d_sum(%rip), %rdi
	salq	$3, %rdx
	call	cudaMemcpy@PLT
	movl	n(%rip), %edx
	movl	$1, %ecx
	imull	numthreads(%rip), %edx
	movq	sum2(%rip), %rsi
	movq	d_sum2(%rip), %rdi
	movslq	%edx, %rdx
	salq	$3, %rdx
	call	cudaMemcpy@PLT
	movslq	n(%rip), %rdx
	movl	$1, %ecx
	movq	kmatrix(%rip), %rsi
	movq	d_kmatrix(%rip), %rdi
	salq	$2, %rdx
	call	cudaMemcpy@PLT
	movl	n(%rip), %edx
	movl	$1, %ecx
	imull	numthreads(%rip), %edx
	movq	xtemp(%rip), %rsi
	movq	d_xtemp(%rip), %rdi
	movslq	%edx, %rdx
	salq	$3, %rdx
	call	cudaMemcpy@PLT
	movslq	n(%rip), %rdx
	movl	$1, %ecx
	movq	count(%rip), %rsi
	movq	d_count(%rip), %rdi
	salq	$2, %rdx
	call	cudaMemcpy@PLT
	movq	32(%rbp), %rdi
	leaq	.LC7(%rip), %rsi
	call	fopen@PLT
	movq	%rax, myfile(%rip)
	xorl	%eax, %eax
.L57:
	cmpl	%eax, n(%rip)
	movl	%eax, i(%rip)
	jle	.L68
	xorl	%eax, %eax
.L59:
	cmpl	%eax, d(%rip)
	movl	%eax, j(%rip)
	movq	myfile(%rip), %r8
	jle	.L69
	movl	$1, %ecx
	movl	$8, %edx
	movl	$8, %esi
	movq	%rbx, %rdi
	call	__fread_chk@PLT
	movl	j(%rip), %edx
	movsd	p(%rip), %xmm0
	movl	%eax, len(%rip)
	movl	i(%rip), %eax
	imull	d(%rip), %eax
	movq	x(%rip), %rcx
	addl	%edx, %eax
	cltq
	movsd	%xmm0, (%rcx,%rax,8)
	movq	y(%rip), %rcx
	movq	$0x000000000, (%rcx,%rax,8)
	movq	y2(%rip), %rcx
	movsd	p(%rip), %xmm0
	movsd	%xmm0, (%rcx,%rax,8)
	leal	1(%rdx), %eax
	jmp	.L59
.L69:
	movl	i(%rip), %eax
	incl	%eax
	jmp	.L57
.L68:
	movq	myfile(%rip), %rdi
	call	fclose@PLT
	movl	n(%rip), %edx
	movl	$1, %ecx
	imull	d(%rip), %edx
	movq	x(%rip), %rsi
	movq	d_x(%rip), %rdi
	movslq	%edx, %rdx
	salq	$3, %rdx
	call	cudaMemcpy@PLT
	movl	n(%rip), %edx
	movl	$1, %ecx
	imull	d(%rip), %edx
	movq	y(%rip), %rsi
	movq	d_y(%rip), %rdi
	movslq	%edx, %rdx
	salq	$3, %rdx
	call	cudaMemcpy@PLT
	movl	n(%rip), %edx
	movl	$1, %ecx
	imull	d(%rip), %edx
	movq	y2(%rip), %rsi
	movq	d_y2(%rip), %rdi
	movslq	%edx, %rdx
	salq	$3, %rdx
	call	cudaMemcpy@PLT
	xorl	%esi, %esi
	leaq	startwtime(%rip), %rdi
	call	gettimeofday@PLT
	movl	n(%rip), %ecx
	movl	d(%rip), %eax
	xorl	%r9d, %r9d
	movl	numthreads(%rip), %edx
	imull	%ecx, %eax
	movl	%ecx, 8(%rsp)
	movl	%edx, 20(%rsp)
	movabsq	$4294967297, %rdx
	movq	%rdx, 12(%rsp)
	movq	8(%rsp), %rdi
	movq	%rdx, 24(%rsp)
	cltq
	movl	28(%rsp), %ecx
	movq	20(%rsp), %rdx
	movl	16(%rsp), %esi
	leaq	0(,%rax,8), %r8
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L60
	pushq	d_sum(%rip)
	.cfi_def_cfa_offset 72
	movq	d_epsilon(%rip), %r9
	movq	d_y2(%rip), %r8
	pushq	d_numthreads(%rip)
	.cfi_def_cfa_offset 80
	movq	d_y(%rip), %rcx
	pushq	d_sum2(%rip)
	.cfi_def_cfa_offset 88
	movq	d_x(%rip), %rdx
	pushq	d_xtemp(%rip)
	.cfi_def_cfa_offset 96
	movq	d_kmatrix(%rip), %rsi
	pushq	d_count(%rip)
	.cfi_def_cfa_offset 104
	movq	d_m(%rip), %rdi
	pushq	d_d(%rip)
	.cfi_def_cfa_offset 112
	pushq	d_n(%rip)
	.cfi_def_cfa_offset 120
	pushq	d_sigma(%rip)
	.cfi_def_cfa_offset 128
	call	_Z56__device_stub__Z7devMainPdPiS_S_S_S_S_S0_S0_S0_S_S_S0_S_PdPiS_S_S_S_S_S0_S0_S0_S_S_S0_S_
	addq	$64, %rsp
	.cfi_def_cfa_offset 64
.L60:
	xorl	%esi, %esi
	leaq	endwtime(%rip), %rdi
	call	gettimeofday@PLT
	movslq	n(%rip), %rdx
	movl	$2, %ecx
	movq	d_kmatrix(%rip), %rsi
	movq	kmatrix(%rip), %rdi
	salq	$2, %rdx
	call	cudaMemcpy@PLT
	movl	n(%rip), %edx
	movl	$2, %ecx
	imull	d(%rip), %edx
	movq	d_y2(%rip), %rsi
	movq	y2(%rip), %rdi
	movslq	%edx, %rdx
	salq	$3, %rdx
	call	cudaMemcpy@PLT
	movq	kmatrix(%rip), %rcx
	movq	y2(%rip), %rdx
	movl	d(%rip), %esi
	movl	n(%rip), %edi
	call	_Z13printsolutioniiPdPi
	movq	8+endwtime(%rip), %rax
	movl	$2, %edi
	cvtsi2sdq	endwtime(%rip), %xmm1
	subq	8+startwtime(%rip), %rax
	leaq	.LC14(%rip), %rsi
	cvtsi2sdq	%rax, %xmm0
	divsd	.LC13(%rip), %xmm0
	movb	$1, %al
	addsd	%xmm1, %xmm0
	cvtsi2sdq	startwtime(%rip), %xmm1
	subsd	%xmm1, %xmm0
	movsd	%xmm0, seq_time(%rip)
	call	__printf_chk@PLT
	movq	x(%rip), %rdi
	call	free@PLT
	movq	y(%rip), %rdi
	call	free@PLT
	movq	y2(%rip), %rdi
	call	free@PLT
	movq	count(%rip), %rdi
	call	free@PLT
	movq	kmatrix(%rip), %rdi
	call	free@PLT
	movq	sum(%rip), %rdi
	call	free@PLT
	movq	sum2(%rip), %rdi
	call	free@PLT
	movq	m(%rip), %rdi
	call	free@PLT
	movq	d_x(%rip), %rdi
	call	cudaFree@PLT
	movq	d_y(%rip), %rdi
	call	cudaFree@PLT
	movq	d_y2(%rip), %rdi
	call	cudaFree@PLT
	movq	d_count(%rip), %rdi
	call	cudaFree@PLT
	movq	d_kmatrix(%rip), %rdi
	call	cudaFree@PLT
	movq	d_sum2(%rip), %rdi
	call	cudaFree@PLT
	movq	d_sum(%rip), %rdi
	call	cudaFree@PLT
	movq	m(%rip), %rdi
	call	cudaFree@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 32
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2027:
	.size	main, .-main
	.section	.rodata.str1.1
.LC15:
	.string	"_Z7devMainPdPiS_S_S_S_S_S0_S0_S0_S_S_S0_S_"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2061:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 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	.LC15(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z7devMainPdPiS_S_S_S_S_S0_S0_S0_S_S_S0_S_(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	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	%rdx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE2061:
	.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	d_epsilon
	.bss
	.align 8
	.type	d_epsilon, @object
	.size	d_epsilon, 8
d_epsilon:
	.zero	8
	.globl	d_sigma
	.align 8
	.type	d_sigma, @object
	.size	d_sigma, 8
d_sigma:
	.zero	8
	.globl	p
	.align 8
	.type	p, @object
	.size	p, 8
p:
	.zero	8
	.globl	epsilon
	.align 8
	.type	epsilon, @object
	.size	epsilon, 8
epsilon:
	.zero	8
	.globl	sigma
	.align 8
	.type	sigma, @object
	.size	sigma, 8
sigma:
	.zero	8
	.globl	d_y2
	.align 8
	.type	d_y2, @object
	.size	d_y2, 8
d_y2:
	.zero	8
	.globl	d_y
	.align 8
	.type	d_y, @object
	.size	d_y, 8
d_y:
	.zero	8
	.globl	d_x
	.align 8
	.type	d_x, @object
	.size	d_x, 8
d_x:
	.zero	8
	.globl	y2
	.align 8
	.type	y2, @object
	.size	y2, 8
y2:
	.zero	8
	.globl	y
	.align 8
	.type	y, @object
	.size	y, 8
y:
	.zero	8
	.globl	x
	.align 8
	.type	x, @object
	.size	x, 8
x:
	.zero	8
	.globl	myfile
	.align 8
	.type	myfile, @object
	.size	myfile, 8
myfile:
	.zero	8
	.globl	d_numthreads
	.align 8
	.type	d_numthreads, @object
	.size	d_numthreads, 8
d_numthreads:
	.zero	8
	.globl	d_count
	.align 8
	.type	d_count, @object
	.size	d_count, 8
d_count:
	.zero	8
	.globl	d_kmatrix
	.align 8
	.type	d_kmatrix, @object
	.size	d_kmatrix, 8
d_kmatrix:
	.zero	8
	.globl	count
	.align 8
	.type	count, @object
	.size	count, 8
count:
	.zero	8
	.globl	kmatrix
	.align 8
	.type	kmatrix, @object
	.size	kmatrix, 8
kmatrix:
	.zero	8
	.globl	d_sum
	.align 8
	.type	d_sum, @object
	.size	d_sum, 8
d_sum:
	.zero	8
	.globl	d_xtemp
	.align 8
	.type	d_xtemp, @object
	.size	d_xtemp, 8
d_xtemp:
	.zero	8
	.globl	d_m
	.align 8
	.type	d_m, @object
	.size	d_m, 8
d_m:
	.zero	8
	.globl	d_sum2
	.align 8
	.type	d_sum2, @object
	.size	d_sum2, 8
d_sum2:
	.zero	8
	.globl	sum
	.align 8
	.type	sum, @object
	.size	sum, 8
sum:
	.zero	8
	.globl	xtemp
	.align 8
	.type	xtemp, @object
	.size	xtemp, 8
xtemp:
	.zero	8
	.globl	m
	.align 8
	.type	m, @object
	.size	m, 8
m:
	.zero	8
	.globl	sum2
	.align 8
	.type	sum2, @object
	.size	sum2, 8
sum2:
	.zero	8
	.globl	d_d
	.align 8
	.type	d_d, @object
	.size	d_d, 8
d_d:
	.zero	8
	.globl	d_n
	.align 8
	.type	d_n, @object
	.size	d_n, 8
d_n:
	.zero	8
	.globl	numthreads
	.align 4
	.type	numthreads, @object
	.size	numthreads, 4
numthreads:
	.zero	4
	.globl	h
	.align 4
	.type	h, @object
	.size	h, 4
h:
	.zero	4
	.globl	len
	.align 4
	.type	len, @object
	.size	len, 4
len:
	.zero	4
	.globl	d
	.align 4
	.type	d, @object
	.size	d, 4
d:
	.zero	4
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	s
	.align 4
	.type	s, @object
	.size	s, 4
s:
	.zero	4
	.globl	j
	.align 4
	.type	j, @object
	.size	j, 4
j:
	.zero	4
	.globl	i
	.align 4
	.type	i, @object
	.size	i, 4
i:
	.zero	4
	.globl	seq_time
	.align 8
	.type	seq_time, @object
	.size	seq_time, 8
seq_time:
	.zero	8
	.globl	endwtime
	.align 16
	.type	endwtime, @object
	.size	endwtime, 16
endwtime:
	.zero	16
	.globl	startwtime
	.align 16
	.type	startwtime, @object
	.size	startwtime, 16
startwtime:
	.zero	16
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC8:
	.long	0
	.long	1079574528
	.align 8
.LC11:
	.long	-1717986918
	.long	1069128089
	.align 8
.LC12:
	.long	-350469331
	.long	1058682594
	.align 8
.LC13:
	.long	0
	.long	1093567616
	.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 <math.h>
#include <sys/time.h>
#include <float.h>
#include <time.h>
#include <hip/hip_runtime.h>

struct timeval startwtime,endwtime;
double seq_time;

__device__ double kernel(double a,double *d_sigma);
__device__ double distance(int l,int q,double *a, double *b, int *d_d);
void printmatrixd(int a, int b, double *matrix);
void printmatrixi(int a,int b, int *matrix);
void printsolution(int a, int b, double *point, int *kmatrix);
void checkfunction(void);

__global__ void devMain(double *d_m,int *d_kmatrix,double *d_x,double *d_y,double *d_y2, double *d_epsilon, double *d_sigma, int *d_n, int *d_d, int *d_count, double *d_xtemp, double *d_sum2, int *d_numthreads, double *d_sum);

int i,j,s,n,d,len,h,numthreads;
int *d_n, *d_d;

double *sum2,*m, *xtemp, *sum;
double *d_sum2, *d_m, *d_xtemp, *d_sum;

int *kmatrix, *count;
int *d_kmatrix, *d_count, *d_numthreads;

FILE *myfile;

double *x, *y, *y2;
double *d_x, *d_y, *d_y2;

double sigma,epsilon,p; //only use sigma and epsilon
double *d_sigma, *d_epsilon;

int main(int argc, char **argv){
	numthreads=6 ;// you can change this if you want
	if (argc!=5) {
		printf("Usage: %s, s, n, d, file.bin, \nwhere s is sigma*0.1, e is sigma*0.0001, \nn is the number of elements, \nd its dimension and file.bin\nthe binary file with the elements \n",argv[0]);
	    exit(1);
	}
	s=atoi(argv[1]);
	sigma=s*0.1;
	hipMalloc((void **)&d_sigma,sizeof(double));
	hipMemcpy(d_sigma,&sigma,sizeof(double),hipMemcpyHostToDevice);

	
	hipMalloc((void **)&d_numthreads,sizeof(int));
	hipMemcpy(d_numthreads,&numthreads,sizeof(int),hipMemcpyHostToDevice);



	epsilon=sigma*0.0001;
	hipMalloc((void **)&d_epsilon,sizeof(double));
	hipMemcpy(d_epsilon,&epsilon,sizeof(double),hipMemcpyHostToDevice);

	n=atoi(argv[2]);
	hipMalloc((void **)&d_n,sizeof(int));
	hipMemcpy(d_n,&n,sizeof(int),hipMemcpyHostToDevice);

	d=atoi(argv[3]);
	hipMalloc((void **)&d_d,sizeof(int));
	hipMemcpy(d_d,&d,sizeof(int),hipMemcpyHostToDevice);

	xtemp=(double*)malloc(n*numthreads*sizeof(double));
	hipMalloc((void **)&d_xtemp,n*numthreads*sizeof(double));

	m=(double*)malloc(n*sizeof(double));
	hipMalloc((void **)&d_m,n*sizeof(double));

	sum2=(double*)malloc(n*numthreads*sizeof(double));
	hipMalloc((void **)&d_sum2,n*numthreads*sizeof(double));

	sum=(double*)malloc(n*sizeof(double));
	hipMalloc((void **)&d_sum,n*sizeof(double));

	kmatrix=(int*)malloc(n*sizeof(int));
	hipMalloc((void **)&d_kmatrix,n*sizeof(int));

	count=(int*)malloc(n*sizeof(int));
	hipMalloc((void **)&d_count,n*sizeof(int));

	x=(double*)malloc(n*d*sizeof(double));
	hipMalloc((void **)&d_x,n*d*sizeof(double));

	y=(double*)malloc(n*d*sizeof(double));
	hipMalloc((void **)&d_y,n*d*sizeof(double));

	y2=(double*)malloc(n*d*sizeof(double));
	hipMalloc((void **)&d_y2,n*d*sizeof(double));

	for (i=0;i<n;i++){
		m[i]=100;
		for (j=0;j<numthreads;j++){
			xtemp[i*numthreads+j]=0;
			sum2[i*numthreads+j]=0;
		}
		sum[i]=0;
		kmatrix[i]=0;
		count[i]=0;
	}
	hipMemcpy(d_m,m,n*sizeof(double),hipMemcpyHostToDevice);
	hipMemcpy(d_sum,sum,n*sizeof(double),hipMemcpyHostToDevice);
	hipMemcpy(d_sum2,sum2,n*numthreads*sizeof(double),hipMemcpyHostToDevice);
	hipMemcpy(d_kmatrix,kmatrix,n*sizeof(int),hipMemcpyHostToDevice);
	hipMemcpy(d_xtemp,xtemp,n*numthreads*sizeof(double),hipMemcpyHostToDevice);
	hipMemcpy(d_count,count,n*sizeof(int),hipMemcpyHostToDevice);

	myfile=fopen(argv[4],"rb");
	for (i=0;i<n;i++){
		for (j=0;j<d;j++){
			len=fread(&p,8,1,myfile);
			x[i*d+j]=p;
			y[i*d+j]=0;
			y2[i*d+j]=p;
		}
	}
	fclose(myfile);

	hipMemcpy(d_x,x,n*d*sizeof(double),hipMemcpyHostToDevice);
	hipMemcpy(d_y,y,n*d*sizeof(double),hipMemcpyHostToDevice);
	hipMemcpy(d_y2,y2,n*d*sizeof(double),hipMemcpyHostToDevice);
	/** start of the main part of the program**/

	gettimeofday(&startwtime,NULL);

	devMain<<<n,numthreads,n*d*sizeof(double)>>>(d_m,d_kmatrix,d_x,d_y,d_y2,d_epsilon,d_sigma,d_n,d_d,d_count,d_xtemp,d_sum2,d_numthreads,d_sum);

	gettimeofday(&endwtime,NULL);
	hipMemcpy(kmatrix,d_kmatrix,n*sizeof(int),hipMemcpyDeviceToHost);
	hipMemcpy(y2,d_y2,n*d*sizeof(double),hipMemcpyDeviceToHost);

	printsolution(n,d,y2,kmatrix);
	//checkfunction();

	seq_time = (double)((endwtime.tv_usec - startwtime.tv_usec)/1.0e6
		      + endwtime.tv_sec - startwtime.tv_sec);
	printf("total time: %f secs\n",seq_time);

    free(x);
    free(y);
    free(y2);
    free(count);
    free(kmatrix);
    free (sum);
    free (sum2);
    free(m);

    hipFree(d_x);
    hipFree(d_y);
    hipFree(d_y2);
    hipFree(d_count);
    hipFree(d_kmatrix);
    hipFree(d_sum2);
    hipFree(d_sum);
    hipFree(m);

}

__device__ double kernel(double a, double *d_sigma){
	double result;
	result=exp(-a/(2*(*d_sigma)*(*d_sigma)));
	return result;
}

__device__ double distance(int l,int q, double *a, double *b, int *d_d){
	double sum=0;
	double root=0;
	int j;
	for (j=0;j<(*d_d);j++){
		sum+=(a[l*(*d_d)+j]-b[q*(*d_d)+j])*(a[l*(*d_d)+j]-b[q*(*d_d)+j]);
	}
	root=sqrt(sum);
	return root;
}

void printmatrixd(int a,int b, double *matrix){
	int i,j;
	for (i=0;i<a;i++){
		for (j=0;j<b;j++){
			printf("%f ",matrix[i*b+j]);
		}
		printf("\n");
	}
}

void printmatrixi(int a,int b, int *matrix){
	int i,j;
	for (i=0;i<a;i++){
		for (j=0;j<b;j++){
			printf("%d ",matrix[i*b+j]);
		}
		printf("\n");
	}
}

void printsolution(int a, int b, double *point, int *kmatrix){
	int i,j;
	for (i=0;i<a;i++){
		for (j=0;j<b;j++){
			printf("%f ",point[i*b+j]);
		}
		printf("i=%d, k=%d\n",i, kmatrix[i]);
	}
}

void checkfunction(void){
	char binary[50];
	FILE *myfile2;
	int  count,i,j;
	double *a;
	double p,dist;
	a=(double*)malloc(n*d*sizeof(double));
	printf("please give the name of the binary file \n(of double floats-8-bytes) that is a right solution\nto the mean shift problem:\n");
	dist=0;
	count=0;

	scanf("%s",binary);
	myfile2=fopen(binary,"rb");
	for (i=0;i<n;i++){
		//printf("reached here\n");
		for (int j=0;j<d;j++){
			fread(&p,8,1,myfile);
			a[i*d+j]=p;
		}
	}
	fclose(myfile2);
	for (i=0;i<n;i++){
		for (j=0;j<d;j++){
			dist+=(a[i*d+j]-y2[i*d+j])*(a[i*d+j]-y2[i*d+j]);
		}
		if (dist>sigma*sigma/100){ //distance>sigma/10
			count++;
		}
		dist=0;
	}
	free(a);
	printf("we have problem in %d out of %d points\n",count,n);



}

__global__ void devMain(double *d_m,int *d_kmatrix,double *d_x,double *d_y,double *d_y2, double *d_epsilon, double *d_sigma, int *d_n, int *d_d, int *d_count, double *d_xtemp, double *d_sum2, int *d_numthreads, double *d_sum){
	int j,i;
	int h;
	int bid=blockIdx.x;
	int tid=threadIdx.x;
	int steps=(*d_n/(*d_numthreads));
	extern __shared__ double sharedx[];
	

	for (j=0;j<(*d_d);j++){
		sharedx[bid*(*d_d)+j]=d_x[bid*(*d_d)+j];
	}
	__syncthreads();

		while ((d_m[bid]>*d_epsilon)&&(d_kmatrix[bid]<15)){
			//d_count[bid]=0;
			for (j=tid*steps;j<(tid+1)*steps;j++){
				//printf("j=%d\n",j);
				if (distance(bid,j,d_y2,d_x,d_d)<(*d_sigma)*(*d_sigma)){
					d_xtemp[bid*(*d_numthreads)+tid]=kernel(distance(bid,j,d_y2,d_x,d_d),d_sigma);
					//d_count[bid*(*d_numthreads)+tid]++;
					d_sum2[bid*(*d_numthreads)+tid]+=d_xtemp[bid*(*d_numthreads)+tid];
					for (h=0;h<(*d_d);h++){
						for (i=0;i<(*d_numthreads);i++){
						if (i==tid)	//to prevent data races
						d_y[bid*(*d_d)+h]+=d_xtemp[bid*(*d_numthreads)+tid]*d_x[j*(*d_d)+h];
					    __syncthreads();
					}
					}
				}
			}
			if (1==tid){
			for (h=0;h<(*d_numthreads);h++){
				d_sum[bid]+=d_sum2[bid*(*d_numthreads)+h];
			}
			for (h=0;h<*d_d;h++){
				d_y[bid*(*d_d)+h]/=d_sum[bid];
			}
			d_sum[bid]=0;
			d_m[bid]=distance(bid,bid,d_y,d_y2,d_d);
			d_kmatrix[bid]++;
			for (h=0;h<(*d_d);h++){
				d_y2[bid*(*d_d)+h]=d_y[bid*(*d_d)+h];
				d_y[bid*(*d_d)+h]=0;
			}
		}
		__syncthreads();
		d_sum2[bid*(*d_numthreads)+tid]=0;
		__syncthreads();
	}
	
}
	.text
	.file	"ergasia3_parallel_shared_double_1dmatrixes2.hip"
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI0_0:
	.quad	0x3fb999999999999a              # double 0.10000000000000001
.LCPI0_1:
	.quad	0x3f1a36e2eb1c432d              # double 1.0E-4
.LCPI0_2:
	.quad	0x412e848000000000              # double 1.0E+6
	.text
	.globl	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
	pushq	%rax
	.cfi_def_cfa_offset 64
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rsi, %rbx
	movl	$6, numthreads(%rip)
	cmpl	$5, %edi
	jne	.LBB0_18
# %bb.1:
	movq	8(%rbx), %rdi
	callq	atoi
	cvtsi2sd	%eax, %xmm0
	movl	%eax, s(%rip)
	mulsd	.LCPI0_0(%rip), %xmm0
	movsd	%xmm0, sigma(%rip)
	movl	$d_sigma, %edi
	movl	$8, %esi
	callq	hipMalloc
	movq	d_sigma(%rip), %rdi
	movl	$sigma, %esi
	movl	$8, %edx
	movl	$1, %ecx
	callq	hipMemcpy
	movl	$d_numthreads, %edi
	movl	$4, %esi
	callq	hipMalloc
	movq	d_numthreads(%rip), %rdi
	movl	$numthreads, %esi
	movl	$4, %edx
	movl	$1, %ecx
	callq	hipMemcpy
	movsd	sigma(%rip), %xmm0              # xmm0 = mem[0],zero
	mulsd	.LCPI0_1(%rip), %xmm0
	movsd	%xmm0, epsilon(%rip)
	movl	$d_epsilon, %edi
	movl	$8, %esi
	callq	hipMalloc
	movq	d_epsilon(%rip), %rdi
	movl	$epsilon, %esi
	movl	$8, %edx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	16(%rbx), %rdi
	callq	atoi
	movl	%eax, n(%rip)
	movl	$d_n, %edi
	movl	$4, %esi
	callq	hipMalloc
	movq	d_n(%rip), %rdi
	movl	$n, %esi
	movl	$4, %edx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	24(%rbx), %rdi
	callq	atoi
	movl	%eax, d(%rip)
	movl	$d_d, %edi
	movl	$4, %esi
	callq	hipMalloc
	movq	d_d(%rip), %rdi
	movl	$d, %esi
	movl	$4, %edx
	movl	$1, %ecx
	callq	hipMemcpy
	movslq	n(%rip), %rax
	movslq	numthreads(%rip), %r14
	imulq	%rax, %r14
	shlq	$3, %r14
	movq	%r14, %rdi
	callq	malloc
	movq	%rax, xtemp(%rip)
	movl	$d_xtemp, %edi
	movq	%r14, %rsi
	callq	hipMalloc
	movslq	n(%rip), %r14
	shlq	$3, %r14
	movq	%r14, %rdi
	callq	malloc
	movq	%rax, m(%rip)
	movl	$d_m, %edi
	movq	%r14, %rsi
	callq	hipMalloc
	movslq	n(%rip), %rax
	movslq	numthreads(%rip), %r14
	imulq	%rax, %r14
	shlq	$3, %r14
	movq	%r14, %rdi
	callq	malloc
	movq	%rax, sum2(%rip)
	movl	$d_sum2, %edi
	movq	%r14, %rsi
	callq	hipMalloc
	movslq	n(%rip), %r14
	shlq	$3, %r14
	movq	%r14, %rdi
	callq	malloc
	movq	%rax, sum(%rip)
	movl	$d_sum, %edi
	movq	%r14, %rsi
	callq	hipMalloc
	movslq	n(%rip), %r14
	shlq	$2, %r14
	movq	%r14, %rdi
	callq	malloc
	movq	%rax, kmatrix(%rip)
	movl	$d_kmatrix, %edi
	movq	%r14, %rsi
	callq	hipMalloc
	movslq	n(%rip), %r14
	shlq	$2, %r14
	movq	%r14, %rdi
	callq	malloc
	movq	%rax, count(%rip)
	movl	$d_count, %edi
	movq	%r14, %rsi
	callq	hipMalloc
	movslq	n(%rip), %rax
	movslq	d(%rip), %r14
	imulq	%rax, %r14
	shlq	$3, %r14
	movq	%r14, %rdi
	callq	malloc
	movq	%rax, x(%rip)
	movl	$d_x, %edi
	movq	%r14, %rsi
	callq	hipMalloc
	movslq	n(%rip), %rax
	movslq	d(%rip), %r14
	imulq	%rax, %r14
	shlq	$3, %r14
	movq	%r14, %rdi
	callq	malloc
	movq	%rax, y(%rip)
	movl	$d_y, %edi
	movq	%r14, %rsi
	callq	hipMalloc
	movslq	n(%rip), %rax
	movslq	d(%rip), %r14
	imulq	%rax, %r14
	shlq	$3, %r14
	movq	%r14, %rdi
	callq	malloc
	movq	%rax, y2(%rip)
	movl	$d_y2, %edi
	movq	%r14, %rsi
	callq	hipMalloc
	movl	$0, i(%rip)
	movl	n(%rip), %r11d
	movq	m(%rip), %rsi
	testl	%r11d, %r11d
	jle	.LBB0_8
# %bb.2:                                # %.lr.ph21
	movq	xtemp(%rip), %rax
	movq	sum2(%rip), %rcx
	movq	sum(%rip), %rdx
	movq	kmatrix(%rip), %rdi
	xorl	%r8d, %r8d
	movq	count(%rip), %r9
	movabsq	$4636737291354636288, %r10      # imm = 0x4059000000000000
	xorl	%ebp, %ebp
.LBB0_3:                                # =>This Loop Header: Depth=1
                                        #     Child Loop BB0_5 Depth 2
	movslq	%ebp, %r11
	movq	%r10, (%rsi,%r11,8)
	movl	numthreads(%rip), %r14d
	movl	$0, %r15d
	testl	%r14d, %r14d
	jle	.LBB0_7
# %bb.4:                                # %.lr.ph
                                        #   in Loop: Header=BB0_3 Depth=1
	imull	%r14d, %ebp
	movslq	%ebp, %r12
	leaq	(%rax,%r12,8), %r15
	leaq	(%rcx,%r12,8), %r12
	xorl	%r13d, %r13d
.LBB0_5:                                #   Parent Loop BB0_3 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movq	%r8, (%r15,%r13,8)
	movq	%r8, (%r12,%r13,8)
	incq	%r13
	cmpq	%r13, %r14
	jne	.LBB0_5
# %bb.6:                                #   in Loop: Header=BB0_3 Depth=1
	movl	%r14d, %r15d
.LBB0_7:                                # %._crit_edge
                                        #   in Loop: Header=BB0_3 Depth=1
	movl	%r15d, j(%rip)
	movq	$0, (%rdx,%r11,8)
	movl	%r8d, (%rdi,%r11,4)
	movslq	i(%rip), %r11
	movl	%r8d, (%r9,%r11,4)
	movl	i(%rip), %ebp
	incl	%ebp
	movl	%ebp, i(%rip)
	movl	n(%rip), %r11d
	cmpl	%r11d, %ebp
	jl	.LBB0_3
.LBB0_8:                                # %._crit_edge22
	movq	d_m(%rip), %rdi
	movslq	%r11d, %rdx
	shlq	$3, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	d_sum(%rip), %rdi
	movq	sum(%rip), %rsi
	movslq	n(%rip), %rdx
	shlq	$3, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	d_sum2(%rip), %rdi
	movq	sum2(%rip), %rsi
	movslq	n(%rip), %rax
	movslq	numthreads(%rip), %rdx
	imulq	%rax, %rdx
	shlq	$3, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	d_kmatrix(%rip), %rdi
	movq	kmatrix(%rip), %rsi
	movslq	n(%rip), %rdx
	shlq	$2, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	d_xtemp(%rip), %rdi
	movq	xtemp(%rip), %rsi
	movslq	n(%rip), %rax
	movslq	numthreads(%rip), %rdx
	imulq	%rax, %rdx
	shlq	$3, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	d_count(%rip), %rdi
	movq	count(%rip), %rsi
	movslq	n(%rip), %rdx
	shlq	$2, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	32(%rbx), %rdi
	movl	$.L.str.1, %esi
	callq	fopen
	movq	%rax, myfile(%rip)
	movl	$0, i(%rip)
	movl	n(%rip), %edx
	testl	%edx, %edx
	jle	.LBB0_15
# %bb.9:                                # %.preheader.preheader
	xorl	%eax, %eax
	movl	d(%rip), %ecx
.LBB0_10:                               # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB0_11 Depth 2
	movl	$0, j(%rip)
	testl	%ecx, %ecx
	jle	.LBB0_13
.LBB0_11:                               # %.lr.ph24
                                        #   Parent Loop BB0_10 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movq	myfile(%rip), %rcx
	movl	$p, %edi
	movl	$8, %esi
	movl	$1, %edx
	callq	fread
	movl	%eax, len(%rip)
	movsd	p(%rip), %xmm0                  # xmm0 = mem[0],zero
	movq	x(%rip), %rdx
	movl	i(%rip), %eax
	movl	d(%rip), %ecx
	movl	%ecx, %esi
	imull	%eax, %esi
	movl	j(%rip), %edi
	addl	%edi, %esi
	movslq	%esi, %rsi
	movsd	%xmm0, (%rdx,%rsi,8)
	movq	y(%rip), %rdx
	movq	$0, (%rdx,%rsi,8)
	movsd	p(%rip), %xmm0                  # xmm0 = mem[0],zero
	movq	y2(%rip), %rdx
	movsd	%xmm0, (%rdx,%rsi,8)
	incl	%edi
	movl	%edi, j(%rip)
	cmpl	%ecx, %edi
	jl	.LBB0_11
# %bb.12:                               # %._crit_edge25.loopexit
                                        #   in Loop: Header=BB0_10 Depth=1
	movl	n(%rip), %edx
.LBB0_13:                               # %._crit_edge25
                                        #   in Loop: Header=BB0_10 Depth=1
	incl	%eax
	movl	%eax, i(%rip)
	cmpl	%edx, %eax
	jl	.LBB0_10
# %bb.14:                               # %._crit_edge26.loopexit
	movq	myfile(%rip), %rax
.LBB0_15:                               # %._crit_edge26
	movq	%rax, %rdi
	callq	fclose
	movq	d_x(%rip), %rdi
	movq	x(%rip), %rsi
	movslq	n(%rip), %rax
	movslq	d(%rip), %rdx
	imulq	%rax, %rdx
	shlq	$3, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	d_y(%rip), %rdi
	movq	y(%rip), %rsi
	movslq	n(%rip), %rax
	movslq	d(%rip), %rdx
	imulq	%rax, %rdx
	shlq	$3, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	d_y2(%rip), %rdi
	movq	y2(%rip), %rsi
	movslq	n(%rip), %rax
	movslq	d(%rip), %rdx
	imulq	%rax, %rdx
	shlq	$3, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movl	$startwtime, %edi
	xorl	%esi, %esi
	callq	gettimeofday
	movl	n(%rip), %edi
	movl	numthreads(%rip), %edx
	movslq	d(%rip), %rax
	movslq	%edi, %r8
	imulq	%rax, %r8
	shlq	$3, %r8
	btsq	$32, %rdi
	btsq	$32, %rdx
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB0_17
# %bb.16:
	movq	d_m(%rip), %rdi
	movq	d_kmatrix(%rip), %rsi
	movq	d_x(%rip), %rdx
	movq	d_y(%rip), %rcx
	movq	d_y2(%rip), %r8
	movq	d_epsilon(%rip), %r9
	pushq	d_sum(%rip)
	.cfi_adjust_cfa_offset 8
	pushq	d_numthreads(%rip)
	.cfi_adjust_cfa_offset 8
	pushq	d_sum2(%rip)
	.cfi_adjust_cfa_offset 8
	pushq	d_xtemp(%rip)
	.cfi_adjust_cfa_offset 8
	pushq	d_count(%rip)
	.cfi_adjust_cfa_offset 8
	pushq	d_d(%rip)
	.cfi_adjust_cfa_offset 8
	pushq	d_n(%rip)
	.cfi_adjust_cfa_offset 8
	pushq	d_sigma(%rip)
	.cfi_adjust_cfa_offset 8
	callq	_Z22__device_stub__devMainPdPiS_S_S_S_S_S0_S0_S0_S_S_S0_S_
	addq	$64, %rsp
	.cfi_adjust_cfa_offset -64
.LBB0_17:
	movl	$endwtime, %edi
	xorl	%esi, %esi
	callq	gettimeofday
	movq	kmatrix(%rip), %rdi
	movq	d_kmatrix(%rip), %rsi
	movslq	n(%rip), %rdx
	shlq	$2, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	movq	y2(%rip), %rdi
	movq	d_y2(%rip), %rsi
	movslq	n(%rip), %rax
	movslq	d(%rip), %rdx
	imulq	%rax, %rdx
	shlq	$3, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	movl	n(%rip), %edi
	movl	d(%rip), %esi
	movq	y2(%rip), %rdx
	movq	kmatrix(%rip), %rcx
	callq	_Z13printsolutioniiPdPi
	movq	endwtime+8(%rip), %rax
	subq	startwtime+8(%rip), %rax
	cvtsi2sd	%rax, %xmm1
	divsd	.LCPI0_2(%rip), %xmm1
	cvtsi2sdq	endwtime(%rip), %xmm0
	addsd	%xmm1, %xmm0
	xorps	%xmm1, %xmm1
	cvtsi2sdq	startwtime(%rip), %xmm1
	subsd	%xmm1, %xmm0
	movsd	%xmm0, seq_time(%rip)
	movl	$.L.str.2, %edi
	movb	$1, %al
	callq	printf
	movq	x(%rip), %rdi
	callq	free
	movq	y(%rip), %rdi
	callq	free
	movq	y2(%rip), %rdi
	callq	free
	movq	count(%rip), %rdi
	callq	free
	movq	kmatrix(%rip), %rdi
	callq	free
	movq	sum(%rip), %rdi
	callq	free
	movq	sum2(%rip), %rdi
	callq	free
	movq	m(%rip), %rdi
	callq	free
	movq	d_x(%rip), %rdi
	callq	hipFree
	movq	d_y(%rip), %rdi
	callq	hipFree
	movq	d_y2(%rip), %rdi
	callq	hipFree
	movq	d_count(%rip), %rdi
	callq	hipFree
	movq	d_kmatrix(%rip), %rdi
	callq	hipFree
	movq	d_sum2(%rip), %rdi
	callq	hipFree
	movq	d_sum(%rip), %rdi
	callq	hipFree
	movq	m(%rip), %rdi
	callq	hipFree
	xorl	%eax, %eax
	addq	$8, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.LBB0_18:
	.cfi_def_cfa_offset 64
	movq	(%rbx), %rsi
	movl	$.L.str, %edi
	xorl	%eax, %eax
	callq	printf
	movl	$1, %edi
	callq	exit
.Lfunc_end0:
	.size	main, .Lfunc_end0-main
	.cfi_endproc
                                        # -- End function
	.globl	_Z22__device_stub__devMainPdPiS_S_S_S_S_S0_S0_S0_S_S_S0_S_ # -- Begin function _Z22__device_stub__devMainPdPiS_S_S_S_S_S0_S0_S0_S_S_S0_S_
	.type	_Z22__device_stub__devMainPdPiS_S_S_S_S_S0_S0_S0_S_S_S0_S_,@function
_Z22__device_stub__devMainPdPiS_S_S_S_S_S0_S0_S0_S_S_S0_S_: # @_Z22__device_stub__devMainPdPiS_S_S_S_S_S0_S0_S0_S_S_S0_S_
	.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	$208, %rsp
	.cfi_def_cfa_offset 256
	.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	256(%rsp), %rax
	movq	%rax, 48(%rbx)
	leaq	264(%rsp), %rax
	movq	%rax, 56(%rbx)
	leaq	272(%rsp), %rax
	movq	%rax, 64(%rbx)
	leaq	280(%rsp), %rax
	movq	%rax, 72(%rbx)
	leaq	288(%rsp), %rax
	movq	%rax, 80(%rbx)
	leaq	296(%rsp), %rax
	movq	%rax, 88(%rbx)
	leaq	304(%rsp), %rax
	movq	%rax, 96(%rbx)
	leaq	312(%rsp), %rax
	movq	%rax, 104(%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	$_Z7devMainPdPiS_S_S_S_S_S0_S0_S0_S_S_S0_S_, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$224, %rsp
	.cfi_adjust_cfa_offset -224
	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__devMainPdPiS_S_S_S_S_S0_S0_S0_S_S_S0_S_, .Lfunc_end1-_Z22__device_stub__devMainPdPiS_S_S_S_S_S0_S0_S0_S_S_S0_S_
	.cfi_endproc
                                        # -- End function
	.globl	_Z13printsolutioniiPdPi         # -- Begin function _Z13printsolutioniiPdPi
	.type	_Z13printsolutioniiPdPi,@function
_Z13printsolutioniiPdPi:                # @_Z13printsolutioniiPdPi
	.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	$24, %rsp
	.cfi_def_cfa_offset 80
	.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	%rcx, 16(%rsp)                  # 8-byte Spill
	movq	%rdx, (%rsp)                    # 8-byte Spill
	testl	%edi, %edi
	jle	.LBB2_6
# %bb.1:                                # %.preheader.lr.ph
	movl	%esi, %ebp
	movl	%edi, %eax
	movq	%rax, 8(%rsp)                   # 8-byte Spill
	movl	%esi, %r13d
	xorl	%r14d, %r14d
	xorl	%r15d, %r15d
.LBB2_2:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB2_4 Depth 2
	testl	%ebp, %ebp
	jle	.LBB2_5
# %bb.3:                                # %.lr.ph
                                        #   in Loop: Header=BB2_2 Depth=1
	movl	%r14d, %eax
	movq	(%rsp), %rcx                    # 8-byte Reload
	leaq	(%rcx,%rax,8), %rbx
	xorl	%r12d, %r12d
.LBB2_4:                                #   Parent Loop BB2_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movsd	(%rbx,%r12,8), %xmm0            # xmm0 = mem[0],zero
	movl	$.L.str.3, %edi
	movb	$1, %al
	callq	printf
	incq	%r12
	cmpq	%r12, %r13
	jne	.LBB2_4
.LBB2_5:                                # %._crit_edge
                                        #   in Loop: Header=BB2_2 Depth=1
	movq	16(%rsp), %rax                  # 8-byte Reload
	movl	(%rax,%r15,4), %edx
	movl	$.L.str.6, %edi
	movl	%r15d, %esi
	xorl	%eax, %eax
	callq	printf
	incq	%r15
	addl	%ebp, %r14d
	cmpq	8(%rsp), %r15                   # 8-byte Folded Reload
	jne	.LBB2_2
.LBB2_6:                                # %._crit_edge16
	addq	$24, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end2:
	.size	_Z13printsolutioniiPdPi, .Lfunc_end2-_Z13printsolutioniiPdPi
	.cfi_endproc
                                        # -- End function
	.globl	_Z12printmatrixdiiPd            # -- Begin function _Z12printmatrixdiiPd
	.type	_Z12printmatrixdiiPd,@function
_Z12printmatrixdiiPd:                   # @_Z12printmatrixdiiPd
	.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	$24, %rsp
	.cfi_def_cfa_offset 80
	.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	%rdx, 8(%rsp)                   # 8-byte Spill
	testl	%edi, %edi
	jle	.LBB3_6
# %bb.1:                                # %.preheader.lr.ph
	movl	%esi, %ebp
	movl	%edi, %eax
	movq	%rax, 16(%rsp)                  # 8-byte Spill
	movl	%esi, %r15d
	xorl	%r12d, %r12d
	xorl	%r13d, %r13d
.LBB3_2:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB3_4 Depth 2
	testl	%ebp, %ebp
	jle	.LBB3_5
# %bb.3:                                # %.lr.ph
                                        #   in Loop: Header=BB3_2 Depth=1
	movl	%r12d, %eax
	movq	8(%rsp), %rcx                   # 8-byte Reload
	leaq	(%rcx,%rax,8), %rbx
	xorl	%r14d, %r14d
.LBB3_4:                                #   Parent Loop BB3_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movsd	(%rbx,%r14,8), %xmm0            # xmm0 = mem[0],zero
	movl	$.L.str.3, %edi
	movb	$1, %al
	callq	printf
	incq	%r14
	cmpq	%r14, %r15
	jne	.LBB3_4
.LBB3_5:                                # %._crit_edge
                                        #   in Loop: Header=BB3_2 Depth=1
	movl	$10, %edi
	callq	putchar@PLT
	incq	%r13
	addl	%ebp, %r12d
	cmpq	16(%rsp), %r13                  # 8-byte Folded Reload
	jne	.LBB3_2
.LBB3_6:                                # %._crit_edge13
	addq	$24, %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_end3:
	.size	_Z12printmatrixdiiPd, .Lfunc_end3-_Z12printmatrixdiiPd
	.cfi_endproc
                                        # -- End function
	.globl	_Z12printmatrixiiiPi            # -- Begin function _Z12printmatrixiiiPi
	.type	_Z12printmatrixiiiPi,@function
_Z12printmatrixiiiPi:                   # @_Z12printmatrixiiiPi
	.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	$24, %rsp
	.cfi_def_cfa_offset 80
	.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	%rdx, 8(%rsp)                   # 8-byte Spill
	testl	%edi, %edi
	jle	.LBB4_6
# %bb.1:                                # %.preheader.lr.ph
	movl	%esi, %ebp
	movl	%edi, %eax
	movq	%rax, 16(%rsp)                  # 8-byte Spill
	movl	%esi, %r15d
	xorl	%r12d, %r12d
	xorl	%r13d, %r13d
.LBB4_2:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB4_4 Depth 2
	testl	%ebp, %ebp
	jle	.LBB4_5
# %bb.3:                                # %.lr.ph
                                        #   in Loop: Header=BB4_2 Depth=1
	movl	%r12d, %eax
	movq	8(%rsp), %rcx                   # 8-byte Reload
	leaq	(%rcx,%rax,4), %rbx
	xorl	%r14d, %r14d
.LBB4_4:                                #   Parent Loop BB4_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	(%rbx,%r14,4), %esi
	movl	$.L.str.5, %edi
	xorl	%eax, %eax
	callq	printf
	incq	%r14
	cmpq	%r14, %r15
	jne	.LBB4_4
.LBB4_5:                                # %._crit_edge
                                        #   in Loop: Header=BB4_2 Depth=1
	movl	$10, %edi
	callq	putchar@PLT
	incq	%r13
	addl	%ebp, %r12d
	cmpq	16(%rsp), %r13                  # 8-byte Folded Reload
	jne	.LBB4_2
.LBB4_6:                                # %._crit_edge13
	addq	$24, %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_end4:
	.size	_Z12printmatrixiiiPi, .Lfunc_end4-_Z12printmatrixiiiPi
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z13checkfunctionv
.LCPI5_0:
	.quad	0x4059000000000000              # double 100
	.text
	.globl	_Z13checkfunctionv
	.type	_Z13checkfunctionv,@function
_Z13checkfunctionv:                     # @_Z13checkfunctionv
	.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	$72, %rsp
	.cfi_def_cfa_offset 128
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movslq	n(%rip), %rax
	movslq	d(%rip), %rdi
	imulq	%rax, %rdi
	shlq	$3, %rdi
	callq	malloc
	movq	%rax, %rbx
	movl	$.Lstr, %edi
	callq	puts@PLT
	xorl	%ebp, %ebp
	leaq	16(%rsp), %r14
	movl	$.L.str.8, %edi
	movq	%r14, %rsi
	xorl	%eax, %eax
	callq	__isoc23_scanf
	movl	$.L.str.1, %esi
	movq	%r14, %rdi
	callq	fopen
	movq	%rax, %r14
	movl	n(%rip), %ecx
	testl	%ecx, %ecx
	jle	.LBB5_7
# %bb.1:                                # %.preheader33.preheader
	xorl	%r12d, %r12d
	movl	d(%rip), %eax
	leaq	8(%rsp), %r15
.LBB5_2:                                # %.preheader33
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB5_4 Depth 2
	testl	%eax, %eax
	jle	.LBB5_6
# %bb.3:                                # %.lr.ph.preheader
                                        #   in Loop: Header=BB5_2 Depth=1
	xorl	%r13d, %r13d
.LBB5_4:                                # %.lr.ph
                                        #   Parent Loop BB5_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movq	myfile(%rip), %rcx
	movl	$8, %esi
	movl	$1, %edx
	movq	%r15, %rdi
	callq	fread
	movsd	8(%rsp), %xmm0                  # xmm0 = mem[0],zero
	movl	d(%rip), %eax
	movl	%r12d, %ecx
	imull	%eax, %ecx
	movslq	%ecx, %rcx
	addq	%r13, %rcx
	movsd	%xmm0, (%rbx,%rcx,8)
	incq	%r13
	cmpl	%eax, %r13d
	jl	.LBB5_4
# %bb.5:                                # %._crit_edge.loopexit
                                        #   in Loop: Header=BB5_2 Depth=1
	movl	n(%rip), %ecx
.LBB5_6:                                # %._crit_edge
                                        #   in Loop: Header=BB5_2 Depth=1
	incl	%r12d
	cmpl	%ecx, %r12d
	jl	.LBB5_2
.LBB5_7:                                # %._crit_edge36
	movq	%r14, %rdi
	callq	fclose
	movl	n(%rip), %r14d
	testl	%r14d, %r14d
	jle	.LBB5_14
# %bb.8:                                # %.preheader.lr.ph
	movl	d(%rip), %eax
	movsd	sigma(%rip), %xmm0              # xmm0 = mem[0],zero
	mulsd	%xmm0, %xmm0
	divsd	.LCPI5_0(%rip), %xmm0
	movq	y2(%rip), %rcx
	xorl	%edx, %edx
	xorl	%esi, %esi
	xorl	%ebp, %ebp
.LBB5_9:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB5_12 Depth 2
	testl	%eax, %eax
	jle	.LBB5_10
# %bb.11:                               # %.lr.ph39
                                        #   in Loop: Header=BB5_9 Depth=1
	movl	%edx, %r8d
	leaq	(%rcx,%r8,8), %rdi
	leaq	(%rbx,%r8,8), %r8
	xorpd	%xmm1, %xmm1
	xorl	%r9d, %r9d
.LBB5_12:                               #   Parent Loop BB5_9 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movsd	(%r8,%r9,8), %xmm2              # xmm2 = mem[0],zero
	subsd	(%rdi,%r9,8), %xmm2
	mulsd	%xmm2, %xmm2
	addsd	%xmm2, %xmm1
	incq	%r9
	cmpq	%r9, %rax
	jne	.LBB5_12
	jmp	.LBB5_13
.LBB5_10:                               #   in Loop: Header=BB5_9 Depth=1
	xorpd	%xmm1, %xmm1
.LBB5_13:                               # %._crit_edge40
                                        #   in Loop: Header=BB5_9 Depth=1
	xorl	%edi, %edi
	ucomisd	%xmm0, %xmm1
	seta	%dil
	addl	%edi, %ebp
	incq	%rsi
	addl	%eax, %edx
	cmpq	%r14, %rsi
	jne	.LBB5_9
.LBB5_14:                               # %._crit_edge43
	movq	%rbx, %rdi
	callq	free
	movl	$.L.str.9, %edi
	movl	%ebp, %esi
	movl	%r14d, %edx
	xorl	%eax, %eax
	callq	printf
	addq	$72, %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_end5:
	.size	_Z13checkfunctionv, .Lfunc_end5-_Z13checkfunctionv
	.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:
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	jne	.LBB6_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB6_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z7devMainPdPiS_S_S_S_S_S0_S0_S0_S_S_S0_S_, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$__hip_module_dtor, %edi
	addq	$40, %rsp
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end6:
	.size	__hip_module_ctor, .Lfunc_end6-__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	.LBB7_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
.LBB7_2:
	retq
.Lfunc_end7:
	.size	__hip_module_dtor, .Lfunc_end7-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	startwtime,@object              # @startwtime
	.bss
	.globl	startwtime
	.p2align	3, 0x0
startwtime:
	.zero	16
	.size	startwtime, 16

	.type	endwtime,@object                # @endwtime
	.globl	endwtime
	.p2align	3, 0x0
endwtime:
	.zero	16
	.size	endwtime, 16

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"Usage: %s, s, n, d, file.bin, \nwhere s is sigma*0.1, e is sigma*0.0001, \nn is the number of elements, \nd its dimension and file.bin\nthe binary file with the elements \n"
	.size	.L.str, 168

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

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

	.type	.L.str.2,@object                # @.str.2
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.2:
	.asciz	"total time: %f secs\n"
	.size	.L.str.2, 21

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

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

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"i=%d, k=%d\n"
	.size	.L.str.6, 12

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"%s"
	.size	.L.str.8, 3

	.type	.L.str.9,@object                # @.str.9
.L.str.9:
	.asciz	"we have problem in %d out of %d points\n"
	.size	.L.str.9, 40

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z7devMainPdPiS_S_S_S_S_S0_S0_S0_S_S_S0_S_"
	.size	.L__unnamed_1, 43

	.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	"please give the name of the binary file \n(of double floats-8-bytes) that is a right solution\nto the mean shift problem:"
	.size	.Lstr, 120

	.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 _Z22__device_stub__devMainPdPiS_S_S_S_S_S0_S0_S0_S_S_S0_S_
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym startwtime
	.addrsig_sym endwtime
	.addrsig_sym n
	.addrsig_sym d
	.addrsig_sym numthreads
	.addrsig_sym d_n
	.addrsig_sym d_d
	.addrsig_sym d_sum2
	.addrsig_sym d_m
	.addrsig_sym d_xtemp
	.addrsig_sym d_sum
	.addrsig_sym d_kmatrix
	.addrsig_sym d_count
	.addrsig_sym d_numthreads
	.addrsig_sym d_x
	.addrsig_sym d_y
	.addrsig_sym d_y2
	.addrsig_sym sigma
	.addrsig_sym epsilon
	.addrsig_sym p
	.addrsig_sym d_sigma
	.addrsig_sym d_epsilon
	.addrsig_sym _Z7devMainPdPiS_S_S_S_S_S0_S0_S0_S_S_S0_S_
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z7devMainPdPiS_S_S_S_S_S0_S0_S0_S_S_S0_S_ ; -- Begin function _Z7devMainPdPiS_S_S_S_S_S0_S0_S0_S_S_S0_S_
	.globl	_Z7devMainPdPiS_S_S_S_S_S0_S0_S0_S_S_S0_S_
	.p2align	8
	.type	_Z7devMainPdPiS_S_S_S_S_S0_S0_S0_S_S_S0_S_,@function
_Z7devMainPdPiS_S_S_S_S_S0_S0_S0_S_S_S0_S_: ; @_Z7devMainPdPiS_S_S_S_S_S0_S0_S0_S_S_S0_S_
; %bb.0:
	s_load_b64 s[30:31], s[0:1], 0x40
	s_mov_b32 s28, s15
	s_waitcnt lgkmcnt(0)
	s_load_b32 s20, s[30:31], 0x0
	s_load_b512 s[4:19], s[0:1], 0x0
	s_waitcnt lgkmcnt(0)
	s_cmp_lt_i32 s20, 1
	s_cbranch_scc1 .LBB0_3
; %bb.1:                                ; %.lr.ph
	s_mul_i32 s2, s20, s28
	s_delay_alu instid0(SALU_CYCLE_1)
	s_ashr_i32 s3, s2, 31
	s_lshl_b32 s21, s2, 3
	s_lshl_b64 s[2:3], s[2:3], 3
	s_add_i32 s21, s21, 0
	s_add_u32 s2, s8, s2
	s_addc_u32 s3, s9, s3
.LBB0_2:                                ; =>This Inner Loop Header: Depth=1
	s_load_b64 s[22:23], s[2:3], 0x0
	v_mov_b32_e32 v3, s21
	s_add_i32 s20, s20, -1
	s_add_i32 s21, s21, 8
	s_add_u32 s2, s2, 8
	s_addc_u32 s3, s3, 0
	s_cmp_lg_u32 s20, 0
	s_waitcnt lgkmcnt(0)
	v_dual_mov_b32 v1, s22 :: v_dual_mov_b32 v2, s23
	ds_store_b64 v3, v[1:2]
	s_cbranch_scc1 .LBB0_2
.LBB0_3:                                ; %._crit_edge
	s_ashr_i32 s29, s28, 31
	s_waitcnt lgkmcnt(0)
	s_lshl_b64 s[2:3], s[28:29], 3
	s_barrier
	s_add_u32 s4, s4, s2
	s_addc_u32 s5, s5, s3
	buffer_gl0_inv
	s_load_b64 s[20:21], s[4:5], 0x0
	s_load_b64 s[22:23], s[14:15], 0x0
	s_waitcnt lgkmcnt(0)
	v_cmp_ngt_f64_e64 s20, s[20:21], s[22:23]
	s_delay_alu instid0(VALU_DEP_1)
	s_and_b32 vcc_lo, exec_lo, s20
	s_cbranch_vccnz .LBB0_45
; %bb.4:                                ; %.lr.ph175
	s_load_b256 s[20:27], s[0:1], 0x50
	s_lshl_b64 s[0:1], s[28:29], 2
	s_load_b32 s18, s[18:19], 0x0
	s_add_u32 s6, s6, s0
	s_addc_u32 s7, s7, s1
	v_cmp_eq_u32_e64 s0, 1, v0
	s_mov_b32 s34, 0xfefa39ef
	s_mov_b32 s42, 0x623fde64
	s_mov_b32 s44, 0x7c89e6b0
	s_mov_b32 s46, 0x14761f6e
	s_mov_b32 s48, 0x1852b7b0
	s_mov_b32 s50, 0x11122322
	s_mov_b32 s52, 0x555502a1
	s_mov_b32 s54, 0x55555511
	s_mov_b32 s56, 11
	s_mov_b32 s35, 0xbfe62e42
	s_mov_b32 s43, 0x3ec71dee
	s_mov_b32 s45, 0x3efa0199
	s_mov_b32 s47, 0x3f2a01a0
	s_mov_b32 s49, 0x3f56c16c
	s_waitcnt lgkmcnt(0)
	s_load_b32 s33, s[24:25], 0x0
	s_mov_b32 s51, 0x3f811111
	s_ashr_i32 s36, s18, 31
	s_mov_b32 s53, 0x3fa55555
	s_add_i32 s18, s18, s36
	s_mov_b32 s55, 0x3fc55555
	s_xor_b32 s37, s18, s36
	s_mov_b32 s57, 0x3fe00000
	s_waitcnt lgkmcnt(0)
	s_ashr_i32 s1, s33, 31
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_add_i32 s33, s33, s1
	s_xor_b32 s29, s33, s1
	s_xor_b32 s1, s36, s1
	v_cvt_f32_u32_e32 v1, s29
	s_sub_i32 s33, 0, s29
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	v_rcp_iflag_f32_e32 v1, v1
	s_waitcnt_depctr 0xfff
	v_mul_f32_e32 v1, 0x4f7ffffe, v1
	v_cvt_u32_f32_e32 v1, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_readfirstlane_b32 s19, v1
	v_mov_b32_e32 v1, 0
	s_mul_i32 s33, s33, s19
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_mul_hi_u32 s33, s19, s33
	s_add_i32 s33, s19, s33
	s_mov_b32 s18, 0x652b82fe
	s_mul_hi_u32 s33, s37, s33
	s_mov_b32 s19, 0x3ff71547
	s_mul_i32 s38, s33, s29
	s_add_i32 s39, s33, 1
	s_sub_i32 s38, s37, s38
	s_mov_b32 s36, 0x3b39803f
	s_sub_i32 s40, s38, s29
	s_cmp_ge_u32 s38, s29
	s_mov_b32 s37, 0xbc7abc9e
	s_cselect_b32 s33, s39, s33
	s_cselect_b32 s38, s40, s38
	s_add_i32 s40, s33, 1
	s_cmp_ge_u32 s38, s29
	s_mov_b32 s38, 0xfca7ab0c
	s_cselect_b32 s29, s40, s33
	s_mov_b32 s40, 0x6a5dcb37
	s_xor_b32 s29, s29, s1
	s_mov_b32 s39, 0x3e928af3
	s_sub_i32 s1, s29, s1
	s_add_u32 s26, s26, s2
	v_mul_lo_u32 v10, s1, v0
	s_mov_b32 s41, 0x3e5ade15
	s_addc_u32 s27, s27, s3
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_nc_u32_e32 v11, s1, v10
	v_cmp_lt_i32_e64 s1, v10, v11
.LBB0_5:                                ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_8 Depth 2
                                        ;       Child Loop BB0_10 Depth 3
                                        ;       Child Loop BB0_15 Depth 3
                                        ;       Child Loop BB0_19 Depth 3
                                        ;         Child Loop BB0_21 Depth 4
                                        ;     Child Loop BB0_32 Depth 2
                                        ;     Child Loop BB0_37 Depth 2
                                        ;     Child Loop BB0_39 Depth 2
                                        ;     Child Loop BB0_42 Depth 2
	global_load_b32 v2, v1, s[6:7]
	s_mov_b32 s2, -1
	s_waitcnt vmcnt(0)
	v_cmp_lt_i32_e32 vcc_lo, 14, v2
	s_cbranch_vccnz .LBB0_44
; %bb.6:                                ;   in Loop: Header=BB0_5 Depth=1
	s_and_saveexec_b32 s29, s1
	s_cbranch_execz .LBB0_29
; %bb.7:                                ; %.lr.ph165.preheader
                                        ;   in Loop: Header=BB0_5 Depth=1
	global_load_b32 v13, v1, s[30:31]
	v_mov_b32_e32 v12, v10
	s_mov_b32 s33, 0
	s_waitcnt vmcnt(0)
	v_mov_b32_e32 v14, v13
.LBB0_8:                                ; %.lr.ph165
                                        ;   Parent Loop BB0_5 Depth=1
                                        ; =>  This Loop Header: Depth=2
                                        ;       Child Loop BB0_10 Depth 3
                                        ;       Child Loop BB0_15 Depth 3
                                        ;       Child Loop BB0_19 Depth 3
                                        ;         Child Loop BB0_21 Depth 4
	v_mov_b32_e32 v2, 0
	v_mov_b32_e32 v3, 0
	s_delay_alu instid0(VALU_DEP_3)
	v_cmp_lt_i32_e32 vcc_lo, 0, v14
	s_and_saveexec_b32 s58, vcc_lo
	s_cbranch_execz .LBB0_12
; %bb.9:                                ; %.lr.ph.i
                                        ;   in Loop: Header=BB0_8 Depth=2
	v_mul_lo_u32 v2, v14, v12
	v_mul_lo_u32 v4, v14, s28
	s_mov_b32 s59, 0
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_ashrrev_i32_e32 v3, 31, v2
	v_ashrrev_i32_e32 v5, 31, v4
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_lshlrev_b64 v[6:7], 3, v[2:3]
	v_lshlrev_b64 v[8:9], 3, v[4:5]
	v_mov_b32_e32 v2, 0
	v_mov_b32_e32 v3, 0
	s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_co_u32 v4, s2, s8, v6
	v_add_co_ci_u32_e64 v5, s2, s9, v7, s2
	v_add_co_u32 v6, s2, s12, v8
	v_mov_b32_e32 v8, v14
	v_add_co_ci_u32_e64 v7, s2, s13, v9, s2
.LBB0_10:                               ;   Parent Loop BB0_5 Depth=1
                                        ;     Parent Loop BB0_8 Depth=2
                                        ; =>    This Inner Loop Header: Depth=3
	global_load_b64 v[15:16], v[6:7], off
	global_load_b64 v[17:18], v[4:5], off
	v_add_nc_u32_e32 v8, -1, v8
	v_add_co_u32 v4, s2, v4, 8
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_co_ci_u32_e64 v5, s2, 0, v5, s2
	v_cmp_eq_u32_e64 s2, 0, v8
	v_add_co_u32 v6, s3, v6, 8
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_co_ci_u32_e64 v7, s3, 0, v7, s3
	s_or_b32 s59, s2, s59
	s_waitcnt vmcnt(0)
	v_add_f64 v[15:16], v[15:16], -v[17:18]
	s_delay_alu instid0(VALU_DEP_1)
	v_fma_f64 v[2:3], v[15:16], v[15:16], v[2:3]
	s_and_not1_b32 exec_lo, exec_lo, s59
	s_cbranch_execnz .LBB0_10
; %bb.11:                               ; %Flow300
                                        ;   in Loop: Header=BB0_8 Depth=2
	s_or_b32 exec_lo, exec_lo, s59
.LBB0_12:                               ; %Flow301
                                        ;   in Loop: Header=BB0_8 Depth=2
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	s_or_b32 exec_lo, exec_lo, s58
	v_cmp_gt_f64_e64 s2, 0x10000000, v[2:3]
	s_mov_b32 s58, exec_lo
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cndmask_b32_e64 v4, 0, 1, s2
	v_lshlrev_b32_e32 v4, 8, v4
	s_delay_alu instid0(VALU_DEP_1)
	v_ldexp_f64 v[4:5], v[2:3], v4
	global_load_b64 v[2:3], v1, s[16:17]
	v_rsq_f64_e32 v[6:7], v[4:5]
	s_waitcnt_depctr 0xfff
	v_mul_f64 v[8:9], v[4:5], v[6:7]
	v_mul_f64 v[6:7], v[6:7], 0.5
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[15:16], -v[6:7], v[8:9], 0.5
	v_fma_f64 v[8:9], v[8:9], v[15:16], v[8:9]
	v_fma_f64 v[6:7], v[6:7], v[15:16], v[6:7]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[15:16], -v[8:9], v[8:9], v[4:5]
	v_fma_f64 v[8:9], v[15:16], v[6:7], v[8:9]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[15:16], -v[8:9], v[8:9], v[4:5]
	v_fma_f64 v[6:7], v[15:16], v[6:7], v[8:9]
	v_cndmask_b32_e64 v8, 0, 0xffffff80, s2
	v_cmp_class_f64_e64 s2, v[4:5], 0x260
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_2) | instid1(VALU_DEP_2)
	v_ldexp_f64 v[6:7], v[6:7], v8
	s_waitcnt vmcnt(0)
	v_mul_f64 v[8:9], v[2:3], v[2:3]
	v_cndmask_b32_e64 v5, v7, v5, s2
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cndmask_b32_e64 v4, v6, v4, s2
	v_cmpx_lt_f64_e32 v[4:5], v[8:9]
	s_cbranch_execz .LBB0_28
; %bb.13:                               ;   in Loop: Header=BB0_8 Depth=2
	v_mov_b32_e32 v4, 0
	v_mov_b32_e32 v5, 0
	s_and_saveexec_b32 s3, vcc_lo
	s_cbranch_execz .LBB0_17
; %bb.14:                               ; %.lr.ph.i140
                                        ;   in Loop: Header=BB0_8 Depth=2
	v_mul_lo_u32 v4, v14, v12
	v_mul_lo_u32 v6, v14, s28
	s_mov_b32 s59, 0
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_ashrrev_i32_e32 v5, 31, v4
	v_ashrrev_i32_e32 v7, 31, v6
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_lshlrev_b64 v[8:9], 3, v[4:5]
	v_lshlrev_b64 v[15:16], 3, v[6:7]
	v_mov_b32_e32 v4, 0
	v_mov_b32_e32 v5, 0
	s_delay_alu instid0(VALU_DEP_4)
	v_add_co_u32 v6, vcc_lo, s8, v8
	v_add_co_ci_u32_e32 v7, vcc_lo, s9, v9, vcc_lo
	v_add_co_u32 v8, vcc_lo, s12, v15
	v_add_co_ci_u32_e32 v9, vcc_lo, s13, v16, vcc_lo
.LBB0_15:                               ;   Parent Loop BB0_5 Depth=1
                                        ;     Parent Loop BB0_8 Depth=2
                                        ; =>    This Inner Loop Header: Depth=3
	global_load_b64 v[15:16], v[8:9], off
	global_load_b64 v[17:18], v[6:7], off
	v_add_nc_u32_e32 v14, -1, v14
	v_add_co_u32 v6, vcc_lo, v6, 8
	v_add_co_ci_u32_e32 v7, vcc_lo, 0, v7, vcc_lo
	s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_cmp_eq_u32_e32 vcc_lo, 0, v14
	v_add_co_u32 v8, s2, v8, 8
	v_add_co_ci_u32_e64 v9, s2, 0, v9, s2
	s_or_b32 s59, vcc_lo, s59
	s_waitcnt vmcnt(0)
	v_add_f64 v[15:16], v[15:16], -v[17:18]
	s_delay_alu instid0(VALU_DEP_1)
	v_fma_f64 v[4:5], v[15:16], v[15:16], v[4:5]
	s_and_not1_b32 exec_lo, exec_lo, s59
	s_cbranch_execnz .LBB0_15
; %bb.16:                               ; %Flow297
                                        ;   in Loop: Header=BB0_8 Depth=2
	s_or_b32 exec_lo, exec_lo, s59
.LBB0_17:                               ; %Flow298
                                        ;   in Loop: Header=BB0_8 Depth=2
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	s_or_b32 exec_lo, exec_lo, s3
	v_cmp_gt_f64_e32 vcc_lo, 0x10000000, v[4:5]
	v_cndmask_b32_e64 v6, 0, 1, vcc_lo
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b32_e32 v6, 8, v6
	v_ldexp_f64 v[4:5], v[4:5], v6
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_3) | instid1(VALU_DEP_1)
	v_rsq_f64_e32 v[6:7], v[4:5]
	s_waitcnt_depctr 0xfff
	v_mul_f64 v[8:9], v[4:5], v[6:7]
	v_mul_f64 v[6:7], v[6:7], 0.5
	v_fma_f64 v[14:15], -v[6:7], v[8:9], 0.5
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_fma_f64 v[8:9], v[8:9], v[14:15], v[8:9]
	v_fma_f64 v[6:7], v[6:7], v[14:15], v[6:7]
	v_fma_f64 v[14:15], -v[8:9], v[8:9], v[4:5]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[8:9], v[14:15], v[6:7], v[8:9]
	v_fma_f64 v[14:15], -v[8:9], v[8:9], v[4:5]
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_3) | instid1(VALU_DEP_2)
	v_fma_f64 v[6:7], v[14:15], v[6:7], v[8:9]
	v_add_f64 v[8:9], v[2:3], v[2:3]
	v_cndmask_b32_e64 v14, 0, 0xffffff80, vcc_lo
	v_cmp_class_f64_e64 vcc_lo, v[4:5], 0x260
	v_ldexp_f64 v[6:7], v[6:7], v14
	s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_mul_f64 v[2:3], v[2:3], v[8:9]
	v_cndmask_b32_e32 v4, v6, v4, vcc_lo
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cndmask_b32_e64 v5, -v7, -v5, vcc_lo
	v_div_scale_f64 v[6:7], null, v[2:3], v[2:3], v[4:5]
	v_div_scale_f64 v[16:17], vcc_lo, v[4:5], v[2:3], v[4:5]
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	v_rcp_f64_e32 v[8:9], v[6:7]
	s_waitcnt_depctr 0xfff
	v_fma_f64 v[14:15], -v[6:7], v[8:9], 1.0
	v_fma_f64 v[8:9], v[8:9], v[14:15], v[8:9]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[14:15], -v[6:7], v[8:9], 1.0
	v_fma_f64 v[8:9], v[8:9], v[14:15], v[8:9]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_f64 v[14:15], v[16:17], v[8:9]
	v_fma_f64 v[6:7], -v[6:7], v[14:15], v[16:17]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_div_fmas_f64 v[6:7], v[6:7], v[8:9], v[14:15]
	v_div_fixup_f64 v[3:4], v[6:7], v[2:3], v[4:5]
	global_load_b32 v2, v1, s[24:25]
	v_mul_f64 v[5:6], v[3:4], s[18:19]
	v_cmp_nlt_f64_e32 vcc_lo, 0x40900000, v[3:4]
	v_cmp_ngt_f64_e64 s2, 0xc090cc00, v[3:4]
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_rndne_f64_e32 v[5:6], v[5:6]
	v_fma_f64 v[7:8], v[5:6], s[34:35], v[3:4]
	v_cvt_i32_f64_e32 v9, v[5:6]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[7:8], v[5:6], s[36:37], v[7:8]
	v_fma_f64 v[14:15], v[7:8], s[40:41], s[38:39]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[14:15], v[7:8], v[14:15], s[42:43]
	v_fma_f64 v[14:15], v[7:8], v[14:15], s[44:45]
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	v_fma_f64 v[14:15], v[7:8], v[14:15], s[46:47]
	s_waitcnt vmcnt(0)
	v_mad_u64_u32 v[3:4], null, v2, s28, v[0:1]
	v_ashrrev_i32_e32 v4, 31, v3
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_lshlrev_b64 v[3:4], 3, v[3:4]
	v_fma_f64 v[14:15], v[7:8], v[14:15], s[48:49]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[14:15], v[7:8], v[14:15], s[50:51]
	v_fma_f64 v[14:15], v[7:8], v[14:15], s[52:53]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[14:15], v[7:8], v[14:15], s[54:55]
	v_fma_f64 v[14:15], v[7:8], v[14:15], s[56:57]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[14:15], v[7:8], v[14:15], 1.0
	v_fma_f64 v[5:6], v[7:8], v[14:15], 1.0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ldexp_f64 v[5:6], v[5:6], v9
	v_cndmask_b32_e32 v8, 0x7ff00000, v6, vcc_lo
	s_and_b32 vcc_lo, s2, vcc_lo
	v_add_co_u32 v6, s3, s20, v3
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_co_ci_u32_e64 v7, s3, s21, v4, s3
	v_cndmask_b32_e64 v9, 0, v8, s2
	v_cndmask_b32_e32 v8, 0, v5, vcc_lo
	v_add_co_u32 v3, vcc_lo, s22, v3
	v_add_co_ci_u32_e32 v4, vcc_lo, s23, v4, vcc_lo
	global_store_b64 v[6:7], v[8:9], off
	s_mov_b32 s3, exec_lo
	global_load_b64 v[5:6], v[3:4], off
	s_waitcnt vmcnt(0)
	v_add_f64 v[5:6], v[5:6], v[8:9]
	global_store_b64 v[3:4], v[5:6], off
	v_cmpx_lt_i32_e32 0, v13
	s_cbranch_execz .LBB0_27
; %bb.18:                               ; %.preheader.preheader
                                        ;   in Loop: Header=BB0_8 Depth=2
	s_mov_b32 s59, 0
	s_mov_b32 s2, 0
.LBB0_19:                               ; %.preheader
                                        ;   Parent Loop BB0_5 Depth=1
                                        ;     Parent Loop BB0_8 Depth=2
                                        ; =>    This Loop Header: Depth=3
                                        ;         Child Loop BB0_21 Depth 4
	v_cmp_gt_i32_e32 vcc_lo, 1, v2
	s_cbranch_vccnz .LBB0_25
; %bb.20:                               ; %.lr.ph159.preheader
                                        ;   in Loop: Header=BB0_19 Depth=3
	s_mov_b32 s60, 0
.LBB0_21:                               ; %.lr.ph159
                                        ;   Parent Loop BB0_5 Depth=1
                                        ;     Parent Loop BB0_8 Depth=2
                                        ;       Parent Loop BB0_19 Depth=3
                                        ; =>      This Inner Loop Header: Depth=4
	s_mov_b32 s61, exec_lo
	v_cmpx_eq_u32_e64 s60, v0
	s_cbranch_execz .LBB0_23
; %bb.22:                               ;   in Loop: Header=BB0_21 Depth=4
	global_load_b32 v7, v1, s[30:31]
	v_mad_u64_u32 v[3:4], null, v2, s28, v[0:1]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v4, 31, v3
	v_lshlrev_b64 v[2:3], 3, v[3:4]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v2, vcc_lo, s20, v2
	v_add_co_ci_u32_e32 v3, vcc_lo, s21, v3, vcc_lo
	global_load_b64 v[2:3], v[2:3], off
	s_waitcnt vmcnt(1)
	v_mad_u64_u32 v[5:6], null, v7, v12, s[2:3]
	v_readfirstlane_b32 s62, v7
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	s_mul_i32 s62, s62, s28
	v_ashrrev_i32_e32 v6, 31, v5
	s_add_i32 s62, s62, s2
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_ashr_i32 s63, s62, 31
	s_lshl_b64 s[62:63], s[62:63], 3
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[4:5], 3, v[5:6]
	s_add_u32 s62, s10, s62
	s_addc_u32 s63, s11, s63
	v_add_co_u32 v4, vcc_lo, s8, v4
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v5, vcc_lo, s9, v5, vcc_lo
	global_load_b64 v[4:5], v[4:5], off
	global_load_b64 v[6:7], v1, s[62:63]
	s_waitcnt vmcnt(0)
	v_fma_f64 v[2:3], v[2:3], v[4:5], v[6:7]
	global_store_b64 v1, v[2:3], s[62:63]
.LBB0_23:                               ;   in Loop: Header=BB0_21 Depth=4
	s_or_b32 exec_lo, exec_lo, s61
	s_waitcnt_vscnt null, 0x0
	s_barrier
	buffer_gl0_inv
	global_load_b32 v2, v1, s[24:25]
	s_add_i32 s60, s60, 1
	s_waitcnt vmcnt(0)
	v_cmp_lt_i32_e32 vcc_lo, s60, v2
	s_cbranch_vccnz .LBB0_21
; %bb.24:                               ; %._crit_edge160.loopexit
                                        ;   in Loop: Header=BB0_19 Depth=3
	global_load_b32 v13, v1, s[30:31]
.LBB0_25:                               ; %._crit_edge160
                                        ;   in Loop: Header=BB0_19 Depth=3
	s_add_i32 s2, s2, 1
	s_waitcnt vmcnt(0)
	v_cmp_ge_i32_e32 vcc_lo, s2, v13
	s_or_b32 s59, vcc_lo, s59
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_not1_b32 exec_lo, exec_lo, s59
	s_cbranch_execnz .LBB0_19
; %bb.26:                               ; %Flow295
                                        ;   in Loop: Header=BB0_8 Depth=2
	s_or_b32 exec_lo, exec_lo, s59
.LBB0_27:                               ; %Flow296
                                        ;   in Loop: Header=BB0_8 Depth=2
	s_delay_alu instid0(SALU_CYCLE_1)
	s_or_b32 exec_lo, exec_lo, s3
	v_mov_b32_e32 v14, v13
.LBB0_28:                               ; %Flow299
                                        ;   in Loop: Header=BB0_8 Depth=2
	s_or_b32 exec_lo, exec_lo, s58
	v_add_nc_u32_e32 v12, 1, v12
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(SALU_CYCLE_1)
	v_cmp_eq_u32_e32 vcc_lo, v12, v11
	s_or_b32 s33, vcc_lo, s33
	s_and_not1_b32 exec_lo, exec_lo, s33
	s_cbranch_execnz .LBB0_8
.LBB0_29:                               ; %Flow303
                                        ;   in Loop: Header=BB0_5 Depth=1
	s_or_b32 exec_lo, exec_lo, s29
	s_and_saveexec_b32 s29, s0
	s_cbranch_execz .LBB0_43
; %bb.30:                               ; %.preheader153
                                        ;   in Loop: Header=BB0_5 Depth=1
	global_load_b32 v2, v1, s[24:25]
	s_waitcnt vmcnt(0)
	v_cmp_gt_i32_e32 vcc_lo, 1, v2
	v_readfirstlane_b32 s33, v2
	s_cbranch_vccnz .LBB0_33
; %bb.31:                               ; %.lr.ph168
                                        ;   in Loop: Header=BB0_5 Depth=1
	global_load_b64 v[2:3], v1, s[26:27]
	s_mul_i32 s2, s33, s28
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_ashr_i32 s3, s2, 31
	s_lshl_b64 s[2:3], s[2:3], 3
	s_delay_alu instid0(SALU_CYCLE_1)
	s_add_u32 s2, s22, s2
	s_addc_u32 s3, s23, s3
.LBB0_32:                               ;   Parent Loop BB0_5 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	global_load_b64 v[4:5], v1, s[2:3]
	s_add_i32 s33, s33, -1
	s_add_u32 s2, s2, 8
	s_addc_u32 s3, s3, 0
	s_cmp_eq_u32 s33, 0
	s_waitcnt vmcnt(0)
	v_add_f64 v[2:3], v[4:5], v[2:3]
	global_store_b64 v1, v[2:3], s[26:27]
	s_cbranch_scc0 .LBB0_32
.LBB0_33:                               ; %.preheader152
                                        ;   in Loop: Header=BB0_5 Depth=1
	global_load_b32 v2, v1, s[30:31]
	s_mov_b32 s58, -1
                                        ; implicit-def: $sgpr2_sgpr3
	s_waitcnt vmcnt(0)
	v_cmp_gt_i32_e32 vcc_lo, 1, v2
	v_readfirstlane_b32 s33, v2
	s_cbranch_vccz .LBB0_35
; %bb.34:                               ; %_Z8distanceiiPdS_Pi.exit150.critedge
                                        ;   in Loop: Header=BB0_5 Depth=1
	v_mov_b32_e32 v2, v1
	s_mov_b32 s58, 0
	s_mov_b64 s[2:3], 0
	global_store_b64 v1, v[1:2], s[26:27]
.LBB0_35:                               ; %Flow289
                                        ;   in Loop: Header=BB0_5 Depth=1
	v_dual_mov_b32 v4, s3 :: v_dual_mov_b32 v3, s2
	s_and_not1_b32 vcc_lo, exec_lo, s58
	s_cbranch_vccnz .LBB0_40
; %bb.36:                               ; %.lr.ph170
                                        ;   in Loop: Header=BB0_5 Depth=1
	s_mul_i32 s2, s33, s28
	s_mov_b32 s62, s33
	s_ashr_i32 s3, s2, 31
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_lshl_b64 s[58:59], s[2:3], 3
	s_add_u32 s2, s10, s58
	s_addc_u32 s3, s11, s59
	s_delay_alu instid0(SALU_CYCLE_1)
	s_mov_b64 s[60:61], s[2:3]
.LBB0_37:                               ;   Parent Loop BB0_5 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	s_clause 0x1
	global_load_b64 v[2:3], v1, s[26:27]
	global_load_b64 v[4:5], v1, s[60:61]
	s_add_i32 s62, s62, -1
	s_waitcnt vmcnt(0)
	v_div_scale_f64 v[6:7], null, v[2:3], v[2:3], v[4:5]
	v_div_scale_f64 v[14:15], vcc_lo, v[4:5], v[2:3], v[4:5]
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	v_rcp_f64_e32 v[8:9], v[6:7]
	s_waitcnt_depctr 0xfff
	v_fma_f64 v[12:13], -v[6:7], v[8:9], 1.0
	v_fma_f64 v[8:9], v[8:9], v[12:13], v[8:9]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[12:13], -v[6:7], v[8:9], 1.0
	v_fma_f64 v[8:9], v[8:9], v[12:13], v[8:9]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_f64 v[12:13], v[14:15], v[8:9]
	v_fma_f64 v[6:7], -v[6:7], v[12:13], v[14:15]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_div_fmas_f64 v[6:7], v[6:7], v[8:9], v[12:13]
	v_div_fixup_f64 v[2:3], v[6:7], v[2:3], v[4:5]
	global_store_b64 v1, v[2:3], s[60:61]
	s_add_u32 s60, s60, 8
	s_addc_u32 s61, s61, 0
	s_cmp_lg_u32 s62, 0
	s_cbranch_scc1 .LBB0_37
; %bb.38:                               ; %._crit_edge171
                                        ;   in Loop: Header=BB0_5 Depth=1
	v_dual_mov_b32 v2, v1 :: v_dual_mov_b32 v3, 0
	v_mov_b32_e32 v4, 0
	s_add_u32 s58, s12, s58
	s_addc_u32 s59, s13, s59
	global_store_b64 v1, v[1:2], s[26:27]
.LBB0_39:                               ;   Parent Loop BB0_5 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	s_clause 0x1
	global_load_b64 v[5:6], v1, s[2:3]
	global_load_b64 v[7:8], v1, s[58:59]
	s_add_i32 s33, s33, -1
	s_add_u32 s58, s58, 8
	s_addc_u32 s59, s59, 0
	s_add_u32 s2, s2, 8
	s_addc_u32 s3, s3, 0
	s_cmp_eq_u32 s33, 0
	s_waitcnt vmcnt(0)
	v_add_f64 v[5:6], v[5:6], -v[7:8]
	s_delay_alu instid0(VALU_DEP_1)
	v_fma_f64 v[3:4], v[5:6], v[5:6], v[3:4]
	s_cbranch_scc0 .LBB0_39
.LBB0_40:                               ; %_Z8distanceiiPdS_Pi.exit150
                                        ;   in Loop: Header=BB0_5 Depth=1
	global_load_b32 v6, v1, s[6:7]
	v_cmp_gt_f64_e32 vcc_lo, 0x10000000, v[3:4]
	v_cndmask_b32_e64 v2, 0, 1, vcc_lo
	s_and_b32 s2, vcc_lo, exec_lo
	s_cselect_b32 s2, 0xffffff80, 0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b32_e32 v2, 8, v2
	v_ldexp_f64 v[2:3], v[3:4], v2
	s_delay_alu instid0(VALU_DEP_1)
	v_rsq_f64_e32 v[4:5], v[2:3]
	v_cmp_class_f64_e64 vcc_lo, v[2:3], 0x260
	s_waitcnt vmcnt(0)
	v_add_nc_u32_e32 v6, 1, v6
	global_store_b32 v1, v6, s[6:7]
	global_load_b32 v14, v1, s[30:31]
	v_mul_f64 v[6:7], v[2:3], v[4:5]
	v_mul_f64 v[4:5], v[4:5], 0.5
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[8:9], -v[4:5], v[6:7], 0.5
	v_fma_f64 v[6:7], v[6:7], v[8:9], v[6:7]
	v_fma_f64 v[4:5], v[4:5], v[8:9], v[4:5]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[12:13], -v[6:7], v[6:7], v[2:3]
	v_fma_f64 v[6:7], v[12:13], v[4:5], v[6:7]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[8:9], -v[6:7], v[6:7], v[2:3]
	v_fma_f64 v[4:5], v[8:9], v[4:5], v[6:7]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ldexp_f64 v[4:5], v[4:5], s2
	v_dual_cndmask_b32 v3, v5, v3 :: v_dual_cndmask_b32 v2, v4, v2
	global_store_b64 v1, v[2:3], s[4:5]
	s_waitcnt vmcnt(0)
	v_cmp_gt_i32_e64 s2, 1, v14
	v_readfirstlane_b32 s33, v14
	s_delay_alu instid0(VALU_DEP_2)
	s_and_b32 vcc_lo, exec_lo, s2
	s_cbranch_vccnz .LBB0_43
; %bb.41:                               ; %.lr.ph173
                                        ;   in Loop: Header=BB0_5 Depth=1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_mul_i32 s2, s33, s28
	s_ashr_i32 s3, s2, 31
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_lshl_b64 s[58:59], s[2:3], 3
	s_add_u32 s2, s10, s58
	s_addc_u32 s3, s11, s59
	s_add_u32 s58, s12, s58
	s_addc_u32 s59, s13, s59
.LBB0_42:                               ;   Parent Loop BB0_5 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	global_load_b64 v[3:4], v1, s[2:3]
	v_mov_b32_e32 v2, v1
	s_add_i32 s33, s33, -1
	s_waitcnt vmcnt(0)
	s_clause 0x1
	global_store_b64 v1, v[3:4], s[58:59]
	global_store_b64 v1, v[1:2], s[2:3]
	s_add_u32 s2, s2, 8
	s_addc_u32 s3, s3, 0
	s_add_u32 s58, s58, 8
	s_addc_u32 s59, s59, 0
	s_cmp_lg_u32 s33, 0
	s_cbranch_scc1 .LBB0_42
.LBB0_43:                               ; %Flow293
                                        ;   in Loop: Header=BB0_5 Depth=1
	s_or_b32 exec_lo, exec_lo, s29
	s_waitcnt_vscnt null, 0x0
	s_barrier
	buffer_gl0_inv
	global_load_b32 v4, v1, s[24:25]
	s_waitcnt vmcnt(0)
	v_mad_u64_u32 v[2:3], null, v4, s28, v[0:1]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v3, 31, v2
	v_lshlrev_b64 v[3:4], 3, v[2:3]
	v_mov_b32_e32 v2, v1
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_co_u32 v3, vcc_lo, s22, v3
	v_add_co_ci_u32_e32 v4, vcc_lo, s23, v4, vcc_lo
	global_store_b64 v[3:4], v[1:2], off
	s_waitcnt_vscnt null, 0x0
	s_barrier
	buffer_gl0_inv
	s_clause 0x1
	global_load_b64 v[2:3], v1, s[4:5]
	global_load_b64 v[4:5], v1, s[14:15]
	s_waitcnt vmcnt(0)
	v_cmp_ngt_f64_e64 s2, v[2:3], v[4:5]
.LBB0_44:                               ; %Flow304
                                        ;   in Loop: Header=BB0_5 Depth=1
	s_delay_alu instid0(VALU_DEP_1)
	s_and_b32 vcc_lo, exec_lo, s2
	s_cbranch_vccz .LBB0_5
.LBB0_45:                               ; %.critedge
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z7devMainPdPiS_S_S_S_S_S0_S0_S0_S_S_S0_S_
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 112
		.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 19
		.amdhsa_next_free_sgpr 64
		.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	_Z7devMainPdPiS_S_S_S_S_S0_S0_S0_S_S_S0_S_, .Lfunc_end0-_Z7devMainPdPiS_S_S_S_S_S0_S0_S0_S_S_S0_S_
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 3272
; NumSgprs: 66
; NumVgprs: 19
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 8
; VGPRBlocks: 2
; NumSGPRsForWavesPerEU: 66
; NumVGPRsForWavesPerEU: 19
; Occupancy: 16
; WaveLimiterHint : 1
; 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
      - .address_space:  global
        .offset:         32
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         40
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         48
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         56
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         64
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         72
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         80
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         88
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         96
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         104
        .size:           8
        .value_kind:     global_buffer
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 112
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z7devMainPdPiS_S_S_S_S_S0_S0_S0_S_S_S0_S_
    .private_segment_fixed_size: 0
    .sgpr_count:     66
    .sgpr_spill_count: 0
    .symbol:         _Z7devMainPdPiS_S_S_S_S_S0_S0_S0_S_S_S0_S_.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     19
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
