#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <assert.h>


// CUDA runtime
#include <cuda_runtime.h>

typedef unsigned int uint;

using namespace std;

// C[m,k] = A[m,n] * B[n,k]
// m rows, k columns

// C[m,k] is stored as such
// i[m=1, k=1], i[m=1, k=2],
// i[m=2, k=1], i[m=2, k=2], and so on


void print_matrix(float *matrix, uint size) {
  uint how_many_elements = 25;

  if (size < 25) {
    how_many_elements = size;
  }

  for (uint i = 0; i < how_many_elements; i++) {
    printf(" %f", matrix[i]);
  }

  printf("\n");
}

void host_matmul(float *a, float *b, float *c, uint m, uint n, uint k) {
  // Go row by row
  for (uint i = 0; i < m; i++) {
    // Go column by column
    for (uint j = 0; j < k; j++) {
      // Go through the cells of each dest matrix
      for (uint t = 0; t < n; t++) {
	// c (i, j) += a(i, t) * b(t, j)
	c[i * k + j] += a[i * n + t] * b[t * k + j];
      }
    }
  }
}

__global__ void kernel_mathmul(float * a, float * b, float * c, uint k, uint n)
{
	// This does not work yet when the columns count of the first matrix is > 256 or whatever...
    uint i = blockIdx.x * blockDim.x + threadIdx.x;

    if (i < k) {
      /*
      printf("[%d] ", i);

	  if (i == 0) {
		  printf("a now is: ");
	  	  for (uint j = 0; j< n; j++) {
		  	  printf("%f ", a[j]);
	  	  }
	  	  printf("\n");
	  }
	  */
      c[i] = 0; // reset it first, remember it doesn't get cleared everytime
      
      for (uint t=0; t<n; t++) {
    	  	  c[i] += a[t] * b[i + t*k];
      }
    }

}

void dev_matmul(float *a, float *b, float *c, uint m, uint n, uint k) {
    int threads_per_block = 256;
    int blocks =  ceil((float)(m) / threads_per_block);
    // printf("Number of blocks: [%d]\n", blocks);
    
    float * dev_a_onerow;
	cudaMalloc(&dev_a_onerow, n*sizeof(float));
    
    float * dev_c_onerow;
    cudaMalloc(&dev_c_onerow, k*sizeof(float));
    
    float * dev_b;
    cudaMalloc(&dev_b, m*n*sizeof(float));
    
    cudaMemcpy(dev_b, b, m*n*sizeof(float), cudaMemcpyHostToDevice);
    
    // Compute the rows of resulting matrix one line by one line.
    for (uint i = 0; i < m; i++) {
      // copy one row of the a matrix to the device
      cudaMemcpy(dev_a_onerow, a + (i * n), n * sizeof(float), cudaMemcpyHostToDevice);

      //printf("Calling kernel mathmul\n");
      kernel_mathmul <<<blocks,threads_per_block>>> (dev_a_onerow, dev_b, dev_c_onerow, k, n);
      cudaThreadSynchronize();

      // copy the resulting row back
      cudaMemcpy(c + i * k, dev_c_onerow, k * sizeof(float), cudaMemcpyDeviceToHost);

      //print_matrix(c, m*k);
    }
    
    cudaFree(dev_a_onerow);
    cudaFree(dev_b);
    cudaFree(dev_c_onerow);
}

void init_matrix(float *matrix, uint size) {
  for (uint i = 0; i < size; i++) {
    matrix[i] = ((float) rand()) / RAND_MAX;
    //matrix[i] = 1.0;
  }
}

void clear_matrix(float *matrix, uint size) {
  for (uint i = 0; i < size; i++) {
    matrix[i] = 0.0;
  }
}


void verify_matrix(const float *matrix1, const float *matrix2, const uint size) {
  for (uint i = 0; i < size; i++) {
    assert(matrix1[i] == matrix2[i]);
  }
}



int main() {
  uint m = 200;
  uint n = 200;
  uint k = 200;
  
  srand( time (NULL) );
  
  float * a_matrix = new float[m*n];
  float * b_matrix = new float[n*k];
  float * c_matrix = new float[m*k];
  float * c_dev_matrix = new float[m*k];

  clock_t start;
  clock_t end;
  /*
  printf("Initializing matrices with sample numbers\n", 2, 2);
  a_matrix[0] = 1; a_matrix[2] = -2; a_matrix[4] = 3; a_matrix[5] = -1;
  b_matrix[1] = 3; b_matrix[2] = -2; b_matrix[3] = -1; b_matrix[5] = 4;
  
  printf("Here comes the first 25 elements of a, b, c before:\n");
  print_matrix(a_matrix, m*n);
  print_matrix(b_matrix, n*k);
  print_matrix(c_matrix, m*k);
  
  printf("Do host-calculation:\n");
  host_matmul(a_matrix, b_matrix, c_matrix, m, n, k);
  
  printf("Here comes the first 25 elements of a, b, c after:\n");
  print_matrix(a_matrix, m*n);
  print_matrix(b_matrix, n*k);
  print_matrix(c_matrix, m*k);
  
  printf("Asserting that host-calculation is correct: ");
  assert(c_matrix[0] == 0);
  assert(c_matrix[1] == -5);
  assert(c_matrix[2] == -6);
  assert(c_matrix[3] == -7);
  printf("It is.\n");
  ////////////////////////////////////////////////
  */
  printf("Intialize random matrices: ");
  init_matrix(a_matrix, m*n);
  init_matrix(b_matrix, n*k);
  printf("Done. \n");
  print_matrix(a_matrix, m*n);
  print_matrix(b_matrix, n*k);
  print_matrix(c_matrix, m*k);
  ///////////////////////////////////////////////

  printf("Do host-calculation: ");
  clear_matrix(c_matrix, m*k);
  start = clock();
  host_matmul(a_matrix, b_matrix, c_matrix, m, n, k);
  end = clock();
  printf("Took %d clock cycles\n", end - start);

  printf("Here comes the first 25 elements of c:\n");
  print_matrix(c_matrix, m*k);

  printf("Do device-calculation: ");
  start = clock();
  dev_matmul(a_matrix, b_matrix, c_dev_matrix, m, n, k);
  end = clock();
  printf("Took %d clock cycles\n", end - start);

  printf("Here comes the first 25 elements of c on device:\n");
  print_matrix(c_dev_matrix, m*k);
  printf("Checking if GPU result is correct: ");
  verify_matrix(c_matrix, c_dev_matrix, m*k);
  printf("It is.");

  delete a_matrix;
  delete b_matrix;
  delete c_matrix;
  delete c_dev_matrix;
}

	.file	"tmpxft_002545e4_00000000-6_main.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2036:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2036:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	" %f"
