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

#include <cuda_runtime.h>
//#include <helper_cuda.h>

// the number of thread
#define BLOCK_SIZE 32

double my_timer()
{
struct timeval time;
double _ret_val_0;
gettimeofday(( & time), 0);
_ret_val_0=(time.tv_sec+(time.tv_usec/1000000.0));
return _ret_val_0;
}

void mult(float *A, float *B, float *C, int size){
  	int i, j, k;
  	float sum = 0.0;

	for(i = 0; i < size; i++){
		for(j = 0; j < size; j++){
			for(k = 0; k < size; k++){
				sum += A[i * size + k] * B[k * size + j];
			}
		
			C[i * size + j] = sum;
			sum = 0.0;
		}
	}

}

__global__ void mult_gpu(float *A, float *B, float *C, int wA, int wB){
   // Block index
    int bx = blockIdx.x;
    int by = blockIdx.y;

    // Thread index
    int tx = threadIdx.x;
    int ty = threadIdx.y;
    // Index of the first sub-matrix of A processed by the block
    int aBegin = wA * BLOCK_SIZE * by;

    // Index of the last sub-matrix of A processed by the block
    int aEnd   = aBegin + wA - 1;

    // Step size used to iterate through the sub-matrices of A
    int aStep  = BLOCK_SIZE;

    // Index of the first sub-matrix of B processed by the block
    int bBegin = BLOCK_SIZE * bx;

    // Step size used to iterate through the sub-matrices of B
    int bStep  = BLOCK_SIZE * wB;

    // Csub is used to store the element of the block sub-matrix
    // that is computed by the thread
    //float Csub[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
    //float Csub[8] = {0, 0, 0, 0, 0, 0, 0, 0};
    //float Csub[4] = {0, 0, 0, 0};
    //float Csub[2] = {0, 0};
    float Csub = 0;

    // Loop over all the sub-matrices of A and B
    // required to compute the block sub-matrix

    for (int a = aBegin, b = bBegin;
         a <= aEnd;
         a += aStep, b += bStep)
    {

        // Declaration of the shared memory array As used to
        // store the sub-matrix of A
        __shared__ float As[BLOCK_SIZE][BLOCK_SIZE];

        // Declaration of the shared memory array Bs used to
        // store the sub-matrix of B
        __shared__ float Bs[BLOCK_SIZE][BLOCK_SIZE];

        // Load the matrices from device memory
        // to shared memory; each thread loads
        // one element of each matrix
        As[ty][tx] = A[a + wA * ty + tx];
        Bs[ty][tx] = B[b + wB * ty + tx];
/*
	As[ty + 8][tx] = A[a + wA * (ty + 8) + tx];
        Bs[ty + 8][tx] = B[b + wB * (ty + 8) + tx];

	As[ty + 16][tx] = A[a + wA * (ty + 16) + tx];
	Bs[ty + 16][tx] = B[b + wB * (ty + 16) + tx];

	As[ty + 24][tx] = A[a + wA * (ty + 24) + tx];
        Bs[ty + 24][tx] = B[b + wB * (ty + 24) + tx];

	As[ty + 32][tx] = A[a + wA * (ty + 32) + tx];
        Bs[ty + 32][tx] = B[b + wB * (ty + 32) + tx];

        As[ty + 40][tx] = A[a + wA * (ty + 40) + tx];
        Bs[ty + 40][tx] = B[b + wB * (ty + 40) + tx];

        As[ty + 48][tx] = A[a + wA * (ty + 48) + tx];
        Bs[ty + 48][tx] = B[b + wB * (ty + 48) + tx];

	As[ty + 56][tx] = A[a + wA * (ty + 56) + tx];
        Bs[ty + 56][tx] = B[b + wB * (ty + 56) + tx];

	As[ty + 64][tx] = A[a + wA * (ty + 64) + tx];
        Bs[ty + 64][tx] = B[b + wB * (ty + 64) + tx];

        As[ty + 72][tx] = A[a + wA * (ty + 72) + tx];
        Bs[ty + 72][tx] = B[b + wB * (ty + 72) + tx];

        As[ty + 80][tx] = A[a + wA * (ty + 80) + tx];
        Bs[ty + 80][tx] = B[b + wB * (ty + 80) + tx];

        As[ty + 88][tx] = A[a + wA * (ty + 88) + tx];
        Bs[ty + 88][tx] = B[b + wB * (ty + 88) + tx];

        As[ty + 96][tx] = A[a + wA * (ty + 96) + tx];
        Bs[ty + 96][tx] = B[b + wB * (ty + 96) + tx];

        As[ty + 104][tx] = A[a + wA * (ty + 104) + tx];
        Bs[ty + 104][tx] = B[b + wB * (ty + 104) + tx];

        As[ty + 112][tx] = A[a + wA * (ty + 112) + tx];
        Bs[ty + 112][tx] = B[b + wB * (ty + 112) + tx];

	As[ty + 120][tx] = A[a + wA * (ty + 120) + tx];
        Bs[ty + 120][tx] = B[b + wB * (ty + 120) + tx];
*/


	
        // Synchronize to make sure the matrices are loaded
        __syncthreads();

        // Multiply the two matrices together;
        // each thread computes one element
        // of the block sub-matrix
#pragma unroll

        for (int k = 0; k < BLOCK_SIZE; ++k)
        {
	    Csub += As[ty][k] * Bs[k][tx];
/*
            Csub[0] += As[ty][k] * Bs[k][tx];
	    Csub[1] += As[ty + 8][k] * Bs[k][tx];

	    Csub[2] += As[ty + 16][k] * Bs[k][tx];
            Csub[3] += As[ty + 24][k] * Bs[k][tx];

	    Csub[4] += As[ty + 32][k] * Bs[k][tx];
            Csub[5] += As[ty + 40][k] * Bs[k][tx];

            Csub[6] += As[ty + 48][k] * Bs[k][tx];
            Csub[7] += As[ty + 56][k] * Bs[k][tx];

	    Csub[8] += As[ty + 64][k] * Bs[k][tx];
            Csub[9] += As[ty + 72][k] * Bs[k][tx];

            Csub[10] += As[ty + 80][k] * Bs[k][tx];
            Csub[11] += As[ty + 88][k] * Bs[k][tx];

            Csub[12] += As[ty + 96][k] * Bs[k][tx];
            Csub[13] += As[ty + 104][k] * Bs[k][tx];

            Csub[14] += As[ty + 112][k] * Bs[k][tx];
            Csub[15] += As[ty + 120][k] * Bs[k][tx];
*/

        }

        // Synchronize to make sure that the preceding
        // computation is done before loading two new
        // sub-matrices of A and B in the next iteration
        __syncthreads();
    }

    // Write the block sub-matrix to device memory;
    // each thread writes one element
    int c = wB * BLOCK_SIZE * by + BLOCK_SIZE * bx;
    C[c + wB * ty + tx] = Csub;

/*
    C[c + wB * ty + tx] = Csub[0];
    C[c + wB * (ty + 8) + tx] = Csub[1];

    C[c + wB * (ty + 16) + tx] = Csub[2];
    C[c + wB * (ty + 24) + tx] = Csub[3];

    C[c + wB * (ty + 32) + tx] = Csub[4];
    C[c + wB * (ty + 40) + tx] = Csub[5];

    C[c + wB * (ty + 48) + tx] = Csub[6];
    C[c + wB * (ty + 56) + tx] = Csub[7];

    C[c + wB * (ty + 64) + tx] = Csub[8];
    C[c + wB * (ty + 72) + tx] = Csub[9];

    C[c + wB * (ty + 80) + tx] = Csub[10];
    C[c + wB * (ty + 88) + tx] = Csub[11];

    C[c + wB * (ty + 96) + tx] = Csub[12];
    C[c + wB * (ty + 104) + tx] = Csub[13];

    C[c + wB * (ty + 112) + tx] = Csub[14];
    C[c + wB * (ty + 120) + tx] = Csub[15];
*/


}

