//source: https://github.com/lzhengchun/matrix-cuda/blob/master/matrix_cuda.cu

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

#define TYPE float


/*
 Returns the current time in miliseconds.
*/
double getMilitime(){
        struct timeval ret;
        gettimeofday(&ret, NULL);
        return ((ret.tv_sec ) * 1000000u + ret.tv_usec) / 1.e6;
}



void MatrixMultiplicationCPU(TYPE*A, TYPE*B, TYPE*C, int M, int N, int K){
  int i,j,count;
  for(i=0;i<M;++i)
      for(j=0;j<K;++j)
          for(count=0;count<N;++count){
              C[i*K+j] += A[i*N+count] * B[count*K+j];
          }
}

#define err(format, ...) do { fprintf(stderr, format, ##__VA_ARGS__); exit(1); } while (0)

#ifdef __CUDACC__
inline void checkCuda(cudaError_t e) {
    if (e != cudaSuccess) {
        // cudaGetErrorString() isn't always very helpful. Look up the error
        // number in the cudaError enum in driver_types.h in the CUDA includes
        // directory for a better explanation.
        err("CUDA Error %d: %s\n", e, cudaGetErrorString(e));
    }
}

inline void checkLastCudaError() {
    checkCuda(cudaGetLastError());
}
#endif

void Allocate(TYPE**A, TYPE**B, TYPE**C, int M, int N, int K){
  (*A) = (*B) = (*C) = NULL;
  (*A) = (TYPE*)malloc(sizeof(TYPE*) * M * N);
  (*B) = (TYPE*)malloc(sizeof(TYPE*) * N * K);
  (*C) = (TYPE*)malloc(sizeof(TYPE*) * M * K);

  assert((*A) != NULL);
  assert((*B) != NULL);
  assert((*C) != NULL);
}
void Fill(TYPE*A, TYPE*B, int M, int N, int K){
  int i;
  for (i=0; i<M*N; i++) A[i]= 1.0;
  for (i=0; i<N*K; i++) B[i]= 2.0;
}
void UnAllocate(TYPE**A, TYPE**B, TYPE**C){
  free((*A));
  free((*B));
  free((*C));
}

void Print2DMatrix(TYPE*A, int M, int N) {
  int i;
  for(i = 0; i < M*N; ++i){
      if((i%M)==0) printf("\n");
      printf("%f ",A[i]);
  }
  printf("\n");
}



__global__ void MatrixMultiplication(TYPE*A_Device, TYPE*B_Device, TYPE*C_Device, int M, int N, int K){


  unsigned int objectIdX = blockDim.x * blockIdx.x + threadIdx.x;
  unsigned int objectIdY = blockDim.y * blockIdx.y + threadIdx.y;
  TYPE sum=0;
  int count;
  if (objectIdX < M && objectIdY < K) {
      for(count=0;count<N;++count){
          sum += A_Device[objectIdX*N+count] * B_Device[count*K+objectIdY];
      }
      C_Device[objectIdX*K+objectIdY]=sum;
  }
}

int main(int argc, char* argv[]){
  if(argc<4){
      printf("Input Error\n");
      return 1;
  }

  int M = atoi(argv[1]);
  int N = atoi(argv[2]);
  int K = atoi(argv[3]);
  
  TYPE*A,*B,*C, *A_Device, *B_Device, *C_Device;
  Allocate(&A,&B,&C,M,N,K);
  Fill(A,B,M,N,K);

  //Allocate in Device
  checkCuda(cudaMalloc(&A_Device, M*N*sizeof(TYPE)));
  checkCuda(cudaMalloc(&B_Device, N*K*sizeof(TYPE)));
  checkCuda(cudaMalloc(&C_Device, M*K*sizeof(TYPE)));

  //Copy to Device
  cudaMemcpy(A_Device, A, M*N*sizeof(TYPE), cudaMemcpyHostToDevice);
  cudaMemcpy(B_Device, B, N*K*sizeof(TYPE), cudaMemcpyHostToDevice);

  dim3 dimBlock(16, 16);
  dim3 dimGrid;
  dimGrid.x = (M + dimBlock.x - 1) / dimBlock.x;
  dimGrid.y = (K + dimBlock.y - 1) / dimBlock.y;

  printf("start timing\tm=%d,n=%d,k=%d\n",M,N,K);
  double start_time = getMilitime();

  MatrixMultiplication<<<dimGrid,dimBlock>>>(A_Device,B_Device,C_Device,M,N,K);
  cudaDeviceSynchronize(); checkLastCudaError();

  printf("elapsed time (Basic CUDA MatMult): %f sec\n", getMilitime()-start_time);

  //copy to Host
  cudaMemcpy(C, C_Device, M*K*sizeof(TYPE), cudaMemcpyDeviceToHost);

  //Free in Device
  checkCuda(cudaFree(A_Device));
  checkCuda(cudaFree(B_Device));
  checkCuda(cudaFree(C_Device));

  //verify results
  TYPE*C_CPU = (TYPE*) (TYPE*)malloc(sizeof(TYPE*) * M * K);
  MatrixMultiplicationCPU(A,B,C_CPU,M,N,K);
  int count;
  for(count=0;count<M * K;count++){
     if(C_CPU[count]!=C[count]) {printf("Not Equal, idx: %d!",count);break;}
  }
  free(C_CPU);
  
  //free on Host
  UnAllocate(&A,&B,&C);

  return(0);
}
	.file	"tmpxft_0032d452_00000000-6_basicMatrixMult.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2038:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2038:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z11getMilitimev
	.type	_Z11getMilitimev, @function
_Z11getMilitimev:
.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
	imulq	$1000000, 8(%rsp), %rax
	addq	16(%rsp), %rax
	cvtsi2sdq	%rax, %xmm0
	divsd	.LC0(%rip), %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	_Z11getMilitimev, .-_Z11getMilitimev
	.globl	_Z23MatrixMultiplicationCPUPfS_S_iii
	.type	_Z23MatrixMultiplicationCPUPfS_S_iii, @function
_Z23MatrixMultiplicationCPUPfS_S_iii:
.LFB2028:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movslq	%r9d, %r11
	xorl	%r10d, %r10d
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	salq	$2, %r11
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movl	%ecx, %r12d
	xorl	%ecx, %ecx
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%rdx, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	xorl	%ebx, %ebx
	movq	%rsi, -8(%rsp)
.L7:
	cmpl	%r12d, %r10d
	jge	.L6
	movslq	%ecx, %rax
	movq	-8(%rsp), %rsi
	leaq	(%rdi,%rax,4), %r15
	xorl	%eax, %eax
