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

#define bufSize 700000 


struct timeval startwtime,endwtime;

float *h_a;			// Table at host
float *d_a;			// Table at device
int tsize=0;		// number of rows or columns
size_t size = 0 ;	// size of table( tsize* tsize * sizeof(float*))
float* test;

void print(float *);
void make_table();
void serial();
void check();
void copytables();

__global__ void Kernel1(float *A,int N,int k){

	int i = blockDim.x * blockIdx.x + threadIdx.x;
	int j = blockDim.y * blockIdx.y + threadIdx.y;
	//printf("Hello from %d %d \n",threadIdx.x,threadIdx.y);
	if ( A[i*N+j] > A[i*N+k] + A[k*N+j] ){
		A[i*N+j] = A[i*N+k] + A[k*N+j];
	}
}

__global__ void Kernel2(float *A,int N,int k){
	
	int i = blockDim.x * blockIdx.x + threadIdx.x;
	int j = blockDim.y * blockIdx.y + threadIdx.y;

	__shared__ float k_k1,k1_k;
	/*	example:
	 *	if we have to go from D -> F throw k and then k+1 we have to do:
	 *	DkF check
	 *  D(k+1)F check
	 *	Dk(k+1)F check
	 *	D(k+1)kF check
	 *	the min of these is the min dist.
	 */
	if(threadIdx.x==0 && threadIdx.y==0){
		k_k1=A[k*N+(k+1)];
		k1_k=A[(k+1)*N+k];
	}
	float x,y,asked,xn,yn;

	asked=A[i*N+j];
	
	x=A[k*N+j];
	y=A[i*N+k];

	// DkF
	if(asked>x+y){
		asked=x+y;
	}

	xn=A[i*N+(k+1)];
	yn=A[(k+1)*N+j];

	__syncthreads();
	
	//	D(k+1)
	if(xn>y+k_k1){
		xn=y+k_k1;
	}
	//	(k+1)F
	if(yn>x+k1_k){
		yn=x+k1_k;
	}
	//	D(k+1)F or D(k+1)kF or Dk(k+1)F
	if(asked>xn+yn){
		asked=xn+yn;
	}
	//	min dist
	A[i*N+j]=asked;
}

void __global__ Kernel3(float *A,int N,int k){
	int row,col,col_k,col_k_1;
	__shared__ float rowk,rowk_1,k_k1,k1_k;
	row = blockIdx.x*N;
	col_k= k*N;
	col_k_1=(k+1)*N;
	if(threadIdx.x==0 && threadIdx.y==0){
		rowk=A[row+k];
		rowk_1=A[row+(k+1)];
		k_k1=A[k*N+(k+1)];
		k1_k=A[(k+1)*N+k];
	}
	__syncthreads();
	for(col=threadIdx.x*N/blockDim.x;col<(threadIdx.x+1)*N/blockDim.x;col++){
		// DkF
		if(A[row+col]>rowk+A[col_k+col]){
			A[row+col]=rowk+A[col_k+col];
		}
		// D(k+1)F
		if(A[row+col]>rowk_1+A[col_k_1+col]){
			A[row+col]=rowk_1+A[col_k_1+col];
		}
		// Dk(k+1)F
		if(A[row+col]>rowk+k_k1+A[col_k_1+col]){
			A[row+col]=rowk+k_k1+A[col_k_1+col];
		}
		// D(k+1)kF
		if(A[row+col]>rowk_1+k1_k+A[col_k+col]){
			A[row+col]=rowk_1+k1_k+A[col_k+col];
		}
	}
}

int main(){

	make_table();
	gettimeofday(&startwtime,NULL);

	serial();

	gettimeofday(&endwtime,NULL);
	printf("Serial time : %lf\n",	(double)((endwtime.tv_usec - startwtime.tv_usec)/1.0e6 + endwtime.tv_sec - startwtime.tv_sec));

	copytables();
	free(h_a);

	// ----------------------------
	//           Kernel 1
	// ----------------------------
	
	make_table();
	gettimeofday(&startwtime,NULL);

	// Alloc device table
	cudaMalloc((void **)&d_a,size);

	// Transfer table to device
	cudaMemcpy(d_a, h_a, size, cudaMemcpyHostToDevice);	

	// Define dimensions	
	int threads = 32;
	dim3 dimBlock(threads,threads);
	dim3 dimGrid(tsize/dimBlock.x,tsize/dimBlock.y);	

	// Do the math
	int k = 0;
	for ( k = 0 ; k < tsize ; k++){
		Kernel1<<<dimGrid,dimBlock>>>(d_a,tsize,k);
		cudaDeviceSynchronize();	
	}
	
	// Transfer table to host

	cudaMemcpy(h_a, d_a, size, cudaMemcpyDeviceToHost);

	gettimeofday(&endwtime,NULL);
	printf("Kernel 1 time : %lf\n",	(double)((endwtime.tv_usec - startwtime.tv_usec)/1.0e6 + endwtime.tv_sec - startwtime.tv_sec));
	
	// Checks the result
	check();
	
	// Free device and host memory
	cudaFree(d_a);
	free(h_a);


	// ----------------------------
	//           Kernel 2
	// ----------------------------
	
	make_table();
	gettimeofday(&startwtime,NULL);

	// Alloc device table
	cudaMalloc((void **)&d_a,size);

	// Transfer table to device
	cudaMemcpy(d_a, h_a, size, cudaMemcpyHostToDevice);	

	// Do the math
	for ( k = 0 ; k < tsize ; k+=2){
		Kernel2<<<dimGrid,dimBlock>>>(d_a,tsize,k);
		cudaDeviceSynchronize();	
	}
	
	// Transfer table to host

	cudaMemcpy(h_a, d_a, size, cudaMemcpyDeviceToHost);

	gettimeofday(&endwtime,NULL);
	printf("Kernel 2 time : %lf\n",	(double)((endwtime.tv_usec - startwtime.tv_usec)/1.0e6 + endwtime.tv_sec - startwtime.tv_sec));


	// Checks the result
	check();
	
	// Free device and host memory
	cudaFree(d_a);
	free(h_a);

	// ----------------------------
	//           Kernel 3 
	// ----------------------------
	
	make_table();
	gettimeofday(&startwtime,NULL);

	// Alloc device table
	cudaMalloc((void **)&d_a,size);

	// Transfer table to device
	cudaMemcpy(d_a, h_a, size, cudaMemcpyHostToDevice);	

	// Do the math
	for ( k = 0 ; k < tsize ; k+=2){
		Kernel3<<<tsize,16>>>(d_a,tsize,k);
		cudaDeviceSynchronize();	
	}
	
	// Transfer table to host

	cudaMemcpy(h_a, d_a, size, cudaMemcpyDeviceToHost);

	gettimeofday(&endwtime,NULL);
	printf("Kernel 3 time : %lf\n",	(double)((endwtime.tv_usec - startwtime.tv_usec)/1.0e6 + endwtime.tv_sec - startwtime.tv_sec));


	// Checks the result
	check();
	
	// Free device and host memory
	cudaFree(d_a);
	free(h_a);
	return 0;
	
}


/*	serial()
 *	-----
 *	Runs serial Floys Floyd-Warshall's Algorithm
 */
void serial(){
	int i , j , k ;

	for ( k = 0 ; k < tsize ; k++ ){
		for( i = 0 ; i < tsize ; i++ ){
			for( j = 0 ; j < tsize ; j++ ){

				if( h_a[i*tsize+j] > h_a[i*tsize+k] + h_a[k*tsize+j] ){
					h_a[i*tsize+j] = h_a[i*tsize+k] + h_a[k*tsize+j];
				}				
			}
		}
	}
	/*printf("\nDone Serial.\n");*/
}


/*	make_table()
 *	------------
 *	Gets the input table at table A
 *	input file has at first line size of table 
 *	and at the other lines the content.
 */
void make_table(){
	FILE * fp;
	char buf[bufSize];
	int i = 0 ;
	int j = 0 ;
 	
	fp = fopen("input.txt","r");
	
	// Read size of table
	fgets(buf,sizeof(buf),fp);
	tsize =(int) atof(buf);
	size = tsize*tsize*sizeof(float);	
	// Alloc the table at host
	h_a =(float *) malloc (size);
	// Fill the table
	while(fgets(buf,sizeof(buf),fp)!=NULL){
		for(j = 0 ; j < tsize ; j++ ){
			if(isinf(atof(&buf[16*j]))){
				h_a[i*tsize+j]=999999;
			}else{
				h_a[i*tsize+j]=atof(&buf[16*j]);
			}
		}
		i++;
	}

	fclose(fp);
	/*printf("\nDone making table.\n");*/
}



/*	print()
 *	-------
 *	Prints the table A	
 */
void print(float *a){
	int i = 0;
	int j = 0;
	for(i=0;i<tsize;i++){
		for(j=0;j<tsize;j++){
			if(isinf(h_a[i*tsize+j])){
				printf("%f\t\t",a[i*tsize+j]);
			}else{
				printf("%f\t",a[i*tsize+j]);
			}
		}
		printf("\n-------------------------\n");
	}

}

/*	check()
 *	-------
 *	Checks if the produced table of Kernel is the same
 *	as the serial's table.
 */
void check(){
	int i = 0;
	int j = 0;
	for(i=0;i<tsize;i++){
		for(j=0;j<tsize;j++){
			if(fabs(h_a[i*tsize+j]-test[i*tsize+j])>1e-6){
				/*printf("Error at [%d][%d] -> %f %f.\n",i,j,h_a[i*tsize+j],test[i*tsize+j]);*/
				printf("Fail!\n");
				exit(1);
			}
		}
	}
	printf("Success!\n");
}


/*	copytables()
 *	------------
 *	Copys the serial's table to test table.
 *	Test table is used at check().
 */
void copytables(){
	int i = 0;
	test=(float *) malloc (size);	
	for(i=0;i<tsize*tsize;i++){
		test[i]=h_a[i];
	}
}

	.file	"tmpxft_002382ad_00000000-6_apsp.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2035:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2035:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z6serialv
	.type	_Z6serialv, @function
_Z6serialv:
.LFB2028:
	.cfi_startproc
	endbr64
	movslq	tsize(%rip), %rcx
	movq	h_a(%rip), %r11
	xorl	%eax, %eax
	movq	%rcx, %rdx
	movq	%r11, %r9
	salq	$2, %rcx
.L3:
	cmpl	%eax, %edx
	jle	.L13
	movq	%r11, %r8
	xorl	%r10d, %r10d
.L8:
	movq	%r8, %rdi
	xorl	%esi, %esi
.L6:
	movss	(%r8,%rax,4), %xmm0
	addss	(%r9,%rsi,4), %xmm0
	movss	(%rdi), %xmm1
	comiss	%xmm0, %xmm1
	jbe	.L4
	movss	%xmm0, (%rdi)
.L4:
	incq	%rsi
	addq	$4, %rdi
	cmpl	%esi, %edx
	jg	.L6
	incl	%r10d
	addq	%rcx, %r8
	cmpl	%r10d, %edx
	jne	.L8
	incq	%rax
	addq	%rcx, %r9
	jmp	.L3