int main(int argc, char *argv[]){
  	int i;
  	float *A, *B, *C, *D;
  	float *A_dev, *B_dev, *C_dev;
  	double start_timer, end_timer;

	int MROW = atoi(argv[1]);
	int MSIZE = MROW * MROW;

    	A = (float*)malloc(sizeof(float)*MSIZE);
    	cudaMalloc(&A_dev, MSIZE*sizeof(float));
    	B = (float*)malloc(sizeof(float)*MSIZE);
    	cudaMalloc(&B_dev, MSIZE*sizeof(float));
    	C = (float*)malloc(sizeof(float)*MSIZE);
    	cudaMalloc(&C_dev, MSIZE*sizeof(float));
   	D = (float*)malloc(sizeof(float)*MSIZE);

	srand(time(NULL)); 
  	// Init matrix
    	for(i = 0; i < MSIZE; i++){
      		//A[i] = (i%MROW)+1;
		A[i] = ((double) rand() / (RAND_MAX)) + 1;
      		//B[i] = (i%MCOL)+1;
		B[i] = ((double) rand() / (RAND_MAX)) + 1;
      		C[i] = 0;
      		D[i] = 0;
    	}
 	
	//transfer data to device
    	cudaMemcpy(A_dev, A, MSIZE*sizeof(float), cudaMemcpyHostToDevice);
    	cudaMemcpy(B_dev, B, MSIZE*sizeof(float), cudaMemcpyHostToDevice);
  	
  	cudaDeviceSynchronize();
  
	dim3 threads(BLOCK_SIZE, BLOCK_SIZE/1);
  	dim3 grid(MROW / BLOCK_SIZE, MROW / BLOCK_SIZE);
  	printf("block:%d, thread:%d\n", (MROW / BLOCK_SIZE) * (MROW / BLOCK_SIZE), BLOCK_SIZE * BLOCK_SIZE);
  	start_timer = my_timer();
    	mult_gpu<<<grid, threads, 0>>>(A_dev, B_dev, C_dev, MROW, MROW);
  	cudaDeviceSynchronize();
  	end_timer = my_timer();
  	printf("The GPU Elapsed Time:%lf Sec.\n", end_timer - start_timer);
  
  	//transfer data back to host
    	cudaMemcpy(C, C_dev, MSIZE*sizeof(int), cudaMemcpyDeviceToHost);
  	cudaDeviceSynchronize();
#if 1
  	start_timer = my_timer();
    	mult(A, B, D, MROW);
  	end_timer = my_timer();
  	printf("The CPU Elapsed Time:%lf Sec.\n", end_timer - start_timer);

  	//Verification
    FILE *fcpu = fopen("cpu_result.txt", "w");
    FILE *fgpu = fopen("gpu_result.txt", "w");
  	printf("Verifying\n");
    	for(i = 0; i < MSIZE; i++) {
      		if(abs(C[i] - D[i]) > 1e-2){
        		printf("Error:%f, %f\n", C[i], D[i]);
			//break;
      		}
            fprintf(fcpu, "%f\n",D[i]);
            fprintf(fgpu, "%f\n",C[i]);
        }
    fclose(fcpu);
    fclose(fgpu);
#endif

    	free(A);
    	cudaFree(A_dev);
    	free(B);
    	cudaFree(B_dev);
    	free(C);
    	cudaFree(C_dev);
    	free(D);
  return 0;
}

	.file	"tmpxft_002c4da3_00000000-6_cuda_mult.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2032:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2032:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z8my_timerv
	.type	_Z8my_timerv, @function
_Z8my_timerv:
.LFB2027:
	.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	.LC0(%rip), %xmm0
	addsd	%xmm1, %xmm0
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	je	.L3
	call	__stack_chk_fail@PLT
.L3:
	addq	$40, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2027:
	.size	_Z8my_timerv, .-_Z8my_timerv
	.globl	_Z4multPfS_S_i
	.type	_Z4multPfS_S_i, @function
_Z4multPfS_S_i:
.LFB2028:
	.cfi_startproc
	endbr64
	movq	%rdi, %r10
	xorl	%r9d, %r9d
	movslq	%ecx, %rdi
	movq	%rsi, %r11
	salq	$2, %rdi
	xorl	%esi, %esi
	cmpl	%ecx, %r9d
	jl	.L15
	ret
.L15:
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
.L11:
	xorl	%eax, %eax
	leaq	(%r10,%rsi), %rbp
	leaq	(%rdx,%rsi), %r12
.L10:
	leaq	(%r11,%rax,4), %rbx
	xorl	%r8d, %r8d
	xorps	%xmm0, %xmm0
.L8:
	movss	0(%rbp,%r8,4), %xmm1
	mulss	(%rbx), %xmm1
	incq	%r8
	addq	%rdi, %rbx
	addss	%xmm1, %xmm0
	cmpl	%r8d, %ecx
	jg	.L8
	movss	%xmm0, (%r12,%rax,4)
	incq	%rax
	cmpl	%eax, %ecx
	jg	.L10
	incl	%r9d
	addq	%rdi, %rsi
	cmpl	%ecx, %r9d
	jl	.L11
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2028:
	.size	_Z4multPfS_S_i, .-_Z4multPfS_S_i
	.globl	_Z33__device_stub__Z8mult_gpuPfS_S_iiPfS_S_ii
	.type	_Z33__device_stub__Z8mult_gpuPfS_S_iiPfS_S_ii, @function
