#include <sys/time.h>
#include <cuda.h>
#include <stdio.h>


#define HANDLE_ERROR( err ) ( HandleError( err, __FILE__, __LINE__ ) )

static void HandleError( cudaError_t err, const char *file, int line )
{
    if (err != cudaSuccess)
      {
        printf( "Error: %s in %s at line %d\n", cudaGetErrorString( err ),
                file, line );
        exit( EXIT_FAILURE );
    }
}


// time stamp function in seconds
double getTimeStamp() {
	struct timeval tv ;
	gettimeofday( &tv, NULL ) ;
	return (double) tv.tv_usec/1000000 + tv.tv_sec ;
}

// host side matrix addition
void h_addmat(float *A, float *B, float *C, int nx, int ny){

	for (int i =0;i<nx;i++){
		for(int j=0;j<ny;j++){
			C[i*ny+j] = A[i*ny+j]+B[i*ny+j]; 
		}

	}
	return;
}

// device-side matrix addition
__global__ void f_addmat( float *A, float *B, float *C, int nx, int ny ){
	
	int ix = threadIdx.x + blockIdx.x*(blockDim.x) ;
	int iy = threadIdx.y + blockIdx.y*(blockDim.y) ;
	//printf("In add\n");
		
	if( (ix<nx/2) && (iy<ny/2) ){
		int idx = (iy*nx/2 + ix)*4;
		C[idx] = A[idx] + B[idx] ;
		C[idx+1] = A[idx+1] + B[idx+1] ;
		C[idx+2] = A[idx+2] + B[idx+2] ;
		C[idx+3] = A[idx+3] + B[idx+3] ;
		//printf("Thread %d %d\n",ix,iy);
	}
}

void initData(float *M, int x, int y, int flag ){ 
	
	if(flag)
	{	
		//printf("A\n");
		for (int i=0;i<x;i++){
		        for (int j=0;j<y;j++){
			    M[i*y+j] = (float)(i+j)/3.0;
		        }
		}
	}
	else
	{
		//printf("B\n");
		for (int i=0;i<x;i++){
			for (int j=0;j<y;j++){
				M[i*y+j] = (float)3.14*(i+j) ;
			}
		}
	
	}
}

int main( int argc, char *argv[] ) {
	
	
	if (argc!=3){
		printf("Error: Invalid number of arguments.\n");
		exit(1);
	}
	
	int nx = atoi( argv[1] ) ; // should check validity
	int ny = atoi( argv[2] ) ; // should check validity
	
	if(nx <=0 || ny <=0){
		printf("Error: Dimension lessThanOrEqualto Zero.\n");
                exit(1);
	}
	
	if(ny>nx)
	{
		nx=nx^ny;
		ny=nx^ny;
		nx=nx^ny;
	}

	int noElems = (nx)*(ny) ;
	int bytes = noElems * sizeof(float) ;

        // GPU and CPU memory Allocations
        
        float *d_A, *d_B, *d_C ;
        HANDLE_ERROR(cudaMalloc( (float **) &d_A, bytes )) ;
        HANDLE_ERROR(cudaMalloc( (float **) &d_B, bytes )) ;
        HANDLE_ERROR(cudaMalloc( (float **) &d_C, bytes )) ;
	float *h_hC = (float *) malloc( bytes ) ; // host result

        float *h_Ap, *h_Bp, *h_dCp;
        HANDLE_ERROR(cudaMallocHost( (float **) &h_Ap, bytes )) ;
        HANDLE_ERROR(cudaMallocHost( (float **) &h_Bp, bytes )) ;
        HANDLE_ERROR(cudaMallocHost( (float **) &h_dCp, bytes )) ;
	
	// init matrices with random data
	initData(h_Ap,nx,ny,1); 
	initData(h_Bp,nx,ny,0);

	double timeStampA = getTimeStamp() ;

	//transfer data to dev
	HANDLE_ERROR (cudaMemcpy( d_A, h_Ap, bytes, cudaMemcpyHostToDevice )) ;
	HANDLE_ERROR (cudaMemcpy( d_B, h_Bp, bytes, cudaMemcpyHostToDevice )) ;
		
	double timeStampB = getTimeStamp() ;
	
	// invoke Kernel
	dim3 block( 1024, 1) ; // you will want to configure this
	dim3 grid( (nx+block.x-1)/block.x, (ny+block.y-1)/block.y) ; 
	
	//printf("reached add %d %d %d %d %lu %d %d \n",(nx+block.x-1)/block.x, (ny+block.y-1)/block.y, nx, ny, sizeof(float), noElems, bytes);
	f_addmat<<<grid, block>>>( d_A, d_B, d_C, nx, ny ) ;
	cudaError_t err = cudaGetLastError();
	if (err != cudaSuccess) 
		printf("Error: %s\n", cudaGetErrorString(err));	

	HANDLE_ERROR(cudaDeviceSynchronize()) ;
	
	double timeStampC = getTimeStamp() ;
	
	//copy data back
	HANDLE_ERROR(cudaMemcpy(h_dCp, d_C, bytes, cudaMemcpyDeviceToHost));
	
	double timeStampD = getTimeStamp() ;
	
	// free GPU resources
	cudaFree( d_A ) ; cudaFree( d_B ) ; cudaFree( d_C ) ;
	
	// CPU Matrix add
	h_addmat( h_Ap, h_Bp, h_hC, nx, ny ) ;
	
	// Check results
	int flag = 0;
	for(int i=0;i<(nx);i++){
		for(int j=0;j<(ny);j++){
			if(h_hC[i*(ny)+j] != h_dCp[i*(ny)+j])	
				flag++;
		}
	}
	
	if (flag == 0){
		printf("%.6f %.6f %.6f %.6f\n",(timeStampD-timeStampA),(timeStampB-timeStampA),(timeStampC-timeStampB),(timeStampD-timeStampC));
	}
	else printf("host result is not the same as the device result!");
	
	//free other resourses
	cudaFreeHost(h_Ap); cudaFreeHost(h_Bp);	cudaFreeHost(h_dCp);
        free(h_hC);
	cudaDeviceReset() ;
	
}


	.file	"tmpxft_0020f314_00000000-6_1005678036.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2034:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2034:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.type	_Z8initDataPfiii.part.0, @function
_Z8initDataPfiii.part.0:
.LFB2178:
	.cfi_startproc
	movss	.LC0(%rip), %xmm1
	xorl	%r8d, %r8d
	xorl	%ecx, %ecx
.L3:
	cmpl	%esi, %ecx
	jge	.L2
	movslq	%r8d, %rax
	leaq	(%rdi,%rax,4), %r9
	xorl	%eax, %eax
.L6:
	cmpl	%eax, %edx
	jle	.L8
	leal	(%rcx,%rax), %r10d
	cvtsi2ssl	%r10d, %xmm0
	divss	%xmm1, %xmm0
	movss	%xmm0, (%r9,%rax,4)
	incq	%rax
	jmp	.L6