.L12:
	cmpl	%r9d, %eax
	jge	.L9
	leal	(%rax,%rbx), %edx
	movq	%rsi, %r13
	movslq	%edx, %rdx
	leaq	0(%rbp,%rdx,4), %r14
	xorl	%edx, %edx
.L10:
	cmpl	%edx, %r8d
	jle	.L14
	movss	(%r15,%rdx,4), %xmm0
	mulss	0(%r13), %xmm0
	incq	%rdx
	addq	%r11, %r13
	addss	(%r14), %xmm0
	movss	%xmm0, (%r14)
	jmp	.L10
.L14:
	incl	%eax
	addq	$4, %rsi
	jmp	.L12
.L9:
	incl	%r10d
	addl	%r9d, %ebx
	addl	%r8d, %ecx
	jmp	.L7
.L6:
	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
.LFE2028:
	.size	_Z23MatrixMultiplicationCPUPfS_S_iii, .-_Z23MatrixMultiplicationCPUPfS_S_iii
	.section	.rodata._Z9checkCuda9cudaError.str1.1,"aMS",@progbits,1
.LC1:
	.string	"CUDA Error %d: %s\n"
	.section	.text._Z9checkCuda9cudaError,"axG",@progbits,_Z9checkCuda9cudaError,comdat
	.weak	_Z9checkCuda9cudaError
	.type	_Z9checkCuda9cudaError, @function
_Z9checkCuda9cudaError:
.LFB2029:
	.cfi_startproc
	endbr64
	testl	%edi, %edi
	je	.L15
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	movl	%edi, %ebx
	call	cudaGetErrorString@PLT
	movq	stderr(%rip), %rdi
	movl	%ebx, %ecx
	leaq	.LC1(%rip), %rdx
	movq	%rax, %r8
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	movl	$1, %edi
	call	exit@PLT
.L15:
	.cfi_def_cfa_offset 8
	.cfi_restore 3
	ret
	.cfi_endproc
.LFE2029:
	.size	_Z9checkCuda9cudaError, .-_Z9checkCuda9cudaError
	.text
	.globl	_Z8AllocatePPfS0_S0_iii
	.type	_Z8AllocatePPfS0_S0_iii, @function
_Z8AllocatePPfS0_S0_iii:
.LFB2031:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movq	%rdi, %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movq	%rsi, %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%rdx, %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movslq	%r8d, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movslq	%r9d, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movslq	%ecx, %rbx
	salq	$3, %rbp
	movq	%rbx, %rdi
	pushq	%rax
	.cfi_def_cfa_offset 64
	imulq	%rbp, %rbx
	imulq	%r12, %rdi
	salq	$3, %rdi
	call	malloc@PLT
	movq	%r12, %rdi
	imulq	%rbp, %rdi
	movq	%rax, (%r15)
	call	malloc@PLT
	movq	%rbx, %rdi
	movq	%rax, (%r14)
	call	malloc@PLT
	movq	%rax, 0(%r13)
	popq	%rdx
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2031:
	.size	_Z8AllocatePPfS0_S0_iii, .-_Z8AllocatePPfS0_S0_iii
	.globl	_Z4FillPfS_iii
	.type	_Z4FillPfS_iii, @function
_Z4FillPfS_iii:
.LFB2032:
	.cfi_startproc
	endbr64
	imull	%ecx, %edx
	movss	.LC2(%rip), %xmm0
	xorl	%eax, %eax
.L23:
	cmpl	%eax, %edx
	jle	.L27
	movss	%xmm0, (%rdi,%rax,4)
	incq	%rax
	jmp	.L23
.L27:
	imull	%r8d, %ecx
	movss	.LC3(%rip), %xmm0
	xorl	%eax, %eax
.L25:
	cmpl	%eax, %ecx
	jle	.L28
	movss	%xmm0, (%rsi,%rax,4)
	incq	%rax
	jmp	.L25
.L28:
	ret
	.cfi_endproc
.LFE2032:
	.size	_Z4FillPfS_iii, .-_Z4FillPfS_iii
	.globl	_Z10UnAllocatePPfS0_S0_
	.type	_Z10UnAllocatePPfS0_S0_, @function
_Z10UnAllocatePPfS0_S0_:
.LFB2033:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	movq	%rdx, %rbx
	pushq	%rax
	.cfi_def_cfa_offset 32
	movq	(%rdi), %rdi
	call	free@PLT
	movq	0(%rbp), %rdi
	call	free@PLT
	movq	(%rbx), %rdi
	popq	%rdx
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	jmp	free@PLT
	.cfi_endproc
.LFE2033:
	.size	_Z10UnAllocatePPfS0_S0_, .-_Z10UnAllocatePPfS0_S0_
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC4:
	.string	"\n"
.LC5:
	.string	"%f "
	.text
	.globl	_Z13Print2DMatrixPfii
	.type	_Z13Print2DMatrixPfii, @function