.L13:
	ret
	.cfi_endproc
.LFE2028:
	.size	_Z6serialv, .-_Z6serialv
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC1:
	.string	"r"
.LC2:
	.string	"input.txt"
	.text
	.globl	_Z10make_tablev
	.type	_Z10make_tablev, @function
_Z10make_tablev:
.LFB2029:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	-696320(%rsp), %r11
	.cfi_def_cfa 11, 696376
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$3720, %rsp
	.cfi_def_cfa_offset 700096
	leaq	.LC1(%rip), %rsi
	leaq	.LC2(%rip), %rdi
	xorl	%r12d, %r12d
	movq	%fs:40, %rax
	movq	%rax, 700024(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rbp
	call	fopen@PLT
	movl	$700000, %edx
	movl	$700000, %esi
	movq	%rbp, %rdi
	movq	%rax, %rcx
	movq	%rax, 8(%rsp)
	call	__fgets_chk@PLT
	movq	%rbp, %rdi
	call	atof@PLT
	cvttsd2sil	%xmm0, %edi
	movl	%edi, tsize(%rip)
	imull	%edi, %edi
	movslq	%edi, %rdi
	salq	$2, %rdi
	movq	%rdi, size(%rip)
	call	malloc@PLT
	movq	%rax, h_a(%rip)
.L15:
	movq	8(%rsp), %rcx
	movl	$700000, %edx
	movl	$700000, %esi
	movq	%rbp, %rdi
	call	__fgets_chk@PLT
	testq	%rax, %rax
	je	.L19
	movl	tsize(%rip), %r15d
	movl	%r12d, %eax
	movq	%rbp, %r14
	xorl	%r13d, %r13d
	movq	h_a(%rip), %rdx
	imull	%r15d, %eax
	cltq
	leaq	(%rdx,%rax,4), %rbx
.L20:
	cmpl	%r13d, %r15d
	jle	.L26
	movq	%r14, %rdi
	call	atof@PLT
	movaps	%xmm0, %xmm1
	andps	.LC3(%rip), %xmm1
	ucomisd	.LC4(%rip), %xmm1
	ja	.L24
	cvtsd2ss	%xmm0, %xmm0
	jmp	.L16
.L24:
	movss	.LC0(%rip), %xmm0
.L16:
	movss	%xmm0, (%rbx,%r13,4)
	addq	$16, %r14
	incq	%r13
	jmp	.L20
.L26:
	incl	%r12d
	jmp	.L15
.L19:
	movq	8(%rsp), %rdi
	call	fclose@PLT
	movq	700024(%rsp), %rax
	subq	%fs:40, %rax
	je	.L21
	call	__stack_chk_fail@PLT
.L21:
	addq	$700040, %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
.LFE2029:
	.size	_Z10make_tablev, .-_Z10make_tablev
	.section	.rodata.str1.1
.LC7:
	.string	"%f\t\t"
.LC8:
	.string	"%f\t"
.LC9:
	.string	"\n-------------------------\n"
	.text
	.globl	_Z5printPf
	.type	_Z5printPf, @function
_Z5printPf:
.LFB2030:
	.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	%rdi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	xorl	%ebx, %ebx
.L28:
	cmpl	%ebx, tsize(%rip)
	jle	.L36
	xorl	%r12d, %r12d
.L32:
	movl	tsize(%rip), %eax
	cmpl	%r12d, %eax
	jle	.L37
	imull	%ebx, %eax
	movq	h_a(%rip), %rdx
	leaq	.LC7(%rip), %rsi
	addl	%r12d, %eax
	cltq
	movss	(%rdx,%rax,4), %xmm0
	andps	.LC5(%rip), %xmm0
	cvtss2sd	0(%rbp,%rax,4), %xmm1
	ucomiss	.LC6(%rip), %xmm0
	movaps	%xmm1, %xmm0
	ja	.L35
	leaq	.LC8(%rip), %rsi
.L35:
	movl	$2, %edi
	movb	$1, %al
	incl	%r12d
	call	__printf_chk@PLT
	jmp	.L32
.L37:
	leaq	.LC9(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	incl	%ebx
	call	__printf_chk@PLT
	jmp	.L28
.L36:
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2030:
	.size	_Z5printPf, .-_Z5printPf
	.section	.rodata.str1.1
.LC11:
	.string	"Fail!\n"
.LC12:
	.string	"Success!\n"
	.text
	.globl	_Z5checkv
	.type	_Z5checkv, @function
_Z5checkv:
.LFB2031:
	.cfi_startproc
	endbr64
	movslq	tsize(%rip), %rsi
	xorl	%edi, %edi
	xorl	%edx, %edx
	movq	h_a(%rip), %r9
	movq	test(%rip), %r10
	movsd	.LC10(%rip), %xmm2
	movss	.LC5(%rip), %xmm1
	movq	%rsi, %rcx
	salq	$2, %rsi
.L39:
	cmpl	%edx, %ecx
	jle	.L50
	movq	%rdi, %rax
	xorl	%r8d, %r8d
.L42:
	movss	(%r9,%rax), %xmm0
	subss	(%r10,%rax), %xmm0
	andps	%xmm1, %xmm0
	cvtss2sd	%xmm0, %xmm0
	comisd	%xmm2, %xmm0
	jbe	.L46
	pushq	%rax
	.cfi_def_cfa_offset 16
	movl	$2, %edi
	leaq	.LC11(%rip), %rsi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$1, %edi
	call	exit@PLT
.L46:
	.cfi_def_cfa_offset 8
	incl	%r8d
	addq	$4, %rax
	cmpl	%r8d, %ecx
	jne	.L42
	incl	%edx
	addq	%rsi, %rdi
	jmp	.L39
.L50:
	leaq	.LC12(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	jmp	__printf_chk@PLT
	.cfi_endproc
.LFE2031:
	.size	_Z5checkv, .-_Z5checkv
	.globl	_Z10copytablesv
	.type	_Z10copytablesv, @function
_Z10copytablesv:
.LFB2032:
	.cfi_startproc
	endbr64
	pushq	%rdx
	.cfi_def_cfa_offset 16
	movq	size(%rip), %rdi
	call	malloc@PLT
	movl	tsize(%rip), %edx
	movq	h_a(%rip), %rsi
	movq	%rax, test(%rip)
	movl	%edx, %ecx
	imull	%edx, %ecx
	xorl	%edx, %edx
.L52:
	cmpl	%edx, %ecx
	jle	.L55
	movss	(%rsi,%rdx,4), %xmm0
	movss	%xmm0, (%rax,%rdx,4)
	incq	%rdx
	jmp	.L52
.L55:
	popq	%rax
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2032:
	.size	_Z10copytablesv, .-_Z10copytablesv
	.globl	_Z28__device_stub__Z7Kernel1PfiiPfii
	.type	_Z28__device_stub__Z7Kernel1PfiiPfii, @function
_Z28__device_stub__Z7Kernel1PfiiPfii:
.LFB2057:
	.cfi_startproc
	endbr64
	subq	$120, %rsp
	.cfi_def_cfa_offset 128
	movq	%rdi, 8(%rsp)
	leaq	24(%rsp), %rcx
	leaq	32(%rsp), %rdi
	movl	%esi, 4(%rsp)
	leaq	44(%rsp), %rsi
	movl	%edx, (%rsp)
	leaq	16(%rsp), %rdx
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rax
	movl	$1, 40(%rsp)
	movq	%rax, 80(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 88(%rsp)
	movq	%rsp, %rax
	movq	%rax, 96(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 32(%rsp)
	movq	%rax, 44(%rsp)
	movl	$1, 52(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L56
	pushq	24(%rsp)
	.cfi_def_cfa_offset 136
	leaq	_Z7Kernel1Pfii(%rip), %rdi
	pushq	24(%rsp)
	.cfi_def_cfa_offset 144
	movq	60(%rsp), %rcx
	movl	68(%rsp), %r8d
	movq	48(%rsp), %rsi
	movl	56(%rsp), %edx
	leaq	96(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 136
	popq	%rdx
	.cfi_def_cfa_offset 128
.L56:
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L58
	call	__stack_chk_fail@PLT
.L58:
	addq	$120, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2057:
	.size	_Z28__device_stub__Z7Kernel1PfiiPfii, .-_Z28__device_stub__Z7Kernel1PfiiPfii
	.globl	_Z7Kernel1Pfii
	.type	_Z7Kernel1Pfii, @function
_Z7Kernel1Pfii:
.LFB2058:
	.cfi_startproc
	endbr64
	jmp	_Z28__device_stub__Z7Kernel1PfiiPfii
	.cfi_endproc
.LFE2058:
	.size	_Z7Kernel1Pfii, .-_Z7Kernel1Pfii
	.globl	_Z28__device_stub__Z7Kernel2PfiiPfii
	.type	_Z28__device_stub__Z7Kernel2PfiiPfii, @function
_Z28__device_stub__Z7Kernel2PfiiPfii:
.LFB2059:
	.cfi_startproc
	endbr64
	subq	$120, %rsp
	.cfi_def_cfa_offset 128
	movq	%rdi, 8(%rsp)
	leaq	24(%rsp), %rcx
	leaq	32(%rsp), %rdi
	movl	%esi, 4(%rsp)
	leaq	44(%rsp), %rsi
	movl	%edx, (%rsp)
	leaq	16(%rsp), %rdx
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rax
	movl	$1, 40(%rsp)
	movq	%rax, 80(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 88(%rsp)
	movq	%rsp, %rax
	movq	%rax, 96(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 32(%rsp)
	movq	%rax, 44(%rsp)
	movl	$1, 52(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L61
	pushq	24(%rsp)
	.cfi_def_cfa_offset 136
	leaq	_Z7Kernel2Pfii(%rip), %rdi
	pushq	24(%rsp)
	.cfi_def_cfa_offset 144
	movq	60(%rsp), %rcx
	movl	68(%rsp), %r8d
	movq	48(%rsp), %rsi
	movl	56(%rsp), %edx
	leaq	96(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 136
	popq	%rdx
	.cfi_def_cfa_offset 128
.L61:
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L63
	call	__stack_chk_fail@PLT
.L63:
	addq	$120, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2059:
	.size	_Z28__device_stub__Z7Kernel2PfiiPfii, .-_Z28__device_stub__Z7Kernel2PfiiPfii
	.globl	_Z7Kernel2Pfii
	.type	_Z7Kernel2Pfii, @function
_Z7Kernel2Pfii:
.LFB2060:
	.cfi_startproc
	endbr64
	jmp	_Z28__device_stub__Z7Kernel2PfiiPfii
	.cfi_endproc
.LFE2060:
	.size	_Z7Kernel2Pfii, .-_Z7Kernel2Pfii
	.globl	_Z28__device_stub__Z7Kernel3PfiiPfii
	.type	_Z28__device_stub__Z7Kernel3PfiiPfii, @function
_Z28__device_stub__Z7Kernel3PfiiPfii:
.LFB2061:
	.cfi_startproc
	endbr64
	subq	$120, %rsp
	.cfi_def_cfa_offset 128
	movq	%rdi, 8(%rsp)
	leaq	24(%rsp), %rcx
	leaq	32(%rsp), %rdi
	movl	%esi, 4(%rsp)
	leaq	44(%rsp), %rsi
	movl	%edx, (%rsp)
	leaq	16(%rsp), %rdx
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rax
	movl	$1, 40(%rsp)
	movq	%rax, 80(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 88(%rsp)
	movq	%rsp, %rax
	movq	%rax, 96(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 32(%rsp)
	movq	%rax, 44(%rsp)
	movl	$1, 52(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L66
	pushq	24(%rsp)
	.cfi_def_cfa_offset 136
	leaq	_Z7Kernel3Pfii(%rip), %rdi
	pushq	24(%rsp)
	.cfi_def_cfa_offset 144
	movq	60(%rsp), %rcx
	movl	68(%rsp), %r8d
	movq	48(%rsp), %rsi
	movl	56(%rsp), %edx
	leaq	96(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 136
	popq	%rdx
	.cfi_def_cfa_offset 128
.L66:
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L68
	call	__stack_chk_fail@PLT
.L68:
	addq	$120, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2061:
	.size	_Z28__device_stub__Z7Kernel3PfiiPfii, .-_Z28__device_stub__Z7Kernel3PfiiPfii
	.globl	_Z7Kernel3Pfii
	.type	_Z7Kernel3Pfii, @function
_Z7Kernel3Pfii:
.LFB2062:
	.cfi_startproc
	endbr64
	jmp	_Z28__device_stub__Z7Kernel3PfiiPfii
	.cfi_endproc
.LFE2062:
	.size	_Z7Kernel3Pfii, .-_Z7Kernel3Pfii
	.section	.rodata.str1.1
.LC14:
	.string	"Serial time : %lf\n"
.LC15:
	.string	"Kernel 1 time : %lf\n"
.LC16:
	.string	"Kernel 2 time : %lf\n"
.LC17:
	.string	"Kernel 3 time : %lf\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2027:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	movabsq	$137438953504, %r14
	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
	leaq	d_a(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	leaq	startwtime(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	leaq	endwtime(%rip), %rbx
	subq	$48, %rsp
	.cfi_def_cfa_offset 96
	call	_Z10make_tablev
	xorl	%esi, %esi
	movq	%rbp, %rdi
	call	gettimeofday@PLT
	call	_Z6serialv
	xorl	%esi, %esi
	movq	%rbx, %rdi
	call	gettimeofday@PLT
	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
	call	__printf_chk@PLT
	call	_Z10copytablesv
	movq	h_a(%rip), %rdi
	call	free@PLT
	call	_Z10make_tablev
	xorl	%esi, %esi
	movq	%rbp, %rdi
	call	gettimeofday@PLT
	movq	size(%rip), %rsi
	movq	%r12, %rdi
	call	cudaMalloc@PLT
	movq	size(%rip), %rdx
	movl	$1, %ecx
	movq	h_a(%rip), %rsi
	movq	d_a(%rip), %rdi
	call	cudaMemcpy@PLT
	movl	tsize(%rip), %eax
	movl	$1, 8(%rsp)
	movl	$1, 20(%rsp)
	shrl	$5, %eax
	movl	%eax, 12(%rsp)
	movl	%eax, 16(%rsp)
.L72:
	cmpl	%r13d, tsize(%rip)
	jle	.L82
	movl	8(%rsp), %ecx
	movq	12(%rsp), %rdi
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	20(%rsp), %esi
	movq	%r14, %rdx
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L73
	movl	tsize(%rip), %esi
	movq	d_a(%rip), %rdi
	movl	%r13d, %edx
	call	_Z28__device_stub__Z7Kernel1PfiiPfii
.L73:
	call	cudaDeviceSynchronize@PLT
	incl	%r13d
	jmp	.L72
.L82:
	movq	size(%rip), %rdx
	movq	d_a(%rip), %rsi
	movl	$2, %ecx
	xorl	%r13d, %r13d
	movq	h_a(%rip), %rdi
	movabsq	$137438953504, %r14
	call	cudaMemcpy@PLT
	xorl	%esi, %esi
	movq	%rbx, %rdi
	call	gettimeofday@PLT
	movq	8+endwtime(%rip), %rax
	movl	$2, %edi
	cvtsi2sdq	endwtime(%rip), %xmm1
	subq	8+startwtime(%rip), %rax
	leaq	.LC15(%rip), %rsi
	cvtsi2sdq	%rax, %xmm0
	divsd	.LC13(%rip), %xmm0
	movb	$1, %al
	addsd	%xmm1, %xmm0
	cvtsi2sdq	startwtime(%rip), %xmm1
	subsd	%xmm1, %xmm0
	call	__printf_chk@PLT
	call	_Z5checkv
	movq	d_a(%rip), %rdi
	call	cudaFree@PLT
	movq	h_a(%rip), %rdi
	call	free@PLT
	call	_Z10make_tablev
	xorl	%esi, %esi
	movq	%rbp, %rdi
	call	gettimeofday@PLT
	movq	size(%rip), %rsi
	movq	%r12, %rdi
	call	cudaMalloc@PLT
	movq	size(%rip), %rdx
	movl	$1, %ecx
	movq	h_a(%rip), %rsi
	movq	d_a(%rip), %rdi
	call	cudaMemcpy@PLT
.L75:
	cmpl	%r13d, tsize(%rip)
	jle	.L83
	movl	8(%rsp), %ecx
	movq	12(%rsp), %rdi
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	20(%rsp), %esi
	movq	%r14, %rdx
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L76
	movl	tsize(%rip), %esi
	movq	d_a(%rip), %rdi
	movl	%r13d, %edx
	call	_Z28__device_stub__Z7Kernel2PfiiPfii
.L76:
	call	cudaDeviceSynchronize@PLT
	addl	$2, %r13d
	jmp	.L75
.L83:
	movq	size(%rip), %rdx
	movq	d_a(%rip), %rsi
	movl	$2, %ecx
	movq	h_a(%rip), %rdi
	call	cudaMemcpy@PLT
	xorl	%esi, %esi
	movq	%rbx, %rdi
	call	gettimeofday@PLT
	movq	8+endwtime(%rip), %rax
	movl	$2, %edi
	cvtsi2sdq	endwtime(%rip), %xmm1
	subq	8+startwtime(%rip), %rax
	leaq	.LC16(%rip), %rsi
	cvtsi2sdq	%rax, %xmm0
	divsd	.LC13(%rip), %xmm0
	movb	$1, %al
	addsd	%xmm1, %xmm0
	cvtsi2sdq	startwtime(%rip), %xmm1
	subsd	%xmm1, %xmm0
	call	__printf_chk@PLT
	call	_Z5checkv
	movq	d_a(%rip), %rdi
	call	cudaFree@PLT
	movq	h_a(%rip), %rdi
	call	free@PLT
	call	_Z10make_tablev
	movq	%rbp, %rdi
	xorl	%esi, %esi
	xorl	%ebp, %ebp
	call	gettimeofday@PLT
	movq	size(%rip), %rsi
	movq	%r12, %rdi
	movabsq	$4294967312, %r12
	call	cudaMalloc@PLT
	movq	size(%rip), %rdx
	movl	$1, %ecx
	movq	h_a(%rip), %rsi
	movq	d_a(%rip), %rdi
	call	cudaMemcpy@PLT
.L78:
	movl	tsize(%rip), %eax
	cmpl	%ebp, %eax
	jle	.L84
	movl	%eax, 24(%rsp)
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movq	%r12, %rdx
	movabsq	$4294967297, %rax
	movl	$1, %ecx
	movq	%rax, 28(%rsp)
	movq	24(%rsp), %rdi
	movl	32(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L79
	movl	tsize(%rip), %esi
	movq	d_a(%rip), %rdi
	movl	%ebp, %edx
	call	_Z28__device_stub__Z7Kernel3PfiiPfii
.L79:
	call	cudaDeviceSynchronize@PLT
	addl	$2, %ebp
	jmp	.L78
.L84:
	movq	size(%rip), %rdx
	movq	d_a(%rip), %rsi
	movl	$2, %ecx
	movq	h_a(%rip), %rdi
	call	cudaMemcpy@PLT
	movq	%rbx, %rdi
	xorl	%esi, %esi
	call	gettimeofday@PLT
	movq	8+endwtime(%rip), %rax
	movl	$2, %edi
	cvtsi2sdq	endwtime(%rip), %xmm1
	subq	8+startwtime(%rip), %rax
	leaq	.LC17(%rip), %rsi
	cvtsi2sdq	%rax, %xmm0
	divsd	.LC13(%rip), %xmm0
	movb	$1, %al
	addsd	%xmm1, %xmm0
	cvtsi2sdq	startwtime(%rip), %xmm1
	subsd	%xmm1, %xmm0
	call	__printf_chk@PLT
	call	_Z5checkv
	movq	d_a(%rip), %rdi
	call	cudaFree@PLT
	movq	h_a(%rip), %rdi
	call	free@PLT
	addq	$48, %rsp
	.cfi_def_cfa_offset 48
	xorl	%eax, %eax
	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
.LFE2027:
	.size	main, .-main
	.section	.rodata.str1.1
.LC18:
	.string	"_Z7Kernel3Pfii"
.LC19:
	.string	"_Z7Kernel2Pfii"
.LC20:
	.string	"_Z7Kernel1Pfii"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2064:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	pushq	$0
	.cfi_def_cfa_offset 24
	xorl	%r9d, %r9d
	orl	$-1, %r8d
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC18(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z7Kernel3Pfii(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r9d, %r9d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC19(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z7Kernel2Pfii(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 40
	pushq	$0
	.cfi_def_cfa_offset 48
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r9d, %r9d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC20(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z7Kernel1Pfii(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 40
	pushq	$0
	.cfi_def_cfa_offset 48
	call	__cudaRegisterFunction@PLT
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE2064:
	.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	test
	.bss
	.align 8
	.type	test, @object
	.size	test, 8
test:
	.zero	8
	.globl	size
	.align 8
	.type	size, @object
	.size	size, 8
size:
	.zero	8
	.globl	tsize
	.align 4
	.type	tsize, @object
	.size	tsize, 4
tsize:
	.zero	4
	.globl	d_a
	.align 8
	.type	d_a, @object
	.size	d_a, 8
d_a:
	.zero	8
	.globl	h_a
	.align 8
	.type	h_a, @object
	.size	h_a, 8
h_a:
	.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.cst4,"aM",@progbits,4
	.align 4
.LC0:
	.long	1232348144
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC3:
	.long	-1
	.long	2147483647
	.long	0
	.long	0
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC4:
	.long	-1
	.long	2146435071
	.section	.rodata.cst16
	.align 16
.LC5:
	.long	2147483647
	.long	0
	.long	0
	.long	0
	.section	.rodata.cst4
	.align 4
.LC6:
	.long	2139095039
	.section	.rodata.cst8
	.align 8
.LC10:
	.long	-1598689907
	.long	1051772663
	.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 <hip/hip_runtime.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <sys/time.h>

#define bufSize 700000 


struct timeval startwtime,endwtime;

float *h_a;			// Table at host
float *d_a;			// Table at device
int tsize=0;		// number of rows or columns
size_t size = 0 ;	// size of table( tsize* tsize * sizeof(float*))
float* test;

void print(float *);
void make_table();
void serial();
void check();
void copytables();

__global__ void Kernel1(float *A,int N,int k){

	int i = blockDim.x * blockIdx.x + threadIdx.x;
	int j = blockDim.y * blockIdx.y + threadIdx.y;
	//printf("Hello from %d %d \n",threadIdx.x,threadIdx.y);
	if ( A[i*N+j] > A[i*N+k] + A[k*N+j] ){
		A[i*N+j] = A[i*N+k] + A[k*N+j];
	}
}

__global__ void Kernel2(float *A,int N,int k){
	
	int i = blockDim.x * blockIdx.x + threadIdx.x;
	int j = blockDim.y * blockIdx.y + threadIdx.y;

	__shared__ float k_k1,k1_k;
	/*	example:
	 *	if we have to go from D -> F throw k and then k+1 we have to do:
	 *	DkF check
	 *  D(k+1)F check
	 *	Dk(k+1)F check
	 *	D(k+1)kF check
	 *	the min of these is the min dist.
	 */
	if(threadIdx.x==0 && threadIdx.y==0){
		k_k1=A[k*N+(k+1)];
		k1_k=A[(k+1)*N+k];
	}
	float x,y,asked,xn,yn;

	asked=A[i*N+j];
	
	x=A[k*N+j];
	y=A[i*N+k];

	// DkF
	if(asked>x+y){
		asked=x+y;
	}

	xn=A[i*N+(k+1)];
	yn=A[(k+1)*N+j];

	__syncthreads();
	
	//	D(k+1)
	if(xn>y+k_k1){
		xn=y+k_k1;
	}
	//	(k+1)F
	if(yn>x+k1_k){
		yn=x+k1_k;
	}
	//	D(k+1)F or D(k+1)kF or Dk(k+1)F
	if(asked>xn+yn){
		asked=xn+yn;
	}
	//	min dist
	A[i*N+j]=asked;
}

void __global__ Kernel3(float *A,int N,int k){
	int row,col,col_k,col_k_1;
	__shared__ float rowk,rowk_1,k_k1,k1_k;
	row = blockIdx.x*N;
	col_k= k*N;
	col_k_1=(k+1)*N;
	if(threadIdx.x==0 && threadIdx.y==0){
		rowk=A[row+k];
		rowk_1=A[row+(k+1)];
		k_k1=A[k*N+(k+1)];
		k1_k=A[(k+1)*N+k];
	}
	__syncthreads();
	for(col=threadIdx.x*N/blockDim.x;col<(threadIdx.x+1)*N/blockDim.x;col++){
		// DkF
		if(A[row+col]>rowk+A[col_k+col]){
			A[row+col]=rowk+A[col_k+col];
		}
		// D(k+1)F
		if(A[row+col]>rowk_1+A[col_k_1+col]){
			A[row+col]=rowk_1+A[col_k_1+col];
		}
		// Dk(k+1)F
		if(A[row+col]>rowk+k_k1+A[col_k_1+col]){
			A[row+col]=rowk+k_k1+A[col_k_1+col];
		}
		// D(k+1)kF
		if(A[row+col]>rowk_1+k1_k+A[col_k+col]){
			A[row+col]=rowk_1+k1_k+A[col_k+col];
		}
	}
}

int main(){

	make_table();
	gettimeofday(&startwtime,NULL);

	serial();

	gettimeofday(&endwtime,NULL);
	printf("Serial time : %lf\n",	(double)((endwtime.tv_usec - startwtime.tv_usec)/1.0e6 + endwtime.tv_sec - startwtime.tv_sec));

	copytables();
	free(h_a);

	// ----------------------------
	//           Kernel 1
	// ----------------------------
	
	make_table();
	gettimeofday(&startwtime,NULL);

	// Alloc device table
	hipMalloc((void **)&d_a,size);

	// Transfer table to device
	hipMemcpy(d_a, h_a, size, hipMemcpyHostToDevice);	

	// Define dimensions	
	int threads = 32;
	dim3 dimBlock(threads,threads);
	dim3 dimGrid(tsize/dimBlock.x,tsize/dimBlock.y);	

	// Do the math
	int k = 0;
	for ( k = 0 ; k < tsize ; k++){
		Kernel1<<<dimGrid,dimBlock>>>(d_a,tsize,k);
		hipDeviceSynchronize();	
	}
	
	// Transfer table to host

	hipMemcpy(h_a, d_a, size, hipMemcpyDeviceToHost);

	gettimeofday(&endwtime,NULL);
	printf("Kernel 1 time : %lf\n",	(double)((endwtime.tv_usec - startwtime.tv_usec)/1.0e6 + endwtime.tv_sec - startwtime.tv_sec));
	
	// Checks the result
	check();
	
	// Free device and host memory
	hipFree(d_a);
	free(h_a);


	// ----------------------------
	//           Kernel 2
	// ----------------------------
	
	make_table();
	gettimeofday(&startwtime,NULL);

	// Alloc device table
	hipMalloc((void **)&d_a,size);

	// Transfer table to device
	hipMemcpy(d_a, h_a, size, hipMemcpyHostToDevice);	

	// Do the math
	for ( k = 0 ; k < tsize ; k+=2){
		Kernel2<<<dimGrid,dimBlock>>>(d_a,tsize,k);
		hipDeviceSynchronize();	
	}
	
	// Transfer table to host

	hipMemcpy(h_a, d_a, size, hipMemcpyDeviceToHost);

	gettimeofday(&endwtime,NULL);
	printf("Kernel 2 time : %lf\n",	(double)((endwtime.tv_usec - startwtime.tv_usec)/1.0e6 + endwtime.tv_sec - startwtime.tv_sec));


	// Checks the result
	check();
	
	// Free device and host memory
	hipFree(d_a);
	free(h_a);

	// ----------------------------
	//           Kernel 3 
	// ----------------------------
	
	make_table();
	gettimeofday(&startwtime,NULL);

	// Alloc device table
	hipMalloc((void **)&d_a,size);

	// Transfer table to device
	hipMemcpy(d_a, h_a, size, hipMemcpyHostToDevice);	

	// Do the math
	for ( k = 0 ; k < tsize ; k+=2){
		Kernel3<<<tsize,16>>>(d_a,tsize,k);
		hipDeviceSynchronize();	
	}
	
	// Transfer table to host

	hipMemcpy(h_a, d_a, size, hipMemcpyDeviceToHost);

	gettimeofday(&endwtime,NULL);
	printf("Kernel 3 time : %lf\n",	(double)((endwtime.tv_usec - startwtime.tv_usec)/1.0e6 + endwtime.tv_sec - startwtime.tv_sec));


	// Checks the result
	check();
	
	// Free device and host memory
	hipFree(d_a);
	free(h_a);
	return 0;
	
}


/*	serial()
 *	-----
 *	Runs serial Floys Floyd-Warshall's Algorithm
 */
void serial(){
	int i , j , k ;

	for ( k = 0 ; k < tsize ; k++ ){
		for( i = 0 ; i < tsize ; i++ ){
			for( j = 0 ; j < tsize ; j++ ){

				if( h_a[i*tsize+j] > h_a[i*tsize+k] + h_a[k*tsize+j] ){
					h_a[i*tsize+j] = h_a[i*tsize+k] + h_a[k*tsize+j];
				}				
			}
		}
	}
	/*printf("\nDone Serial.\n");*/
}


/*	make_table()
 *	------------
 *	Gets the input table at table A
 *	input file has at first line size of table 
 *	and at the other lines the content.
 */
void make_table(){
	FILE * fp;
	char buf[bufSize];
	int i = 0 ;
	int j = 0 ;
 	
	fp = fopen("input.txt","r");
	
	// Read size of table
	fgets(buf,sizeof(buf),fp);
	tsize =(int) atof(buf);
	size = tsize*tsize*sizeof(float);	
	// Alloc the table at host
	h_a =(float *) malloc (size);
	// Fill the table
	while(fgets(buf,sizeof(buf),fp)!=NULL){
		for(j = 0 ; j < tsize ; j++ ){
			if(isinf(atof(&buf[16*j]))){
				h_a[i*tsize+j]=999999;
			}else{
				h_a[i*tsize+j]=atof(&buf[16*j]);
			}
		}
		i++;
	}

	fclose(fp);
	/*printf("\nDone making table.\n");*/
}



/*	print()
 *	-------
 *	Prints the table A	
 */
void print(float *a){
	int i = 0;
	int j = 0;
	for(i=0;i<tsize;i++){
		for(j=0;j<tsize;j++){
			if(isinf(h_a[i*tsize+j])){
				printf("%f\t\t",a[i*tsize+j]);
			}else{
				printf("%f\t",a[i*tsize+j]);
			}
		}
		printf("\n-------------------------\n");
	}

}

/*	check()
 *	-------
 *	Checks if the produced table of Kernel is the same
 *	as the serial's table.
 */
void check(){
	int i = 0;
	int j = 0;
	for(i=0;i<tsize;i++){
		for(j=0;j<tsize;j++){
			if(fabs(h_a[i*tsize+j]-test[i*tsize+j])>1e-6){
				/*printf("Error at [%d][%d] -> %f %f.\n",i,j,h_a[i*tsize+j],test[i*tsize+j]);*/
				printf("Fail!\n");
				exit(1);
			}
		}
	}
	printf("Success!\n");
}


/*	copytables()
 *	------------
 *	Copys the serial's table to test table.
 *	Test table is used at check().
 */
void copytables(){
	int i = 0;
	test=(float *) malloc (size);	
	for(i=0;i<tsize*tsize;i++){
		test[i]=h_a[i];
	}
}

	.text
	.file	"apsp.hip"
	.globl	_Z22__device_stub__Kernel1Pfii  # -- Begin function _Z22__device_stub__Kernel1Pfii
	.type	_Z22__device_stub__Kernel1Pfii,@function
_Z22__device_stub__Kernel1Pfii:         # @_Z22__device_stub__Kernel1Pfii
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$96, %rsp
	.cfi_def_cfa_offset 144
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	24(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	4(%rsp), %rcx
	movl	%esi, (%rcx)
	movq	%rsp, %rsi
	movl	%edx, (%rsi)
	leaq	64(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	movq	%rsi, 16(%rbx)
	leaq	48(%rsp), %r14
	leaq	32(%rsp), %r15
	leaq	16(%rsp), %r12
	leaq	8(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z7Kernel1Pfii, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$112, %rsp
	.cfi_adjust_cfa_offset -112
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_Z22__device_stub__Kernel1Pfii, .Lfunc_end0-_Z22__device_stub__Kernel1Pfii
	.cfi_endproc
                                        # -- End function
	.globl	_Z22__device_stub__Kernel2Pfii  # -- Begin function _Z22__device_stub__Kernel2Pfii
	.type	_Z22__device_stub__Kernel2Pfii,@function
_Z22__device_stub__Kernel2Pfii:         # @_Z22__device_stub__Kernel2Pfii
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$96, %rsp
	.cfi_def_cfa_offset 144
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	24(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	4(%rsp), %rcx
	movl	%esi, (%rcx)
	movq	%rsp, %rsi
	movl	%edx, (%rsi)
	leaq	64(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	movq	%rsi, 16(%rbx)
	leaq	48(%rsp), %r14
	leaq	32(%rsp), %r15
	leaq	16(%rsp), %r12
	leaq	8(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z7Kernel2Pfii, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$112, %rsp
	.cfi_adjust_cfa_offset -112
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end1:
	.size	_Z22__device_stub__Kernel2Pfii, .Lfunc_end1-_Z22__device_stub__Kernel2Pfii
	.cfi_endproc
                                        # -- End function
	.globl	_Z22__device_stub__Kernel3Pfii  # -- Begin function _Z22__device_stub__Kernel3Pfii
	.type	_Z22__device_stub__Kernel3Pfii,@function
_Z22__device_stub__Kernel3Pfii:         # @_Z22__device_stub__Kernel3Pfii
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$96, %rsp
	.cfi_def_cfa_offset 144
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	24(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	4(%rsp), %rcx
	movl	%esi, (%rcx)
	movq	%rsp, %rsi
	movl	%edx, (%rsi)
	leaq	64(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	movq	%rsi, 16(%rbx)
	leaq	48(%rsp), %r14
	leaq	32(%rsp), %r15
	leaq	16(%rsp), %r12
	leaq	8(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z7Kernel3Pfii, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$112, %rsp
	.cfi_adjust_cfa_offset -112
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end2:
	.size	_Z22__device_stub__Kernel3Pfii, .Lfunc_end2-_Z22__device_stub__Kernel3Pfii
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI3_0:
	.quad	0x412e848000000000              # double 1.0E+6
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r12
	.cfi_def_cfa_offset 32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	pushq	%rax
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -40
	.cfi_offset %r12, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movabsq	$137438953504, %rbx             # imm = 0x2000000020
	movabsq	$4294967296, %r12               # imm = 0x100000000
	callq	_Z10make_tablev
	xorl	%r15d, %r15d
	movl	$startwtime, %edi
	xorl	%esi, %esi
	callq	gettimeofday
	callq	_Z6serialv
	movl	$endwtime, %edi
	xorl	%esi, %esi
	callq	gettimeofday
	movq	endwtime+8(%rip), %rax
	subq	startwtime+8(%rip), %rax
	cvtsi2sd	%rax, %xmm1
	divsd	.LCPI3_0(%rip), %xmm1
	cvtsi2sdq	endwtime(%rip), %xmm0
	addsd	%xmm1, %xmm0
	xorps	%xmm1, %xmm1
	cvtsi2sdq	startwtime(%rip), %xmm1
	subsd	%xmm1, %xmm0
	movl	$.L.str, %edi
	movb	$1, %al
	callq	printf
	callq	_Z10copytablesv
	movq	h_a(%rip), %rdi
	callq	free
	callq	_Z10make_tablev
	movl	$startwtime, %edi
	xorl	%esi, %esi
	callq	gettimeofday
	movq	size(%rip), %rsi
	movl	$d_a, %edi
	callq	hipMalloc
	movq	d_a(%rip), %rdi
	movq	h_a(%rip), %rsi
	movq	size(%rip), %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movl	tsize(%rip), %eax
	movl	%eax, %ecx
	shrl	$5, %ecx
	leaq	1(%r12), %r14
	imulq	%rcx, %r14
	testl	%eax, %eax
	jle	.LBB3_4
.LBB3_1:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movq	%r14, %rdi
	movl	$1, %esi
	movq	%rbx, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB3_3
# %bb.2:                                #   in Loop: Header=BB3_1 Depth=1
	movq	d_a(%rip), %rdi
	movl	tsize(%rip), %esi
	movl	%r15d, %edx
	callq	_Z22__device_stub__Kernel1Pfii
.LBB3_3:                                #   in Loop: Header=BB3_1 Depth=1
	callq	hipDeviceSynchronize
	incl	%r15d
	cmpl	tsize(%rip), %r15d
	jl	.LBB3_1
.LBB3_4:                                # %._crit_edge
	movq	h_a(%rip), %rdi
	movq	d_a(%rip), %rsi
	movq	size(%rip), %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	xorl	%r15d, %r15d
	movl	$endwtime, %edi
	xorl	%esi, %esi
	callq	gettimeofday
	movq	endwtime+8(%rip), %rax
	subq	startwtime+8(%rip), %rax
	xorps	%xmm1, %xmm1
	cvtsi2sd	%rax, %xmm1
	divsd	.LCPI3_0(%rip), %xmm1
	xorps	%xmm0, %xmm0
	cvtsi2sdq	endwtime(%rip), %xmm0
	addsd	%xmm1, %xmm0
	xorps	%xmm1, %xmm1
	cvtsi2sdq	startwtime(%rip), %xmm1
	subsd	%xmm1, %xmm0
	movl	$.L.str.1, %edi
	movb	$1, %al
	callq	printf
	callq	_Z5checkv
	movq	d_a(%rip), %rdi
	callq	hipFree
	movq	h_a(%rip), %rdi
	callq	free
	callq	_Z10make_tablev
	movl	$startwtime, %edi
	xorl	%esi, %esi
	callq	gettimeofday
	movq	size(%rip), %rsi
	movl	$d_a, %edi
	callq	hipMalloc
	movq	d_a(%rip), %rdi
	movq	h_a(%rip), %rsi
	movq	size(%rip), %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	cmpl	$0, tsize(%rip)
	jle	.LBB3_8
.LBB3_5:                                # %.lr.ph45
                                        # =>This Inner Loop Header: Depth=1
	movq	%r14, %rdi
	movl	$1, %esi
	movq	%rbx, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB3_7
# %bb.6:                                #   in Loop: Header=BB3_5 Depth=1
	movq	d_a(%rip), %rdi
	movl	tsize(%rip), %esi
	movl	%r15d, %edx
	callq	_Z22__device_stub__Kernel2Pfii
.LBB3_7:                                #   in Loop: Header=BB3_5 Depth=1
	callq	hipDeviceSynchronize
	addl	$2, %r15d
	cmpl	tsize(%rip), %r15d
	jl	.LBB3_5
.LBB3_8:                                # %._crit_edge46
	movq	h_a(%rip), %rdi
	movq	d_a(%rip), %rsi
	movq	size(%rip), %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	xorl	%ebx, %ebx
	movl	$endwtime, %edi
	xorl	%esi, %esi
	callq	gettimeofday
	movq	endwtime+8(%rip), %rax
	subq	startwtime+8(%rip), %rax
	xorps	%xmm1, %xmm1
	cvtsi2sd	%rax, %xmm1
	divsd	.LCPI3_0(%rip), %xmm1
	xorps	%xmm0, %xmm0
	cvtsi2sdq	endwtime(%rip), %xmm0
	addsd	%xmm1, %xmm0
	xorps	%xmm1, %xmm1
	cvtsi2sdq	startwtime(%rip), %xmm1
	subsd	%xmm1, %xmm0
	movl	$.L.str.2, %edi
	movb	$1, %al
	callq	printf
	callq	_Z5checkv
	movq	d_a(%rip), %rdi
	callq	hipFree
	movq	h_a(%rip), %rdi
	callq	free
	callq	_Z10make_tablev
	movl	$startwtime, %edi
	xorl	%esi, %esi
	callq	gettimeofday
	movq	size(%rip), %rsi
	movl	$d_a, %edi
	callq	hipMalloc
	movq	d_a(%rip), %rdi
	movq	h_a(%rip), %rsi
	movq	size(%rip), %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movl	tsize(%rip), %eax
	testl	%eax, %eax
	jle	.LBB3_13
# %bb.9:                                # %.lr.ph49.preheader
	leaq	16(%r12), %r14
.LBB3_10:                               # %.lr.ph49
                                        # =>This Inner Loop Header: Depth=1
	movl	%eax, %edi
	orq	%r12, %rdi
	movl	$1, %esi
	movq	%r14, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB3_12
# %bb.11:                               #   in Loop: Header=BB3_10 Depth=1
	movq	d_a(%rip), %rdi
	movl	tsize(%rip), %esi
	movl	%ebx, %edx
	callq	_Z22__device_stub__Kernel3Pfii
.LBB3_12:                               #   in Loop: Header=BB3_10 Depth=1
	callq	hipDeviceSynchronize
	addl	$2, %ebx
	movl	tsize(%rip), %eax
	cmpl	%eax, %ebx
	jl	.LBB3_10
.LBB3_13:                               # %._crit_edge50
	movq	h_a(%rip), %rdi
	movq	d_a(%rip), %rsi
	movq	size(%rip), %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	movl	$endwtime, %edi
	xorl	%esi, %esi
	callq	gettimeofday
	movq	endwtime+8(%rip), %rax
	subq	startwtime+8(%rip), %rax
	xorps	%xmm1, %xmm1
	cvtsi2sd	%rax, %xmm1
	divsd	.LCPI3_0(%rip), %xmm1
	xorps	%xmm0, %xmm0
	cvtsi2sdq	endwtime(%rip), %xmm0
	addsd	%xmm1, %xmm0
	xorps	%xmm1, %xmm1
	cvtsi2sdq	startwtime(%rip), %xmm1
	subsd	%xmm1, %xmm0
	movl	$.L.str.3, %edi
	movb	$1, %al
	callq	printf
	callq	_Z5checkv
	movq	d_a(%rip), %rdi
	callq	hipFree
	movq	h_a(%rip), %rdi
	callq	free
	xorl	%eax, %eax
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end3:
	.size	main, .Lfunc_end3-main
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0                          # -- Begin function _Z10make_tablev
.LCPI4_0:
	.quad	0x7fffffffffffffff              # double NaN
	.quad	0x7fffffffffffffff              # double NaN
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0
.LCPI4_1:
	.quad	0x7ff0000000000000              # double +Inf
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0
.LCPI4_2:
	.long	0x497423f0                      # float 999999
	.text
	.globl	_Z10make_tablev
	.type	_Z10make_tablev,@function
_Z10make_tablev:                        # @_Z10make_tablev
	.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	$700008, %rsp                   # imm = 0xAAE68
	.cfi_def_cfa_offset 700064
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	$.L.str.4, %edi
	movl	$.L.str.5, %esi
	callq	fopen
	movq	%rax, %rbx
	movq	%rsp, %r14
	movq	%r14, %rdi
	movl	$700000, %esi                   # imm = 0xAAE60
	movq	%rax, %rdx
	callq	fgets
	movq	%r14, %rdi
	callq	atof
	cvttsd2si	%xmm0, %edi
	movl	%edi, tsize(%rip)
	imull	%edi, %edi
	shlq	$2, %rdi
	movq	%rdi, size(%rip)
	callq	malloc
	movq	%rax, h_a(%rip)
	movq	%r14, %rdi
	movl	$700000, %esi                   # imm = 0xAAE60
	movq	%rbx, %rdx
	callq	fgets
	testq	%rax, %rax
	je	.LBB4_8
# %bb.1:                                # %.preheader.preheader
	xorl	%r12d, %r12d
.LBB4_2:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB4_4 Depth 2
	movl	tsize(%rip), %r13d
	testl	%r13d, %r13d
	jle	.LBB4_7
# %bb.3:                                # %.lr.ph
                                        #   in Loop: Header=BB4_2 Depth=1
	movl	%r13d, %ebp
	imull	%r12d, %ebp
	shlq	$2, %rbp
	addq	h_a(%rip), %rbp
	movq	%rsp, %r15
	xorl	%r14d, %r14d
.LBB4_4:                                #   Parent Loop BB4_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movq	%r15, %rdi
	callq	atof
	movapd	%xmm0, %xmm1
	andpd	.LCPI4_0(%rip), %xmm1
	ucomisd	.LCPI4_1(%rip), %xmm1
	movss	.LCPI4_2(%rip), %xmm1           # xmm1 = mem[0],zero,zero,zero
	jae	.LBB4_6
# %bb.5:                                #   in Loop: Header=BB4_4 Depth=2
	xorps	%xmm1, %xmm1
	cvtsd2ss	%xmm0, %xmm1
.LBB4_6:                                #   in Loop: Header=BB4_4 Depth=2
	movss	%xmm1, (%rbp,%r14,4)
	incq	%r14
	addq	$16, %r15
	cmpq	%r14, %r13
	jne	.LBB4_4
.LBB4_7:                                # %._crit_edge
                                        #   in Loop: Header=BB4_2 Depth=1
	incl	%r12d
	movq	%rsp, %rdi
	movl	$700000, %esi                   # imm = 0xAAE60
	movq	%rbx, %rdx
	callq	fgets
	testq	%rax, %rax
	jne	.LBB4_2
.LBB4_8:                                # %._crit_edge15
	movq	%rbx, %rdi
	callq	fclose
	addq	$700008, %rsp                   # imm = 0xAAE68
	.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	_Z10make_tablev, .Lfunc_end4-_Z10make_tablev
	.cfi_endproc
                                        # -- End function
	.globl	_Z6serialv                      # -- Begin function _Z6serialv
	.type	_Z6serialv,@function
_Z6serialv:                             # @_Z6serialv
	.cfi_startproc
# %bb.0:
	movl	tsize(%rip), %eax
	testl	%eax, %eax
	jle	.LBB5_10
# %bb.1:                                # %.preheader22.lr.ph
	pushq	%r14
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset %rbx, -24
	.cfi_offset %r14, -16
	xorl	%ecx, %ecx
	xorl	%edx, %edx
.LBB5_2:                                # %.preheader.lr.ph
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB5_3 Depth 2
                                        #       Child Loop BB5_4 Depth 3
	movl	%ecx, %r8d
	movq	h_a(%rip), %rsi
	leaq	(%rsi,%rdx,4), %rdi
	leaq	(%rsi,%r8,4), %r8
	xorl	%r9d, %r9d
	xorl	%r10d, %r10d
.LBB5_3:                                # %.preheader
                                        #   Parent Loop BB5_2 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB5_4 Depth 3
	movl	%r9d, %r11d
	leaq	(%rsi,%r11,4), %r11
	movq	%r10, %rbx
	imulq	%rax, %rbx
	xorl	%r14d, %r14d
.LBB5_4:                                #   Parent Loop BB5_2 Depth=1
                                        #     Parent Loop BB5_3 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movss	(%r11,%r14,4), %xmm1            # xmm1 = mem[0],zero,zero,zero
	movss	(%rdi,%rbx,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	addss	(%r8,%r14,4), %xmm0
	ucomiss	%xmm0, %xmm1
	jbe	.LBB5_6
# %bb.5:                                #   in Loop: Header=BB5_4 Depth=3
	movss	%xmm0, (%r11,%r14,4)
.LBB5_6:                                #   in Loop: Header=BB5_4 Depth=3
	incq	%r14
	cmpq	%r14, %rax
	jne	.LBB5_4
# %bb.7:                                # %._crit_edge
                                        #   in Loop: Header=BB5_3 Depth=2
	incq	%r10
	addl	%eax, %r9d
	cmpq	%rax, %r10
	jne	.LBB5_3
# %bb.8:                                # %._crit_edge25
                                        #   in Loop: Header=BB5_2 Depth=1
	incq	%rdx
	addl	%eax, %ecx
	cmpq	%rax, %rdx
	jne	.LBB5_2
# %bb.9:
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	.cfi_restore %rbx
	.cfi_restore %r14
.LBB5_10:                               # %._crit_edge27
	retq
.Lfunc_end5:
	.size	_Z6serialv, .Lfunc_end5-_Z6serialv
	.cfi_endproc
                                        # -- End function
	.globl	_Z10copytablesv                 # -- Begin function _Z10copytablesv
	.type	_Z10copytablesv,@function
_Z10copytablesv:                        # @_Z10copytablesv
	.cfi_startproc
# %bb.0:
	pushq	%rax
	.cfi_def_cfa_offset 16
	movq	size(%rip), %rdi
	callq	malloc
	movq	%rax, test(%rip)
	movl	tsize(%rip), %ecx
	testl	%ecx, %ecx
	je	.LBB6_3
# %bb.1:                                # %.lr.ph
	imull	%ecx, %ecx
	movq	h_a(%rip), %rdx
	cmpl	$1, %ecx
	adcl	$0, %ecx
	xorl	%esi, %esi
.LBB6_2:                                # =>This Inner Loop Header: Depth=1
	movss	(%rdx,%rsi,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, (%rax,%rsi,4)
	incq	%rsi
	cmpq	%rsi, %rcx
	jne	.LBB6_2
.LBB6_3:                                # %._crit_edge
	popq	%rax
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end6:
	.size	_Z10copytablesv, .Lfunc_end6-_Z10copytablesv
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0                          # -- Begin function _Z5checkv
.LCPI7_0:
	.long	0x7fffffff                      # float NaN
	.long	0x7fffffff                      # float NaN
	.long	0x7fffffff                      # float NaN
	.long	0x7fffffff                      # float NaN
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0
.LCPI7_1:
	.quad	0x3eb0c6f7a0b5ed8d              # double 9.9999999999999995E-7
	.text
	.globl	_Z5checkv
	.type	_Z5checkv,@function
_Z5checkv:                              # @_Z5checkv
	.cfi_startproc
# %bb.0:
	pushq	%rax
	.cfi_def_cfa_offset 16
	movl	tsize(%rip), %eax
	testl	%eax, %eax
	jle	.LBB7_7
# %bb.1:                                # %.preheader.lr.ph
	movq	h_a(%rip), %rcx
	xorl	%edx, %edx
	movq	test(%rip), %rsi
	movaps	.LCPI7_0(%rip), %xmm0           # xmm0 = [NaN,NaN,NaN,NaN]
	movsd	.LCPI7_1(%rip), %xmm1           # xmm1 = mem[0],zero
	xorl	%edi, %edi
.LBB7_2:                                # %.lr.ph
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB7_4 Depth 2
	movl	%edx, %r9d
	leaq	(%rsi,%r9,4), %r8
	leaq	(%rcx,%r9,4), %r9
	xorl	%r10d, %r10d
.LBB7_4:                                #   Parent Loop BB7_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movss	(%r9,%r10,4), %xmm2             # xmm2 = mem[0],zero,zero,zero
	subss	(%r8,%r10,4), %xmm2
	andps	%xmm0, %xmm2
	cvtss2sd	%xmm2, %xmm2
	ucomisd	%xmm1, %xmm2
	ja	.LBB7_5
# %bb.3:                                #   in Loop: Header=BB7_4 Depth=2
	incq	%r10
	cmpq	%r10, %rax
	jne	.LBB7_4
# %bb.6:                                # %._crit_edge
                                        #   in Loop: Header=BB7_2 Depth=1
	incq	%rdi
	addl	%eax, %edx
	cmpq	%rax, %rdi
	jne	.LBB7_2
.LBB7_7:                                # %._crit_edge13
	movl	$.Lstr, %edi
	popq	%rax
	.cfi_def_cfa_offset 8
	jmp	puts@PLT                        # TAILCALL
.LBB7_5:
	.cfi_def_cfa_offset 16
	movl	$.Lstr.1, %edi
	callq	puts@PLT
	movl	$1, %edi
	callq	exit
.Lfunc_end7:
	.size	_Z5checkv, .Lfunc_end7-_Z5checkv
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0                          # -- Begin function _Z5printPf
.LCPI8_0:
	.long	0x7fffffff                      # float NaN
	.long	0x7fffffff                      # float NaN
	.long	0x7fffffff                      # float NaN
	.long	0x7fffffff                      # float NaN
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0
.LCPI8_1:
	.long	0x7f800000                      # float +Inf
	.text
	.globl	_Z5printPf
	.type	_Z5printPf,@function
_Z5printPf:                             # @_Z5printPf
	.cfi_startproc
# %bb.0:
	movl	tsize(%rip), %eax
	testl	%eax, %eax
	jle	.LBB8_9
# %bb.1:                                # %.preheader.preheader
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rdi, %rbx
	xorl	%r14d, %r14d
.LBB8_2:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB8_4 Depth 2
	testl	%eax, %eax
	jle	.LBB8_7
# %bb.3:                                # %.lr.ph.preheader
                                        #   in Loop: Header=BB8_2 Depth=1
	xorl	%r15d, %r15d
.LBB8_4:                                # %.lr.ph
                                        #   Parent Loop BB8_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movq	h_a(%rip), %rcx
	imull	%r14d, %eax
	cltq
	addq	%r15, %rax
	movss	(%rcx,%rax,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	andps	.LCPI8_0(%rip), %xmm0
	ucomiss	.LCPI8_1(%rip), %xmm0
	movl	$.L.str.6, %edi
	jae	.LBB8_6
# %bb.5:                                # %.lr.ph
                                        #   in Loop: Header=BB8_4 Depth=2
	movl	$.L.str.7, %edi
.LBB8_6:                                # %.lr.ph
                                        #   in Loop: Header=BB8_4 Depth=2
	xorps	%xmm0, %xmm0
	cvtss2sd	(%rbx,%rax,4), %xmm0
	movb	$1, %al
	callq	printf
	movl	tsize(%rip), %eax
	incq	%r15
	cmpl	%eax, %r15d
	jl	.LBB8_4
.LBB8_7:                                # %._crit_edge
                                        #   in Loop: Header=BB8_2 Depth=1
	movl	$.Lstr.2, %edi
	callq	puts@PLT
	incl	%r14d
	movl	tsize(%rip), %eax
	cmpl	%eax, %r14d
	jl	.LBB8_2
# %bb.8:
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	.cfi_restore %rbx
	.cfi_restore %r14
	.cfi_restore %r15
.LBB8_9:                                # %._crit_edge15
	retq
.Lfunc_end8:
	.size	_Z5printPf, .Lfunc_end8-_Z5printPf
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$32, %rsp
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -16
	movq	__hip_gpubin_handle(%rip), %rbx
	testq	%rbx, %rbx
	jne	.LBB9_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB9_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z7Kernel1Pfii, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z7Kernel2Pfii, %esi
	movl	$.L__unnamed_2, %edx
	movl	$.L__unnamed_2, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z7Kernel3Pfii, %esi
	movl	$.L__unnamed_3, %edx
	movl	$.L__unnamed_3, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$__hip_module_dtor, %edi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end9:
	.size	__hip_module_ctor, .Lfunc_end9-__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	.LBB10_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
.LBB10_2:
	retq
.Lfunc_end10:
	.size	__hip_module_dtor, .Lfunc_end10-__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	h_a,@object                     # @h_a
	.globl	h_a
	.p2align	3, 0x0
h_a:
	.quad	0
	.size	h_a, 8

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

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

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

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

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

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

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

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"Serial time : %lf\n"
	.size	.L.str, 19

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"Kernel 1 time : %lf\n"
	.size	.L.str.1, 21

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"Kernel 2 time : %lf\n"
	.size	.L.str.2, 21

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"Kernel 3 time : %lf\n"
	.size	.L.str.3, 21

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"input.txt"
	.size	.L.str.4, 10

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

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"%f\t\t"
	.size	.L.str.6, 5

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"%f\t"
	.size	.L.str.7, 4

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z7Kernel1Pfii"
	.size	.L__unnamed_1, 15

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

	.type	.L__unnamed_3,@object           # @2
.L__unnamed_3:
	.asciz	"_Z7Kernel3Pfii"
	.size	.L__unnamed_3, 15

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

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

	.type	.Lstr,@object                   # @str
	.section	.rodata.str1.1,"aMS",@progbits,1
.Lstr:
	.asciz	"Success!"
	.size	.Lstr, 9

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"Fail!"
	.size	.Lstr.1, 6

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

	.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__Kernel1Pfii
	.addrsig_sym _Z22__device_stub__Kernel2Pfii
	.addrsig_sym _Z22__device_stub__Kernel3Pfii
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym startwtime
	.addrsig_sym endwtime
	.addrsig_sym d_a
	.addrsig_sym _Z7Kernel1Pfii
	.addrsig_sym _Z7Kernel2Pfii
	.addrsig_sym _Z7Kernel3Pfii
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z7Kernel1Pfii          ; -- Begin function _Z7Kernel1Pfii
	.globl	_Z7Kernel1Pfii
	.p2align	8
	.type	_Z7Kernel1Pfii,@function
_Z7Kernel1Pfii:                         ; @_Z7Kernel1Pfii
; %bb.0:
	s_clause 0x1
	s_load_b32 s4, s[0:1], 0x1c
	s_load_b128 s[0:3], s[0:1], 0x0
	v_and_b32_e32 v1, 0x3ff, v0
	v_bfe_u32 v0, v0, 10, 10
	s_waitcnt lgkmcnt(0)
	s_lshr_b32 s5, s4, 16
	s_and_b32 s4, s4, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_mad_u64_u32 v[2:3], null, s14, s4, v[1:2]
	v_mad_u64_u32 v[3:4], null, s15, s5, v[0:1]
	v_mul_lo_u32 v4, v2, s2
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_2)
	v_mad_u64_u32 v[0:1], null, s3, s2, v[3:4]
	v_add_nc_u32_e32 v2, v4, v3
	v_add_nc_u32_e32 v4, s3, v4
	v_ashrrev_i32_e32 v3, 31, v2
	s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_ashrrev_i32_e32 v1, 31, v0
	v_ashrrev_i32_e32 v5, 31, v4
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_lshlrev_b64 v[2:3], 2, v[2:3]
	v_lshlrev_b64 v[0:1], 2, v[0:1]
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_lshlrev_b64 v[4:5], 2, v[4:5]
	v_add_co_u32 v6, vcc_lo, s0, v0
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_co_ci_u32_e32 v7, vcc_lo, s1, v1, vcc_lo
	v_add_co_u32 v4, vcc_lo, s0, v4
	s_delay_alu instid0(VALU_DEP_4)
	v_add_co_ci_u32_e32 v5, vcc_lo, s1, v5, vcc_lo
	v_add_co_u32 v0, vcc_lo, s0, v2
	v_add_co_ci_u32_e32 v1, vcc_lo, s1, v3, vcc_lo
	s_clause 0x2
	global_load_b32 v2, v[4:5], off
	global_load_b32 v3, v[6:7], off
	global_load_b32 v4, v[0:1], off
	s_mov_b32 s0, exec_lo
	s_waitcnt vmcnt(1)
	v_add_f32_e32 v2, v2, v3
	s_waitcnt vmcnt(0)
	s_delay_alu instid0(VALU_DEP_1)
	v_cmpx_gt_f32_e32 v4, v2
	s_cbranch_execz .LBB0_2
; %bb.1:
	global_store_b32 v[0:1], v2, off
.LBB0_2:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z7Kernel1Pfii
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 272
		.amdhsa_user_sgpr_count 14
		.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 1
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 1
		.amdhsa_next_free_vgpr 8
		.amdhsa_next_free_sgpr 16
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end0:
	.size	_Z7Kernel1Pfii, .Lfunc_end0-_Z7Kernel1Pfii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 268
; NumSgprs: 18
; NumVgprs: 8
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 8
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 14
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 1
	.text
	.protected	_Z7Kernel2Pfii          ; -- Begin function _Z7Kernel2Pfii
	.globl	_Z7Kernel2Pfii
	.p2align	8
	.type	_Z7Kernel2Pfii,@function
_Z7Kernel2Pfii:                         ; @_Z7Kernel2Pfii
; %bb.0:
	s_load_b128 s[4:7], s[0:1], 0x0
	v_and_b32_e32 v1, 0x3ff, v0
	v_bfe_u32 v0, v0, 10, 10
	s_mov_b32 s3, exec_lo
                                        ; implicit-def: $sgpr8
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	v_or_b32_e32 v2, v1, v0
	s_waitcnt lgkmcnt(0)
	s_mul_i32 s2, s7, s6
	v_cmpx_ne_u32_e32 0, v2
	s_xor_b32 s3, exec_lo, s3
; %bb.1:                                ; %._crit_edge
	s_add_i32 s8, s2, s6
; %bb.2:                                ; %Flow
	s_or_saveexec_b32 s3, s3
	s_load_b32 s0, s[0:1], 0x1c
	v_mov_b32_e32 v2, s8
	s_xor_b32 exec_lo, exec_lo, s3
	s_cbranch_execz .LBB1_4
; %bb.3:
	s_ashr_i32 s1, s2, 31
	s_mov_b32 s8, s7
	s_ashr_i32 s9, s7, 31
	s_add_u32 s8, s2, s7
	s_addc_u32 s9, s1, s9
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_lshl_b64 s[8:9], s[8:9], 2
	s_add_u32 s8, s4, s8
	s_addc_u32 s9, s5, s9
	s_add_i32 s1, s2, s6
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(SALU_CYCLE_1)
	v_dual_mov_b32 v5, 0 :: v_dual_mov_b32 v2, s1
	s_add_i32 s10, s1, s7
	s_ashr_i32 s11, s10, 31
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_lshl_b64 s[10:11], s[10:11], 2
	s_add_u32 s10, s4, s10
	s_addc_u32 s11, s5, s11
	s_clause 0x1
	s_load_b32 s8, s[8:9], 0x4
	s_load_b32 s9, s[10:11], 0x0
	s_waitcnt lgkmcnt(0)
	v_dual_mov_b32 v4, s8 :: v_dual_mov_b32 v3, s9
	ds_store_b64 v5, v[3:4]
.LBB1_4:
	s_or_b32 exec_lo, exec_lo, s3
	s_waitcnt lgkmcnt(0)
	s_and_b32 s1, s0, 0xffff
	s_lshr_b32 s0, s0, 16
	v_mad_u64_u32 v[3:4], null, s14, s1, v[1:2]
	v_mad_u64_u32 v[4:5], null, s15, s0, v[0:1]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_mul_lo_u32 v6, v3, s6
	v_add_nc_u32_e32 v0, s2, v4
	v_add_nc_u32_e32 v5, v4, v2
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_ashrrev_i32_e32 v1, 31, v0
	v_add_nc_u32_e32 v3, s7, v6
	v_add_nc_u32_e32 v7, v6, v4
	s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_ashrrev_i32_e32 v6, 31, v5
	v_lshlrev_b64 v[0:1], 2, v[0:1]
	s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_ashrrev_i32_e32 v4, 31, v3
	v_ashrrev_i32_e32 v8, 31, v7
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_co_u32 v0, vcc_lo, s4, v0
	v_lshlrev_b64 v[2:3], 2, v[3:4]
	v_add_co_ci_u32_e32 v1, vcc_lo, s5, v1, vcc_lo
	v_lshlrev_b64 v[4:5], 2, v[5:6]
	v_lshlrev_b64 v[6:7], 2, v[7:8]
	s_delay_alu instid0(VALU_DEP_4)
	v_add_co_u32 v2, vcc_lo, s4, v2
	v_add_co_ci_u32_e32 v3, vcc_lo, s5, v3, vcc_lo
	s_clause 0x1
	global_load_b32 v8, v[0:1], off
	global_load_b64 v[0:1], v[2:3], off
	v_add_co_u32 v2, vcc_lo, s4, v4
	v_add_co_ci_u32_e32 v3, vcc_lo, s5, v5, vcc_lo
	v_add_co_u32 v4, vcc_lo, s4, v6
	v_add_co_ci_u32_e32 v5, vcc_lo, s5, v7, vcc_lo
	s_clause 0x1
	global_load_b32 v6, v[2:3], off
	global_load_b32 v7, v[4:5], off
	v_mov_b32_e32 v2, 0
	s_waitcnt vmcnt(0)
	s_barrier
	buffer_gl0_inv
	ds_load_b64 v[2:3], v2
	s_waitcnt lgkmcnt(0)
	v_add_f32_e32 v2, v8, v2
	v_add_f32_e32 v3, v0, v3
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_4)
	v_cmp_gt_f32_e32 vcc_lo, v1, v3
	v_cndmask_b32_e32 v1, v1, v3, vcc_lo
	v_cmp_gt_f32_e32 vcc_lo, v6, v2
	v_cndmask_b32_e32 v2, v6, v2, vcc_lo
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_dual_add_f32 v0, v8, v0 :: v_dual_add_f32 v1, v1, v2
	v_cmp_gt_f32_e32 vcc_lo, v7, v0
	v_cndmask_b32_e32 v0, v7, v0, vcc_lo
	s_delay_alu instid0(VALU_DEP_1)
	v_cmp_gt_f32_e32 vcc_lo, v0, v1
	v_cndmask_b32_e32 v0, v0, v1, vcc_lo
	global_store_b32 v[4:5], v0, off
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z7Kernel2Pfii
		.amdhsa_group_segment_fixed_size 8
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 272
		.amdhsa_user_sgpr_count 14
		.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 1
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 1
		.amdhsa_next_free_vgpr 9
		.amdhsa_next_free_sgpr 16
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end1:
	.size	_Z7Kernel2Pfii, .Lfunc_end1-_Z7Kernel2Pfii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 528
; NumSgprs: 18
; NumVgprs: 9
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 8 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 9
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 14
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 1
	.text
	.protected	_Z7Kernel3Pfii          ; -- Begin function _Z7Kernel3Pfii
	.globl	_Z7Kernel3Pfii
	.p2align	8
	.type	_Z7Kernel3Pfii,@function
_Z7Kernel3Pfii:                         ; @_Z7Kernel3Pfii
; %bb.0:
	s_load_b128 s[4:7], s[0:1], 0x0
	v_lshrrev_b32_e32 v1, 10, v0
	s_mov_b32 s9, exec_lo
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_or_b32_e32 v1, v0, v1
	v_and_b32_e32 v0, 0x3ff, v0
	v_and_b32_e32 v1, 0x3ff, v1
	s_waitcnt lgkmcnt(0)
	s_mul_i32 s8, s7, s6
	s_mul_i32 s3, s15, s6
	s_add_i32 s2, s8, s6
	v_cmpx_eq_u32_e32 0, v1
	s_cbranch_execz .LBB2_2
; %bb.1:
	s_add_i32 s10, s3, s7
	s_mov_b32 s12, s7
	s_ashr_i32 s11, s10, 31
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_lshl_b64 s[10:11], s[10:11], 2
	s_add_u32 s10, s4, s10
	s_addc_u32 s11, s5, s11
	s_ashr_i32 s13, s8, 31
	s_ashr_i32 s14, s7, 31
	s_add_u32 s12, s8, s7
	s_addc_u32 s13, s13, s14
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_lshl_b64 s[12:13], s[12:13], 2
	s_add_u32 s12, s4, s12
	s_addc_u32 s13, s5, s13
	s_add_i32 s14, s2, s7
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_ashr_i32 s15, s14, 31
	s_lshl_b64 s[14:15], s[14:15], 2
	s_delay_alu instid0(SALU_CYCLE_1)
	s_add_u32 s14, s4, s14
	s_addc_u32 s15, s5, s15
	s_clause 0x2
	s_load_b64 s[10:11], s[10:11], 0x0
	s_load_b32 s7, s[14:15], 0x0
	s_load_b32 s12, s[12:13], 0x4
	v_mov_b32_e32 v5, 0
	s_waitcnt lgkmcnt(0)
	v_dual_mov_b32 v1, s10 :: v_dual_mov_b32 v2, s11
	v_dual_mov_b32 v4, s12 :: v_dual_mov_b32 v3, s7
	ds_store_2addr_b64 v5, v[3:4], v[1:2] offset1:1
.LBB2_2:
	s_or_b32 exec_lo, exec_lo, s9
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	s_load_b32 s0, s[0:1], 0x1c
	v_mul_lo_u32 v0, v0, s6
	s_waitcnt lgkmcnt(0)
	s_and_b32 s1, s0, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_cvt_f32_u32_e32 v1, s1
	s_sub_i32 s0, 0, s1
	v_rcp_iflag_f32_e32 v1, v1
	s_waitcnt_depctr 0xfff
	v_mul_f32_e32 v1, 0x4f7ffffe, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cvt_u32_f32_e32 v1, v1
	v_mul_lo_u32 v2, s0, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_hi_u32 v2, v1, v2
	v_add_nc_u32_e32 v1, v1, v2
	v_add_nc_u32_e32 v2, s6, v0
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_hi_u32 v3, v0, v1
	v_mul_lo_u32 v4, v3, s1
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_sub_nc_u32_e32 v0, v0, v4
	v_add_nc_u32_e32 v4, 1, v3
	v_cmp_le_u32_e32 vcc_lo, s1, v0
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_cndmask_b32_e32 v3, v3, v4, vcc_lo
	v_subrev_nc_u32_e32 v4, s1, v0
	v_cndmask_b32_e32 v0, v0, v4, vcc_lo
	v_mul_hi_u32 v1, v2, v1
	s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_nc_u32_e32 v4, 1, v3
	v_cmp_le_u32_e32 vcc_lo, s1, v0
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_mul_lo_u32 v5, v1, s1
	v_cndmask_b32_e32 v8, v3, v4, vcc_lo
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_sub_nc_u32_e32 v2, v2, v5
	v_add_nc_u32_e32 v5, 1, v1
	v_subrev_nc_u32_e32 v6, s1, v2
	v_cmp_le_u32_e64 s0, s1, v2
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_cndmask_b32_e64 v1, v1, v5, s0
	v_cndmask_b32_e64 v2, v2, v6, s0
	s_mov_b32 s0, exec_lo
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_nc_u32_e32 v5, 1, v1
	v_cmp_le_u32_e32 vcc_lo, s1, v2
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cndmask_b32_e32 v9, v1, v5, vcc_lo
	v_cmpx_lt_u32_e64 v8, v9
	s_cbranch_execz .LBB2_13
; %bb.3:                                ; %.lr.ph
	v_mov_b32_e32 v0, 0
	v_add_nc_u32_e32 v4, s8, v8
	v_add_nc_u32_e32 v6, s3, v8
	s_mov_b32 s1, 0
	ds_load_2addr_b64 v[0:3], v0 offset1:1
	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[4:5], 2, v[4:5]
	v_lshlrev_b64 v[6:7], 2, v[6:7]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_co_u32 v4, vcc_lo, s4, v4
	v_add_co_ci_u32_e32 v5, vcc_lo, s5, v5, vcc_lo
	s_waitcnt lgkmcnt(0)
	v_dual_add_f32 v10, v2, v1 :: v_dual_add_f32 v11, v3, v0
	s_delay_alu instid0(VALU_DEP_4)
	v_add_co_u32 v0, vcc_lo, s4, v6
	v_add_co_ci_u32_e32 v1, vcc_lo, s5, v7, vcc_lo
.LBB2_4:                                ; =>This Inner Loop Header: Depth=1
	global_load_b32 v6, v[4:5], off
	global_load_b32 v12, v[0:1], off
	s_mov_b32 s0, exec_lo
	s_waitcnt vmcnt(1)
	v_add_f32_e32 v6, v2, v6
	s_waitcnt vmcnt(0)
	s_delay_alu instid0(VALU_DEP_1)
	v_cmpx_gt_f32_e32 v12, v6
	s_cbranch_execz .LBB2_6
; %bb.5:                                ;   in Loop: Header=BB2_4 Depth=1
	v_mov_b32_e32 v12, v6
	global_store_b32 v[0:1], v6, off
.LBB2_6:                                ;   in Loop: Header=BB2_4 Depth=1
	s_or_b32 exec_lo, exec_lo, s0
	v_add_nc_u32_e32 v6, s2, v8
	s_mov_b32 s0, exec_lo
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v7, 31, v6
	v_lshlrev_b64 v[6:7], 2, v[6:7]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v6, vcc_lo, s4, v6
	v_add_co_ci_u32_e32 v7, vcc_lo, s5, v7, vcc_lo
	global_load_b32 v13, v[6:7], off
	s_waitcnt vmcnt(0)
	v_add_f32_e32 v14, v3, v13
	s_delay_alu instid0(VALU_DEP_1)
	v_cmpx_gt_f32_e32 v12, v14
	s_cbranch_execz .LBB2_8
; %bb.7:                                ;   in Loop: Header=BB2_4 Depth=1
	global_store_b32 v[0:1], v14, off
	global_load_b32 v13, v[6:7], off
	v_mov_b32_e32 v12, v14
.LBB2_8:                                ;   in Loop: Header=BB2_4 Depth=1
	s_or_b32 exec_lo, exec_lo, s0
	s_waitcnt vmcnt(0)
	v_add_f32_e32 v6, v10, v13
	s_mov_b32 s0, exec_lo
	s_delay_alu instid0(VALU_DEP_1)
	v_cmpx_gt_f32_e32 v12, v6
	s_cbranch_execz .LBB2_10
; %bb.9:                                ;   in Loop: Header=BB2_4 Depth=1
	v_mov_b32_e32 v12, v6
	global_store_b32 v[0:1], v6, off
.LBB2_10:                               ;   in Loop: Header=BB2_4 Depth=1
	s_or_b32 exec_lo, exec_lo, s0
	global_load_b32 v6, v[4:5], off
	s_mov_b32 s0, exec_lo
	s_waitcnt vmcnt(0)
	v_add_f32_e32 v6, v11, v6
	s_delay_alu instid0(VALU_DEP_1)
	v_cmpx_gt_f32_e32 v12, v6
	s_cbranch_execz .LBB2_12
; %bb.11:                               ;   in Loop: Header=BB2_4 Depth=1
	global_store_b32 v[0:1], v6, off
.LBB2_12:                               ;   in Loop: Header=BB2_4 Depth=1
	s_or_b32 exec_lo, exec_lo, s0
	v_add_nc_u32_e32 v8, 1, v8
	v_add_co_u32 v4, vcc_lo, v4, 4
	v_add_co_ci_u32_e32 v5, vcc_lo, 0, v5, vcc_lo
	s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_cmp_ge_u32_e32 vcc_lo, v8, v9
	v_add_co_u32 v0, s0, v0, 4
	v_add_co_ci_u32_e64 v1, s0, 0, v1, s0
	s_or_b32 s1, vcc_lo, s1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_not1_b32 exec_lo, exec_lo, s1
	s_cbranch_execnz .LBB2_4
.LBB2_13:                               ; %._crit_edge
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z7Kernel3Pfii
		.amdhsa_group_segment_fixed_size 16
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 272
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 1
		.amdhsa_next_free_vgpr 15
		.amdhsa_next_free_sgpr 16
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end2:
	.size	_Z7Kernel3Pfii, .Lfunc_end2-_Z7Kernel3Pfii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 892
; NumSgprs: 18
; NumVgprs: 15
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 16 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 15
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 1
	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_
	.amdgpu_metadata
---
amdhsa.kernels:
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .offset:         8
        .size:           4
        .value_kind:     by_value
      - .offset:         12
        .size:           4
        .value_kind:     by_value
      - .offset:         16
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         20
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         24
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         28
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         30
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         32
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         34
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         36
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         38
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         56
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         64
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         80
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 272
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z7Kernel1Pfii
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z7Kernel1Pfii.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     8
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .offset:         8
        .size:           4
        .value_kind:     by_value
      - .offset:         12
        .size:           4
        .value_kind:     by_value
      - .offset:         16
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         20
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         24
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         28
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         30
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         32
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         34
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         36
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         38
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         56
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         64
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         80
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 8
    .kernarg_segment_align: 8
    .kernarg_segment_size: 272
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z7Kernel2Pfii
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z7Kernel2Pfii.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     9
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .offset:         8
        .size:           4
        .value_kind:     by_value
      - .offset:         12
        .size:           4
        .value_kind:     by_value
      - .offset:         16
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         20
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         24
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         28
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         30
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         32
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         34
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         36
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         38
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         56
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         64
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         80
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 16
    .kernarg_segment_align: 8
    .kernarg_segment_size: 272
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z7Kernel3Pfii
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z7Kernel3Pfii.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     15
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