.L8:
	incl	%ecx
	addl	%edx, %r8d
	jmp	.L3
.L2:
	ret
	.cfi_endproc
.LFE2178:
	.size	_Z8initDataPfiii.part.0, .-_Z8initDataPfiii.part.0
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC1:
	.string	"/home/ubuntu/Datasets/stackv2/train-structured/Eavenx/assignment2/master/1005678036.cu"
.LC2:
	.string	"Error: %s in %s at line %d\n"
	.text
	.type	_ZL11HandleError9cudaErrorPKci.constprop.0, @function
_ZL11HandleError9cudaErrorPKci.constprop.0:
.LFB2179:
	.cfi_startproc
	testl	%edi, %edi
	je	.L9
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	%esi, 12(%rsp)
	call	cudaGetErrorString@PLT
	movl	12(%rsp), %r8d
	movl	$2, %edi
	leaq	.LC1(%rip), %rcx
	movq	%rax, %rdx
	leaq	.LC2(%rip), %rsi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$1, %edi
	call	exit@PLT
.L9:
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2179:
	.size	_ZL11HandleError9cudaErrorPKci.constprop.0, .-_ZL11HandleError9cudaErrorPKci.constprop.0
	.globl	_Z12getTimeStampv
	.type	_Z12getTimeStampv, @function
_Z12getTimeStampv:
.LFB2028:
	.cfi_startproc
	endbr64
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	xorl	%esi, %esi
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rdi
	call	gettimeofday@PLT
	cvtsi2sdq	8(%rsp), %xmm1
	cvtsi2sdq	16(%rsp), %xmm0
	divsd	.LC3(%rip), %xmm0
	addsd	%xmm1, %xmm0
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	je	.L15
	call	__stack_chk_fail@PLT
.L15:
	addq	$40, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2028:
	.size	_Z12getTimeStampv, .-_Z12getTimeStampv
	.globl	_Z8h_addmatPfS_S_ii
	.type	_Z8h_addmatPfS_S_ii, @function
_Z8h_addmatPfS_S_ii:
.LFB2029:
	.cfi_startproc
	endbr64
	movq	%rdi, %r10
	movq	%rsi, %r11
	xorl	%edi, %edi
	xorl	%r9d, %r9d
.L18:
	cmpl	%ecx, %r9d
	jge	.L17
	movslq	%edi, %rax
	xorl	%esi, %esi
	salq	$2, %rax
.L21:
	cmpl	%r8d, %esi
	jge	.L22
	movss	(%r10,%rax), %xmm0
	addss	(%r11,%rax), %xmm0
	incl	%esi
	movss	%xmm0, (%rdx,%rax)
	addq	$4, %rax
	jmp	.L21
.L22:
	incl	%r9d
	addl	%r8d, %edi
	jmp	.L18
.L17:
	ret
	.cfi_endproc
.LFE2029:
	.size	_Z8h_addmatPfS_S_ii, .-_Z8h_addmatPfS_S_ii
	.globl	_Z8initDataPfiii
	.type	_Z8initDataPfiii, @function
_Z8initDataPfiii:
.LFB2030:
	.cfi_startproc
	endbr64
	testl	%ecx, %ecx
	jne	.L24
	movss	.LC4(%rip), %xmm1
	xorl	%r8d, %r8d
	jmp	.L25
.L24:
	jmp	_Z8initDataPfiii.part.0
.L29:
	incl	%ecx
	addl	%edx, %r8d
.L25:
	cmpl	%esi, %ecx
	jge	.L23
	movslq	%r8d, %rax
	leaq	(%rdi,%rax,4), %r9
	xorl	%eax, %eax
.L28:
	cmpl	%eax, %edx
	jle	.L29
	leal	(%rcx,%rax), %r10d
	cvtsi2ssl	%r10d, %xmm0
	mulss	%xmm1, %xmm0
	movss	%xmm0, (%r9,%rax,4)
	incq	%rax
	jmp	.L28
.L23:
	ret
	.cfi_endproc
.LFE2030:
	.size	_Z8initDataPfiii, .-_Z8initDataPfiii
	.globl	_Z33__device_stub__Z8f_addmatPfS_S_iiPfS_S_ii
	.type	_Z33__device_stub__Z8f_addmatPfS_S_iiPfS_S_ii, @function