_Z33__device_stub__Z8mult_gpuPfS_S_iiPfS_S_ii:
.LFB2054:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdi, 24(%rsp)
	leaq	48(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	60(%rsp), %rsi
	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	.L16
	pushq	40(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z8mult_gpuPfS_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
.L16:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L18
	call	__stack_chk_fail@PLT
.L18:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2054:
	.size	_Z33__device_stub__Z8mult_gpuPfS_S_iiPfS_S_ii, .-_Z33__device_stub__Z8mult_gpuPfS_S_iiPfS_S_ii
	.globl	_Z8mult_gpuPfS_S_ii
	.type	_Z8mult_gpuPfS_S_ii, @function
_Z8mult_gpuPfS_S_ii:
.LFB2055:
	.cfi_startproc
	endbr64
	jmp	_Z33__device_stub__Z8mult_gpuPfS_S_iiPfS_S_ii
	.cfi_endproc
.LFE2055:
	.size	_Z8mult_gpuPfS_S_ii, .-_Z8mult_gpuPfS_S_ii
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC4:
	.string	"block:%d, thread:%d\n"
.LC5:
	.string	"The GPU Elapsed Time:%lf Sec.\n"
.LC6:
	.string	"The CPU Elapsed Time:%lf Sec.\n"
.LC7:
	.string	"w"
.LC8:
	.string	"cpu_result.txt"
.LC9:
	.string	"gpu_result.txt"
.LC10:
	.string	"Verifying\n"
.LC13:
	.string	"Error:%f, %f\n"
.LC14:
	.string	"%f\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.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
	xorl	%r12d, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$104, %rsp
	.cfi_def_cfa_offset 160
	movq	8(%rsi), %rdi
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	xorl	%eax, %eax
	call	atoi@PLT
	movl	%eax, %r15d
	movl	%eax, %r14d
	imull	%eax, %r15d
	movslq	%r15d, %rax
	salq	$2, %rax
	movq	%rax, %rdi
	movq	%rax, 8(%rsp)
	call	malloc@PLT
	movq	8(%rsp), %rsi
	leaq	40(%rsp), %rdi
	movq	%rax, %r13
	call	cudaMalloc@PLT
	movq	8(%rsp), %rdi
	call	malloc@PLT
	movq	8(%rsp), %rsi
	leaq	48(%rsp), %rdi
	movq	%rax, 16(%rsp)
	call	cudaMalloc@PLT
	movq	8(%rsp), %rdi
	call	malloc@PLT
	movq	8(%rsp), %rsi
	leaq	56(%rsp), %rdi
	movq	%rax, %rbx
	call	cudaMalloc@PLT
	movq	8(%rsp), %rdi
	call	malloc@PLT
	xorl	%edi, %edi
	movq	%rax, %rbp
	call	time@PLT
	movl	%eax, %edi
	call	srand@PLT
.L22:
	cmpl	%r12d, %r15d
	jle	.L32
	call	rand@PLT
	cvtsi2sdl	%eax, %xmm0
	divsd	.LC2(%rip), %xmm0
	addsd	.LC3(%rip), %xmm0
	cvtsd2ss	%xmm0, %xmm0
	movss	%xmm0, 0(%r13,%r12,4)
	call	rand@PLT
	movl	$0x00000000, (%rbx,%r12,4)
	movl	$0x00000000, 0(%rbp,%r12,4)
	cvtsi2sdl	%eax, %xmm0
	divsd	.LC2(%rip), %xmm0
	addsd	.LC3(%rip), %xmm0
	movq	16(%rsp), %rax
	cvtsd2ss	%xmm0, %xmm0
	movss	%xmm0, (%rax,%r12,4)
	incq	%r12
	jmp	.L22
.L32:
	movq	8(%rsp), %rdx
	movq	40(%rsp), %rdi
	movl	$1, %ecx
	movq	%r13, %rsi
	call	cudaMemcpy@PLT
	movq	8(%rsp), %rdx
	movq	16(%rsp), %rsi
	movl	$1, %ecx
	movq	48(%rsp), %rdi
	call	cudaMemcpy@PLT
	call	cudaDeviceSynchronize@PLT
	movl	$32, %ecx
	movabsq	$137438953504, %rax
	leaq	.LC4(%rip), %rsi
	movq	%rax, 64(%rsp)
	movl	%r14d, %eax
	movl	$2, %edi
	cltd
	movl	$1, 72(%rsp)
	idivl	%ecx
	movl	$1, 84(%rsp)
	movl	$1024, %ecx
	movl	%eax, 76(%rsp)
	movl	%eax, 80(%rsp)
	imull	%eax, %eax
	movl	%eax, %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	call	_Z8my_timerv
	movl	72(%rsp), %ecx
	movl	84(%rsp), %esi
	xorl	%r9d, %r9d
	movq	64(%rsp), %rdx
	movq	76(%rsp), %rdi
	xorl	%r8d, %r8d
	movsd	%xmm0, 24(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L24
	movq	56(%rsp), %rdx
	movq	48(%rsp), %rsi
	movl	%r14d, %r8d
	movl	%r14d, %ecx
	movq	40(%rsp), %rdi
	call	_Z33__device_stub__Z8mult_gpuPfS_S_iiPfS_S_ii
.L24:
	call	cudaDeviceSynchronize@PLT
	call	_Z8my_timerv
	subsd	24(%rsp), %xmm0
	leaq	.LC5(%rip), %rsi
	movb	$1, %al
	movl	$2, %edi
	call	__printf_chk@PLT
	movq	8(%rsp), %rdx
	movq	56(%rsp), %rsi
	movq	%rbx, %rdi
	movl	$2, %ecx
	call	cudaMemcpy@PLT
	call	cudaDeviceSynchronize@PLT
	call	_Z8my_timerv
	movq	16(%rsp), %rsi
	movl	%r14d, %ecx
	movq	%rbp, %rdx
	movq	%r13, %rdi
	movsd	%xmm0, 8(%rsp)
	leaq	.LC7(%rip), %r14
	call	_Z4multPfS_S_i
	call	_Z8my_timerv
	subsd	8(%rsp), %xmm0
	leaq	.LC6(%rip), %rsi
	movb	$1, %al
	movl	$2, %edi
	call	__printf_chk@PLT
	movq	%r14, %rsi
	leaq	.LC8(%rip), %rdi
	call	fopen@PLT
	movq	%r14, %rsi
	leaq	.LC9(%rip), %rdi
	xorl	%r14d, %r14d
	movq	%rax, %r12
	call	fopen@PLT
	leaq	.LC10(%rip), %rsi
	movl	$2, %edi
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L25:
	cmpl	%r14d, %r15d
	jle	.L33
	movss	(%rbx,%r14,4), %xmm0
	movss	0(%rbp,%r14,4), %xmm3
	movaps	%xmm0, %xmm2
	cvtss2sd	%xmm3, %xmm1
	subss	%xmm3, %xmm2
	andps	.LC11(%rip), %xmm2
	cvtss2sd	%xmm2, %xmm2
	comisd	.LC12(%rip), %xmm2
	jbe	.L26
	leaq	.LC13(%rip), %rsi
	movl	$2, %edi
	movb	$2, %al
	movsd	%xmm1, 24(%rsp)
	cvtss2sd	%xmm0, %xmm0
	call	__printf_chk@PLT
	movsd	24(%rsp), %xmm1
.L26:
	movaps	%xmm1, %xmm0
	leaq	.LC14(%rip), %rdx
	movq	%r12, %rdi
	movb	$1, %al
	movl	$2, %esi
	call	__fprintf_chk@PLT
	movq	8(%rsp), %rdi
	leaq	.LC14(%rip), %rdx
	movb	$1, %al
	movl	$2, %esi
	cvtss2sd	(%rbx,%r14,4), %xmm0
	incq	%r14
	call	__fprintf_chk@PLT
	jmp	.L25
.L33:
	movq	%r12, %rdi
	call	fclose@PLT
	movq	8(%rsp), %rdi
	call	fclose@PLT
	movq	%r13, %rdi
	call	free@PLT
	movq	40(%rsp), %rdi
	call	cudaFree@PLT
	movq	16(%rsp), %rdi
	call	free@PLT
	movq	48(%rsp), %rdi
	call	cudaFree@PLT
	movq	%rbx, %rdi
	call	free@PLT
	movq	56(%rsp), %rdi
	call	cudaFree@PLT
	movq	%rbp, %rdi
	call	free@PLT
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	je	.L29
	call	__stack_chk_fail@PLT
.L29:
	addq	$104, %rsp
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	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	main, .-main
	.section	.rodata.str1.1
.LC15:
	.string	"_Z8mult_gpuPfS_S_ii"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2057:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	pushq	$0
	.cfi_def_cfa_offset 24
	xorl	%r9d, %r9d
	orl	$-1, %r8d
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC15(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z8mult_gpuPfS_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
.LFE2057:
	.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.cst8,"aM",@progbits,8
	.align 8
.LC0:
	.long	0
	.long	1093567616
	.align 8
.LC2:
	.long	-4194304
	.long	1105199103
	.align 8
.LC3:
	.long	0
	.long	1072693248
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC11:
	.long	2147483647
	.long	0
	.long	0
	.long	0
	.section	.rodata.cst8
	.align 8
.LC12:
	.long	1202590843
	.long	1065646817
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

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

#include <hip/hip_runtime.h>
//#include <helper_cuda.h>

// the number of thread
#define BLOCK_SIZE 32

double my_timer()
{
struct timeval time;
double _ret_val_0;
gettimeofday(( & time), 0);
_ret_val_0=(time.tv_sec+(time.tv_usec/1000000.0));
return _ret_val_0;
}

void mult(float *A, float *B, float *C, int size){
  	int i, j, k;
  	float sum = 0.0;

	for(i = 0; i < size; i++){
		for(j = 0; j < size; j++){
			for(k = 0; k < size; k++){
				sum += A[i * size + k] * B[k * size + j];
			}
		
			C[i * size + j] = sum;
			sum = 0.0;
		}
	}

}

__global__ void mult_gpu(float *A, float *B, float *C, int wA, int wB){
   // Block index
    int bx = blockIdx.x;
    int by = blockIdx.y;

    // Thread index
    int tx = threadIdx.x;
    int ty = threadIdx.y;
    // Index of the first sub-matrix of A processed by the block
    int aBegin = wA * BLOCK_SIZE * by;

    // Index of the last sub-matrix of A processed by the block
    int aEnd   = aBegin + wA - 1;

    // Step size used to iterate through the sub-matrices of A
    int aStep  = BLOCK_SIZE;

    // Index of the first sub-matrix of B processed by the block
    int bBegin = BLOCK_SIZE * bx;

    // Step size used to iterate through the sub-matrices of B
    int bStep  = BLOCK_SIZE * wB;

    // Csub is used to store the element of the block sub-matrix
    // that is computed by the thread
    //float Csub[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
    //float Csub[8] = {0, 0, 0, 0, 0, 0, 0, 0};
    //float Csub[4] = {0, 0, 0, 0};
    //float Csub[2] = {0, 0};
    float Csub = 0;

    // Loop over all the sub-matrices of A and B
    // required to compute the block sub-matrix

    for (int a = aBegin, b = bBegin;
         a <= aEnd;
         a += aStep, b += bStep)
    {

        // Declaration of the shared memory array As used to
        // store the sub-matrix of A
        __shared__ float As[BLOCK_SIZE][BLOCK_SIZE];

        // Declaration of the shared memory array Bs used to
        // store the sub-matrix of B
        __shared__ float Bs[BLOCK_SIZE][BLOCK_SIZE];

        // Load the matrices from device memory
        // to shared memory; each thread loads
        // one element of each matrix
        As[ty][tx] = A[a + wA * ty + tx];
        Bs[ty][tx] = B[b + wB * ty + tx];
/*
	As[ty + 8][tx] = A[a + wA * (ty + 8) + tx];
        Bs[ty + 8][tx] = B[b + wB * (ty + 8) + tx];

	As[ty + 16][tx] = A[a + wA * (ty + 16) + tx];
	Bs[ty + 16][tx] = B[b + wB * (ty + 16) + tx];

	As[ty + 24][tx] = A[a + wA * (ty + 24) + tx];
        Bs[ty + 24][tx] = B[b + wB * (ty + 24) + tx];

	As[ty + 32][tx] = A[a + wA * (ty + 32) + tx];
        Bs[ty + 32][tx] = B[b + wB * (ty + 32) + tx];

        As[ty + 40][tx] = A[a + wA * (ty + 40) + tx];
        Bs[ty + 40][tx] = B[b + wB * (ty + 40) + tx];

        As[ty + 48][tx] = A[a + wA * (ty + 48) + tx];
        Bs[ty + 48][tx] = B[b + wB * (ty + 48) + tx];

	As[ty + 56][tx] = A[a + wA * (ty + 56) + tx];
        Bs[ty + 56][tx] = B[b + wB * (ty + 56) + tx];

	As[ty + 64][tx] = A[a + wA * (ty + 64) + tx];
        Bs[ty + 64][tx] = B[b + wB * (ty + 64) + tx];

        As[ty + 72][tx] = A[a + wA * (ty + 72) + tx];
        Bs[ty + 72][tx] = B[b + wB * (ty + 72) + tx];

        As[ty + 80][tx] = A[a + wA * (ty + 80) + tx];
        Bs[ty + 80][tx] = B[b + wB * (ty + 80) + tx];

        As[ty + 88][tx] = A[a + wA * (ty + 88) + tx];
        Bs[ty + 88][tx] = B[b + wB * (ty + 88) + tx];

        As[ty + 96][tx] = A[a + wA * (ty + 96) + tx];
        Bs[ty + 96][tx] = B[b + wB * (ty + 96) + tx];

        As[ty + 104][tx] = A[a + wA * (ty + 104) + tx];
        Bs[ty + 104][tx] = B[b + wB * (ty + 104) + tx];

        As[ty + 112][tx] = A[a + wA * (ty + 112) + tx];
        Bs[ty + 112][tx] = B[b + wB * (ty + 112) + tx];

	As[ty + 120][tx] = A[a + wA * (ty + 120) + tx];
        Bs[ty + 120][tx] = B[b + wB * (ty + 120) + tx];
*/


	
        // Synchronize to make sure the matrices are loaded
        __syncthreads();

        // Multiply the two matrices together;
        // each thread computes one element
        // of the block sub-matrix
#pragma unroll

        for (int k = 0; k < BLOCK_SIZE; ++k)
        {
	    Csub += As[ty][k] * Bs[k][tx];
/*
            Csub[0] += As[ty][k] * Bs[k][tx];
	    Csub[1] += As[ty + 8][k] * Bs[k][tx];

	    Csub[2] += As[ty + 16][k] * Bs[k][tx];
            Csub[3] += As[ty + 24][k] * Bs[k][tx];

	    Csub[4] += As[ty + 32][k] * Bs[k][tx];
            Csub[5] += As[ty + 40][k] * Bs[k][tx];

            Csub[6] += As[ty + 48][k] * Bs[k][tx];
            Csub[7] += As[ty + 56][k] * Bs[k][tx];

	    Csub[8] += As[ty + 64][k] * Bs[k][tx];
            Csub[9] += As[ty + 72][k] * Bs[k][tx];

            Csub[10] += As[ty + 80][k] * Bs[k][tx];
            Csub[11] += As[ty + 88][k] * Bs[k][tx];

            Csub[12] += As[ty + 96][k] * Bs[k][tx];
            Csub[13] += As[ty + 104][k] * Bs[k][tx];

            Csub[14] += As[ty + 112][k] * Bs[k][tx];
            Csub[15] += As[ty + 120][k] * Bs[k][tx];
*/

        }

        // Synchronize to make sure that the preceding
        // computation is done before loading two new
        // sub-matrices of A and B in the next iteration
        __syncthreads();
    }

    // Write the block sub-matrix to device memory;
    // each thread writes one element
    int c = wB * BLOCK_SIZE * by + BLOCK_SIZE * bx;
    C[c + wB * ty + tx] = Csub;

/*
    C[c + wB * ty + tx] = Csub[0];
    C[c + wB * (ty + 8) + tx] = Csub[1];

    C[c + wB * (ty + 16) + tx] = Csub[2];
    C[c + wB * (ty + 24) + tx] = Csub[3];

    C[c + wB * (ty + 32) + tx] = Csub[4];
    C[c + wB * (ty + 40) + tx] = Csub[5];

    C[c + wB * (ty + 48) + tx] = Csub[6];
    C[c + wB * (ty + 56) + tx] = Csub[7];

    C[c + wB * (ty + 64) + tx] = Csub[8];
    C[c + wB * (ty + 72) + tx] = Csub[9];

    C[c + wB * (ty + 80) + tx] = Csub[10];
    C[c + wB * (ty + 88) + tx] = Csub[11];

    C[c + wB * (ty + 96) + tx] = Csub[12];
    C[c + wB * (ty + 104) + tx] = Csub[13];

    C[c + wB * (ty + 112) + tx] = Csub[14];
    C[c + wB * (ty + 120) + tx] = Csub[15];
*/


}

int main(int argc, char *argv[]){
  	int i;
  	float *A, *B, *C, *D;
  	float *A_dev, *B_dev, *C_dev;
  	double start_timer, end_timer;

	int MROW = atoi(argv[1]);
	int MSIZE = MROW * MROW;

    	A = (float*)malloc(sizeof(float)*MSIZE);
    	hipMalloc(&A_dev, MSIZE*sizeof(float));
    	B = (float*)malloc(sizeof(float)*MSIZE);
    	hipMalloc(&B_dev, MSIZE*sizeof(float));
    	C = (float*)malloc(sizeof(float)*MSIZE);
    	hipMalloc(&C_dev, MSIZE*sizeof(float));
   	D = (float*)malloc(sizeof(float)*MSIZE);

	srand(time(NULL)); 
  	// Init matrix
    	for(i = 0; i < MSIZE; i++){
      		//A[i] = (i%MROW)+1;
		A[i] = ((double) rand() / (RAND_MAX)) + 1;
      		//B[i] = (i%MCOL)+1;
		B[i] = ((double) rand() / (RAND_MAX)) + 1;
      		C[i] = 0;
      		D[i] = 0;
    	}
 	
	//transfer data to device
    	hipMemcpy(A_dev, A, MSIZE*sizeof(float), hipMemcpyHostToDevice);
    	hipMemcpy(B_dev, B, MSIZE*sizeof(float), hipMemcpyHostToDevice);
  	
  	hipDeviceSynchronize();
  
	dim3 threads(BLOCK_SIZE, BLOCK_SIZE/1);
  	dim3 grid(MROW / BLOCK_SIZE, MROW / BLOCK_SIZE);
  	printf("block:%d, thread:%d\n", (MROW / BLOCK_SIZE) * (MROW / BLOCK_SIZE), BLOCK_SIZE * BLOCK_SIZE);
  	start_timer = my_timer();
    	mult_gpu<<<grid, threads, 0>>>(A_dev, B_dev, C_dev, MROW, MROW);
  	hipDeviceSynchronize();
  	end_timer = my_timer();
  	printf("The GPU Elapsed Time:%lf Sec.\n", end_timer - start_timer);
  
  	//transfer data back to host
    	hipMemcpy(C, C_dev, MSIZE*sizeof(int), hipMemcpyDeviceToHost);
  	hipDeviceSynchronize();
#if 1
  	start_timer = my_timer();
    	mult(A, B, D, MROW);
  	end_timer = my_timer();
  	printf("The CPU Elapsed Time:%lf Sec.\n", end_timer - start_timer);

  	//Verification
    FILE *fcpu = fopen("cpu_result.txt", "w");
    FILE *fgpu = fopen("gpu_result.txt", "w");
  	printf("Verifying\n");
    	for(i = 0; i < MSIZE; i++) {
      		if(abs(C[i] - D[i]) > 1e-2){
        		printf("Error:%f, %f\n", C[i], D[i]);
			//break;
      		}
            fprintf(fcpu, "%f\n",D[i]);
            fprintf(fgpu, "%f\n",C[i]);
        }
    fclose(fcpu);
    fclose(fgpu);
#endif

    	free(A);
    	hipFree(A_dev);
    	free(B);
    	hipFree(B_dev);
    	free(C);
    	hipFree(C_dev);
    	free(D);
  return 0;
}

	.text
	.file	"cuda_mult.hip"
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z8my_timerv
.LCPI0_0:
	.quad	0x412e848000000000              # double 1.0E+6
	.text
	.globl	_Z8my_timerv
	.type	_Z8my_timerv,@function
_Z8my_timerv:                           # @_Z8my_timerv
	.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	(%rbx), %xmm1
	cvtsi2sdq	8(%rbx), %xmm0
	divsd	.LCPI0_0(%rip), %xmm0
	addsd	%xmm1, %xmm0
	addq	$16, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_Z8my_timerv, .Lfunc_end0-_Z8my_timerv
	.cfi_endproc
                                        # -- End function
	.globl	_Z4multPfS_S_i                  # -- Begin function _Z4multPfS_S_i
	.type	_Z4multPfS_S_i,@function
_Z4multPfS_S_i:                         # @_Z4multPfS_S_i
	.cfi_startproc
# %bb.0:
	testl	%ecx, %ecx
	jle	.LBB1_8
# %bb.1:                                # %.preheader26.lr.ph
	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
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movl	%ecx, %eax
	leaq	(,%rax,4), %r8
	xorl	%r9d, %r9d
	xorl	%r10d, %r10d
.LBB1_2:                                # %.preheader.lr.ph
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_3 Depth 2
                                        #       Child Loop BB1_4 Depth 3
	movl	%r9d, %r11d
	leaq	(%rdi,%r11,4), %r11
	movq	%r10, %rbx
	imulq	%rax, %rbx
	leaq	(%rdx,%rbx,4), %rbx
	movq	%rsi, %r14
	xorl	%r15d, %r15d
.LBB1_3:                                # %.preheader
                                        #   Parent Loop BB1_2 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB1_4 Depth 3
	xorps	%xmm0, %xmm0
	movq	%r14, %r12
	xorl	%r13d, %r13d
.LBB1_4:                                #   Parent Loop BB1_2 Depth=1
                                        #     Parent Loop BB1_3 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movss	(%r11,%r13,4), %xmm1            # xmm1 = mem[0],zero,zero,zero
	mulss	(%r12), %xmm1
	addss	%xmm1, %xmm0
	incq	%r13
	addq	%r8, %r12
	cmpq	%r13, %rax
	jne	.LBB1_4
# %bb.5:                                # %._crit_edge
                                        #   in Loop: Header=BB1_3 Depth=2
	movss	%xmm0, (%rbx,%r15,4)
	incq	%r15
	addq	$4, %r14
	cmpq	%rax, %r15
	jne	.LBB1_3
# %bb.6:                                # %._crit_edge30
                                        #   in Loop: Header=BB1_2 Depth=1
	incq	%r10
	addl	%ecx, %r9d
	cmpq	%rax, %r10
	jne	.LBB1_2
# %bb.7:
	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
	.cfi_restore %rbx
	.cfi_restore %r12
	.cfi_restore %r13
	.cfi_restore %r14
	.cfi_restore %r15
.LBB1_8:                                # %._crit_edge32
	retq
.Lfunc_end1:
	.size	_Z4multPfS_S_i, .Lfunc_end1-_Z4multPfS_S_i
	.cfi_endproc
                                        # -- End function
	.globl	_Z23__device_stub__mult_gpuPfS_S_ii # -- Begin function _Z23__device_stub__mult_gpuPfS_S_ii
	.type	_Z23__device_stub__mult_gpuPfS_S_ii,@function
_Z23__device_stub__mult_gpuPfS_S_ii:    # @_Z23__device_stub__mult_gpuPfS_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	$_Z8mult_gpuPfS_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__mult_gpuPfS_S_ii, .Lfunc_end2-_Z23__device_stub__mult_gpuPfS_S_ii
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI3_0:
	.quad	0x41dfffffffc00000              # double 2147483647
.LCPI3_1:
	.quad	0x3ff0000000000000              # double 1
.LCPI3_2:
	.quad	0x412e848000000000              # double 1.0E+6
.LCPI3_4:
	.quad	0x3f847ae147ae147b              # double 0.01
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0
.LCPI3_3:
	.long	0x7fffffff                      # float NaN
	.long	0x7fffffff                      # float NaN
	.long	0x7fffffff                      # float NaN
	.long	0x7fffffff                      # float NaN
	.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	$104, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	8(%rsi), %rdi
	callq	atoi
	movl	%eax, %r13d
	imull	%eax, %eax
	movq	%rax, 56(%rsp)                  # 8-byte Spill
	leaq	(,%rax,4), %rbx
	movq	%rbx, %rdi
	callq	malloc
	movq	%rax, 24(%rsp)                  # 8-byte Spill
	leaq	48(%rsp), %rdi
	movq	%rbx, %rsi
	callq	hipMalloc
	movq	%rbx, %rdi
	callq	malloc
	movq	%rax, %r14
	leaq	40(%rsp), %rdi
	movq	%rbx, %rsi
	callq	hipMalloc
	movq	%rbx, %rdi
	callq	malloc
	movq	%rax, %r12
	leaq	32(%rsp), %rdi
	movq	%rbx, %rsi
	callq	hipMalloc
	movq	%rbx, 8(%rsp)                   # 8-byte Spill
	movq	%rbx, %rdi
	callq	malloc
	movq	%rax, %r15
	xorl	%ebx, %ebx
	xorl	%edi, %edi
	callq	time
	movl	%eax, %edi
	callq	srand
	movq	%r13, 80(%rsp)                  # 8-byte Spill
	testl	%r13d, %r13d
	je	.LBB3_3
# %bb.1:                                # %.lr.ph.preheader
	movq	56(%rsp), %r13                  # 8-byte Reload
	cmpl	$1, %r13d
                                        # kill: def $r13d killed $r13d killed $r13 def $r13
	adcl	$0, %r13d
	xorl	%ebp, %ebp
.LBB3_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	callq	rand
	xorps	%xmm0, %xmm0
	cvtsi2sd	%eax, %xmm0
	movsd	.LCPI3_0(%rip), %xmm1           # xmm1 = mem[0],zero
	divsd	%xmm1, %xmm0
	movsd	.LCPI3_1(%rip), %xmm1           # xmm1 = mem[0],zero
	addsd	%xmm1, %xmm0
	cvtsd2ss	%xmm0, %xmm0
	movq	24(%rsp), %rax                  # 8-byte Reload
	movss	%xmm0, (%rax,%rbp,4)
	callq	rand
	xorps	%xmm0, %xmm0
	cvtsi2sd	%eax, %xmm0
	divsd	.LCPI3_0(%rip), %xmm0
	addsd	.LCPI3_1(%rip), %xmm0
	cvtsd2ss	%xmm0, %xmm0
	movss	%xmm0, (%r14,%rbp,4)
	movl	%ebx, (%r12,%rbp,4)
	movl	%ebx, (%r15,%rbp,4)
	incq	%rbp
	cmpq	%rbp, %r13
	jne	.LBB3_2
.LBB3_3:                                # %._crit_edge
	movq	%r12, 64(%rsp)                  # 8-byte Spill
	movq	%r15, 72(%rsp)                  # 8-byte Spill
	movq	48(%rsp), %rdi
	movq	24(%rsp), %r15                  # 8-byte Reload
	movq	%r15, %rsi
	movq	8(%rsp), %r12                   # 8-byte Reload
	movq	%r12, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	40(%rsp), %rdi
	movq	%r14, %rbx
	movq	%r14, %rsi
	movq	%r12, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	callq	hipDeviceSynchronize
	movq	80(%rsp), %r12                  # 8-byte Reload
	leal	31(%r12), %esi
	testl	%r12d, %r12d
	cmovnsl	%r12d, %esi
	sarl	$5, %esi
	movq	%rsi, %r13
	shlq	$32, %r13
	orq	%rsi, %r13
	imull	%esi, %esi
	movl	$.L.str, %edi
                                        # kill: def $esi killed $esi killed $rsi
	movl	$1024, %edx                     # imm = 0x400
	xorl	%eax, %eax
	callq	printf
	leaq	88(%rsp), %rbp
	movq	%rbp, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	xorps	%xmm0, %xmm0
	cvtsi2sdq	(%rbp), %xmm0
	xorps	%xmm1, %xmm1
	cvtsi2sdq	8(%rbp), %xmm1
	divsd	.LCPI3_2(%rip), %xmm1
	addsd	%xmm0, %xmm1
	movsd	%xmm1, 16(%rsp)                 # 8-byte Spill
	movabsq	$137438953504, %rdx             # imm = 0x2000000020
	movq	%r13, %rdi
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB3_5
# %bb.4:
	movq	48(%rsp), %rdi
	movq	40(%rsp), %rsi
	movq	32(%rsp), %rdx
	movl	%r12d, %ecx
	movl	%r12d, %r8d
	callq	_Z23__device_stub__mult_gpuPfS_S_ii
.LBB3_5:
	callq	hipDeviceSynchronize
	xorl	%ebp, %ebp
	leaq	88(%rsp), %r13
	movq	%r13, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	xorps	%xmm1, %xmm1
	cvtsi2sdq	(%r13), %xmm1
	xorps	%xmm0, %xmm0
	cvtsi2sdq	8(%r13), %xmm0
	divsd	.LCPI3_2(%rip), %xmm0
	addsd	%xmm1, %xmm0
	subsd	16(%rsp), %xmm0                 # 8-byte Folded Reload
	movl	$.L.str.1, %edi
	movb	$1, %al
	callq	printf
	movq	32(%rsp), %rsi
	movq	64(%rsp), %rdi                  # 8-byte Reload
	movq	8(%rsp), %rdx                   # 8-byte Reload
	movl	$2, %ecx
	callq	hipMemcpy
	callq	hipDeviceSynchronize
	leaq	88(%rsp), %r13
	movq	%r13, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	xorps	%xmm0, %xmm0
	cvtsi2sdq	(%r13), %xmm0
	xorps	%xmm1, %xmm1
	cvtsi2sdq	8(%r13), %xmm1
	divsd	.LCPI3_2(%rip), %xmm1
	addsd	%xmm0, %xmm1
	movsd	%xmm1, 8(%rsp)                  # 8-byte Spill
	testl	%r12d, %r12d
	movq	%r12, %r13
	movq	72(%rsp), %r12                  # 8-byte Reload
	jle	.LBB3_12
# %bb.6:                                # %.preheader26.lr.ph.i
	movl	%r13d, %eax
	leaq	(,%rax,4), %rcx
	xorl	%edx, %edx
.LBB3_7:                                # %.preheader.lr.ph.i
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB3_8 Depth 2
                                        #       Child Loop BB3_9 Depth 3
	movl	%ebp, %esi
	leaq	(%r15,%rsi,4), %rsi
	movq	%rdx, %rdi
	imulq	%rax, %rdi
	leaq	(%r12,%rdi,4), %rdi
	movq	%rbx, %r8
	xorl	%r9d, %r9d
.LBB3_8:                                # %.preheader.i
                                        #   Parent Loop BB3_7 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB3_9 Depth 3
	xorpd	%xmm0, %xmm0
	movq	%r8, %r10
	xorl	%r11d, %r11d
.LBB3_9:                                #   Parent Loop BB3_7 Depth=1
                                        #     Parent Loop BB3_8 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movss	(%rsi,%r11), %xmm1              # xmm1 = mem[0],zero,zero,zero
	mulss	(%r10), %xmm1
	addss	%xmm1, %xmm0
	addq	$4, %r11
	addq	%rcx, %r10
	cmpq	%r11, %rcx
	jne	.LBB3_9
# %bb.10:                               # %._crit_edge.i
                                        #   in Loop: Header=BB3_8 Depth=2
	movss	%xmm0, (%rdi,%r9,4)
	incq	%r9
	addq	$4, %r8
	cmpq	%rax, %r9
	jne	.LBB3_8
# %bb.11:                               # %._crit_edge30.i
                                        #   in Loop: Header=BB3_7 Depth=1
	incq	%rdx
	addl	%r13d, %ebp
	cmpq	%rax, %rdx
	jne	.LBB3_7
.LBB3_12:                               # %_Z4multPfS_S_i.exit
	movq	%rbx, 16(%rsp)                  # 8-byte Spill
	movq	%r13, %rbx
	leaq	88(%rsp), %r13
	movq	%r13, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	xorps	%xmm1, %xmm1
	cvtsi2sdq	(%r13), %xmm1
	xorps	%xmm0, %xmm0
	cvtsi2sdq	8(%r13), %xmm0
	divsd	.LCPI3_2(%rip), %xmm0
	addsd	%xmm1, %xmm0
	subsd	8(%rsp), %xmm0                  # 8-byte Folded Reload
	movl	$.L.str.2, %edi
	movb	$1, %al
	callq	printf
	movl	$.L.str.3, %edi
	movl	$.L.str.4, %esi
	callq	fopen
	movq	%rax, %rbp
	movl	$.L.str.5, %edi
	movl	$.L.str.4, %esi
	callq	fopen
	movq	%rax, %r13
	movl	$.Lstr, %edi
	callq	puts@PLT
	testl	%ebx, %ebx
	movq	64(%rsp), %r15                  # 8-byte Reload
	je	.LBB3_18
# %bb.13:                               # %.lr.ph74.preheader
	movq	56(%rsp), %r14                  # 8-byte Reload
	cmpl	$1, %r14d
	adcl	$0, %r14d
	xorl	%ebx, %ebx
.LBB3_14:                               # %.lr.ph74
                                        # =>This Inner Loop Header: Depth=1
	movss	(%r15,%rbx,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	movss	(%r12,%rbx,4), %xmm1            # xmm1 = mem[0],zero,zero,zero
	movaps	%xmm0, %xmm2
	subss	%xmm1, %xmm2
	andps	.LCPI3_3(%rip), %xmm2
	cvtss2sd	%xmm2, %xmm2
	ucomisd	.LCPI3_4(%rip), %xmm2
	jbe	.LBB3_15
# %bb.16:                               #   in Loop: Header=BB3_14 Depth=1
	cvtss2sd	%xmm0, %xmm0
	cvtss2sd	%xmm1, %xmm1
	movsd	%xmm1, 8(%rsp)                  # 8-byte Spill
	movl	$.L.str.7, %edi
	movb	$2, %al
	callq	printf
	movsd	8(%rsp), %xmm0                  # 8-byte Reload
                                        # xmm0 = mem[0],zero
	jmp	.LBB3_17
.LBB3_15:                               # %.lr.ph74._crit_edge
                                        #   in Loop: Header=BB3_14 Depth=1
	xorps	%xmm0, %xmm0
	cvtss2sd	%xmm1, %xmm0
.LBB3_17:                               #   in Loop: Header=BB3_14 Depth=1
	movl	$.L.str.8, %esi
	movq	%rbp, %rdi
	movb	$1, %al
	callq	fprintf
	xorps	%xmm0, %xmm0
	cvtss2sd	(%r15,%rbx,4), %xmm0
	movl	$.L.str.8, %esi
	movq	%r13, %rdi
	movb	$1, %al
	callq	fprintf
	incq	%rbx
	cmpq	%rbx, %r14
	jne	.LBB3_14
.LBB3_18:                               # %._crit_edge75
	movq	%rbp, %rdi
	callq	fclose
	movq	%r13, %rdi
	callq	fclose
	movq	24(%rsp), %rdi                  # 8-byte Reload
	callq	free
	movq	48(%rsp), %rdi
	callq	hipFree
	movq	16(%rsp), %rdi                  # 8-byte Reload
	callq	free
	movq	40(%rsp), %rdi
	callq	hipFree
	movq	%r15, %rdi
	callq	free
	movq	32(%rsp), %rdi
	callq	hipFree
	movq	%r12, %rdi
	callq	free
	xorl	%eax, %eax
	addq	$104, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end3:
	.size	main, .Lfunc_end3-main
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	jne	.LBB4_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB4_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z8mult_gpuPfS_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_end4:
	.size	__hip_module_ctor, .Lfunc_end4-__hip_module_ctor
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_dtor
	.type	__hip_module_dtor,@function
__hip_module_dtor:                      # @__hip_module_dtor
	.cfi_startproc
# %bb.0:
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	je	.LBB5_2
# %bb.1:
	pushq	%rax
	.cfi_def_cfa_offset 16
	callq	__hipUnregisterFatBinary
	movq	$0, __hip_gpubin_handle(%rip)
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
.LBB5_2:
	retq
.Lfunc_end5:
	.size	__hip_module_dtor, .Lfunc_end5-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	_Z8mult_gpuPfS_S_ii,@object     # @_Z8mult_gpuPfS_S_ii
	.section	.rodata,"a",@progbits
	.globl	_Z8mult_gpuPfS_S_ii
	.p2align	3, 0x0
_Z8mult_gpuPfS_S_ii:
	.quad	_Z23__device_stub__mult_gpuPfS_S_ii
	.size	_Z8mult_gpuPfS_S_ii, 8

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"block:%d, thread:%d\n"
	.size	.L.str, 21

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"The GPU Elapsed Time:%lf Sec.\n"
	.size	.L.str.1, 31

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"The CPU Elapsed Time:%lf Sec.\n"
	.size	.L.str.2, 31

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"cpu_result.txt"
	.size	.L.str.3, 15

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

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"gpu_result.txt"
	.size	.L.str.5, 15

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"Error:%f, %f\n"
	.size	.L.str.7, 14

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

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z8mult_gpuPfS_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	"Verifying"
	.size	.Lstr, 10

	.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__mult_gpuPfS_S_ii
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z8mult_gpuPfS_S_ii
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z8mult_gpuPfS_S_ii     ; -- Begin function _Z8mult_gpuPfS_S_ii
	.globl	_Z8mult_gpuPfS_S_ii
	.p2align	8
	.type	_Z8mult_gpuPfS_S_ii,@function
_Z8mult_gpuPfS_S_ii:                    ; @_Z8mult_gpuPfS_S_ii
; %bb.0:
	s_load_b256 s[0:7], s[0:1], 0x0
	v_bfe_u32 v2, v0, 10, 10
	s_mov_b32 s9, 0
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_1)
	v_mul_lo_u32 v5, v2, s7
	s_cmp_gt_i32 s6, 0
	s_cbranch_scc1 .LBB0_2
; %bb.1:                                ; %.._crit_edge_crit_edge
	v_mul_lo_u32 v1, v2, s7
	s_mov_b32 s10, 0
	s_branch .LBB0_3
.LBB0_2:
	s_mov_b32 s9, -1
                                        ; implicit-def: $sgpr10
                                        ; implicit-def: $vgpr1
.LBB0_3:                                ; %Flow132
	v_and_b32_e32 v0, 0x3ff, v0
	s_lshl_b32 s8, s14, 5
	s_and_not1_b32 vcc_lo, exec_lo, s9
	s_lshl_b32 s7, s7, 5
	s_cbranch_vccnz .LBB0_7
; %bb.4:                                ; %.lr.ph
	v_dual_mov_b32 v6, 0 :: v_dual_lshlrev_b32 v3, 2, v0
	v_lshlrev_b32_e32 v7, 7, v2
	v_add3_u32 v1, v0, v5, s8
	v_lshl_add_u32 v2, s15, 5, v2
	s_delay_alu instid0(VALU_DEP_4)
	v_or_b32_e32 v8, 0x1000, v3
	s_mul_i32 s9, s6, s15
	v_add_nc_u32_e32 v9, v7, v3
	s_lshl_b32 s9, s9, 5
	v_mad_u64_u32 v[3:4], null, s6, v2, v[0:1]
	v_add_nc_u32_e32 v10, v8, v7
	v_add_nc_u32_e32 v11, 0x400, v8
	v_add_nc_u32_e32 v12, 0x800, v8
	v_add_nc_u32_e32 v13, 0xc00, v8
	s_add_i32 s6, s9, s6
.LBB0_5:                                ; =>This Inner Loop Header: Depth=1
	v_ashrrev_i32_e32 v4, 31, v3
	v_ashrrev_i32_e32 v2, 31, v1
	s_add_i32 s9, s9, 32
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	s_cmp_ge_i32 s9, s6
	v_lshlrev_b64 v[14:15], 2, v[3:4]
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_2) | instid1(VALU_DEP_4)
	v_lshlrev_b64 v[16:17], 2, v[1:2]
	v_add_nc_u32_e32 v1, s7, v1
	v_add_nc_u32_e32 v3, 32, v3
	v_add_co_u32 v14, vcc_lo, s0, v14
	v_add_co_ci_u32_e32 v15, vcc_lo, s1, v15, vcc_lo
	v_add_co_u32 v16, vcc_lo, s2, v16
	v_add_co_ci_u32_e32 v17, vcc_lo, s3, v17, vcc_lo
	global_load_b32 v2, v[14:15], off
	global_load_b32 v4, v[16:17], off
	s_waitcnt vmcnt(1)
	ds_store_b32 v9, v2
	s_waitcnt vmcnt(0)
	ds_store_b32 v10, v4
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	ds_load_2addr_b32 v[22:23], v8 offset1:32
	ds_load_b128 v[14:17], v7
	ds_load_2addr_b32 v[24:25], v8 offset0:64 offset1:96
	ds_load_b128 v[18:21], v7 offset:16
	ds_load_2addr_b32 v[26:27], v8 offset0:128 offset1:160
	s_waitcnt lgkmcnt(3)
	v_fmac_f32_e32 v6, v14, v22
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_3) | instid1(VALU_DEP_1)
	v_fmac_f32_e32 v6, v15, v23
	ds_load_2addr_b32 v[22:23], v8 offset0:192 offset1:224
	s_waitcnt lgkmcnt(3)
	v_fmac_f32_e32 v6, v16, v24
	v_fmac_f32_e32 v6, v17, v25
	ds_load_2addr_b32 v[24:25], v11 offset1:32
	ds_load_b128 v[14:17], v7 offset:32
	s_waitcnt lgkmcnt(3)
	v_fmac_f32_e32 v6, v18, v26
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_3) | instid1(VALU_DEP_1)
	v_fmac_f32_e32 v6, v19, v27
	ds_load_2addr_b32 v[26:27], v11 offset0:64 offset1:96
	s_waitcnt lgkmcnt(3)
	v_fmac_f32_e32 v6, v20, v22
	v_fmac_f32_e32 v6, v21, v23
	ds_load_b128 v[18:21], v7 offset:48
	ds_load_2addr_b32 v[22:23], v11 offset0:128 offset1:160
	s_waitcnt lgkmcnt(3)
	v_fmac_f32_e32 v6, v14, v24
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_3) | instid1(VALU_DEP_1)
	v_fmac_f32_e32 v6, v15, v25
	ds_load_2addr_b32 v[24:25], v11 offset0:192 offset1:224
	s_waitcnt lgkmcnt(3)
	v_fmac_f32_e32 v6, v16, v26
	v_fmac_f32_e32 v6, v17, v27
	ds_load_2addr_b32 v[26:27], v12 offset1:32
	ds_load_b128 v[14:17], v7 offset:64
	s_waitcnt lgkmcnt(3)
	v_fmac_f32_e32 v6, v18, v22
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_3) | instid1(VALU_DEP_1)
	v_fmac_f32_e32 v6, v19, v23
	ds_load_2addr_b32 v[22:23], v12 offset0:64 offset1:96
	s_waitcnt lgkmcnt(3)
	v_fmac_f32_e32 v6, v20, v24
	v_fmac_f32_e32 v6, v21, v25
	ds_load_b128 v[18:21], v7 offset:80
	ds_load_2addr_b32 v[24:25], v12 offset0:128 offset1:160
	s_waitcnt lgkmcnt(3)
	v_fmac_f32_e32 v6, v14, v26
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_3) | instid1(VALU_DEP_1)
	v_fmac_f32_e32 v6, v15, v27
	ds_load_2addr_b32 v[26:27], v12 offset0:192 offset1:224
	s_waitcnt lgkmcnt(3)
	v_fmac_f32_e32 v6, v16, v22
	v_fmac_f32_e32 v6, v17, v23
	ds_load_2addr_b32 v[22:23], v13 offset1:32
	ds_load_b128 v[14:17], v7 offset:96
	s_waitcnt lgkmcnt(3)
	v_fmac_f32_e32 v6, v18, v24
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_3) | instid1(VALU_DEP_1)
	v_fmac_f32_e32 v6, v19, v25
	ds_load_2addr_b32 v[24:25], v13 offset0:64 offset1:96
	s_waitcnt lgkmcnt(3)
	v_fmac_f32_e32 v6, v20, v26
	v_fmac_f32_e32 v6, v21, v27
	ds_load_b128 v[18:21], v7 offset:112
	ds_load_2addr_b32 v[26:27], v13 offset0:128 offset1:160
	s_waitcnt lgkmcnt(3)
	v_fmac_f32_e32 v6, v14, v22
	s_delay_alu instid0(VALU_DEP_1)
	v_fmac_f32_e32 v6, v15, v23
	ds_load_2addr_b32 v[14:15], v13 offset0:192 offset1:224
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	v_fmac_f32_e32 v6, v16, v24
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fmac_f32_e32 v6, v17, v25
	v_fmac_f32_e32 v6, v18, v26
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fmac_f32_e32 v6, v19, v27
	v_fmac_f32_e32 v6, v20, v14
	s_delay_alu instid0(VALU_DEP_1)
	v_fmac_f32_e32 v6, v21, v15
	s_cbranch_scc0 .LBB0_5
; %bb.6:                                ; %Flow
	v_mov_b32_e32 v1, v5
	s_branch .LBB0_8
.LBB0_7:
	v_mov_b32_e32 v6, s10
.LBB0_8:                                ; %Flow133
	v_add_nc_u32_e32 v0, s8, v0
	s_mul_i32 s7, s7, s15
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	v_add3_u32 v0, v0, v1, s7
	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_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v0, vcc_lo, s4, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s5, v1, vcc_lo
	global_store_b32 v[0:1], v6, off
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z8mult_gpuPfS_S_ii
		.amdhsa_group_segment_fixed_size 8192
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 32
		.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 28
		.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	_Z8mult_gpuPfS_S_ii, .Lfunc_end0-_Z8mult_gpuPfS_S_ii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 824
; NumSgprs: 18
; NumVgprs: 28
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 8192 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 3
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 28
; 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
    .group_segment_fixed_size: 8192
    .kernarg_segment_align: 8
    .kernarg_segment_size: 32
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z8mult_gpuPfS_S_ii
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z8mult_gpuPfS_S_ii.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     28
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