_Z13Print2DMatrixPfii:
.LFB2034:
	.cfi_startproc
	endbr64
	imull	%esi, %edx
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	leaq	.LC4(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	movq	%rdi, %r13
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	movl	%edx, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	movl	%esi, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	xorl	%ebx, %ebx
.L32:
	movl	%ebx, %eax
	cmpl	%ebx, %r12d
	jle	.L36
	cltd
	idivl	%ebp
	testl	%edx, %edx
	jne	.L33
	movq	%r14, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L33:
	leaq	.LC5(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	cvtss2sd	0(%r13,%rbx,4), %xmm0
	call	__printf_chk@PLT
	incq	%rbx
	jmp	.L32
.L36:
	popq	%rbx
	.cfi_def_cfa_offset 40
	leaq	.LC4(%rip), %rsi
	popq	%rbp
	.cfi_def_cfa_offset 32
	movl	$2, %edi
	popq	%r12
	.cfi_def_cfa_offset 24
	xorl	%eax, %eax
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	jmp	__printf_chk@PLT
	.cfi_endproc
.LFE2034:
	.size	_Z13Print2DMatrixPfii, .-_Z13Print2DMatrixPfii
	.globl	_Z47__device_stub__Z20MatrixMultiplicationPfS_S_iiiPfS_S_iii
	.type	_Z47__device_stub__Z20MatrixMultiplicationPfS_S_iiiPfS_S_iii, @function
_Z47__device_stub__Z20MatrixMultiplicationPfS_S_iiiPfS_S_iii:
.LFB2060:
	.cfi_startproc
	endbr64
	subq	$184, %rsp
	.cfi_def_cfa_offset 192
	movq	%rdi, 40(%rsp)
	leaq	72(%rsp), %rdi
	movq	%rsi, 32(%rsp)
	leaq	84(%rsp), %rsi
	movq	%rdx, 24(%rsp)
	leaq	56(%rsp), %rdx
	movl	%ecx, 20(%rsp)
	leaq	64(%rsp), %rcx
	movl	%r8d, 16(%rsp)
	movl	%r9d, 12(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 168(%rsp)
	xorl	%eax, %eax
	leaq	40(%rsp), %rax
	movl	$1, 80(%rsp)
	movq	%rax, 120(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 128(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 136(%rsp)
	leaq	20(%rsp), %rax
	movq	%rax, 144(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 152(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 160(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 72(%rsp)
	movq	%rax, 84(%rsp)
	movl	$1, 92(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L37
	pushq	64(%rsp)
	.cfi_def_cfa_offset 200
	leaq	_Z20MatrixMultiplicationPfS_S_iii(%rip), %rdi
	pushq	64(%rsp)
	.cfi_def_cfa_offset 208
	movq	100(%rsp), %rcx
	movl	108(%rsp), %r8d
	movq	88(%rsp), %rsi
	movl	96(%rsp), %edx
	leaq	136(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 200
	popq	%rdx
	.cfi_def_cfa_offset 192
.L37:
	movq	168(%rsp), %rax
	subq	%fs:40, %rax
	je	.L39
	call	__stack_chk_fail@PLT
.L39:
	addq	$184, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2060:
	.size	_Z47__device_stub__Z20MatrixMultiplicationPfS_S_iiiPfS_S_iii, .-_Z47__device_stub__Z20MatrixMultiplicationPfS_S_iiiPfS_S_iii
	.globl	_Z20MatrixMultiplicationPfS_S_iii
	.type	_Z20MatrixMultiplicationPfS_S_iii, @function
_Z20MatrixMultiplicationPfS_S_iii:
.LFB2061:
	.cfi_startproc
	endbr64
	jmp	_Z47__device_stub__Z20MatrixMultiplicationPfS_S_iiiPfS_S_iii
	.cfi_endproc
.LFE2061:
	.size	_Z20MatrixMultiplicationPfS_S_iii, .-_Z20MatrixMultiplicationPfS_S_iii
	.section	.rodata.str1.1
.LC6:
	.string	"Input Error\n"
.LC7:
	.string	"start timing\tm=%d,n=%d,k=%d\n"
.LC8:
	.string	"elapsed time (Basic CUDA MatMult): %f sec\n"
.LC9:
	.string	"Not Equal, idx: %d!"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2035:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$136, %rsp
	.cfi_def_cfa_offset 192
	movq	%fs:40, %rax
	movq	%rax, 120(%rsp)
	xorl	%eax, %eax
	cmpl	$3, %edi
	jg	.L43
	leaq	.LC6(%rip), %rsi
	movl	$2, %edi
	call	__printf_chk@PLT
	movl	$1, %eax
	jmp	.L42
.L43:
	movq	8(%rsi), %rdi
	movq	%rsi, %rbp
	call	atoi@PLT
	movq	16(%rbp), %rdi
	movl	%eax, %ebx
	call	atoi@PLT
	movq	24(%rbp), %rdi
	movl	%ebx, %r15d
	movl	%eax, %r12d
	call	atoi@PLT
	leaq	48(%rsp), %rdi
	movl	%r12d, %r8d
	movl	%ebx, %ecx
	movl	%eax, %ebp
	leaq	64(%rsp), %rax
	movq	%rax, 24(%rsp)
	leaq	56(%rsp), %rax
	movq	24(%rsp), %rdx
	movl	%ebp, %r9d
	movq	%rax, %rsi
	movq	%rax, 32(%rsp)
	imull	%ebp, %r15d
	call	_Z8AllocatePPfS0_S0_iii
	movq	56(%rsp), %rax
	movl	%ebp, %r8d
	movl	%r12d, %ecx
	movl	%ebx, %edx
	movq	%rax, (%rsp)
	movq	48(%rsp), %rax
	movq	(%rsp), %rsi
	movq	%rax, %rdi
	movq	%rax, 8(%rsp)
	call	_Z4FillPfS_iii
	movl	%ebx, %edx
	leaq	72(%rsp), %rdi
	imull	%r12d, %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %r14
	movq	%r14, %rsi
	call	cudaMalloc@PLT
	movl	%eax, %edi
	call	_Z9checkCuda9cudaError
	movl	%r12d, %eax
	leaq	80(%rsp), %rdi
	imull	%ebp, %eax
	cltq
	leaq	0(,%rax,4), %r13
	movq	%r13, %rsi
	call	cudaMalloc@PLT
	movl	%eax, %edi
	call	_Z9checkCuda9cudaError
	movslq	%r15d, %rax
	leaq	88(%rsp), %rdi
	salq	$2, %rax
	movq	%rax, %rsi
	movq	%rax, 16(%rsp)
	call	cudaMalloc@PLT
	movl	%eax, %edi
	call	_Z9checkCuda9cudaError
	movq	8(%rsp), %rsi
	movq	72(%rsp), %rdi
	movq	%r14, %rdx
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movq	(%rsp), %rsi
	movq	80(%rsp), %rdi
	movq	%r13, %rdx
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	leal	15(%rbx), %eax
	movl	%ebp, %r8d
	movl	%r12d, %ecx
	shrl	$4, %eax
	movl	%ebx, %edx
	leaq	.LC7(%rip), %rsi
	movl	$2, %edi
	movl	%eax, 108(%rsp)
	leal	15(%rbp), %eax
	shrl	$4, %eax
	movl	$1, 116(%rsp)
	movl	%eax, 112(%rsp)
	xorl	%eax, %eax
	call	__printf_chk@PLT
	call	_Z11getMilitimev
	movq	108(%rsp), %rdi
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	116(%rsp), %esi
	movl	$1, %ecx
	movabsq	$68719476752, %rdx
	movl	$1, 104(%rsp)
	movq	%rdx, 96(%rsp)
	movsd	%xmm0, 40(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L45
	movq	88(%rsp), %rdx
	movq	80(%rsp), %rsi
	movl	%ebp, %r9d
	movl	%r12d, %r8d
	movq	72(%rsp), %rdi
	movl	%ebx, %ecx
	call	_Z47__device_stub__Z20MatrixMultiplicationPfS_S_iiiPfS_S_iii
.L45:
	call	cudaDeviceSynchronize@PLT
	call	cudaGetLastError@PLT
	movl	%eax, %edi
	call	_Z9checkCuda9cudaError
	call	_Z11getMilitimev
	subsd	40(%rsp), %xmm0
	leaq	.LC8(%rip), %rsi
	movb	$1, %al
	movl	$2, %edi
	call	__printf_chk@PLT
	movq	64(%rsp), %r14
	movq	16(%rsp), %rdx
	movl	$2, %ecx
	movq	88(%rsp), %rsi
	movq	%r14, %rdi
	call	cudaMemcpy@PLT
	movq	72(%rsp), %rdi
	call	cudaFree@PLT
	movl	%eax, %edi
	call	_Z9checkCuda9cudaError
	movq	80(%rsp), %rdi
	call	cudaFree@PLT
	movl	%eax, %edi
	call	_Z9checkCuda9cudaError
	movq	88(%rsp), %rdi
	call	cudaFree@PLT
	movl	%eax, %edi
	call	_Z9checkCuda9cudaError
	movslq	%ebp, %rax
	movslq	%ebx, %rdi
	imulq	%rax, %rdi
	salq	$3, %rdi
	call	malloc@PLT
	movq	(%rsp), %rsi
	movq	8(%rsp), %rdi
	movl	%ebx, %ecx
	movq	%rax, %rdx
	movl	%ebp, %r9d
	movl	%r12d, %r8d
	movq	%rax, %r13
	call	_Z23MatrixMultiplicationCPUPfS_S_iii
	xorl	%edx, %edx
.L46:
	cmpl	%edx, %r15d
	jle	.L48
	movss	0(%r13,%rdx,4), %xmm0
	ucomiss	(%r14,%rdx,4), %xmm0
	leaq	1(%rdx), %rax
	jp	.L52
	je	.L51
.L52:
	leaq	.LC9(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L48
.L51:
	movq	%rax, %rdx
	jmp	.L46
.L48:
	movq	%r13, %rdi
	call	free@PLT
	movq	24(%rsp), %rdx
	movq	32(%rsp), %rsi
	leaq	48(%rsp), %rdi
	call	_Z10UnAllocatePPfS0_S0_
	xorl	%eax, %eax
.L42:
	movq	120(%rsp), %rdx
	subq	%fs:40, %rdx
	je	.L50
	call	__stack_chk_fail@PLT
.L50:
	addq	$136, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2035:
	.size	main, .-main
	.section	.rodata.str1.1
.LC10:
	.string	"_Z20MatrixMultiplicationPfS_S_iii"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2063:
	.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	_Z20MatrixMultiplicationPfS_S_iii(%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
.LFE2063:
	.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
	.section	.rodata.cst4,"aM",@progbits,4
	.align 4
.LC2:
	.long	1065353216
	.align 4
.LC3:
	.long	1073741824
	.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:

//source: https://github.com/lzhengchun/matrix-cuda/blob/master/matrix_cuda.cu


#include <hip/hip_runtime.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <assert.h>

#define TYPE float


/*
 Returns the current time in miliseconds.
*/
double getMilitime(){
        struct timeval ret;
        gettimeofday(&ret, NULL);
        return ((ret.tv_sec ) * 1000000u + ret.tv_usec) / 1.e6;
}



void MatrixMultiplicationCPU(TYPE*A, TYPE*B, TYPE*C, int M, int N, int K){
  int i,j,count;
  for(i=0;i<M;++i)
      for(j=0;j<K;++j)
          for(count=0;count<N;++count){
              C[i*K+j] += A[i*N+count] * B[count*K+j];
          }
}

#define err(format, ...) do { fprintf(stderr, format, ##__VA_ARGS__); exit(1); } while (0)

#ifdef __HIPCC__
inline void checkCuda(hipError_t e) {
    if (e != hipSuccess) {
        // cudaGetErrorString() isn't always very helpful. Look up the error
        // number in the cudaError enum in driver_types.h in the CUDA includes
        // directory for a better explanation.
        err("CUDA Error %d: %s\n", e, hipGetErrorString(e));
    }
}

inline void checkLastCudaError() {
    checkCuda(hipGetLastError());
}
#endif

void Allocate(TYPE**A, TYPE**B, TYPE**C, int M, int N, int K){
  (*A) = (*B) = (*C) = NULL;
  (*A) = (TYPE*)malloc(sizeof(TYPE*) * M * N);
  (*B) = (TYPE*)malloc(sizeof(TYPE*) * N * K);
  (*C) = (TYPE*)malloc(sizeof(TYPE*) * M * K);

  assert((*A) != NULL);
  assert((*B) != NULL);
  assert((*C) != NULL);
}
void Fill(TYPE*A, TYPE*B, int M, int N, int K){
  int i;
  for (i=0; i<M*N; i++) A[i]= 1.0;
  for (i=0; i<N*K; i++) B[i]= 2.0;
}
void UnAllocate(TYPE**A, TYPE**B, TYPE**C){
  free((*A));
  free((*B));
  free((*C));
}

void Print2DMatrix(TYPE*A, int M, int N) {
  int i;
  for(i = 0; i < M*N; ++i){
      if((i%M)==0) printf("\n");
      printf("%f ",A[i]);
  }
  printf("\n");
}



__global__ void MatrixMultiplication(TYPE*A_Device, TYPE*B_Device, TYPE*C_Device, int M, int N, int K){


  unsigned int objectIdX = blockDim.x * blockIdx.x + threadIdx.x;
  unsigned int objectIdY = blockDim.y * blockIdx.y + threadIdx.y;
  TYPE sum=0;
  int count;
  if (objectIdX < M && objectIdY < K) {
      for(count=0;count<N;++count){
          sum += A_Device[objectIdX*N+count] * B_Device[count*K+objectIdY];
      }
      C_Device[objectIdX*K+objectIdY]=sum;
  }
}

int main(int argc, char* argv[]){
  if(argc<4){
      printf("Input Error\n");
      return 1;
  }

  int M = atoi(argv[1]);
  int N = atoi(argv[2]);
  int K = atoi(argv[3]);
  
  TYPE*A,*B,*C, *A_Device, *B_Device, *C_Device;
  Allocate(&A,&B,&C,M,N,K);
  Fill(A,B,M,N,K);

  //Allocate in Device
  checkCuda(hipMalloc(&A_Device, M*N*sizeof(TYPE)));
  checkCuda(hipMalloc(&B_Device, N*K*sizeof(TYPE)));
  checkCuda(hipMalloc(&C_Device, M*K*sizeof(TYPE)));

  //Copy to Device
  hipMemcpy(A_Device, A, M*N*sizeof(TYPE), hipMemcpyHostToDevice);
  hipMemcpy(B_Device, B, N*K*sizeof(TYPE), hipMemcpyHostToDevice);

  dim3 dimBlock(16, 16);
  dim3 dimGrid;
  dimGrid.x = (M + dimBlock.x - 1) / dimBlock.x;
  dimGrid.y = (K + dimBlock.y - 1) / dimBlock.y;

  printf("start timing\tm=%d,n=%d,k=%d\n",M,N,K);
  double start_time = getMilitime();

  MatrixMultiplication<<<dimGrid,dimBlock>>>(A_Device,B_Device,C_Device,M,N,K);
  hipDeviceSynchronize(); checkLastCudaError();

  printf("elapsed time (Basic CUDA MatMult): %f sec\n", getMilitime()-start_time);

  //copy to Host
  hipMemcpy(C, C_Device, M*K*sizeof(TYPE), hipMemcpyDeviceToHost);

  //Free in Device
  checkCuda(hipFree(A_Device));
  checkCuda(hipFree(B_Device));
  checkCuda(hipFree(C_Device));

  //verify results
  TYPE*C_CPU = (TYPE*) (TYPE*)malloc(sizeof(TYPE*) * M * K);
  MatrixMultiplicationCPU(A,B,C_CPU,M,N,K);
  int count;
  for(count=0;count<M * K;count++){
     if(C_CPU[count]!=C[count]) {printf("Not Equal, idx: %d!",count);break;}
  }
  free(C_CPU);
  
  //free on Host
  UnAllocate(&A,&B,&C);

  return(0);
}
	.text
	.file	"basicMatrixMult.hip"
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z11getMilitimev
.LCPI0_0:
	.quad	0x412e848000000000              # double 1.0E+6
	.text
	.globl	_Z11getMilitimev
	.type	_Z11getMilitimev,@function
_Z11getMilitimev:                       # @_Z11getMilitimev
	.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
	imulq	$1000000, (%rbx), %rax          # imm = 0xF4240
	addq	8(%rbx), %rax
	cvtsi2sd	%rax, %xmm0
	divsd	.LCPI0_0(%rip), %xmm0
	addq	$16, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_Z11getMilitimev, .Lfunc_end0-_Z11getMilitimev
	.cfi_endproc
                                        # -- End function
	.globl	_Z23MatrixMultiplicationCPUPfS_S_iii # -- Begin function _Z23MatrixMultiplicationCPUPfS_S_iii
	.type	_Z23MatrixMultiplicationCPUPfS_S_iii,@function
_Z23MatrixMultiplicationCPUPfS_S_iii:   # @_Z23MatrixMultiplicationCPUPfS_S_iii
	.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
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rdx, -8(%rsp)                  # 8-byte Spill
	movq	%rsi, -16(%rsp)                 # 8-byte Spill
	movq	%rdi, -24(%rsp)                 # 8-byte Spill
	testl	%ecx, %ecx
	jle	.LBB1_9
# %bb.1:                                # %.preheader24.lr.ph
	movslq	%r9d, %rdi
	movl	%ecx, %ecx
	movl	%edi, %r10d
	movl	%r8d, %r11d
	leaq	(,%rdi,4), %rbx
	xorl	%r14d, %r14d
	xorl	%r15d, %r15d
.LBB1_2:                                # %.preheader24
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_4 Depth 2
                                        #       Child Loop BB1_6 Depth 3
	testl	%r9d, %r9d
	jle	.LBB1_8
# %bb.3:                                # %.preheader.lr.ph
                                        #   in Loop: Header=BB1_2 Depth=1
	movl	%r14d, %eax
	movq	-24(%rsp), %rdx                 # 8-byte Reload
	leaq	(%rdx,%rax,4), %r12
	movq	%r15, %rax
	imulq	%rdi, %rax
	movq	-8(%rsp), %rdx                  # 8-byte Reload
	leaq	(%rdx,%rax,4), %r13
	movq	-16(%rsp), %rsi                 # 8-byte Reload
	xorl	%eax, %eax
.LBB1_4:                                # %.preheader
                                        #   Parent Loop BB1_2 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB1_6 Depth 3
	testl	%r8d, %r8d
	jle	.LBB1_7
# %bb.5:                                # %.lr.ph
                                        #   in Loop: Header=BB1_4 Depth=2
	movss	(%r13,%rax,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	movq	%rsi, %rbp
	xorl	%edx, %edx
.LBB1_6:                                #   Parent Loop BB1_2 Depth=1
                                        #     Parent Loop BB1_4 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movss	(%r12,%rdx,4), %xmm1            # xmm1 = mem[0],zero,zero,zero
	mulss	(%rbp), %xmm1
	addss	%xmm1, %xmm0
	movss	%xmm0, (%r13,%rax,4)
	incq	%rdx
	addq	%rbx, %rbp
	cmpq	%rdx, %r11
	jne	.LBB1_6
.LBB1_7:                                # %._crit_edge
                                        #   in Loop: Header=BB1_4 Depth=2
	incq	%rax
	addq	$4, %rsi
	cmpq	%r10, %rax
	jne	.LBB1_4
.LBB1_8:                                # %._crit_edge27
                                        #   in Loop: Header=BB1_2 Depth=1
	incq	%r15
	addl	%r8d, %r14d
	cmpq	%rcx, %r15
	jne	.LBB1_2
.LBB1_9:                                # %._crit_edge29
	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_end1:
	.size	_Z23MatrixMultiplicationCPUPfS_S_iii, .Lfunc_end1-_Z23MatrixMultiplicationCPUPfS_S_iii
	.cfi_endproc
                                        # -- End function
	.globl	_Z8AllocatePPfS0_S0_iii         # -- Begin function _Z8AllocatePPfS0_S0_iii
	.type	_Z8AllocatePPfS0_S0_iii,@function
_Z8AllocatePPfS0_S0_iii:                # @_Z8AllocatePPfS0_S0_iii
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	pushq	%rax
	.cfi_def_cfa_offset 64
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%r9d, %ebp
	movq	%rdx, %rbx
	movq	%rsi, %r14
	movq	%rdi, %r15
	movslq	%ecx, %r12
	shlq	$3, %r12
	movslq	%r8d, %r13
	movq	%r12, %rdi
	imulq	%r13, %rdi
	callq	malloc
	movq	%rax, (%r15)
	movslq	%ebp, %r15
	imulq	%r15, %r13
	shlq	$3, %r13
	movq	%r13, %rdi
	callq	malloc
	movq	%rax, (%r14)
	imulq	%r15, %r12
	movq	%r12, %rdi
	callq	malloc
	movq	%rax, (%rbx)
	addq	$8, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end2:
	.size	_Z8AllocatePPfS0_S0_iii, .Lfunc_end2-_Z8AllocatePPfS0_S0_iii
	.cfi_endproc
                                        # -- End function
	.globl	_Z4FillPfS_iii                  # -- Begin function _Z4FillPfS_iii
	.type	_Z4FillPfS_iii,@function
_Z4FillPfS_iii:                         # @_Z4FillPfS_iii
	.cfi_startproc
# %bb.0:
	imull	%ecx, %edx
	testl	%edx, %edx
	jle	.LBB3_3
# %bb.1:                                # %.lr.ph.preheader
	movl	%edx, %eax
	xorl	%edx, %edx
.LBB3_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movl	$1065353216, (%rdi,%rdx,4)      # imm = 0x3F800000
	incq	%rdx
	cmpq	%rdx, %rax
	jne	.LBB3_2
.LBB3_3:                                # %.preheader
	imull	%ecx, %r8d
	testl	%r8d, %r8d
	jle	.LBB3_6
# %bb.4:                                # %.lr.ph13.preheader
	movl	%r8d, %eax
	xorl	%ecx, %ecx
.LBB3_5:                                # %.lr.ph13
                                        # =>This Inner Loop Header: Depth=1
	movl	$1073741824, (%rsi,%rcx,4)      # imm = 0x40000000
	incq	%rcx
	cmpq	%rcx, %rax
	jne	.LBB3_5
.LBB3_6:                                # %._crit_edge
	retq
.Lfunc_end3:
	.size	_Z4FillPfS_iii, .Lfunc_end3-_Z4FillPfS_iii
	.cfi_endproc
                                        # -- End function
	.globl	_Z10UnAllocatePPfS0_S0_         # -- Begin function _Z10UnAllocatePPfS0_S0_
	.type	_Z10UnAllocatePPfS0_S0_,@function
_Z10UnAllocatePPfS0_S0_:                # @_Z10UnAllocatePPfS0_S0_
	.cfi_startproc
# %bb.0:
	pushq	%r14
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	pushq	%rax
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -24
	.cfi_offset %r14, -16
	movq	%rdx, %rbx
	movq	%rsi, %r14
	movq	(%rdi), %rdi
	callq	free
	movq	(%r14), %rdi
	callq	free
	movq	(%rbx), %rdi
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	jmp	free                            # TAILCALL
.Lfunc_end4:
	.size	_Z10UnAllocatePPfS0_S0_, .Lfunc_end4-_Z10UnAllocatePPfS0_S0_
	.cfi_endproc
                                        # -- End function
	.globl	_Z13Print2DMatrixPfii           # -- Begin function _Z13Print2DMatrixPfii
	.type	_Z13Print2DMatrixPfii,@function
_Z13Print2DMatrixPfii:                  # @_Z13Print2DMatrixPfii
	.cfi_startproc
# %bb.0:
	imull	%esi, %edx
	testl	%edx, %edx
	jle	.LBB5_6
# %bb.1:                                # %.lr.ph.preheader
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r12
	.cfi_def_cfa_offset 32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	pushq	%rax
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -40
	.cfi_offset %r12, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movl	%esi, %ebx
	movq	%rdi, %r14
	movl	%edx, %r12d
	xorl	%r15d, %r15d
.LBB5_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movl	%r15d, %eax
	cltd
	idivl	%ebx
	testl	%edx, %edx
	jne	.LBB5_4
# %bb.3:                                #   in Loop: Header=BB5_2 Depth=1
	movl	$10, %edi
	callq	putchar@PLT
.LBB5_4:                                #   in Loop: Header=BB5_2 Depth=1
	xorps	%xmm0, %xmm0
	cvtss2sd	(%r14,%r15,4), %xmm0
	movl	$.L.str.1, %edi
	movb	$1, %al
	callq	printf
	incq	%r15
	cmpq	%r15, %r12
	jne	.LBB5_2
# %bb.5:
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	.cfi_restore %rbx
	.cfi_restore %r12
	.cfi_restore %r14
	.cfi_restore %r15
.LBB5_6:                                # %._crit_edge
	movl	$10, %edi
	jmp	putchar@PLT                     # TAILCALL
.Lfunc_end5:
	.size	_Z13Print2DMatrixPfii, .Lfunc_end5-_Z13Print2DMatrixPfii
	.cfi_endproc
                                        # -- End function
	.globl	_Z35__device_stub__MatrixMultiplicationPfS_S_iii # -- Begin function _Z35__device_stub__MatrixMultiplicationPfS_S_iii
	.type	_Z35__device_stub__MatrixMultiplicationPfS_S_iii,@function
_Z35__device_stub__MatrixMultiplicationPfS_S_iii: # @_Z35__device_stub__MatrixMultiplicationPfS_S_iii
	.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	$144, %rsp
	.cfi_def_cfa_offset 192
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	56(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	48(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	40(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	20(%rsp), %rdx
	movl	%ecx, (%rdx)
	leaq	16(%rsp), %rcx
	movl	%r8d, (%rcx)
	leaq	12(%rsp), %r8
	movl	%r9d, (%r8)
	leaq	96(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	movq	%rcx, 32(%rbx)
	movq	%r8, 40(%rbx)
	leaq	80(%rsp), %r14
	leaq	64(%rsp), %r15
	leaq	32(%rsp), %r12
	leaq	24(%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	$_Z20MatrixMultiplicationPfS_S_iii, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$160, %rsp
	.cfi_adjust_cfa_offset -160
	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_end6:
	.size	_Z35__device_stub__MatrixMultiplicationPfS_S_iii, .Lfunc_end6-_Z35__device_stub__MatrixMultiplicationPfS_S_iii
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI7_0:
	.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	$120, %rsp
	.cfi_def_cfa_offset 176
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	cmpl	$3, %edi
	jg	.LBB7_2
# %bb.1:
	movl	$.Lstr, %edi
	callq	puts@PLT
	movl	$1, %eax
	jmp	.LBB7_29
.LBB7_2:
	movq	%rsi, %rbx
	movq	8(%rsi), %rdi
	callq	atoi
	movl	%eax, %r15d
	movq	16(%rbx), %rdi
	callq	atoi
	movl	%eax, %ebp
	movq	24(%rbx), %rdi
	callq	atoi
	movl	%eax, %r12d
	leaq	96(%rsp), %rbx
	leaq	88(%rsp), %rsi
	leaq	80(%rsp), %rdx
	movq	%rbx, %rdi
	movl	%r15d, %ecx
	movl	%ebp, %r8d
	movl	%eax, %r9d
	callq	_Z8AllocatePPfS0_S0_iii
	movq	(%rbx), %rbx
	movl	%ebp, %eax
	imull	%r15d, %eax
	testl	%eax, %eax
	jle	.LBB7_5
# %bb.3:                                # %.lr.ph.preheader.i
	movl	%eax, %ecx
	xorl	%edx, %edx
.LBB7_4:                                # %.lr.ph.i
                                        # =>This Inner Loop Header: Depth=1
	movl	$1065353216, (%rbx,%rdx,4)      # imm = 0x3F800000
	incq	%rdx
	cmpq	%rdx, %rcx
	jne	.LBB7_4
.LBB7_5:                                # %.preheader.i
	movq	88(%rsp), %r14
	movq	%r12, 16(%rsp)                  # 8-byte Spill
                                        # kill: def $r12d killed $r12d killed $r12
	movl	%ebp, 12(%rsp)                  # 4-byte Spill
	imull	%ebp, %r12d
	testl	%r12d, %r12d
	jle	.LBB7_8
# %bb.6:                                # %.lr.ph13.preheader.i
	movl	%r12d, %ecx
	xorl	%edx, %edx
.LBB7_7:                                # %.lr.ph13.i
                                        # =>This Inner Loop Header: Depth=1
	movl	$1073741824, (%r14,%rdx,4)      # imm = 0x40000000
	incq	%rdx
	cmpq	%rdx, %rcx
	jne	.LBB7_7
.LBB7_8:                                # %_Z4FillPfS_iii.exit
	movq	%r15, 24(%rsp)                  # 8-byte Spill
	movslq	%eax, %rbp
	shlq	$2, %rbp
	leaq	48(%rsp), %rdi
	movq	%rbp, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB7_9
# %bb.10:                               # %_Z9checkCuda10hipError_t.exit
	movslq	%r12d, %r15
	shlq	$2, %r15
	leaq	40(%rsp), %rdi
	movq	%r15, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB7_11
# %bb.12:                               # %_Z9checkCuda10hipError_t.exit54
	movq	16(%rsp), %r12                  # 8-byte Reload
	movl	%r12d, %eax
	movq	24(%rsp), %r13                  # 8-byte Reload
	imull	%r13d, %eax
	movl	%eax, 60(%rsp)                  # 4-byte Spill
	movslq	%eax, %rsi
	shlq	$2, %rsi
	leaq	32(%rsp), %rdi
	movq	%rsi, 72(%rsp)                  # 8-byte Spill
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB7_13
# %bb.16:                               # %_Z9checkCuda10hipError_t.exit56
	movq	48(%rsp), %rdi
	movq	%rbx, %rsi
	movq	%rbp, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	40(%rsp), %rdi
	movq	%r14, %rsi
	movq	%r15, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	leal	15(%r13), %eax
	shrl	$4, %eax
	leal	15(%r12), %r15d
	shrl	$4, %r15d
	shlq	$32, %r15
	orq	%rax, %r15
	movl	$.L.str.3, %edi
	movl	%r13d, %esi
	movl	12(%rsp), %ebp                  # 4-byte Reload
	movl	%ebp, %edx
	movl	%r12d, %ecx
	xorl	%eax, %eax
	callq	printf
	leaq	104(%rsp), %r12
	movq	%r12, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	imulq	$1000000, (%r12), %r13          # imm = 0xF4240
	addq	8(%r12), %r13
	movabsq	$68719476752, %rdx              # imm = 0x1000000010
	movq	%r15, %rdi
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB7_18
# %bb.17:
	movq	48(%rsp), %rdi
	movq	40(%rsp), %rsi
	movq	32(%rsp), %rdx
	movq	24(%rsp), %rcx                  # 8-byte Reload
                                        # kill: def $ecx killed $ecx killed $rcx
	movl	%ebp, %r8d
	movq	16(%rsp), %r9                   # 8-byte Reload
                                        # kill: def $r9d killed $r9d killed $r9
	callq	_Z35__device_stub__MatrixMultiplicationPfS_S_iii
.LBB7_18:
	callq	hipDeviceSynchronize
	callq	hipGetLastError
	testl	%eax, %eax
	jne	.LBB7_19
# %bb.20:                               # %_Z18checkLastCudaErrorv.exit
	cvtsi2sd	%r13, %xmm0
	divsd	.LCPI7_0(%rip), %xmm0
	movsd	%xmm0, 64(%rsp)                 # 8-byte Spill
	leaq	104(%rsp), %r15
	movq	%r15, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	imulq	$1000000, (%r15), %rax          # imm = 0xF4240
	addq	8(%r15), %rax
	xorps	%xmm0, %xmm0
	cvtsi2sd	%rax, %xmm0
	divsd	.LCPI7_0(%rip), %xmm0
	subsd	64(%rsp), %xmm0                 # 8-byte Folded Reload
	movl	$.L.str.4, %edi
	movb	$1, %al
	callq	printf
	movq	80(%rsp), %rbp
	movq	32(%rsp), %rsi
	movq	%rbp, %rdi
	movq	72(%rsp), %rdx                  # 8-byte Reload
	movl	$2, %ecx
	callq	hipMemcpy
	movq	48(%rsp), %rdi
	callq	hipFree
	testl	%eax, %eax
	jne	.LBB7_9
# %bb.21:                               # %_Z9checkCuda10hipError_t.exit58
	movq	40(%rsp), %rdi
	callq	hipFree
	testl	%eax, %eax
	movq	24(%rsp), %r12                  # 8-byte Reload
	jne	.LBB7_9
# %bb.22:                               # %_Z9checkCuda10hipError_t.exit60
	movq	32(%rsp), %rdi
	callq	hipFree
	testl	%eax, %eax
	jne	.LBB7_9
# %bb.23:                               # %_Z9checkCuda10hipError_t.exit62
	movslq	%r12d, %rax
	movq	16(%rsp), %r15                  # 8-byte Reload
	movslq	%r15d, %rdi
	imulq	%rax, %rdi
	shlq	$3, %rdi
	callq	malloc
	movq	%r12, %rcx
	movq	%rax, %r13
	movq	%rbx, %rdi
	movq	%r14, %rsi
	movq	%rax, %rdx
                                        # kill: def $ecx killed $ecx killed $rcx
	movl	12(%rsp), %r8d                  # 4-byte Reload
	movl	%r15d, %r9d
	callq	_Z23MatrixMultiplicationCPUPfS_S_iii
	movl	60(%rsp), %eax                  # 4-byte Reload
	testl	%eax, %eax
	jle	.LBB7_28
# %bb.24:                               # %.lr.ph.preheader
	movl	%eax, %eax
	xorl	%esi, %esi
.LBB7_25:                               # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movss	(%r13,%rsi,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	ucomiss	(%rbp,%rsi,4), %xmm0
	jne	.LBB7_26
	jp	.LBB7_26
# %bb.27:                               #   in Loop: Header=BB7_25 Depth=1
	incq	%rsi
	cmpq	%rsi, %rax
	jne	.LBB7_25
	jmp	.LBB7_28
.LBB7_26:
	movl	$.L.str.5, %edi
                                        # kill: def $esi killed $esi killed $rsi
	xorl	%eax, %eax
	callq	printf
.LBB7_28:                               # %.loopexit
	movq	%r13, %rdi
	callq	free
	movq	%rbx, %rdi
	callq	free
	movq	%r14, %rdi
	callq	free
	movq	%rbp, %rdi
	callq	free
	xorl	%eax, %eax
.LBB7_29:
	addq	$120, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.LBB7_9:
	.cfi_def_cfa_offset 176
	movl	%eax, %r15d
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.6, %esi
	movq	%rbx, %rdi
	movl	%r15d, %edx
	jmp	.LBB7_15
.LBB7_11:
	movl	%eax, %r13d
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.6, %esi
	movq	%rbx, %rdi
	movl	%r13d, %edx
	jmp	.LBB7_15
.LBB7_13:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	movl	%eax, %ebp
	jmp	.LBB7_14
.LBB7_19:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
.LBB7_14:
	callq	hipGetErrorString
	movl	$.L.str.6, %esi
	movq	%rbx, %rdi
	movl	%ebp, %edx
.LBB7_15:
	movq	%rax, %rcx
	xorl	%eax, %eax
	callq	fprintf
	movl	$1, %edi
	callq	exit
.Lfunc_end7:
	.size	main, .Lfunc_end7-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	.LBB8_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB8_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z20MatrixMultiplicationPfS_S_iii, %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_end8:
	.size	__hip_module_ctor, .Lfunc_end8-__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	.LBB9_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
.LBB9_2:
	retq
.Lfunc_end9:
	.size	__hip_module_dtor, .Lfunc_end9-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	.L.str.1,@object                # @.str.1
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.1:
	.asciz	"%f "
	.size	.L.str.1, 4

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

	.type	.L.str.3,@object                # @.str.3
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.3:
	.asciz	"start timing\tm=%d,n=%d,k=%d\n"
	.size	.L.str.3, 29

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"elapsed time (Basic CUDA MatMult): %f sec\n"
	.size	.L.str.4, 43

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"Not Equal, idx: %d!"
	.size	.L.str.5, 20

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"CUDA Error %d: %s\n"
	.size	.L.str.6, 19

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z20MatrixMultiplicationPfS_S_iii"
	.size	.L__unnamed_1, 34

	.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	"Input Error"
	.size	.Lstr, 12

	.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 _Z35__device_stub__MatrixMultiplicationPfS_S_iii
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z20MatrixMultiplicationPfS_S_iii
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z20MatrixMultiplicationPfS_S_iii ; -- Begin function _Z20MatrixMultiplicationPfS_S_iii
	.globl	_Z20MatrixMultiplicationPfS_S_iii
	.p2align	8
	.type	_Z20MatrixMultiplicationPfS_S_iii,@function
_Z20MatrixMultiplicationPfS_S_iii:      ; @_Z20MatrixMultiplicationPfS_S_iii
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x34
	s_load_b128 s[4:7], 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_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_cmp_gt_u32_e32 vcc_lo, s4, v0
	v_cmp_gt_u32_e64 s2, s6, 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_6
; %bb.1:                                ; %.preheader
	s_clause 0x1
	s_load_b128 s[8:11], s[0:1], 0x0
	s_load_b64 s[0:1], s[0:1], 0x10
	s_cmp_lt_i32 s5, 1
	s_cbranch_scc1 .LBB0_4
; %bb.2:                                ; %.lr.ph
	v_dual_mov_b32 v3, 0 :: v_dual_mov_b32 v4, v1
	v_mul_lo_u32 v2, v0, s5
	s_delay_alu instid0(VALU_DEP_2)
	v_mov_b32_e32 v6, v3
.LBB0_3:                                ; =>This Inner Loop Header: Depth=1
	v_mov_b32_e32 v5, v3
	s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_2) | instid1(SALU_CYCLE_1)
	v_lshlrev_b64 v[7:8], 2, v[2:3]
	v_add_nc_u32_e32 v2, 1, v2
	s_add_i32 s5, s5, -1
	s_cmp_lg_u32 s5, 0
	v_lshlrev_b64 v[9:10], 2, v[4:5]
	s_waitcnt lgkmcnt(0)
	v_add_co_u32 v7, vcc_lo, s8, v7
	v_add_co_ci_u32_e32 v8, vcc_lo, s9, v8, vcc_lo
	v_add_nc_u32_e32 v4, s6, v4
	s_delay_alu instid0(VALU_DEP_4)
	v_add_co_u32 v9, vcc_lo, s10, v9
	v_add_co_ci_u32_e32 v10, vcc_lo, s11, v10, vcc_lo
	global_load_b32 v5, v[7:8], off
	global_load_b32 v7, v[9:10], off
	s_waitcnt vmcnt(0)
	v_fmac_f32_e32 v6, v5, v7
	s_cbranch_scc1 .LBB0_3
	s_branch .LBB0_5
.LBB0_4:
	v_mov_b32_e32 v6, 0
.LBB0_5:                                ; %._crit_edge
	v_mad_u64_u32 v[2:3], null, v0, s6, v[1:2]
	v_mov_b32_e32 v3, 0
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[0:1], 2, v[2:3]
	s_waitcnt lgkmcnt(0)
	v_add_co_u32 v0, vcc_lo, s0, v0
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v1, vcc_lo, s1, v1, vcc_lo
	global_store_b32 v[0:1], v6, off
.LBB0_6:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z20MatrixMultiplicationPfS_S_iii
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 296
		.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 11
		.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	_Z20MatrixMultiplicationPfS_S_iii, .Lfunc_end0-_Z20MatrixMultiplicationPfS_S_iii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 328
; NumSgprs: 18
; NumVgprs: 11
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 11
; 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:     by_value
      - .offset:         40
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         44
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         48
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         52
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         54
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         56
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         58
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         60
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         62
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         88
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         96
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         104
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 296
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z20MatrixMultiplicationPfS_S_iii
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z20MatrixMultiplicationPfS_S_iii.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     11
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