.LC1:
	.string	"\n"
	.text
	.globl	_Z12print_matrixPfj
	.type	_Z12print_matrixPfj, @function
_Z12print_matrixPfj:
.LFB2027:
	.cfi_startproc
	endbr64
	movl	$25, %eax
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	leaq	.LC0(%rip), %r12
	cmpl	%eax, %esi
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	cmova	%eax, %esi
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movq	%rdi, %rbx
	movl	%esi, %esi
	leaq	(%rdi,%rsi,4), %rbp
.L3:
	cmpq	%rbp, %rbx
	je	.L7
	movq	%r12, %rsi
	movl	$2, %edi
	movb	$1, %al
	cvtss2sd	(%rbx), %xmm0
	call	__printf_chk@PLT
	addq	$4, %rbx
	jmp	.L3
.L7:
	popq	%rbx
	.cfi_def_cfa_offset 24
	leaq	.LC1(%rip), %rsi
	popq	%rbp
	.cfi_def_cfa_offset 16
	movl	$2, %edi
	xorl	%eax, %eax
	popq	%r12
	.cfi_def_cfa_offset 8
	jmp	__printf_chk@PLT
	.cfi_endproc
.LFE2027:
	.size	_Z12print_matrixPfj, .-_Z12print_matrixPfj
	.globl	_Z11host_matmulPfS_S_jjj
	.type	_Z11host_matmulPfS_S_jjj, @function
_Z11host_matmulPfS_S_jjj:
.LFB2028:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movq	%rdi, %r10
	movq	%rsi, %r11
	xorl	%edi, %edi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	xorl	%esi, %esi
	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
	xorl	%ebp, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%rdx, %rbx
.L9:
	cmpl	%ecx, %esi
	je	.L16
	xorl	%eax, %eax
.L13:
	cmpl	%r9d, %eax
	je	.L11
	leal	(%rax,%rdi), %edx
	movl	%eax, %r12d
	leaq	(%rbx,%rdx,4), %r13
	xorl	%edx, %edx
.L12:
	cmpl	%r8d, %edx
	je	.L17
	leal	(%rdx,%rbp), %r15d
	movl	%r12d, %r14d
	incl	%edx
	addl	%r9d, %r12d
	movss	(%r10,%r15,4), %xmm0
	mulss	(%r11,%r14,4), %xmm0
	addss	0(%r13), %xmm0
	movss	%xmm0, 0(%r13)
	jmp	.L12
.L17:
	incl	%eax
	jmp	.L13
.L11:
	incl	%esi
	addl	%r9d, %edi
	addl	%r8d, %ebp
	jmp	.L9
.L16:
	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	_Z11host_matmulPfS_S_jjj, .-_Z11host_matmulPfS_S_jjj
	.globl	_Z11init_matrixPfj
	.type	_Z11init_matrixPfj, @function
_Z11init_matrixPfj:
.LFB2030:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movl	%esi, %esi
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	leaq	(%rdi,%rsi,4), %rbp
	movq	%rdi, %rbx
	pushq	%rdx
	.cfi_def_cfa_offset 32
.L19:
	cmpq	%rbp, %rbx
	je	.L22
	call	rand@PLT
	addq	$4, %rbx
	cvtsi2ssl	%eax, %xmm0
	mulss	.LC2(%rip), %xmm0
	movss	%xmm0, -4(%rbx)
	jmp	.L19
.L22:
	popq	%rax
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2030:
	.size	_Z11init_matrixPfj, .-_Z11init_matrixPfj
	.globl	_Z12clear_matrixPfj
	.type	_Z12clear_matrixPfj, @function
_Z12clear_matrixPfj:
.LFB2031:
	.cfi_startproc
	endbr64
	xorl	%eax, %eax
.L24:
	cmpl	%esi, %eax
	jnb	.L26
	movl	$0x00000000, (%rdi,%rax,4)
	incq	%rax
	jmp	.L24
.L26:
	ret
	.cfi_endproc
.LFE2031:
	.size	_Z12clear_matrixPfj, .-_Z12clear_matrixPfj
	.globl	_Z13verify_matrixPKfS0_j
	.type	_Z13verify_matrixPKfS0_j, @function
_Z13verify_matrixPKfS0_j:
.LFB2032:
	.cfi_startproc
	endbr64
	ret
	.cfi_endproc
.LFE2032:
	.size	_Z13verify_matrixPKfS0_j, .-_Z13verify_matrixPKfS0_j
	.globl	_Z40__device_stub__Z14kernel_mathmulPfS_S_jjPfS_S_jj
	.type	_Z40__device_stub__Z14kernel_mathmulPfS_S_jjPfS_S_jj, @function