_Z33__device_stub__Z8f_addmatPfS_S_iiPfS_S_ii:
.LFB2056:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdi, 24(%rsp)
	leaq	48(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	60(%rsp), %rsi
	movq	%rdx, 8(%rsp)
	leaq	32(%rsp), %rdx
	movl	%ecx, 4(%rsp)
	leaq	40(%rsp), %rcx
	movl	%r8d, (%rsp)
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 56(%rsp)
	movq	%rax, 96(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 104(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 120(%rsp)
	movq	%rsp, %rax
	movq	%rax, 128(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 48(%rsp)
	movq	%rax, 60(%rsp)
	movl	$1, 68(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L30
	pushq	40(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z8f_addmatPfS_S_ii(%rip), %rdi
	pushq	40(%rsp)
	.cfi_def_cfa_offset 176
	movq	76(%rsp), %rcx
	movl	84(%rsp), %r8d
	movq	64(%rsp), %rsi
	movl	72(%rsp), %edx
	leaq	112(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 168
	popq	%rdx
	.cfi_def_cfa_offset 160
.L30:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L32
	call	__stack_chk_fail@PLT
.L32:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2056:
	.size	_Z33__device_stub__Z8f_addmatPfS_S_iiPfS_S_ii, .-_Z33__device_stub__Z8f_addmatPfS_S_iiPfS_S_ii
	.globl	_Z8f_addmatPfS_S_ii
	.type	_Z8f_addmatPfS_S_ii, @function
_Z8f_addmatPfS_S_ii:
.LFB2057:
	.cfi_startproc
	endbr64
	jmp	_Z33__device_stub__Z8f_addmatPfS_S_iiPfS_S_ii
	.cfi_endproc
.LFE2057:
	.size	_Z8f_addmatPfS_S_ii, .-_Z8f_addmatPfS_S_ii
	.section	.rodata.str1.1
.LC5:
	.string	"Error: Invalid number of arguments.\n"
.LC6:
	.string	"Error: Dimension lessThanOrEqualto Zero.\n"
.LC7:
	.string	"Error: %s\n"
.LC8:
	.string	"%.6f %.6f %.6f %.6f\n"
.LC9:
	.string	"host result is not the same as the device result!"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2031:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$120, %rsp
	.cfi_def_cfa_offset 160
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	cmpl	$3, %edi
	je	.L36
	leaq	.LC5(%rip), %rsi
	movl	$2, %edi
	jmp	.L57
.L36:
	movq	8(%rsi), %rdi
	movq	%rsi, %rbp
	call	atoi@PLT
	movq	16(%rbp), %rdi
	movl	%eax, %ebx
	call	atoi@PLT
	movl	%eax, %r12d
	testl	%ebx, %ebx
	jle	.L50
	testl	%eax, %eax
	jg	.L37
.L50:
	leaq	.LC6(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
.L57:
	call	__printf_chk@PLT
	movl	$1, %edi
	call	exit@PLT
.L37:
	cmpl	%eax, %ebx
	jl	.L39
	xchgl	%ebx, %r12d
.L39:
	movl	%r12d, %ebp
	leaq	32(%rsp), %rdi
	imull	%ebx, %ebp
	sall	$2, %ebp
	movslq	%ebp, %rbp
	movq	%rbp, %rsi
	call	cudaMalloc@PLT
	movl	$107, %esi
	movl	%eax, %edi
	call	_ZL11HandleError9cudaErrorPKci.constprop.0
	leaq	40(%rsp), %rdi
	movq	%rbp, %rsi
	call	cudaMalloc@PLT
	movl	$108, %esi
	movl	%eax, %edi
	call	_ZL11HandleError9cudaErrorPKci.constprop.0
	leaq	48(%rsp), %rdi
	movq	%rbp, %rsi
	call	cudaMalloc@PLT
	movl	$109, %esi
	movl	%eax, %edi
	call	_ZL11HandleError9cudaErrorPKci.constprop.0
	movq	%rbp, %rdi
	call	malloc@PLT
	xorl	%edx, %edx
	leaq	56(%rsp), %rdi
	movq	%rbp, %rsi
	movq	%rax, %r13
	call	cudaHostAlloc@PLT
	movl	$113, %esi
	movl	%eax, %edi
	call	_ZL11HandleError9cudaErrorPKci.constprop.0
	xorl	%edx, %edx
	leaq	64(%rsp), %rdi
	movq	%rbp, %rsi
	call	cudaHostAlloc@PLT
	movl	$114, %esi
	movl	%eax, %edi
	call	_ZL11HandleError9cudaErrorPKci.constprop.0
	xorl	%edx, %edx
	leaq	72(%rsp), %rdi
	movq	%rbp, %rsi
	call	cudaHostAlloc@PLT
	movl	$115, %esi
	movl	%eax, %edi
	call	_ZL11HandleError9cudaErrorPKci.constprop.0
	movq	56(%rsp), %rdi
	movl	%ebx, %edx
	movl	%r12d, %esi
	call	_Z8initDataPfiii.part.0
	movq	64(%rsp), %rdi
	xorl	%ecx, %ecx
	call	_Z8initDataPfiii
	call	_Z12getTimeStampv
	movq	56(%rsp), %rsi
	movq	32(%rsp), %rdi
	movq	%rbp, %rdx
	movl	$1, %ecx
	movsd	%xmm0, (%rsp)
	call	cudaMemcpy@PLT
	movl	$124, %esi
	movl	%eax, %edi
	call	_ZL11HandleError9cudaErrorPKci.constprop.0
	movq	64(%rsp), %rsi
	movq	40(%rsp), %rdi
	movq	%rbp, %rdx
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movl	$125, %esi
	movl	%eax, %edi
	call	_ZL11HandleError9cudaErrorPKci.constprop.0
	call	_Z12getTimeStampv
	movl	%ebx, 96(%rsp)
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	$4194305, %edx
	movl	$1, %ecx
	leal	1023(%r12), %eax
	movl	$1, %esi
	shrl	$10, %eax
	salq	$10, %rdx
	movl	$1, 100(%rsp)
	movl	%eax, 92(%rsp)
	movq	92(%rsp), %rdi
	movq	%rdx, 80(%rsp)
	movl	$1, 88(%rsp)
	movsd	%xmm0, 8(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L40
	movq	48(%rsp), %rdx
	movq	40(%rsp), %rsi
	movl	%ebx, %r8d
	movl	%r12d, %ecx
	movq	32(%rsp), %rdi
	call	_Z33__device_stub__Z8f_addmatPfS_S_iiPfS_S_ii
.L40:
	call	cudaGetLastError@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L41
	call	cudaGetErrorString@PLT
	leaq	.LC7(%rip), %rsi
	movl	$2, %edi
	movq	%rax, %rdx
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L41:
	call	cudaDeviceSynchronize@PLT
	movl	$139, %esi
	movl	%eax, %edi
	call	_ZL11HandleError9cudaErrorPKci.constprop.0
	call	_Z12getTimeStampv
	movq	48(%rsp), %rsi
	movq	72(%rsp), %rdi
	movq	%rbp, %rdx
	movl	$2, %ecx
	movsd	%xmm0, 24(%rsp)
	call	cudaMemcpy@PLT
	movl	$144, %esi
	movl	%eax, %edi
	call	_ZL11HandleError9cudaErrorPKci.constprop.0
	call	_Z12getTimeStampv
	movq	32(%rsp), %rdi
	movsd	%xmm0, 16(%rsp)
	call	cudaFree@PLT
	movq	40(%rsp), %rdi
	call	cudaFree@PLT
	movq	48(%rsp), %rdi
	call	cudaFree@PLT
	movq	64(%rsp), %rsi
	movl	%ebx, %r8d
	movq	%r13, %rdx
	movq	56(%rsp), %rdi
	movl	%r12d, %ecx
	call	_Z8h_addmatPfS_S_ii
	movslq	%ebx, %r8
	movq	72(%rsp), %r9
	xorl	%esi, %esi
	movsd	16(%rsp), %xmm3
	movsd	24(%rsp), %xmm2
	xorl	%edi, %edi
	xorl	%edx, %edx
	salq	$2, %r8
.L42:
	movq	%rsi, %rax
	xorl	%ecx, %ecx
.L45:
	movss	0(%r13,%rax), %xmm0
	ucomiss	(%r9,%rax), %xmm0
	jp	.L51
	je	.L43
.L51:
	incl	%edx
.L43:
	incl	%ecx
	addq	$4, %rax
	cmpl	%ecx, %ebx
	jne	.L45
	incl	%edi
	addq	%r8, %rsi
	cmpl	%edi, %r12d
	jne	.L42
	testl	%edx, %edx
	jne	.L47
	movsd	8(%rsp), %xmm1
	movaps	%xmm3, %xmm0
	subsd	(%rsp), %xmm1
	movb	$4, %al
	subsd	%xmm2, %xmm3
	subsd	(%rsp), %xmm0
	movl	$2, %edi
	subsd	8(%rsp), %xmm2
	leaq	.LC8(%rip), %rsi
	call	__printf_chk@PLT
	jmp	.L48
.L47:
	leaq	.LC9(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L48:
	movq	56(%rsp), %rdi
	call	cudaFreeHost@PLT
	movq	64(%rsp), %rdi
	call	cudaFreeHost@PLT
	movq	72(%rsp), %rdi
	call	cudaFreeHost@PLT
	movq	%r13, %rdi
	call	free@PLT
	call	cudaDeviceReset@PLT
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L49
	call	__stack_chk_fail@PLT
.L49:
	addq	$120, %rsp
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2031:
	.size	main, .-main
	.section	.rodata.str1.1
.LC10:
	.string	"_Z8f_addmatPfS_S_ii"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2059:
	.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	.LC10(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z8f_addmatPfS_S_ii(%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
.LFE2059:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.section	.rodata.cst4,"aM",@progbits,4
	.align 4
.LC0:
	.long	1077936128
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC3:
	.long	0
	.long	1093567616
	.section	.rodata.cst4
	.align 4
.LC4:
	.long	1078523331
	.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 <sys/time.h>
#include <hip/hip_runtime.h>
#include <stdio.h>


#define HANDLE_ERROR( err ) ( HandleError( err, __FILE__, __LINE__ ) )

static void HandleError( hipError_t err, const char *file, int line )
{
    if (err != hipSuccess)
      {
        printf( "Error: %s in %s at line %d\n", hipGetErrorString( err ),
                file, line );
        exit( EXIT_FAILURE );
    }
}


// time stamp function in seconds
double getTimeStamp() {
	struct timeval tv ;
	gettimeofday( &tv, NULL ) ;
	return (double) tv.tv_usec/1000000 + tv.tv_sec ;
}

// host side matrix addition
void h_addmat(float *A, float *B, float *C, int nx, int ny){

	for (int i =0;i<nx;i++){
		for(int j=0;j<ny;j++){
			C[i*ny+j] = A[i*ny+j]+B[i*ny+j]; 
		}

	}
	return;
}

// device-side matrix addition
__global__ void f_addmat( float *A, float *B, float *C, int nx, int ny ){
	
	int ix = threadIdx.x + blockIdx.x*(blockDim.x) ;
	int iy = threadIdx.y + blockIdx.y*(blockDim.y) ;
	//printf("In add\n");
		
	if( (ix<nx/2) && (iy<ny/2) ){
		int idx = (iy*nx/2 + ix)*4;
		C[idx] = A[idx] + B[idx] ;
		C[idx+1] = A[idx+1] + B[idx+1] ;
		C[idx+2] = A[idx+2] + B[idx+2] ;
		C[idx+3] = A[idx+3] + B[idx+3] ;
		//printf("Thread %d %d\n",ix,iy);
	}
}

void initData(float *M, int x, int y, int flag ){ 
	
	if(flag)
	{	
		//printf("A\n");
		for (int i=0;i<x;i++){
		        for (int j=0;j<y;j++){
			    M[i*y+j] = (float)(i+j)/3.0;
		        }
		}
	}
	else
	{
		//printf("B\n");
		for (int i=0;i<x;i++){
			for (int j=0;j<y;j++){
				M[i*y+j] = (float)3.14*(i+j) ;
			}
		}
	
	}
}

int main( int argc, char *argv[] ) {
	
	
	if (argc!=3){
		printf("Error: Invalid number of arguments.\n");
		exit(1);
	}
	
	int nx = atoi( argv[1] ) ; // should check validity
	int ny = atoi( argv[2] ) ; // should check validity
	
	if(nx <=0 || ny <=0){
		printf("Error: Dimension lessThanOrEqualto Zero.\n");
                exit(1);
	}
	
	if(ny>nx)
	{
		nx=nx^ny;
		ny=nx^ny;
		nx=nx^ny;
	}

	int noElems = (nx)*(ny) ;
	int bytes = noElems * sizeof(float) ;

        // GPU and CPU memory Allocations
        
        float *d_A, *d_B, *d_C ;
        HANDLE_ERROR(hipMalloc( (float **) &d_A, bytes )) ;
        HANDLE_ERROR(hipMalloc( (float **) &d_B, bytes )) ;
        HANDLE_ERROR(hipMalloc( (float **) &d_C, bytes )) ;
	float *h_hC = (float *) malloc( bytes ) ; // host result

        float *h_Ap, *h_Bp, *h_dCp;
        HANDLE_ERROR(hipHostMalloc( (float **) &h_Ap, bytes , hipHostMallocDefault)) ;
        HANDLE_ERROR(hipHostMalloc( (float **) &h_Bp, bytes , hipHostMallocDefault)) ;
        HANDLE_ERROR(hipHostMalloc( (float **) &h_dCp, bytes , hipHostMallocDefault)) ;
	
	// init matrices with random data
	initData(h_Ap,nx,ny,1); 
	initData(h_Bp,nx,ny,0);

	double timeStampA = getTimeStamp() ;

	//transfer data to dev
	HANDLE_ERROR (hipMemcpy( d_A, h_Ap, bytes, hipMemcpyHostToDevice )) ;
	HANDLE_ERROR (hipMemcpy( d_B, h_Bp, bytes, hipMemcpyHostToDevice )) ;
		
	double timeStampB = getTimeStamp() ;
	
	// invoke Kernel
	dim3 block( 1024, 1) ; // you will want to configure this
	dim3 grid( (nx+block.x-1)/block.x, (ny+block.y-1)/block.y) ; 
	
	//printf("reached add %d %d %d %d %lu %d %d \n",(nx+block.x-1)/block.x, (ny+block.y-1)/block.y, nx, ny, sizeof(float), noElems, bytes);
	f_addmat<<<grid, block>>>( d_A, d_B, d_C, nx, ny ) ;
	hipError_t err = hipGetLastError();
	if (err != hipSuccess) 
		printf("Error: %s\n", hipGetErrorString(err));	

	HANDLE_ERROR(hipDeviceSynchronize()) ;
	
	double timeStampC = getTimeStamp() ;
	
	//copy data back
	HANDLE_ERROR(hipMemcpy(h_dCp, d_C, bytes, hipMemcpyDeviceToHost));
	
	double timeStampD = getTimeStamp() ;
	
	// free GPU resources
	hipFree( d_A ) ; hipFree( d_B ) ; hipFree( d_C ) ;
	
	// CPU Matrix add
	h_addmat( h_Ap, h_Bp, h_hC, nx, ny ) ;
	
	// Check results
	int flag = 0;
	for(int i=0;i<(nx);i++){
		for(int j=0;j<(ny);j++){
			if(h_hC[i*(ny)+j] != h_dCp[i*(ny)+j])	
				flag++;
		}
	}
	
	if (flag == 0){
		printf("%.6f %.6f %.6f %.6f\n",(timeStampD-timeStampA),(timeStampB-timeStampA),(timeStampC-timeStampB),(timeStampD-timeStampC));
	}
	else printf("host result is not the same as the device result!");
	
	//free other resourses
	hipHostFree(h_Ap); hipHostFree(h_Bp);	hipHostFree(h_dCp);
        free(h_hC);
	hipDeviceReset() ;
	
}


	.text
	.file	"1005678036.hip"
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z12getTimeStampv
.LCPI0_0:
	.quad	0x412e848000000000              # double 1.0E+6
	.text
	.globl	_Z12getTimeStampv
	.type	_Z12getTimeStampv,@function
_Z12getTimeStampv:                      # @_Z12getTimeStampv
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$16, %rsp
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -16
	movq	%rsp, %rbx
	movq	%rbx, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	cvtsi2sdq	8(%rbx), %xmm1
	divsd	.LCPI0_0(%rip), %xmm1
	cvtsi2sdq	(%rbx), %xmm0
	addsd	%xmm1, %xmm0
	addq	$16, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_Z12getTimeStampv, .Lfunc_end0-_Z12getTimeStampv
	.cfi_endproc
                                        # -- End function
	.globl	_Z8h_addmatPfS_S_ii             # -- Begin function _Z8h_addmatPfS_S_ii
	.type	_Z8h_addmatPfS_S_ii,@function
_Z8h_addmatPfS_S_ii:                    # @_Z8h_addmatPfS_S_ii
	.cfi_startproc
# %bb.0:
	testl	%ecx, %ecx
	jle	.LBB1_7
# %bb.1:                                # %.preheader.lr.ph
	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
	movl	%ecx, %eax
	movl	%r8d, %ecx
	xorl	%r9d, %r9d
	xorl	%r10d, %r10d
.LBB1_2:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_4 Depth 2
	testl	%r8d, %r8d
	jle	.LBB1_5
# %bb.3:                                # %.lr.ph
                                        #   in Loop: Header=BB1_2 Depth=1
	movl	%r9d, %r14d
	leaq	(%rdx,%r14,4), %r11
	leaq	(%rsi,%r14,4), %rbx
	leaq	(%rdi,%r14,4), %r14
	xorl	%r15d, %r15d
.LBB1_4:                                #   Parent Loop BB1_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movss	(%r14,%r15,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	addss	(%rbx,%r15,4), %xmm0
	movss	%xmm0, (%r11,%r15,4)
	incq	%r15
	cmpq	%r15, %rcx
	jne	.LBB1_4
.LBB1_5:                                # %._crit_edge
                                        #   in Loop: Header=BB1_2 Depth=1
	incq	%r10
	addl	%r8d, %r9d
	cmpq	%rax, %r10
	jne	.LBB1_2
# %bb.6:
	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
.LBB1_7:                                # %._crit_edge21
	retq
.Lfunc_end1:
	.size	_Z8h_addmatPfS_S_ii, .Lfunc_end1-_Z8h_addmatPfS_S_ii
	.cfi_endproc
                                        # -- End function
	.globl	_Z23__device_stub__f_addmatPfS_S_ii # -- Begin function _Z23__device_stub__f_addmatPfS_S_ii
	.type	_Z23__device_stub__f_addmatPfS_S_ii,@function
_Z23__device_stub__f_addmatPfS_S_ii:    # @_Z23__device_stub__f_addmatPfS_S_ii
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$128, %rsp
	.cfi_def_cfa_offset 176
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	32(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	24(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	4(%rsp), %rdx
	movl	%ecx, (%rdx)
	movq	%rsp, %rcx
	movl	%r8d, (%rcx)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	movq	%rcx, 32(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	16(%rsp), %r12
	leaq	8(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z8f_addmatPfS_S_ii, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$144, %rsp
	.cfi_adjust_cfa_offset -144
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end2:
	.size	_Z23__device_stub__f_addmatPfS_S_ii, .Lfunc_end2-_Z23__device_stub__f_addmatPfS_S_ii
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function _Z8initDataPfiii
.LCPI3_0:
	.long	0x40400000                      # float 3
.LCPI3_1:
	.long	0x4048f5c3                      # float 3.1400001
	.text
	.globl	_Z8initDataPfiii
	.type	_Z8initDataPfiii,@function
_Z8initDataPfiii:                       # @_Z8initDataPfiii
	.cfi_startproc
# %bb.0:
	testl	%ecx, %ecx
	je	.LBB3_7
# %bb.1:                                # %.preheader30
	testl	%esi, %esi
	jle	.LBB3_13
# %bb.2:                                # %.preheader29.lr.ph
	movl	%esi, %eax
	movl	%edx, %ecx
	xorl	%esi, %esi
	movss	.LCPI3_0(%rip), %xmm0           # xmm0 = mem[0],zero,zero,zero
	xorl	%r8d, %r8d
.LBB3_3:                                # %.preheader29
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB3_5 Depth 2
	testl	%edx, %edx
	jle	.LBB3_6
# %bb.4:                                # %.lr.ph
                                        #   in Loop: Header=BB3_3 Depth=1
	movl	%esi, %r9d
	leaq	(%rdi,%r9,4), %r9
	xorl	%r10d, %r10d
.LBB3_5:                                #   Parent Loop BB3_3 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	leal	(%r8,%r10), %r11d
	xorps	%xmm1, %xmm1
	cvtsi2ss	%r11d, %xmm1
	divss	%xmm0, %xmm1
	movss	%xmm1, (%r9,%r10,4)
	incq	%r10
	cmpq	%r10, %rcx
	jne	.LBB3_5
.LBB3_6:                                # %._crit_edge
                                        #   in Loop: Header=BB3_3 Depth=1
	incq	%r8
	addl	%edx, %esi
	cmpq	%rax, %r8
	jne	.LBB3_3
	jmp	.LBB3_13
.LBB3_7:                                # %.preheader28
	testl	%esi, %esi
	jle	.LBB3_13
# %bb.8:                                # %.preheader.lr.ph
	movl	%esi, %eax
	movl	%edx, %ecx
	xorl	%esi, %esi
	movss	.LCPI3_1(%rip), %xmm0           # xmm0 = mem[0],zero,zero,zero
	xorl	%r8d, %r8d
.LBB3_9:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB3_11 Depth 2
	testl	%edx, %edx
	jle	.LBB3_12
# %bb.10:                               # %.lr.ph35
                                        #   in Loop: Header=BB3_9 Depth=1
	movl	%esi, %r9d
	leaq	(%rdi,%r9,4), %r9
	xorl	%r10d, %r10d
.LBB3_11:                               #   Parent Loop BB3_9 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	leal	(%r8,%r10), %r11d
	xorps	%xmm1, %xmm1
	cvtsi2ss	%r11d, %xmm1
	mulss	%xmm0, %xmm1
	movss	%xmm1, (%r9,%r10,4)
	incq	%r10
	cmpq	%r10, %rcx
	jne	.LBB3_11
.LBB3_12:                               # %._crit_edge36
                                        #   in Loop: Header=BB3_9 Depth=1
	incq	%r8
	addl	%edx, %esi
	cmpq	%rax, %r8
	jne	.LBB3_9
.LBB3_13:                               # %.loopexit
	retq
.Lfunc_end3:
	.size	_Z8initDataPfiii, .Lfunc_end3-_Z8initDataPfiii
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function main
.LCPI4_0:
	.long	0x40400000                      # float 3
.LCPI4_1:
	.long	0x4048f5c3                      # float 3.1400001
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0
.LCPI4_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
	subq	$136, %rsp
	.cfi_def_cfa_offset 192
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	cmpl	$3, %edi
	jne	.LBB4_1
# %bb.3:
	movq	%rsi, %r14
	movq	8(%rsi), %rdi
	callq	atoi
	movl	%eax, %ebx
	movq	16(%r14), %rdi
	callq	atoi
	testl	%ebx, %ebx
	jle	.LBB4_5
# %bb.4:
	testl	%eax, %eax
	jle	.LBB4_5
# %bb.6:                                # %.preheader29.lr.ph.i
	cmpl	%ebx, %eax
	movl	%ebx, %r14d
	cmovbl	%eax, %r14d
	movl	%ebx, %r15d
	cmoval	%eax, %r15d
	imull	%eax, %ebx
	shll	$2, %ebx
	movslq	%ebx, %r12
	leaq	48(%rsp), %rdi
	movq	%r12, %rsi
	callq	hipMalloc
	movl	%eax, %edi
	movl	$107, %esi
	callq	_ZL11HandleError10hipError_tPKci
	leaq	40(%rsp), %rdi
	movq	%r12, %rsi
	callq	hipMalloc
	movl	%eax, %edi
	movl	$108, %esi
	callq	_ZL11HandleError10hipError_tPKci
	leaq	32(%rsp), %rdi
	movq	%r12, %rsi
	callq	hipMalloc
	movl	%eax, %edi
	movl	$109, %esi
	callq	_ZL11HandleError10hipError_tPKci
	movq	%r12, %rdi
	callq	malloc
	movq	%rax, %rbx
	leaq	24(%rsp), %r13
	xorl	%ebp, %ebp
	movq	%r13, %rdi
	movq	%r12, %rsi
	xorl	%edx, %edx
	callq	hipHostMalloc
	movl	%eax, %edi
	movl	$113, %esi
	callq	_ZL11HandleError10hipError_tPKci
	leaq	8(%rsp), %rdi
	movq	%r12, %rsi
	xorl	%edx, %edx
	callq	hipHostMalloc
	movl	%eax, %edi
	movl	$114, %esi
	callq	_ZL11HandleError10hipError_tPKci
	leaq	16(%rsp), %rdi
	movq	%r12, %rsi
	xorl	%edx, %edx
	callq	hipHostMalloc
	movl	%eax, %edi
	movl	$115, %esi
	callq	_ZL11HandleError10hipError_tPKci
	movq	(%r13), %rax
	movss	.LCPI4_0(%rip), %xmm0           # xmm0 = mem[0],zero,zero,zero
	xorl	%ecx, %ecx
.LBB4_7:                                # %.preheader29.i
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB4_8 Depth 2
	movl	%ebp, %edx
	leaq	(%rax,%rdx,4), %rdx
	xorl	%esi, %esi
.LBB4_8:                                #   Parent Loop BB4_7 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	leal	(%rcx,%rsi), %edi
	xorps	%xmm1, %xmm1
	cvtsi2ss	%edi, %xmm1
	divss	%xmm0, %xmm1
	movss	%xmm1, (%rdx,%rsi,4)
	incq	%rsi
	cmpq	%rsi, %r14
	jne	.LBB4_8
# %bb.9:                                # %._crit_edge.i
                                        #   in Loop: Header=BB4_7 Depth=1
	incq	%rcx
	addl	%r14d, %ebp
	cmpq	%r15, %rcx
	jne	.LBB4_7
# %bb.10:                               # %_Z8initDataPfiii.exit
	testl	%r15d, %r15d
	jle	.LBB4_16
# %bb.11:                               # %.preheader.lr.ph.i
	movq	8(%rsp), %rax
	xorl	%ecx, %ecx
	movss	.LCPI4_1(%rip), %xmm0           # xmm0 = mem[0],zero,zero,zero
	xorl	%edx, %edx
.LBB4_12:                               # %.preheader.i
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB4_14 Depth 2
	testl	%r14d, %r14d
	jle	.LBB4_15
# %bb.13:                               # %.lr.ph35.i
                                        #   in Loop: Header=BB4_12 Depth=1
	movl	%ecx, %esi
	leaq	(%rax,%rsi,4), %rsi
	xorl	%edi, %edi
.LBB4_14:                               #   Parent Loop BB4_12 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	leal	(%rdx,%rdi), %r8d
	xorps	%xmm1, %xmm1
	cvtsi2ss	%r8d, %xmm1
	mulss	%xmm0, %xmm1
	movss	%xmm1, (%rsi,%rdi,4)
	incq	%rdi
	cmpq	%rdi, %r14
	jne	.LBB4_14
.LBB4_15:                               # %._crit_edge36.i
                                        #   in Loop: Header=BB4_12 Depth=1
	incq	%rdx
	addl	%r14d, %ecx
	cmpq	%r15, %rdx
	jne	.LBB4_12
.LBB4_16:                               # %_Z8initDataPfiii.exit81
	leaq	120(%rsp), %r13
	movq	%r13, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	xorps	%xmm0, %xmm0
	cvtsi2sdq	8(%r13), %xmm0
	movsd	%xmm0, 112(%rsp)                # 8-byte Spill
	xorps	%xmm0, %xmm0
	cvtsi2sdq	(%r13), %xmm0
	movsd	%xmm0, 104(%rsp)                # 8-byte Spill
	movq	48(%rsp), %rdi
	movq	24(%rsp), %rsi
	movq	%r12, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movl	%eax, %edi
	movl	$124, %esi
	callq	_ZL11HandleError10hipError_tPKci
	movq	40(%rsp), %rdi
	movq	8(%rsp), %rsi
	movq	%r12, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movl	%eax, %edi
	movl	$125, %esi
	callq	_ZL11HandleError10hipError_tPKci
	leaq	120(%rsp), %r13
	movq	%r13, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	xorps	%xmm0, %xmm0
	cvtsi2sdq	8(%r13), %xmm0
	movsd	%xmm0, 96(%rsp)                 # 8-byte Spill
	xorps	%xmm0, %xmm0
	cvtsi2sdq	(%r13), %xmm0
	movsd	%xmm0, 88(%rsp)                 # 8-byte Spill
	leal	1023(%r15), %eax
	shrl	$10, %eax
	movq	%r14, %rdi
	shlq	$32, %rdi
	orq	%rax, %rdi
	movabsq	$4294968320, %rdx               # imm = 0x100000400
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB4_18
# %bb.17:
	movq	48(%rsp), %rdi
	movq	40(%rsp), %rsi
	movq	32(%rsp), %rdx
	movl	%r15d, %ecx
	movl	%r14d, %r8d
	callq	_Z23__device_stub__f_addmatPfS_S_ii
.LBB4_18:
	callq	hipGetLastError
	testl	%eax, %eax
	je	.LBB4_20
# %bb.19:
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.3, %edi
	movq	%rax, %rsi
	xorl	%eax, %eax
	callq	printf
.LBB4_20:
	callq	hipDeviceSynchronize
	movl	%eax, %edi
	movl	$139, %esi
	callq	_ZL11HandleError10hipError_tPKci
	xorl	%ebp, %ebp
	leaq	120(%rsp), %r13
	movq	%r13, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	xorps	%xmm0, %xmm0
	cvtsi2sdq	8(%r13), %xmm0
	movsd	%xmm0, 80(%rsp)                 # 8-byte Spill
	xorps	%xmm0, %xmm0
	cvtsi2sdq	(%r13), %xmm0
	movsd	%xmm0, 72(%rsp)                 # 8-byte Spill
	movq	16(%rsp), %rdi
	movq	32(%rsp), %rsi
	movq	%r12, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	movl	%eax, %edi
	movl	$144, %esi
	callq	_ZL11HandleError10hipError_tPKci
	leaq	120(%rsp), %r12
	movq	%r12, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	xorps	%xmm0, %xmm0
	cvtsi2sdq	8(%r12), %xmm0
	movsd	%xmm0, 64(%rsp)                 # 8-byte Spill
	xorps	%xmm0, %xmm0
	cvtsi2sdq	(%r12), %xmm0
	movsd	%xmm0, 56(%rsp)                 # 8-byte Spill
	movq	48(%rsp), %rdi
	callq	hipFree
	movq	40(%rsp), %rdi
	callq	hipFree
	movq	32(%rsp), %rdi
	callq	hipFree
	testl	%r15d, %r15d
	jle	.LBB4_33
# %bb.21:                               # %.preheader.lr.ph.i82
	movq	24(%rsp), %rax
	movq	8(%rsp), %rcx
	xorl	%edx, %edx
.LBB4_22:                               # %.preheader.i84
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB4_24 Depth 2
	testl	%r14d, %r14d
	jle	.LBB4_25
# %bb.23:                               # %.lr.ph.i86
                                        #   in Loop: Header=BB4_22 Depth=1
	movl	%ebp, %r8d
	leaq	(%rbx,%r8,4), %rsi
	leaq	(%rcx,%r8,4), %rdi
	leaq	(%rax,%r8,4), %r8
	xorl	%r9d, %r9d
.LBB4_24:                               #   Parent Loop BB4_22 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movss	(%r8,%r9,4), %xmm0              # xmm0 = mem[0],zero,zero,zero
	addss	(%rdi,%r9,4), %xmm0
	movss	%xmm0, (%rsi,%r9,4)
	incq	%r9
	cmpq	%r9, %r14
	jne	.LBB4_24
.LBB4_25:                               # %._crit_edge.i85
                                        #   in Loop: Header=BB4_22 Depth=1
	incq	%rdx
	addl	%r14d, %ebp
	cmpq	%r15, %rdx
	jne	.LBB4_22
# %bb.26:                               # %_Z8h_addmatPfS_S_ii.exit
	testl	%r15d, %r15d
	jle	.LBB4_33
# %bb.27:                               # %.preheader.lr.ph
	xorl	%eax, %eax
	movq	16(%rsp), %rcx
	xorl	%esi, %esi
	xorl	%edx, %edx
.LBB4_28:                               # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB4_30 Depth 2
	testl	%r14d, %r14d
	jle	.LBB4_31
# %bb.29:                               # %.lr.ph
                                        #   in Loop: Header=BB4_28 Depth=1
	movl	%eax, %r8d
	leaq	(%rcx,%r8,4), %rdi
	leaq	(%rbx,%r8,4), %r8
	xorl	%r9d, %r9d
.LBB4_30:                               #   Parent Loop BB4_28 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movss	(%rdi,%r9,4), %xmm0             # xmm0 = mem[0],zero,zero,zero
	cmpneqss	(%r8,%r9,4), %xmm0
	movd	%xmm0, %r10d
	subl	%r10d, %edx
	incq	%r9
	cmpq	%r9, %r14
	jne	.LBB4_30
.LBB4_31:                               # %._crit_edge
                                        #   in Loop: Header=BB4_28 Depth=1
	incq	%rsi
	addl	%r14d, %eax
	cmpq	%r15, %rsi
	jne	.LBB4_28
# %bb.32:                               # %._crit_edge96
	testl	%edx, %edx
	je	.LBB4_33
# %bb.34:
	movl	$.L.str.5, %edi
	xorl	%eax, %eax
	callq	printf
	jmp	.LBB4_35
.LBB4_33:                               # %._crit_edge96.thread
	movsd	.LCPI4_2(%rip), %xmm0           # xmm0 = mem[0],zero
	movsd	112(%rsp), %xmm4                # 8-byte Reload
                                        # xmm4 = mem[0],zero
	divsd	%xmm0, %xmm4
	addsd	104(%rsp), %xmm4                # 8-byte Folded Reload
	movsd	96(%rsp), %xmm1                 # 8-byte Reload
                                        # xmm1 = mem[0],zero
	divsd	%xmm0, %xmm1
	addsd	88(%rsp), %xmm1                 # 8-byte Folded Reload
	movsd	80(%rsp), %xmm2                 # 8-byte Reload
                                        # xmm2 = mem[0],zero
	divsd	%xmm0, %xmm2
	addsd	72(%rsp), %xmm2                 # 8-byte Folded Reload
	movsd	64(%rsp), %xmm3                 # 8-byte Reload
                                        # xmm3 = mem[0],zero
	divsd	%xmm0, %xmm3
	addsd	56(%rsp), %xmm3                 # 8-byte Folded Reload
	movapd	%xmm3, %xmm0
	subsd	%xmm4, %xmm0
	subsd	%xmm2, %xmm3
	subsd	%xmm1, %xmm2
	subsd	%xmm4, %xmm1
	movl	$.L.str.4, %edi
	movb	$4, %al
	callq	printf
.LBB4_35:
	movq	24(%rsp), %rdi
	callq	hipHostFree
	movq	8(%rsp), %rdi
	callq	hipHostFree
	movq	16(%rsp), %rdi
	callq	hipHostFree
	movq	%rbx, %rdi
	callq	free
	callq	hipDeviceReset
	xorl	%eax, %eax
	addq	$136, %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
.LBB4_1:
	.cfi_def_cfa_offset 192
	movl	$.Lstr.1, %edi
	jmp	.LBB4_2
.LBB4_5:
	movl	$.Lstr, %edi
.LBB4_2:
	callq	puts@PLT
	movl	$1, %edi
	callq	exit
.Lfunc_end4:
	.size	main, .Lfunc_end4-main
	.cfi_endproc
                                        # -- End function
	.type	_ZL11HandleError10hipError_tPKci,@function # -- Begin function _ZL11HandleError10hipError_tPKci
_ZL11HandleError10hipError_tPKci:       # @_ZL11HandleError10hipError_tPKci
	.cfi_startproc
# %bb.0:
	testl	%edi, %edi
	jne	.LBB5_2
# %bb.1:
	retq
.LBB5_2:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset %rbx, -16
	movl	%esi, %ebx
	callq	hipGetErrorString
	movl	$.L.str.6, %edi
	movl	$.L.str.2, %edx
	movq	%rax, %rsi
	movl	%ebx, %ecx
	xorl	%eax, %eax
	callq	printf
	movl	$1, %edi
	callq	exit
.Lfunc_end5:
	.size	_ZL11HandleError10hipError_tPKci, .Lfunc_end5-_ZL11HandleError10hipError_tPKci
	.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	$_Z8f_addmatPfS_S_ii, %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	_Z8f_addmatPfS_S_ii,@object     # @_Z8f_addmatPfS_S_ii
	.section	.rodata,"a",@progbits
	.globl	_Z8f_addmatPfS_S_ii
	.p2align	3, 0x0
_Z8f_addmatPfS_S_ii:
	.quad	_Z23__device_stub__f_addmatPfS_S_ii
	.size	_Z8f_addmatPfS_S_ii, 8

	.type	.L.str.2,@object                # @.str.2
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.2:
	.asciz	"/home/ubuntu/Datasets/stackv2/train-structured-repos-hip-sm89/Eavenx/assignment2/master/1005678036.hip"
	.size	.L.str.2, 103

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"Error: %s\n"
	.size	.L.str.3, 11

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"%.6f %.6f %.6f %.6f\n"
	.size	.L.str.4, 21

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"host result is not the same as the device result!"
	.size	.L.str.5, 50

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"Error: %s in %s at line %d\n"
	.size	.L.str.6, 28

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z8f_addmatPfS_S_ii"
	.size	.L__unnamed_1, 20

	.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	"Error: Dimension lessThanOrEqualto Zero."
	.size	.Lstr, 41

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"Error: Invalid number of arguments."
	.size	.Lstr.1, 36

	.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 _Z23__device_stub__f_addmatPfS_S_ii
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z8f_addmatPfS_S_ii
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z8f_addmatPfS_S_ii     ; -- Begin function _Z8f_addmatPfS_S_ii
	.globl	_Z8f_addmatPfS_S_ii
	.p2align	8
	.type	_Z8f_addmatPfS_S_ii,@function
_Z8f_addmatPfS_S_ii:                    ; @_Z8f_addmatPfS_S_ii
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x2c
	s_load_b64 s[4:5], s[0:1], 0x18
	v_and_b32_e32 v2, 0x3ff, v0
	v_bfe_u32 v3, v0, 10, 10
	s_waitcnt lgkmcnt(0)
	s_lshr_b32 s3, s2, 16
	s_and_b32 s2, s2, 0xffff
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	v_mad_u64_u32 v[0:1], null, s14, s2, v[2:3]
	v_mad_u64_u32 v[1:2], null, s15, s3, v[3:4]
	s_lshr_b32 s2, s4, 31
	s_lshr_b32 s3, s5, 31
	s_add_i32 s2, s4, s2
	s_add_i32 s3, s5, s3
	s_ashr_i32 s2, s2, 1
	s_ashr_i32 s3, s3, 1
	v_cmp_gt_i32_e32 vcc_lo, s2, v0
	v_cmp_gt_i32_e64 s2, s3, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_and_b32 s2, vcc_lo, s2
	s_and_saveexec_b32 s3, s2
	s_cbranch_execz .LBB0_2
; %bb.1:
	v_mul_lo_u32 v1, v1, s4
	s_clause 0x1
	s_load_b128 s[4:7], s[0:1], 0x0
	s_load_b64 s[0:1], s[0:1], 0x10
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshrrev_b32_e32 v2, 31, v1
	v_add_nc_u32_e32 v1, v1, v2
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshrrev_b32_e32 v1, 1, v1
	v_add_lshl_u32 v0, v1, v0, 2
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v1, 31, v0
	v_lshlrev_b64 v[0:1], 2, v[0:1]
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v2, vcc_lo, s4, v0
	v_add_co_ci_u32_e32 v3, vcc_lo, s5, v1, vcc_lo
	v_add_co_u32 v4, vcc_lo, s6, v0
	v_add_co_ci_u32_e32 v5, vcc_lo, s7, v1, vcc_lo
	v_add_co_u32 v0, vcc_lo, s0, v0
	global_load_b32 v6, v[2:3], off
	global_load_b32 v7, v[4:5], off
	v_add_co_ci_u32_e32 v1, vcc_lo, s1, v1, vcc_lo
	s_waitcnt vmcnt(0)
	v_add_f32_e32 v6, v6, v7
	global_store_b32 v[0:1], v6, off
	global_load_b32 v6, v[2:3], off offset:4
	global_load_b32 v7, v[4:5], off offset:4
	s_waitcnt vmcnt(0)
	v_add_f32_e32 v6, v6, v7
	global_store_b32 v[0:1], v6, off offset:4
	global_load_b32 v6, v[2:3], off offset:8
	global_load_b32 v7, v[4:5], off offset:8
	s_waitcnt vmcnt(0)
	v_add_f32_e32 v6, v6, v7
	global_store_b32 v[0:1], v6, off offset:8
	global_load_b32 v2, v[2:3], off offset:12
	global_load_b32 v3, v[4:5], off offset:12
	s_waitcnt vmcnt(0)
	v_add_f32_e32 v2, v2, v3
	global_store_b32 v[0:1], v2, off offset:12
.LBB0_2:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z8f_addmatPfS_S_ii
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 288
		.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	_Z8f_addmatPfS_S_ii, .Lfunc_end0-_Z8f_addmatPfS_S_ii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 380
; 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
	.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
      - .offset:         24
        .size:           4
        .value_kind:     by_value
      - .offset:         28
        .size:           4
        .value_kind:     by_value
      - .offset:         32
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         36
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         40
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         44
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         46
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         48
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         50
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         52
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         54
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         88
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         96
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 288
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z8f_addmatPfS_S_ii
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z8f_addmatPfS_S_ii.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     8
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