_Z40__device_stub__Z14kernel_mathmulPfS_S_jjPfS_S_jj:
.LFB2058:
	.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	.L28
	pushq	40(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z14kernel_mathmulPfS_S_jj(%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
.L28:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L30
	call	__stack_chk_fail@PLT
.L30:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2058:
	.size	_Z40__device_stub__Z14kernel_mathmulPfS_S_jjPfS_S_jj, .-_Z40__device_stub__Z14kernel_mathmulPfS_S_jjPfS_S_jj
	.globl	_Z14kernel_mathmulPfS_S_jj
	.type	_Z14kernel_mathmulPfS_S_jj, @function
_Z14kernel_mathmulPfS_S_jj:
.LFB2059:
	.cfi_startproc
	endbr64
	jmp	_Z40__device_stub__Z14kernel_mathmulPfS_S_jjPfS_S_jj
	.cfi_endproc
.LFE2059:
	.size	_Z14kernel_mathmulPfS_S_jj, .-_Z14kernel_mathmulPfS_S_jj
	.globl	_Z10dev_matmulPfS_S_jjj
	.type	_Z10dev_matmulPfS_S_jjj, @function
_Z10dev_matmulPfS_S_jjj:
.LFB2029:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	%ecx, %r15d
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	cvtsi2ssq	%r15, %xmm0
	xorl	%r14d, %r14d
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%r15, %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movq	%rsi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movl	%r9d, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movl	%r8d, %ebx
	imull	%ebx, %r13d
	subq	$120, %rsp
	.cfi_def_cfa_offset 176
	mulss	.LC4(%rip), %xmm0
	movq	%rdx, 40(%rsp)
	salq	$2, %r13
	movq	%rdi, 32(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	call	ceilf@PLT
	leaq	56(%rsp), %rdi
	cvttss2sil	%xmm0, %eax
	movl	%eax, 28(%rsp)
	movl	%ebx, %eax
	salq	$2, %rax
	movq	%rax, %rsi
	movq	%rax, 8(%rsp)
	call	cudaMalloc@PLT
	movl	%ebp, %eax
	leaq	64(%rsp), %rdi
	salq	$2, %rax
	movq	%rax, %rsi
	movq	%rax, 16(%rsp)
	call	cudaMalloc@PLT
	movq	%r13, %rsi
	leaq	72(%rsp), %rdi
	call	cudaMalloc@PLT
	movq	72(%rsp), %rdi
	movq	%r13, %rdx
	movq	%r12, %rsi
	movl	$1, %ecx
	xorl	%r13d, %r13d
	xorl	%r12d, %r12d
	call	cudaMemcpy@PLT
.L36:
	movq	56(%rsp), %rdi
	cmpq	%r15, %r12
	je	.L41
	movq	32(%rsp), %rdx
	movl	%r14d, %eax
	movl	$1, %ecx
	leaq	(%rdx,%rax,4), %rsi
	movq	8(%rsp), %rdx
	call	cudaMemcpy@PLT
	movl	28(%rsp), %eax
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	$16777217, %edx
	movl	$1, %ecx
	movl	%eax, 80(%rsp)
	salq	$8, %rdx
	movabsq	$4294967297, %rax
	movq	%rax, 84(%rsp)
	movq	80(%rsp), %rdi
	movl	88(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L37
	movq	64(%rsp), %rdx
	movq	72(%rsp), %rsi
	movl	%ebx, %r8d
	movl	%ebp, %ecx
	movq	56(%rsp), %rdi
	call	_Z40__device_stub__Z14kernel_mathmulPfS_S_jjPfS_S_jj
.L37:
	call	cudaThreadSynchronize@PLT
	movq	40(%rsp), %rcx
	movl	%r13d, %eax
	incq	%r12
	movq	16(%rsp), %rdx
	movq	64(%rsp), %rsi
	addl	%ebp, %r13d
	addl	%ebx, %r14d
	leaq	(%rcx,%rax,4), %rdi
	movl	$2, %ecx
	call	cudaMemcpy@PLT
	jmp	.L36
.L41:
	call	cudaFree@PLT
	movq	72(%rsp), %rdi
	call	cudaFree@PLT
	movq	64(%rsp), %rdi
	call	cudaFree@PLT
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L39
	call	__stack_chk_fail@PLT
.L39:
	addq	$120, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2029:
	.size	_Z10dev_matmulPfS_S_jjj, .-_Z10dev_matmulPfS_S_jjj
	.section	.rodata.str1.1
.LC5:
	.string	"Intialize random matrices: "
.LC6:
	.string	"Done. \n"
.LC7:
	.string	"Do host-calculation: "
.LC8:
	.string	"Took %d clock cycles\n"
.LC9:
	.string	"Here comes the first 25 elements of c:\n"
.LC10:
	.string	"Do device-calculation: "
.LC11:
	.string	"Here comes the first 25 elements of c on device:\n"
.LC12:
	.string	"Checking if GPU result is correct: "
.LC13:
	.string	"It is."
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2033:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	xorl	%edi, %edi
	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
	pushq	%rax
	.cfi_def_cfa_offset 64
	call	time@PLT
	movl	%eax, %edi
	call	srand@PLT
	movl	$160000, %edi
	call	_Znam@PLT
	movl	$160000, %edi
	movq	%rax, %r12
	call	_Znam@PLT
	movl	$160000, %edi
	movq	%rax, %rbp
	call	_Znam@PLT
	movl	$160000, %edi
	movq	%rax, %rbx
	call	_Znam@PLT
	leaq	.LC5(%rip), %rsi
	movl	$2, %edi
	movq	%rax, %r13
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	%r12, %rdi
	movl	$40000, %esi
	call	_Z11init_matrixPfj
	movq	%rbp, %rdi
	movl	$40000, %esi
	call	_Z11init_matrixPfj
	leaq	.LC6(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	%r12, %rdi
	movl	$40000, %esi
	call	_Z12print_matrixPfj
	movq	%rbp, %rdi
	movl	$40000, %esi
	call	_Z12print_matrixPfj
	movq	%rbx, %rdi
	movl	$40000, %esi
	call	_Z12print_matrixPfj
	leaq	.LC7(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	%rbx, %rdi
	movl	$40000, %esi
	call	_Z12clear_matrixPfj
	call	clock@PLT
	movl	$200, %ecx
	movq	%rbx, %rdx
	movq	%rbp, %rsi
	movl	$200, %r9d
	movl	$200, %r8d
	movq	%r12, %rdi
	movq	%rax, %r14
	call	_Z11host_matmulPfS_S_jjj
	call	clock@PLT
	movl	$2, %edi
	subq	%r14, %rax
	leaq	.LC8(%rip), %r14
	movq	%rax, %rdx
	movq	%r14, %rsi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	.LC9(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	%rbx, %rdi
	movl	$40000, %esi
	call	_Z12print_matrixPfj
	leaq	.LC10(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	call	clock@PLT
	movl	$200, %ecx
	movq	%r13, %rdx
	movq	%rbp, %rsi
	movl	$200, %r9d
	movl	$200, %r8d
	movq	%r12, %rdi
	movq	%rax, %r15
	call	_Z10dev_matmulPfS_S_jjj
	call	clock@PLT
	movq	%r14, %rsi
	movl	$2, %edi
	subq	%r15, %rax
	movq	%rax, %rdx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	.LC11(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	%r13, %rdi
	movl	$40000, %esi
	call	_Z12print_matrixPfj
	leaq	.LC12(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	.LC13(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	%r12, %rdi
	movl	$4, %esi
	call	_ZdlPvm@PLT
	movq	%rbp, %rdi
	movl	$4, %esi
	call	_ZdlPvm@PLT
	movq	%rbx, %rdi
	movl	$4, %esi
	call	_ZdlPvm@PLT
	movq	%r13, %rdi
	movl	$4, %esi
	call	_ZdlPvm@PLT
	popq	%rdx
	.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
.LFE2033:
	.size	main, .-main
	.section	.rodata.str1.1
.LC14:
	.string	"_Z14kernel_mathmulPfS_S_jj"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2061:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	pushq	$0
	.cfi_def_cfa_offset 24
	xorl	%r9d, %r9d
	orl	$-1, %r8d
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC14(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z14kernel_mathmulPfS_S_jj(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFunction@PLT
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rdx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE2061:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.section	.rodata.cst4,"aM",@progbits,4
	.align 4
.LC2:
	.long	805306368
	.align 4
.LC4:
	.long	998244352
	.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 <time.h>
#include <math.h>
#include <assert.h>


// CUDA runtime
#include <hip/hip_runtime.h>

typedef unsigned int uint;

using namespace std;

// C[m,k] = A[m,n] * B[n,k]
// m rows, k columns

// C[m,k] is stored as such
// i[m=1, k=1], i[m=1, k=2],
// i[m=2, k=1], i[m=2, k=2], and so on


void print_matrix(float *matrix, uint size) {
  uint how_many_elements = 25;

  if (size < 25) {
    how_many_elements = size;
  }

  for (uint i = 0; i < how_many_elements; i++) {
    printf(" %f", matrix[i]);
  }

  printf("\n");
}

void host_matmul(float *a, float *b, float *c, uint m, uint n, uint k) {
  // Go row by row
  for (uint i = 0; i < m; i++) {
    // Go column by column
    for (uint j = 0; j < k; j++) {
      // Go through the cells of each dest matrix
      for (uint t = 0; t < n; t++) {
	// c (i, j) += a(i, t) * b(t, j)
	c[i * k + j] += a[i * n + t] * b[t * k + j];
      }
    }
  }
}

__global__ void kernel_mathmul(float * a, float * b, float * c, uint k, uint n)
{
	// This does not work yet when the columns count of the first matrix is > 256 or whatever...
    uint i = blockIdx.x * blockDim.x + threadIdx.x;

    if (i < k) {
      /*
      printf("[%d] ", i);

	  if (i == 0) {
		  printf("a now is: ");
	  	  for (uint j = 0; j< n; j++) {
		  	  printf("%f ", a[j]);
	  	  }
	  	  printf("\n");
	  }
	  */
      c[i] = 0; // reset it first, remember it doesn't get cleared everytime
      
      for (uint t=0; t<n; t++) {
    	  	  c[i] += a[t] * b[i + t*k];
      }
    }

}

void dev_matmul(float *a, float *b, float *c, uint m, uint n, uint k) {
    int threads_per_block = 256;
    int blocks =  ceil((float)(m) / threads_per_block);
    // printf("Number of blocks: [%d]\n", blocks);
    
    float * dev_a_onerow;
	hipMalloc(&dev_a_onerow, n*sizeof(float));
    
    float * dev_c_onerow;
    hipMalloc(&dev_c_onerow, k*sizeof(float));
    
    float * dev_b;
    hipMalloc(&dev_b, m*n*sizeof(float));
    
    hipMemcpy(dev_b, b, m*n*sizeof(float), hipMemcpyHostToDevice);
    
    // Compute the rows of resulting matrix one line by one line.
    for (uint i = 0; i < m; i++) {
      // copy one row of the a matrix to the device
      hipMemcpy(dev_a_onerow, a + (i * n), n * sizeof(float), hipMemcpyHostToDevice);

      //printf("Calling kernel mathmul\n");
      kernel_mathmul <<<blocks,threads_per_block>>> (dev_a_onerow, dev_b, dev_c_onerow, k, n);
      hipDeviceSynchronize();

      // copy the resulting row back
      hipMemcpy(c + i * k, dev_c_onerow, k * sizeof(float), hipMemcpyDeviceToHost);

      //print_matrix(c, m*k);
    }
    
    hipFree(dev_a_onerow);
    hipFree(dev_b);
    hipFree(dev_c_onerow);
}

void init_matrix(float *matrix, uint size) {
  for (uint i = 0; i < size; i++) {
    matrix[i] = ((float) rand()) / RAND_MAX;
    //matrix[i] = 1.0;
  }
}

void clear_matrix(float *matrix, uint size) {
  for (uint i = 0; i < size; i++) {
    matrix[i] = 0.0;
  }
}


void verify_matrix(const float *matrix1, const float *matrix2, const uint size) {
  for (uint i = 0; i < size; i++) {
    assert(matrix1[i] == matrix2[i]);
  }
}



int main() {
  uint m = 200;
  uint n = 200;
  uint k = 200;
  
  srand( time (NULL) );
  
  float * a_matrix = new float[m*n];
  float * b_matrix = new float[n*k];
  float * c_matrix = new float[m*k];
  float * c_dev_matrix = new float[m*k];

  clock_t start;
  clock_t end;
  /*
  printf("Initializing matrices with sample numbers\n", 2, 2);
  a_matrix[0] = 1; a_matrix[2] = -2; a_matrix[4] = 3; a_matrix[5] = -1;
  b_matrix[1] = 3; b_matrix[2] = -2; b_matrix[3] = -1; b_matrix[5] = 4;
  
  printf("Here comes the first 25 elements of a, b, c before:\n");
  print_matrix(a_matrix, m*n);
  print_matrix(b_matrix, n*k);
  print_matrix(c_matrix, m*k);
  
  printf("Do host-calculation:\n");
  host_matmul(a_matrix, b_matrix, c_matrix, m, n, k);
  
  printf("Here comes the first 25 elements of a, b, c after:\n");
  print_matrix(a_matrix, m*n);
  print_matrix(b_matrix, n*k);
  print_matrix(c_matrix, m*k);
  
  printf("Asserting that host-calculation is correct: ");
  assert(c_matrix[0] == 0);
  assert(c_matrix[1] == -5);
  assert(c_matrix[2] == -6);
  assert(c_matrix[3] == -7);
  printf("It is.\n");
  ////////////////////////////////////////////////
  */
  printf("Intialize random matrices: ");
  init_matrix(a_matrix, m*n);
  init_matrix(b_matrix, n*k);
  printf("Done. \n");
  print_matrix(a_matrix, m*n);
  print_matrix(b_matrix, n*k);
  print_matrix(c_matrix, m*k);
  ///////////////////////////////////////////////

  printf("Do host-calculation: ");
  clear_matrix(c_matrix, m*k);
  start = clock();
  host_matmul(a_matrix, b_matrix, c_matrix, m, n, k);
  end = clock();
  printf("Took %d clock cycles\n", end - start);

  printf("Here comes the first 25 elements of c:\n");
  print_matrix(c_matrix, m*k);

  printf("Do device-calculation: ");
  start = clock();
  dev_matmul(a_matrix, b_matrix, c_dev_matrix, m, n, k);
  end = clock();
  printf("Took %d clock cycles\n", end - start);

  printf("Here comes the first 25 elements of c on device:\n");
  print_matrix(c_dev_matrix, m*k);
  printf("Checking if GPU result is correct: ");
  verify_matrix(c_matrix, c_dev_matrix, m*k);
  printf("It is.");

  delete a_matrix;
  delete b_matrix;
  delete c_matrix;
  delete c_dev_matrix;
}

	.text
	.file	"main.hip"
	.globl	_Z12print_matrixPfj             # -- Begin function _Z12print_matrixPfj
	.type	_Z12print_matrixPfj,@function
_Z12print_matrixPfj:                    # @_Z12print_matrixPfj
	.cfi_startproc
# %bb.0:
	testl	%esi, %esi
	je	.LBB0_4
# %bb.1:                                # %.lr.ph.preheader
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rdi, %rbx
	cmpl	$25, %esi
	movl	$25, %r14d
	cmovbl	%esi, %r14d
	xorl	%r15d, %r15d
.LBB0_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	xorps	%xmm0, %xmm0
	cvtss2sd	(%rbx,%r15,4), %xmm0
	movl	$.L.str, %edi
	movb	$1, %al
	callq	printf
	incq	%r15
	cmpq	%r15, %r14
	jne	.LBB0_2
# %bb.3:
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	.cfi_restore %rbx
	.cfi_restore %r14
	.cfi_restore %r15
.LBB0_4:                                # %._crit_edge
	movl	$10, %edi
	jmp	putchar@PLT                     # TAILCALL
.Lfunc_end0:
	.size	_Z12print_matrixPfj, .Lfunc_end0-_Z12print_matrixPfj
	.cfi_endproc
                                        # -- End function
	.globl	_Z11host_matmulPfS_S_jjj        # -- Begin function _Z11host_matmulPfS_S_jjj
	.type	_Z11host_matmulPfS_S_jjj,@function
_Z11host_matmulPfS_S_jjj:               # @_Z11host_matmulPfS_S_jjj
	.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
	movl	%ecx, -4(%rsp)                  # 4-byte Spill
	testl	%ecx, %ecx
	je	.LBB1_9
# %bb.1:                                # %.preheader24.lr.ph
	movl	%r9d, %eax
	movl	%r8d, %r10d
	xorl	%r11d, %r11d
	movl	$0, -8(%rsp)                    # 4-byte Folded Spill
.LBB1_2:                                # %.preheader24
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_4 Depth 2
                                        #       Child Loop BB1_6 Depth 3
	testl	%r9d, %r9d
	je	.LBB1_8
# %bb.3:                                # %.preheader.lr.ph
                                        #   in Loop: Header=BB1_2 Depth=1
	movl	-8(%rsp), %ecx                  # 4-byte Reload
	movl	%ecx, %r14d
	imull	%r9d, %r14d
	xorl	%r15d, %r15d
.LBB1_4:                                # %.preheader
                                        #   Parent Loop BB1_2 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB1_6 Depth 3
	testl	%r8d, %r8d
	je	.LBB1_7
# %bb.5:                                # %.lr.ph
                                        #   in Loop: Header=BB1_4 Depth=2
	leal	(%r14,%r15), %r12d
	movss	(%rdx,%r12,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	movq	%r10, %r13
	movl	%r11d, %ebp
	movl	%r15d, %ebx
.LBB1_6:                                #   Parent Loop BB1_2 Depth=1
                                        #     Parent Loop BB1_4 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movl	%ebp, %ecx
	movss	(%rdi,%rcx,4), %xmm1            # xmm1 = mem[0],zero,zero,zero
	movl	%ebx, %ecx
	mulss	(%rsi,%rcx,4), %xmm1
	addss	%xmm1, %xmm0
	movss	%xmm0, (%rdx,%r12,4)
	addl	%r9d, %ebx
	incl	%ebp
	decq	%r13
	jne	.LBB1_6
.LBB1_7:                                # %._crit_edge
                                        #   in Loop: Header=BB1_4 Depth=2
	incq	%r15
	cmpq	%rax, %r15
	jne	.LBB1_4
.LBB1_8:                                # %._crit_edge27
                                        #   in Loop: Header=BB1_2 Depth=1
	movl	-8(%rsp), %ecx                  # 4-byte Reload
	incl	%ecx
	addl	%r8d, %r11d
	movl	%ecx, -8(%rsp)                  # 4-byte Spill
	cmpl	-4(%rsp), %ecx                  # 4-byte Folded Reload
	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	_Z11host_matmulPfS_S_jjj, .Lfunc_end1-_Z11host_matmulPfS_S_jjj
	.cfi_endproc
                                        # -- End function
	.globl	_Z29__device_stub__kernel_mathmulPfS_S_jj # -- Begin function _Z29__device_stub__kernel_mathmulPfS_S_jj
	.type	_Z29__device_stub__kernel_mathmulPfS_S_jj,@function
_Z29__device_stub__kernel_mathmulPfS_S_jj: # @_Z29__device_stub__kernel_mathmulPfS_S_jj
	.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	$_Z14kernel_mathmulPfS_S_jj, %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	_Z29__device_stub__kernel_mathmulPfS_S_jj, .Lfunc_end2-_Z29__device_stub__kernel_mathmulPfS_S_jj
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function _Z10dev_matmulPfS_S_jjj
.LCPI3_0:
	.long	0x3b800000                      # float 0.00390625
	.text
	.globl	_Z10dev_matmulPfS_S_jjj
	.type	_Z10dev_matmulPfS_S_jjj,@function
_Z10dev_matmulPfS_S_jjj:                # @_Z10dev_matmulPfS_S_jjj
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$72, %rsp
	.cfi_def_cfa_offset 128
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%r9d, %ebx
	movl	%r8d, %r14d
	movl	%ecx, %r12d
	movq	%rdx, 64(%rsp)                  # 8-byte Spill
	movq	%rsi, %r13
	movq	%rdi, 56(%rsp)                  # 8-byte Spill
	movl	%r8d, %esi
	shlq	$2, %rsi
	leaq	24(%rsp), %rdi
	movq	%rsi, 48(%rsp)                  # 8-byte Spill
	callq	hipMalloc
	movl	%ebx, 12(%rsp)                  # 4-byte Spill
	movl	%ebx, %esi
	shlq	$2, %rsi
	leaq	16(%rsp), %rdi
	movq	%rsi, 40(%rsp)                  # 8-byte Spill
	callq	hipMalloc
	movl	%r14d, %ebp
	movl	%r14d, %r15d
	imull	%r12d, %r15d
	shlq	$2, %r15
	leaq	32(%rsp), %r14
	movq	%r14, %rdi
	movq	%r15, %rsi
	callq	hipMalloc
	movq	(%r14), %rdi
	movq	%r13, %rsi
	movq	%r15, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%r12d, %r12d
	je	.LBB3_5
# %bb.1:                                # %.lr.ph
	movl	%r12d, %r12d
	cvtsi2ss	%r12, %xmm0
	movabsq	$4294967296, %r14               # imm = 0x100000000
	mulss	.LCPI3_0(%rip), %xmm0
	callq	ceilf@PLT
	cvttss2si	%xmm0, %r15d
	btsq	$32, %r15
	xorl	%r13d, %r13d
	addq	$256, %r14                      # imm = 0x100
	xorl	%ebx, %ebx
.LBB3_2:                                # =>This Inner Loop Header: Depth=1
	movq	24(%rsp), %rdi
	movl	%r13d, %eax
	movq	56(%rsp), %rcx                  # 8-byte Reload
	leaq	(%rcx,%rax,4), %rsi
	movq	48(%rsp), %rdx                  # 8-byte Reload
	movl	$1, %ecx
	callq	hipMemcpy
	movq	%r15, %rdi
	movl	$1, %esi
	movq	%r14, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB3_4
# %bb.3:                                #   in Loop: Header=BB3_2 Depth=1
	movq	24(%rsp), %rdi
	movq	32(%rsp), %rsi
	movq	16(%rsp), %rdx
	movl	12(%rsp), %ecx                  # 4-byte Reload
	movl	%ebp, %r8d
	callq	_Z29__device_stub__kernel_mathmulPfS_S_jj
.LBB3_4:                                #   in Loop: Header=BB3_2 Depth=1
	callq	hipDeviceSynchronize
	movl	%ebx, %eax
	movq	64(%rsp), %rcx                  # 8-byte Reload
	leaq	(%rcx,%rax,4), %rdi
	movq	16(%rsp), %rsi
	movq	40(%rsp), %rdx                  # 8-byte Reload
	movl	$2, %ecx
	callq	hipMemcpy
	addl	12(%rsp), %ebx                  # 4-byte Folded Reload
	addl	%ebp, %r13d
	decq	%r12
	jne	.LBB3_2
.LBB3_5:                                # %._crit_edge
	movq	24(%rsp), %rdi
	callq	hipFree
	movq	32(%rsp), %rdi
	callq	hipFree
	movq	16(%rsp), %rdi
	callq	hipFree
	addq	$72, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end3:
	.size	_Z10dev_matmulPfS_S_jjj, .Lfunc_end3-_Z10dev_matmulPfS_S_jjj
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function _Z11init_matrixPfj
.LCPI4_0:
	.long	0x30000000                      # float 4.65661287E-10
	.text
	.globl	_Z11init_matrixPfj
	.type	_Z11init_matrixPfj,@function
_Z11init_matrixPfj:                     # @_Z11init_matrixPfj
	.cfi_startproc
# %bb.0:
	testl	%esi, %esi
	je	.LBB4_4
# %bb.1:                                # %.lr.ph.preheader
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rdi, %rbx
	movl	%esi, %r14d
	xorl	%r15d, %r15d
.LBB4_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	callq	rand
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	mulss	.LCPI4_0(%rip), %xmm0
	movss	%xmm0, (%rbx,%r15,4)
	incq	%r15
	cmpq	%r15, %r14
	jne	.LBB4_2
# %bb.3:
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	.cfi_restore %rbx
	.cfi_restore %r14
	.cfi_restore %r15
.LBB4_4:                                # %._crit_edge
	retq
.Lfunc_end4:
	.size	_Z11init_matrixPfj, .Lfunc_end4-_Z11init_matrixPfj
	.cfi_endproc
                                        # -- End function
	.globl	_Z12clear_matrixPfj             # -- Begin function _Z12clear_matrixPfj
	.type	_Z12clear_matrixPfj,@function
_Z12clear_matrixPfj:                    # @_Z12clear_matrixPfj
	.cfi_startproc
# %bb.0:
	testl	%esi, %esi
	je	.LBB5_1
# %bb.2:                                # %.lr.ph.preheader
	movl	%esi, %edx
	shlq	$2, %rdx
	xorl	%esi, %esi
	jmp	memset@PLT                      # TAILCALL
.LBB5_1:                                # %._crit_edge
	retq
.Lfunc_end5:
	.size	_Z12clear_matrixPfj, .Lfunc_end5-_Z12clear_matrixPfj
	.cfi_endproc
                                        # -- End function
	.globl	_Z13verify_matrixPKfS0_j        # -- Begin function _Z13verify_matrixPKfS0_j
	.type	_Z13verify_matrixPKfS0_j,@function
_Z13verify_matrixPKfS0_j:               # @_Z13verify_matrixPKfS0_j
	.cfi_startproc
# %bb.0:
	retq
.Lfunc_end6:
	.size	_Z13verify_matrixPKfS0_j, .Lfunc_end6-_Z13verify_matrixPKfS0_j
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function main
.LCPI7_0:
	.long	0x30000000                      # float 4.65661287E-10
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	pushq	%rax
	.cfi_def_cfa_offset 64
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	xorl	%r13d, %r13d
	xorl	%edi, %edi
	callq	time
	movl	%eax, %edi
	callq	srand
	movl	$160000, %edi                   # imm = 0x27100
	callq	_Znam
	movq	%rax, %rbx
	movl	$160000, %edi                   # imm = 0x27100
	callq	_Znam
	movq	%rax, %r14
	movl	$160000, %edi                   # imm = 0x27100
	callq	_Znam
	movq	%rax, %r15
	movl	$160000, %edi                   # imm = 0x27100
	callq	_Znam
	movq	%rax, %r12
	movl	$.L.str.2, %edi
	xorl	%eax, %eax
	callq	printf
.LBB7_1:                                # %.lr.ph.i
                                        # =>This Inner Loop Header: Depth=1
	callq	rand
	movss	.LCPI7_0(%rip), %xmm1           # xmm1 = mem[0],zero,zero,zero
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	mulss	%xmm1, %xmm0
	movss	%xmm0, (%rbx,%r13,4)
	incq	%r13
	cmpq	$40000, %r13                    # imm = 0x9C40
	jne	.LBB7_1
# %bb.2:                                # %.lr.ph.i58.preheader
	xorl	%r13d, %r13d
.LBB7_3:                                # %.lr.ph.i58
                                        # =>This Inner Loop Header: Depth=1
	callq	rand
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	mulss	.LCPI7_0(%rip), %xmm0
	movss	%xmm0, (%r14,%r13,4)
	incq	%r13
	cmpq	$40000, %r13                    # imm = 0x9C40
	jne	.LBB7_3
# %bb.4:                                # %_Z11init_matrixPfj.exit62
	movl	$.Lstr, %edi
	callq	puts@PLT
	movq	%rbx, %rdi
	movl	$40000, %esi                    # imm = 0x9C40
	callq	_Z12print_matrixPfj
	movq	%r14, %rdi
	movl	$40000, %esi                    # imm = 0x9C40
	callq	_Z12print_matrixPfj
	movq	%r15, %rdi
	movl	$40000, %esi                    # imm = 0x9C40
	callq	_Z12print_matrixPfj
	xorl	%ebp, %ebp
	movl	$.L.str.4, %edi
	xorl	%eax, %eax
	callq	printf
	movl	$160000, %edx                   # imm = 0x27100
	movq	%r15, %rdi
	xorl	%esi, %esi
	callq	memset@PLT
	callq	clock
	movq	%rax, %r13
	movq	%rbx, %rax
.LBB7_5:                                # %.preheader24.i
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB7_6 Depth 2
                                        #       Child Loop BB7_7 Depth 3
	imull	$200, %ebp, %ecx
	movq	%r14, %rdx
	xorl	%esi, %esi
.LBB7_6:                                # %.preheader.i
                                        #   Parent Loop BB7_5 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB7_7 Depth 3
	leal	(%rcx,%rsi), %edi
	movss	(%r15,%rdi,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	movq	%rdx, %r8
	xorl	%r9d, %r9d
.LBB7_7:                                #   Parent Loop BB7_5 Depth=1
                                        #     Parent Loop BB7_6 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movss	(%rax,%r9,4), %xmm1             # xmm1 = mem[0],zero,zero,zero
	mulss	(%r8), %xmm1
	addss	%xmm1, %xmm0
	incq	%r9
	addq	$800, %r8                       # imm = 0x320
	cmpq	$200, %r9
	jne	.LBB7_7
# %bb.8:                                # %._crit_edge.i
                                        #   in Loop: Header=BB7_6 Depth=2
	movss	%xmm0, (%r15,%rdi,4)
	incq	%rsi
	addq	$4, %rdx
	cmpq	$200, %rsi
	jne	.LBB7_6
# %bb.9:                                # %._crit_edge27.i
                                        #   in Loop: Header=BB7_5 Depth=1
	incl	%ebp
	addq	$800, %rax                      # imm = 0x320
	cmpl	$200, %ebp
	jne	.LBB7_5
# %bb.10:                               # %_Z11host_matmulPfS_S_jjj.exit
	callq	clock
	subq	%r13, %rax
	movl	$.L.str.5, %edi
	movq	%rax, %rsi
	xorl	%eax, %eax
	callq	printf
	movl	$.Lstr.1, %edi
	callq	puts@PLT
	movq	%r15, %rdi
	movl	$40000, %esi                    # imm = 0x9C40
	callq	_Z12print_matrixPfj
	movl	$.L.str.7, %edi
	xorl	%eax, %eax
	callq	printf
	callq	clock
	movq	%rax, %r13
	movq	%rbx, %rdi
	movq	%r14, %rsi
	movq	%r12, %rdx
	movl	$200, %ecx
	movl	$200, %r8d
	movl	$200, %r9d
	callq	_Z10dev_matmulPfS_S_jjj
	callq	clock
	subq	%r13, %rax
	movl	$.L.str.5, %edi
	movq	%rax, %rsi
	xorl	%eax, %eax
	callq	printf
	movl	$.Lstr.2, %edi
	callq	puts@PLT
	movq	%r12, %rdi
	movl	$40000, %esi                    # imm = 0x9C40
	callq	_Z12print_matrixPfj
	movl	$.L.str.9, %edi
	xorl	%eax, %eax
	callq	printf
	movl	$.L.str.10, %edi
	xorl	%eax, %eax
	callq	printf
	movq	%rbx, %rdi
	callq	_ZdlPv
	movq	%r14, %rdi
	callq	_ZdlPv
	movq	%r15, %rdi
	callq	_ZdlPv
	movq	%r12, %rdi
	callq	_ZdlPv
	xorl	%eax, %eax
	addq	$8, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.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	$_Z14kernel_mathmulPfS_S_jj, %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,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	" %f"
	.size	.L.str, 4

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

	.type	.L.str.2,@object                # @.str.2
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.2:
	.asciz	"Intialize random matrices: "
	.size	.L.str.2, 28

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"Do host-calculation: "
	.size	.L.str.4, 22

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"Took %d clock cycles\n"
	.size	.L.str.5, 22

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"Do device-calculation: "
	.size	.L.str.7, 24

	.type	.L.str.9,@object                # @.str.9
.L.str.9:
	.asciz	"Checking if GPU result is correct: "
	.size	.L.str.9, 36

	.type	.L.str.10,@object               # @.str.10
.L.str.10:
	.asciz	"It is."
	.size	.L.str.10, 7

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z14kernel_mathmulPfS_S_jj"
	.size	.L__unnamed_1, 27

	.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	"Done. "
	.size	.Lstr, 7

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"Here comes the first 25 elements of c:"
	.size	.Lstr.1, 39

	.type	.Lstr.2,@object                 # @str.2
.Lstr.2:
	.asciz	"Here comes the first 25 elements of c on device:"
	.size	.Lstr.2, 49

	.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 _Z29__device_stub__kernel_mathmulPfS_S_jj
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z14kernel_mathmulPfS_S_jj
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z14kernel_mathmulPfS_S_jj ; -- Begin function _Z14kernel_mathmulPfS_S_jj
	.globl	_Z14kernel_mathmulPfS_S_jj
	.p2align	8
	.type	_Z14kernel_mathmulPfS_S_jj,@function
_Z14kernel_mathmulPfS_S_jj:             ; @_Z14kernel_mathmulPfS_S_jj
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x2c
	s_load_b64 s[4:5], s[0:1], 0x18
	s_waitcnt lgkmcnt(0)
	s_and_b32 s2, s2, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s15, s2, v[0:1]
	s_mov_b32 s2, exec_lo
	v_cmpx_gt_u32_e64 s4, v1
	s_cbranch_execz .LBB0_4
; %bb.1:
	s_load_b64 s[2:3], s[0:1], 0x10
	v_mov_b32_e32 v2, 0
	s_cmp_eq_u32 s5, 0
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[3:4], 2, v[1:2]
	s_waitcnt lgkmcnt(0)
	v_add_co_u32 v3, vcc_lo, s2, v3
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v4, vcc_lo, s3, v4, vcc_lo
	global_store_b32 v[3:4], v2, off
	s_cbranch_scc1 .LBB0_4
; %bb.2:                                ; %.lr.ph.preheader
	s_load_b128 s[0:3], s[0:1], 0x0
	v_mov_b32_e32 v0, v2
.LBB0_3:                                ; %.lr.ph
                                        ; =>This Inner Loop Header: Depth=1
	v_lshlrev_b64 v[5:6], 2, v[1:2]
	s_add_i32 s5, s5, -1
	v_add_nc_u32_e32 v1, s4, v1
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_co_u32 v5, vcc_lo, s2, v5
	v_add_co_ci_u32_e32 v6, vcc_lo, s3, v6, vcc_lo
	global_load_b32 v7, v2, s[0:1]
	global_load_b32 v5, v[5:6], off
	s_add_u32 s0, s0, 4
	s_addc_u32 s1, s1, 0
	s_cmp_lg_u32 s5, 0
	s_waitcnt vmcnt(0)
	v_fmac_f32_e32 v0, v7, v5
	global_store_b32 v[3:4], v0, off
	s_cbranch_scc1 .LBB0_3
.LBB0_4:                                ; %.loopexit
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z14kernel_mathmulPfS_S_jj
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 288
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 8
		.amdhsa_next_free_sgpr 16
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end0:
	.size	_Z14kernel_mathmulPfS_S_jj, .Lfunc_end0-_Z14kernel_mathmulPfS_S_jj
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 228
; NumSgprs: 18
; NumVgprs: 8
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 8
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

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

	.end_amdgpu_metadata
