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


#define SUBMATRIX_SIZE 10000
#define BLOCK_SIZE 16

float getnum() {
  return rand()/((float) RAND_MAX);
}


__global__ void gpu_matrix_multiply(float *a, float *b, float *c, int n) 
{
  __shared__ float tile_a[BLOCK_SIZE][BLOCK_SIZE];
  __shared__ float tile_b[BLOCK_SIZE][BLOCK_SIZE];

  int row = blockIdx.y * BLOCK_SIZE + threadIdx.y;
  int col = blockIdx.x * BLOCK_SIZE + threadIdx.x;
  float tmp = 0.0f;
  int idx;

  for (int sub = 0; sub < gridDim.x; ++sub) // gridDim.x
    {
      idx = row * n + sub * BLOCK_SIZE + threadIdx.x;
      if(idx >= n*n)
        {
	  // n may not divisible by BLOCK_SIZE
	  tile_a[threadIdx.y][threadIdx.x] = 0.0f;
        }
      else
        {
	  tile_a[threadIdx.y][threadIdx.x] = a[idx];
        }

      idx = (sub * BLOCK_SIZE + threadIdx.y) * n + col;
      if(idx >= n*n)
        {
	  tile_b[threadIdx.y][threadIdx.x] = 0.0f;
        }  
      else
        {
	  tile_b[threadIdx.y][threadIdx.x] = b[idx];
        }
      __syncthreads();

      for (int k = 0; k < BLOCK_SIZE; ++k) 
        {
	  tmp += tile_a[threadIdx.y][k] * tile_b[k][threadIdx.x];
        }
      __syncthreads();
    }
  if(row < n && col < n)
    {
      c[row * n + col] = tmp;
    }
}


void make_identity(float* a, int startx, int starty, int length, int n) {
  // fill a with the identity from start to end
  int i, j;
  for (i=startx; i<length+startx; i++) {
    for (j=starty; j<length+starty; j++) {
      a[i*n+j] = (i-startx==j-starty) ? 1.0f : 0.0f;
    }
  }
}

void make_negidentity(float* a, int startx, int starty, int length, int n) {
  // fill a with the identity from start to end
  int i, j;
  for (i=startx; i<length+startx; i++) {
    for (j=starty; j<length+starty; j++) {
      a[i*n+j] = (i-startx==j-starty) ? -1.0f : 0.0f;
    }
  }
}

void make_x(float* x, int length) {
  int i, j;
  for (i=0; i<length; i++) {
    for (j=0; j<length; j++) {
      x[i*length+j] = getnum();
    }
  }
}

void make_zero(float* a, int startx, int starty, int length, int n) {
  int i, j;
  for (i=startx; i<length+startx; i++) {
    for (j=starty; j<length+starty; j++) {
      a[i*n+j] = 0.0f;
    }
  }
}

void copy_x(float* a, float* x, int startx, int starty, int length, int n) {
  int i, j;
  for (i=startx; i<length+startx; i++) {
    for (j=starty; j<length+starty; j++) {
      a[i*n+j] = x[(i-startx)*length+(j-starty)];
    }
  }
}

void copy_2x(float* a, float* x, int startx, int starty, int length, int n) {
  int i, j;
  for (i=startx; i<length+startx; i++) {
    for (j=starty; j<length+starty; j++) {
      a[i*n+j] = 2*x[(i-startx)*length+(j-starty)];
    }
  }
}

void copy_negx(float* a, float* x, int startx, int starty, int length, int n) {
  int i, j;
  for (i=startx; i<length+startx; i++) {
    for (j=starty; j<length+starty; j++) {
      a[i*n+j] = (-1)*x[(i-startx)*length+(j-starty)];
    }
  }
}

void make_result(float* a, int length) {
  int i, j;
  int half = length>>1;
  for (i=0; i<length; i++) {
    for (j=0; j<length; j++) {
      if (i == j) {
	if (i>=half)
	  a[i*length+j] = -1.0f;
	else
	  a[i*length+j] = 1.0f;
      }
      else
	a[i*length+j] = 0.0f;
    }
  }
}

float rothVerf(float* a, float* b, int n) {
  float sum = 0;
  int i, j;
  for (i=0; i<n; i++) {
    for (j=0; j<n; j++) {
      sum += (float) fabs(a[i*n+j] - b[i*n+j]);
    }
  }
  return sum;
}

void print_mat(float* a, int n) {
  int i, j;
  for (i=0; i<n; i++) {
    for (j=0; j<n; j++) {
      printf("%.2f\t", a[i*n+j]);
    }
    printf("\n");
  }
  printf("\n");
}


int main() {
  srand(100);
  int n = 2*SUBMATRIX_SIZE;
  int half = n>>1;
  size_t totalsize = sizeof(float)*n*n;
  size_t halfsize = sizeof(float)*half*half;
  float *x, *a, *b, *c, *d;

  cudaMallocHost((void**) &a, totalsize);
  cudaMallocHost((void**) &b, totalsize);
  cudaMallocHost((void**) &c, totalsize);
  cudaMallocHost((void**) &d, totalsize);
  cudaMallocHost((void**) &x, halfsize);
  
  if ((x==NULL) || (a==NULL) || (b==NULL) || (c==NULL) ||
      (d==NULL)) {
    printf("Matrix allocation error on host\n");
    exit(1);
  }

  make_x(x, half);

  // construct first matrix
  make_identity(a, 0, 0, half, n);
  copy_x(a, x, 0, half, half, n);
  make_zero(a, half, 0, half, n);
  make_identity(a, half, half, half, n);

  // second matrix
  make_identity(b, 0, 0, half, n);
  copy_2x(b, x, 0, half, half, n);
  make_zero(b, half, 0, half, n);
  make_negidentity(b, half, half, half, n);

  // third
  make_identity(c, 0, 0, half, n);
  copy_negx(c, x, 0, half, half, n);
  make_zero(c, half, 0, half, n);
  make_identity(c, half, half, half, n);

  // result
  make_result(d, n);

  // allocate on device
  float *dev_a, *dev_b, *dev_c, *dev_inter;
  cudaMalloc((void**) &dev_a, totalsize);
  cudaMalloc((void**) &dev_b, totalsize);
  cudaMalloc((void**) &dev_c, totalsize);
  cudaMalloc((void**) &dev_inter, totalsize);
  
  // copy to device
  cudaMemcpy(dev_a, a, totalsize, cudaMemcpyHostToDevice);
  cudaMemcpy(dev_b, b, totalsize, cudaMemcpyHostToDevice);
  cudaMemcpy(dev_c, c, totalsize, cudaMemcpyHostToDevice);

  unsigned int grid_rows = n / BLOCK_SIZE;
  unsigned int grid_cols = n / BLOCK_SIZE;
  dim3 dimGrid(grid_cols, grid_rows);
  dim3 dimBlock(BLOCK_SIZE, BLOCK_SIZE);

  // intermediate matrix product
  gpu_matrix_multiply<<<dimGrid, dimBlock>>>(dev_a, dev_b, dev_inter, n);
  cudaThreadSynchronize();

  // reuse old matrix
  gpu_matrix_multiply<<<dimGrid, dimBlock>>>(dev_inter, dev_c, dev_a, n);

  // bring product back to cpu
  cudaMemcpy(a, dev_a, totalsize, cudaMemcpyDeviceToHost);
  cudaThreadSynchronize();

  // check a against the result d
  float sum = rothVerf(a, d, n);
  printf("Total Error: %f\n", sum);

  // cleanup and exit
  cudaFree(dev_a);
  cudaFree(dev_b);
  cudaFree(dev_c);
  cudaFree(dev_inter);
  cudaFreeHost(a);
  cudaFreeHost(b);
  cudaFreeHost(c);
  cudaFreeHost(d);
  cudaFreeHost(x);
  return 0;
}

	.file	"tmpxft_00240e36_00000000-6_parallel.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2041:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2041:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z6getnumv
	.type	_Z6getnumv, @function
_Z6getnumv:
.LFB2027:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	call	rand@PLT
	cvtsi2ssl	%eax, %xmm0
	mulss	.LC0(%rip), %xmm0
	popq	%rdx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2027:
	.size	_Z6getnumv, .-_Z6getnumv
	.globl	_Z13make_identityPfiiii
	.type	_Z13make_identityPfiiii, @function
_Z13make_identityPfiiii:
.LFB2028:
	.cfi_startproc
	endbr64
	movl	%r8d, %r10d
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rdi, %r9
	xorl	%edi, %edi
	imull	%esi, %r10d
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	leal	(%rsi,%rcx), %ebx
	addl	%edx, %ecx
.L5:
	leal	(%rdi,%rsi), %eax
	cmpl	%eax, %ebx
	jle	.L4
	movslq	%r10d, %r11
	movslq	%edx, %rax
	leaq	(%r9,%r11,4), %r11
.L9:
	cmpl	%eax, %ecx
	jle	.L13
	movl	%eax, %ebp
	xorps	%xmm0, %xmm0
	subl	%edx, %ebp
	cmpl	%edi, %ebp
	jne	.L6
	movss	.LC1(%rip), %xmm0
.L6:
	movss	%xmm0, (%r11,%rax,4)
	incq	%rax
	jmp	.L9
.L13:
	incl	%edi
	addl	%r8d, %r10d
	jmp	.L5
.L4:
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2028:
	.size	_Z13make_identityPfiiii, .-_Z13make_identityPfiiii
	.globl	_Z16make_negidentityPfiiii
	.type	_Z16make_negidentityPfiiii, @function
_Z16make_negidentityPfiiii:
.LFB2029:
	.cfi_startproc
	endbr64
	movl	%r8d, %r10d
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rdi, %r9
	xorl	%edi, %edi
	imull	%esi, %r10d
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	leal	(%rsi,%rcx), %ebx
	addl	%edx, %ecx
.L15:
	leal	(%rdi,%rsi), %eax
	cmpl	%eax, %ebx
	jle	.L14
	movslq	%r10d, %r11
	movslq	%edx, %rax
	leaq	(%r9,%r11,4), %r11
.L19:
	cmpl	%eax, %ecx
	jle	.L22
	movl	%eax, %ebp
	xorps	%xmm0, %xmm0
	subl	%edx, %ebp
	cmpl	%edi, %ebp
	jne	.L16
	movss	.LC3(%rip), %xmm0
.L16:
	movss	%xmm0, (%r11,%rax,4)
	incq	%rax
	jmp	.L19
.L22:
	incl	%edi
	addl	%r8d, %r10d
	jmp	.L15
.L14:
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2029:
	.size	_Z16make_negidentityPfiiii, .-_Z16make_negidentityPfiiii
	.globl	_Z6make_xPfi
	.type	_Z6make_xPfi, @function
_Z6make_xPfi:
.LFB2030:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	movslq	%esi, %r13
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	xorl	%r12d, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	movq	%r13, %rbp
	salq	$2, %r13
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	movq	%rdi, %rbx
.L24:
	cmpl	%ebp, %r12d
	jge	.L29
	leaq	(%rbx,%r13), %r14
.L25:
	call	_Z6getnumv
	addq	$4, %rbx
	movss	%xmm0, -4(%rbx)
	cmpq	%r14, %rbx
	jne	.L25
	incl	%r12d
	jmp	.L24
.L29:
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2030:
	.size	_Z6make_xPfi, .-_Z6make_xPfi
	.globl	_Z9make_zeroPfiiii
	.type	_Z9make_zeroPfiiii, @function
_Z9make_zeroPfiiii:
.LFB2031:
	.cfi_startproc
	endbr64
	movl	%esi, %r9d
	leal	(%rsi,%rcx), %r11d
	addl	%edx, %ecx
	imull	%r8d, %r9d
.L31:
	cmpl	%esi, %r11d
	jle	.L30
	movslq	%r9d, %r10
	movslq	%edx, %rax
	leaq	(%rdi,%r10,4), %r10
.L34:
	cmpl	%eax, %ecx
	jle	.L35
	movl	$0x00000000, (%r10,%rax,4)
	incq	%rax
	jmp	.L34
.L35:
	incl	%esi
	addl	%r8d, %r9d
	jmp	.L31
.L30:
	ret
	.cfi_endproc
.LFE2031:
	.size	_Z9make_zeroPfiiii, .-_Z9make_zeroPfiiii
	.globl	_Z6copy_xPfS_iiii
	.type	_Z6copy_xPfS_iiii, @function
_Z6copy_xPfS_iiii:
.LFB2032:
	.cfi_startproc
	endbr64
	movq	%rsi, %r11
	movl	%edx, %esi
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leal	(%r8,%rcx), %r13d
	imull	%r9d, %esi
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	leal	(%rdx,%r8), %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	xorl	%ebx, %ebx
.L37:
	cmpl	%edx, %r12d
	jle	.L36
	movslq	%ebx, %r10
	movslq	%esi, %rbp
	movslq	%ecx, %rax
	leaq	(%r11,%r10,4), %r10
	leaq	(%rdi,%rbp,4), %rbp
.L40:
	cmpl	%eax, %r13d
	jle	.L42
	movss	(%r10), %xmm0
	addq	$4, %r10
	movss	%xmm0, 0(%rbp,%rax,4)
	incq	%rax
	jmp	.L40
.L42:
	incl	%edx
	addl	%r8d, %ebx
	addl	%r9d, %esi
	jmp	.L37
.L36:
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2032:
	.size	_Z6copy_xPfS_iiii, .-_Z6copy_xPfS_iiii
	.globl	_Z7copy_2xPfS_iiii
	.type	_Z7copy_2xPfS_iiii, @function
_Z7copy_2xPfS_iiii:
.LFB2033:
	.cfi_startproc
	endbr64
	movq	%rsi, %r10
	movl	%edx, %esi
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leal	(%r8,%rcx), %r13d
	imull	%r9d, %esi
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	leal	(%rdx,%r8), %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	xorl	%ebx, %ebx
.L44:
	cmpl	%edx, %r12d
	jle	.L43
	movslq	%ebx, %r11
	movslq	%esi, %rbp
	movslq	%ecx, %rax
	leaq	(%r10,%r11,4), %r11
	leaq	(%rdi,%rbp,4), %rbp
.L47:
	cmpl	%eax, %r13d
	jle	.L49
	movss	(%r11), %xmm0
	addq	$4, %r11
	addss	%xmm0, %xmm0
	movss	%xmm0, 0(%rbp,%rax,4)
	incq	%rax
	jmp	.L47
.L49:
	incl	%edx
	addl	%r8d, %ebx
	addl	%r9d, %esi
	jmp	.L44
.L43:
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2033:
	.size	_Z7copy_2xPfS_iiii, .-_Z7copy_2xPfS_iiii
	.globl	_Z9copy_negxPfS_iiii
	.type	_Z9copy_negxPfS_iiii, @function
_Z9copy_negxPfS_iiii:
.LFB2034:
	.cfi_startproc
	endbr64
	movq	%rsi, %r11
	movl	%edx, %esi
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	movss	.LC4(%rip), %xmm1
	imull	%r9d, %esi
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	leal	(%r8,%rcx), %r13d
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	leal	(%rdx,%r8), %r12d
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	xorl	%ebx, %ebx
.L51:
	cmpl	%edx, %r12d
	jle	.L50
	movslq	%ebx, %r10
	movslq	%esi, %rbp
	movslq	%ecx, %rax
	leaq	(%r11,%r10,4), %r10
	leaq	(%rdi,%rbp,4), %rbp
.L54:
	cmpl	%eax, %r13d
	jle	.L56
	movss	(%r10), %xmm0
	addq	$4, %r10
	xorps	%xmm1, %xmm0
	movss	%xmm0, 0(%rbp,%rax,4)
	incq	%rax
	jmp	.L54
.L56:
	incl	%edx
	addl	%r8d, %ebx
	addl	%r9d, %esi
	jmp	.L51
.L50:
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2034:
	.size	_Z9copy_negxPfS_iiii, .-_Z9copy_negxPfS_iiii
	.globl	_Z11make_resultPfi
	.type	_Z11make_resultPfi, @function
_Z11make_resultPfi:
.LFB2035:
	.cfi_startproc
	endbr64
	movl	%esi, %r10d
	movss	.LC1(%rip), %xmm0
	xorl	%ecx, %ecx
	xorl	%eax, %eax
	movss	.LC3(%rip), %xmm1
	sarl	%r10d
.L58:
	cmpl	%esi, %eax
	jge	.L65
	leal	(%rax,%rcx), %r9d
	xorl	%edx, %edx
	movslq	%r9d, %r11
.L62:
	cmpl	%edx, %eax
	jne	.L59
	cmpl	%r10d, %eax
	jl	.L60
	movslq	%r9d, %r8
	movss	%xmm1, (%rdi,%r8,4)
	jmp	.L61
.L60:
	movss	%xmm0, (%rdi,%r11,4)
	jmp	.L61
.L59:
	leal	(%rdx,%rcx), %r8d
	movslq	%r8d, %r8
	movl	$0x00000000, (%rdi,%r8,4)
.L61:
	incl	%edx
	cmpl	%edx, %esi
	jne	.L62
	incl	%eax
	addl	%esi, %ecx
	jmp	.L58
.L65:
	ret
	.cfi_endproc
.LFE2035:
	.size	_Z11make_resultPfi, .-_Z11make_resultPfi
	.globl	_Z8rothVerfPfS_i
	.type	_Z8rothVerfPfS_i, @function
_Z8rothVerfPfS_i:
.LFB2036:
	.cfi_startproc
	endbr64
	movslq	%edx, %r8
	xorl	%r9d, %r9d
	xorps	%xmm1, %xmm1
	xorl	%ecx, %ecx
	salq	$2, %r8
	movss	.LC5(%rip), %xmm2
.L67:
	cmpl	%edx, %ecx
	jge	.L71
	movq	%r9, %rax
	xorl	%r10d, %r10d
.L68:
	movss	(%rdi,%rax), %xmm0
	subss	(%rsi,%rax), %xmm0
	incl	%r10d
	addq	$4, %rax
	andps	%xmm2, %xmm0
	addss	%xmm0, %xmm1
	cmpl	%r10d, %edx
	jne	.L68
	incl	%ecx
	addq	%r8, %r9
	jmp	.L67
.L71:
	movaps	%xmm1, %xmm0
	ret
	.cfi_endproc
.LFE2036:
	.size	_Z8rothVerfPfS_i, .-_Z8rothVerfPfS_i
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC6:
	.string	"%.2f\t"
.LC7:
	.string	"\n"
	.text
	.globl	_Z9print_matPfi
	.type	_Z9print_matPfi, @function
_Z9print_matPfi:
.LFB2037:
	.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
	leaq	.LC6(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movslq	%esi, %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	xorl	%r12d, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%r13, %rbp
	salq	$2, %r13
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%rdi, %rbx
	pushq	%rcx
	.cfi_def_cfa_offset 64
.L73:
	cmpl	%ebp, %r12d
	jge	.L78
	leaq	(%rbx,%r13), %r15
.L74:
	cvtss2sd	(%rbx), %xmm0
	movq	%r14, %rsi
	movl	$2, %edi
	movb	$1, %al
	call	__printf_chk@PLT
	addq	$4, %rbx
	cmpq	%r15, %rbx
	jne	.L74
	leaq	.LC7(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	incl	%r12d
	call	__printf_chk@PLT
	jmp	.L73
.L78:
	popq	%rdx
	.cfi_def_cfa_offset 56
	leaq	.LC7(%rip), %rsi
	popq	%rbx
	.cfi_def_cfa_offset 48
	movl	$2, %edi
	popq	%rbp
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	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
	jmp	__printf_chk@PLT
	.cfi_endproc
.LFE2037:
	.size	_Z9print_matPfi, .-_Z9print_matPfi
	.globl	_Z44__device_stub__Z19gpu_matrix_multiplyPfS_S_iPfS_S_i
	.type	_Z44__device_stub__Z19gpu_matrix_multiplyPfS_S_iPfS_S_i, @function
_Z44__device_stub__Z19gpu_matrix_multiplyPfS_S_iPfS_S_i:
.LFB2063:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdi, 24(%rsp)
	leaq	56(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	68(%rsp), %rsi
	movq	%rdx, 8(%rsp)
	leaq	40(%rsp), %rdx
	movl	%ecx, 4(%rsp)
	leaq	48(%rsp), %rcx
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 64(%rsp)
	movq	%rax, 104(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 128(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 56(%rsp)
	movq	%rax, 68(%rsp)
	movl	$1, 76(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L79
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z19gpu_matrix_multiplyPfS_S_i(%rip), %rdi
	pushq	48(%rsp)
	.cfi_def_cfa_offset 176
	movq	84(%rsp), %rcx
	movl	92(%rsp), %r8d
	movq	72(%rsp), %rsi
	movl	80(%rsp), %edx
	leaq	120(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 168
	popq	%rdx
	.cfi_def_cfa_offset 160
.L79:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L81
	call	__stack_chk_fail@PLT
.L81:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2063:
	.size	_Z44__device_stub__Z19gpu_matrix_multiplyPfS_S_iPfS_S_i, .-_Z44__device_stub__Z19gpu_matrix_multiplyPfS_S_iPfS_S_i
	.globl	_Z19gpu_matrix_multiplyPfS_S_i
	.type	_Z19gpu_matrix_multiplyPfS_S_i, @function
_Z19gpu_matrix_multiplyPfS_S_i:
.LFB2064:
	.cfi_startproc
	endbr64
	jmp	_Z44__device_stub__Z19gpu_matrix_multiplyPfS_S_iPfS_S_i
	.cfi_endproc
.LFE2064:
	.size	_Z19gpu_matrix_multiplyPfS_S_i, .-_Z19gpu_matrix_multiplyPfS_S_i
	.section	.rodata.str1.1
.LC8:
	.string	"Matrix allocation error on host\n"
.LC9:
	.string	"Total Error: %f\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2038:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movl	$100, %edi
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	subq	$120, %rsp
	.cfi_def_cfa_offset 144
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	call	srand@PLT
	leaq	16(%rsp), %rdi
	movl	$1600000000, %esi
	call	cudaMallocHost@PLT
	leaq	24(%rsp), %rdi
	movl	$1600000000, %esi
	call	cudaMallocHost@PLT
	leaq	32(%rsp), %rdi
	movl	$1600000000, %esi
	call	cudaMallocHost@PLT
	leaq	40(%rsp), %rdi
	movl	$1600000000, %esi
	call	cudaMallocHost@PLT
	leaq	8(%rsp), %rdi
	movl	$400000000, %esi
	call	cudaMallocHost@PLT
	movq	8(%rsp), %rdi
	testq	%rdi, %rdi
	je	.L85
	cmpq	$0, 16(%rsp)
	je	.L85
	cmpq	$0, 24(%rsp)
	je	.L85
	cmpq	$0, 32(%rsp)
	je	.L85
	cmpq	$0, 40(%rsp)
	jne	.L86
.L85:
	movl	$2, %edi
	leaq	.LC8(%rip), %rsi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$1, %edi
	call	exit@PLT
.L86:
	movl	$10000, %esi
	call	_Z6make_xPfi
	movq	16(%rsp), %rbx
	xorl	%edx, %edx
	xorl	%esi, %esi
	movl	$20000, %r8d
	movl	$10000, %ecx
	movq	%rbx, %rdi
	call	_Z13make_identityPfiiii
	movq	8(%rsp), %rbp
	movl	$20000, %r9d
	movq	%rbx, %rdi
	movl	$10000, %ecx
	movl	$10000, %r8d
	movq	%rbp, %rsi
	call	_Z6copy_xPfS_iiii
	movl	$20000, %r8d
	xorl	%edx, %edx
	movl	$10000, %esi
	call	_Z9make_zeroPfiiii
	movl	$10000, %ecx
	movl	$10000, %edx
	movl	$10000, %esi
	call	_Z13make_identityPfiiii
	movq	24(%rsp), %rbx
	xorl	%edx, %edx
	xorl	%esi, %esi
	movl	$10000, %ecx
	movq	%rbx, %rdi
	call	_Z13make_identityPfiiii
	movq	%rbx, %rdi
	movl	$10000, %ecx
	movq	%rbp, %rsi
	movl	$20000, %r9d
	movl	$10000, %r8d
	call	_Z7copy_2xPfS_iiii
	movl	$20000, %r8d
	xorl	%edx, %edx
	movl	$10000, %esi
	call	_Z9make_zeroPfiiii
	movl	$10000, %ecx
	movl	$10000, %edx
	movl	$10000, %esi
	call	_Z16make_negidentityPfiiii
	movq	32(%rsp), %rbx
	xorl	%edx, %edx
	xorl	%esi, %esi
	movl	$10000, %ecx
	movq	%rbx, %rdi
	call	_Z13make_identityPfiiii
	movq	%rbx, %rdi
	movl	$10000, %ecx
	movq	%rbp, %rsi
	movl	$20000, %r9d
	movl	$10000, %r8d
	call	_Z9copy_negxPfS_iiii
	movl	$20000, %r8d
	xorl	%edx, %edx
	movl	$10000, %esi
	call	_Z9make_zeroPfiiii
	movl	$10000, %ecx
	movl	$10000, %edx
	movl	$10000, %esi
	call	_Z13make_identityPfiiii
	movq	40(%rsp), %rdi
	movl	$20000, %esi
	call	_Z11make_resultPfi
	leaq	48(%rsp), %rdi
	movl	$1600000000, %esi
	call	cudaMalloc@PLT
	leaq	56(%rsp), %rdi
	movl	$1600000000, %esi
	call	cudaMalloc@PLT
	leaq	64(%rsp), %rdi
	movl	$1600000000, %esi
	call	cudaMalloc@PLT
	leaq	72(%rsp), %rdi
	movl	$1600000000, %esi
	call	cudaMalloc@PLT
	movq	16(%rsp), %rsi
	movq	48(%rsp), %rdi
	movl	$1, %ecx
	movl	$1600000000, %edx
	call	cudaMemcpy@PLT
	movq	24(%rsp), %rsi
	movq	56(%rsp), %rdi
	movl	$1, %ecx
	movl	$1600000000, %edx
	call	cudaMemcpy@PLT
	movq	32(%rsp), %rsi
	movq	64(%rsp), %rdi
	movl	$1, %ecx
	movl	$1600000000, %edx
	call	cudaMemcpy@PLT
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	$1, %ecx
	movabsq	$5368709121250, %rdi
	movl	$1, %esi
	movabsq	$68719476752, %rdx
	movl	$1, 88(%rsp)
	movq	%rdi, 80(%rsp)
	movq	%rdx, 92(%rsp)
	movl	$1, 100(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L87
	movq	72(%rsp), %rdx
	movq	56(%rsp), %rsi
	movl	$20000, %ecx
	movq	48(%rsp), %rdi
	call	_Z44__device_stub__Z19gpu_matrix_multiplyPfS_S_iPfS_S_i
.L87:
	call	cudaThreadSynchronize@PLT
	movl	100(%rsp), %ecx
	movl	88(%rsp), %esi
	xorl	%r9d, %r9d
	movq	92(%rsp), %rdx
	movq	80(%rsp), %rdi
	xorl	%r8d, %r8d
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L88
	movq	48(%rsp), %rdx
	movq	64(%rsp), %rsi
	movl	$20000, %ecx
	movq	72(%rsp), %rdi
	call	_Z44__device_stub__Z19gpu_matrix_multiplyPfS_S_iPfS_S_i
.L88:
	movq	48(%rsp), %rsi
	movq	16(%rsp), %rdi
	movl	$2, %ecx
	movl	$1600000000, %edx
	call	cudaMemcpy@PLT
	call	cudaThreadSynchronize@PLT
	movq	40(%rsp), %rsi
	movq	16(%rsp), %rdi
	movl	$20000, %edx
	call	_Z8rothVerfPfS_i
	leaq	.LC9(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	cvtss2sd	%xmm0, %xmm0
	call	__printf_chk@PLT
	movq	48(%rsp), %rdi
	call	cudaFree@PLT
	movq	56(%rsp), %rdi
	call	cudaFree@PLT
	movq	64(%rsp), %rdi
	call	cudaFree@PLT
	movq	72(%rsp), %rdi
	call	cudaFree@PLT
	movq	16(%rsp), %rdi
	call	cudaFreeHost@PLT
	movq	24(%rsp), %rdi
	call	cudaFreeHost@PLT
	movq	32(%rsp), %rdi
	call	cudaFreeHost@PLT
	movq	40(%rsp), %rdi
	call	cudaFreeHost@PLT
	movq	8(%rsp), %rdi
	call	cudaFreeHost@PLT
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L89
	call	__stack_chk_fail@PLT
.L89:
	addq	$120, %rsp
	.cfi_def_cfa_offset 24
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2038:
	.size	main, .-main
	.section	.rodata.str1.1
.LC10:
	.string	"_Z19gpu_matrix_multiplyPfS_S_i"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2066:
	.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	_Z19gpu_matrix_multiplyPfS_S_i(%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
.LFE2066:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.section	.rodata.cst4,"aM",@progbits,4
	.align 4
.LC0:
	.long	805306368
	.align 4
.LC1:
	.long	1065353216
	.align 4
.LC3:
	.long	-1082130432
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC4:
	.long	-2147483648
	.long	0
	.long	0
	.long	0
	.align 16
.LC5:
	.long	2147483647
	.long	0
	.long	0
	.long	0
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:


#include <hip/hip_runtime.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>


#define SUBMATRIX_SIZE 10000
#define BLOCK_SIZE 16

float getnum() {
  return rand()/((float) RAND_MAX);
}


__global__ void gpu_matrix_multiply(float *a, float *b, float *c, int n) 
{
  __shared__ float tile_a[BLOCK_SIZE][BLOCK_SIZE];
  __shared__ float tile_b[BLOCK_SIZE][BLOCK_SIZE];

  int row = blockIdx.y * BLOCK_SIZE + threadIdx.y;
  int col = blockIdx.x * BLOCK_SIZE + threadIdx.x;
  float tmp = 0.0f;
  int idx;

  for (int sub = 0; sub < gridDim.x; ++sub) // gridDim.x
    {
      idx = row * n + sub * BLOCK_SIZE + threadIdx.x;
      if(idx >= n*n)
        {
	  // n may not divisible by BLOCK_SIZE
	  tile_a[threadIdx.y][threadIdx.x] = 0.0f;
        }
      else
        {
	  tile_a[threadIdx.y][threadIdx.x] = a[idx];
        }

      idx = (sub * BLOCK_SIZE + threadIdx.y) * n + col;
      if(idx >= n*n)
        {
	  tile_b[threadIdx.y][threadIdx.x] = 0.0f;
        }  
      else
        {
	  tile_b[threadIdx.y][threadIdx.x] = b[idx];
        }
      __syncthreads();

      for (int k = 0; k < BLOCK_SIZE; ++k) 
        {
	  tmp += tile_a[threadIdx.y][k] * tile_b[k][threadIdx.x];
        }
      __syncthreads();
    }
  if(row < n && col < n)
    {
      c[row * n + col] = tmp;
    }
}


void make_identity(float* a, int startx, int starty, int length, int n) {
  // fill a with the identity from start to end
  int i, j;
  for (i=startx; i<length+startx; i++) {
    for (j=starty; j<length+starty; j++) {
      a[i*n+j] = (i-startx==j-starty) ? 1.0f : 0.0f;
    }
  }
}

void make_negidentity(float* a, int startx, int starty, int length, int n) {
  // fill a with the identity from start to end
  int i, j;
  for (i=startx; i<length+startx; i++) {
    for (j=starty; j<length+starty; j++) {
      a[i*n+j] = (i-startx==j-starty) ? -1.0f : 0.0f;
    }
  }
}

void make_x(float* x, int length) {
  int i, j;
  for (i=0; i<length; i++) {
    for (j=0; j<length; j++) {
      x[i*length+j] = getnum();
    }
  }
}

void make_zero(float* a, int startx, int starty, int length, int n) {
  int i, j;
  for (i=startx; i<length+startx; i++) {
    for (j=starty; j<length+starty; j++) {
      a[i*n+j] = 0.0f;
    }
  }
}

void copy_x(float* a, float* x, int startx, int starty, int length, int n) {
  int i, j;
  for (i=startx; i<length+startx; i++) {
    for (j=starty; j<length+starty; j++) {
      a[i*n+j] = x[(i-startx)*length+(j-starty)];
    }
  }
}

void copy_2x(float* a, float* x, int startx, int starty, int length, int n) {
  int i, j;
  for (i=startx; i<length+startx; i++) {
    for (j=starty; j<length+starty; j++) {
      a[i*n+j] = 2*x[(i-startx)*length+(j-starty)];
    }
  }
}

void copy_negx(float* a, float* x, int startx, int starty, int length, int n) {
  int i, j;
  for (i=startx; i<length+startx; i++) {
    for (j=starty; j<length+starty; j++) {
      a[i*n+j] = (-1)*x[(i-startx)*length+(j-starty)];
    }
  }
}

void make_result(float* a, int length) {
  int i, j;
  int half = length>>1;
  for (i=0; i<length; i++) {
    for (j=0; j<length; j++) {
      if (i == j) {
	if (i>=half)
	  a[i*length+j] = -1.0f;
	else
	  a[i*length+j] = 1.0f;
      }
      else
	a[i*length+j] = 0.0f;
    }
  }
}

float rothVerf(float* a, float* b, int n) {
  float sum = 0;
  int i, j;
  for (i=0; i<n; i++) {
    for (j=0; j<n; j++) {
      sum += (float) fabs(a[i*n+j] - b[i*n+j]);
    }
  }
  return sum;
}

void print_mat(float* a, int n) {
  int i, j;
  for (i=0; i<n; i++) {
    for (j=0; j<n; j++) {
      printf("%.2f\t", a[i*n+j]);
    }
    printf("\n");
  }
  printf("\n");
}


int main() {
  srand(100);
  int n = 2*SUBMATRIX_SIZE;
  int half = n>>1;
  size_t totalsize = sizeof(float)*n*n;
  size_t halfsize = sizeof(float)*half*half;
  float *x, *a, *b, *c, *d;

  hipHostMalloc((void**) &a, totalsize, hipHostMallocDefault);
  hipHostMalloc((void**) &b, totalsize, hipHostMallocDefault);
  hipHostMalloc((void**) &c, totalsize, hipHostMallocDefault);
  hipHostMalloc((void**) &d, totalsize, hipHostMallocDefault);
  hipHostMalloc((void**) &x, halfsize, hipHostMallocDefault);
  
  if ((x==NULL) || (a==NULL) || (b==NULL) || (c==NULL) ||
      (d==NULL)) {
    printf("Matrix allocation error on host\n");
    exit(1);
  }

  make_x(x, half);

  // construct first matrix
  make_identity(a, 0, 0, half, n);
  copy_x(a, x, 0, half, half, n);
  make_zero(a, half, 0, half, n);
  make_identity(a, half, half, half, n);

  // second matrix
  make_identity(b, 0, 0, half, n);
  copy_2x(b, x, 0, half, half, n);
  make_zero(b, half, 0, half, n);
  make_negidentity(b, half, half, half, n);

  // third
  make_identity(c, 0, 0, half, n);
  copy_negx(c, x, 0, half, half, n);
  make_zero(c, half, 0, half, n);
  make_identity(c, half, half, half, n);

  // result
  make_result(d, n);

  // allocate on device
  float *dev_a, *dev_b, *dev_c, *dev_inter;
  hipMalloc((void**) &dev_a, totalsize);
  hipMalloc((void**) &dev_b, totalsize);
  hipMalloc((void**) &dev_c, totalsize);
  hipMalloc((void**) &dev_inter, totalsize);
  
  // copy to device
  hipMemcpy(dev_a, a, totalsize, hipMemcpyHostToDevice);
  hipMemcpy(dev_b, b, totalsize, hipMemcpyHostToDevice);
  hipMemcpy(dev_c, c, totalsize, hipMemcpyHostToDevice);

  unsigned int grid_rows = n / BLOCK_SIZE;
  unsigned int grid_cols = n / BLOCK_SIZE;
  dim3 dimGrid(grid_cols, grid_rows);
  dim3 dimBlock(BLOCK_SIZE, BLOCK_SIZE);

  // intermediate matrix product
  gpu_matrix_multiply<<<dimGrid, dimBlock>>>(dev_a, dev_b, dev_inter, n);
  hipDeviceSynchronize();

  // reuse old matrix
  gpu_matrix_multiply<<<dimGrid, dimBlock>>>(dev_inter, dev_c, dev_a, n);

  // bring product back to cpu
  hipMemcpy(a, dev_a, totalsize, hipMemcpyDeviceToHost);
  hipDeviceSynchronize();

  // check a against the result d
  float sum = rothVerf(a, d, n);
  printf("Total Error: %f\n", sum);

  // cleanup and exit
  hipFree(dev_a);
  hipFree(dev_b);
  hipFree(dev_c);
  hipFree(dev_inter);
  hipHostFree(a);
  hipHostFree(b);
  hipHostFree(c);
  hipHostFree(d);
  hipHostFree(x);
  return 0;
}

	.text
	.file	"parallel.hip"
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function _Z6getnumv
.LCPI0_0:
	.long	0x30000000                      # float 4.65661287E-10
	.text
	.globl	_Z6getnumv
	.type	_Z6getnumv,@function
_Z6getnumv:                             # @_Z6getnumv
	.cfi_startproc
# %bb.0:
	pushq	%rax
	.cfi_def_cfa_offset 16
	callq	rand
	cvtsi2ss	%eax, %xmm0
	mulss	.LCPI0_0(%rip), %xmm0
	popq	%rax
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_Z6getnumv, .Lfunc_end0-_Z6getnumv
	.cfi_endproc
                                        # -- End function
	.globl	_Z34__device_stub__gpu_matrix_multiplyPfS_S_i # -- Begin function _Z34__device_stub__gpu_matrix_multiplyPfS_S_i
	.type	_Z34__device_stub__gpu_matrix_multiplyPfS_S_i,@function
_Z34__device_stub__gpu_matrix_multiplyPfS_S_i: # @_Z34__device_stub__gpu_matrix_multiplyPfS_S_i
	.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	$112, %rsp
	.cfi_def_cfa_offset 160
	.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)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%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	$_Z19gpu_matrix_multiplyPfS_S_i, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$128, %rsp
	.cfi_adjust_cfa_offset -128
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end1:
	.size	_Z34__device_stub__gpu_matrix_multiplyPfS_S_i, .Lfunc_end1-_Z34__device_stub__gpu_matrix_multiplyPfS_S_i
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function _Z13make_identityPfiiii
.LCPI2_0:
	.long	0x3f800000                      # float 1
	.text
	.globl	_Z13make_identityPfiiii
	.type	_Z13make_identityPfiiii,@function
_Z13make_identityPfiiii:                # @_Z13make_identityPfiiii
	.cfi_startproc
# %bb.0:
                                        # kill: def $ecx killed $ecx def $rcx
                                        # kill: def $esi killed $esi def $rsi
	testl	%ecx, %ecx
	jle	.LBB2_7
# %bb.1:                                # %.preheader.lr.ph
	leal	(%rcx,%rsi), %r9d
	addl	%edx, %ecx
	movslq	%edx, %rax
	movslq	%ecx, %rcx
	movslq	%esi, %rdx
	movslq	%r8d, %rsi
	movslq	%r9d, %r8
	movq	%rsi, %r9
	imulq	%rdx, %r9
	leaq	(%rdi,%r9,4), %rdi
	shlq	$2, %rsi
	xorl	%r9d, %r9d
	movss	.LCPI2_0(%rip), %xmm0           # xmm0 = mem[0],zero,zero,zero
.LBB2_2:                                # %.lr.ph
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB2_3 Depth 2
	movq	%r9, %r10
	movq	%rax, %r11
.LBB2_3:                                #   Parent Loop BB2_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movaps	%xmm0, %xmm1
	subq	$1, %r10
	jb	.LBB2_5
# %bb.4:                                #   in Loop: Header=BB2_3 Depth=2
	xorps	%xmm1, %xmm1
.LBB2_5:                                #   in Loop: Header=BB2_3 Depth=2
	movss	%xmm1, (%rdi,%r11,4)
	incq	%r11
	cmpq	%rcx, %r11
	jl	.LBB2_3
# %bb.6:                                # %._crit_edge
                                        #   in Loop: Header=BB2_2 Depth=1
	incq	%rdx
	addq	%rsi, %rdi
	incq	%r9
	cmpq	%r8, %rdx
	jl	.LBB2_2
.LBB2_7:                                # %._crit_edge20
	retq
.Lfunc_end2:
	.size	_Z13make_identityPfiiii, .Lfunc_end2-_Z13make_identityPfiiii
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function _Z16make_negidentityPfiiii
.LCPI3_0:
	.long	0xbf800000                      # float -1
	.text
	.globl	_Z16make_negidentityPfiiii
	.type	_Z16make_negidentityPfiiii,@function
_Z16make_negidentityPfiiii:             # @_Z16make_negidentityPfiiii
	.cfi_startproc
# %bb.0:
                                        # kill: def $ecx killed $ecx def $rcx
                                        # kill: def $esi killed $esi def $rsi
	testl	%ecx, %ecx
	jle	.LBB3_7
# %bb.1:                                # %.preheader.lr.ph
	leal	(%rcx,%rsi), %r9d
	addl	%edx, %ecx
	movslq	%edx, %rax
	movslq	%ecx, %rcx
	movslq	%esi, %rdx
	movslq	%r8d, %rsi
	movslq	%r9d, %r8
	movq	%rsi, %r9
	imulq	%rdx, %r9
	leaq	(%rdi,%r9,4), %rdi
	shlq	$2, %rsi
	xorl	%r9d, %r9d
	movss	.LCPI3_0(%rip), %xmm0           # xmm0 = mem[0],zero,zero,zero
.LBB3_2:                                # %.lr.ph
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB3_3 Depth 2
	movq	%r9, %r10
	movq	%rax, %r11
.LBB3_3:                                #   Parent Loop BB3_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movaps	%xmm0, %xmm1
	subq	$1, %r10
	jb	.LBB3_5
# %bb.4:                                #   in Loop: Header=BB3_3 Depth=2
	xorps	%xmm1, %xmm1
.LBB3_5:                                #   in Loop: Header=BB3_3 Depth=2
	movss	%xmm1, (%rdi,%r11,4)
	incq	%r11
	cmpq	%rcx, %r11
	jl	.LBB3_3
# %bb.6:                                # %._crit_edge
                                        #   in Loop: Header=BB3_2 Depth=1
	incq	%rdx
	addq	%rsi, %rdi
	incq	%r9
	cmpq	%r8, %rdx
	jl	.LBB3_2
.LBB3_7:                                # %._crit_edge20
	retq
.Lfunc_end3:
	.size	_Z16make_negidentityPfiiii, .Lfunc_end3-_Z16make_negidentityPfiiii
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function _Z6make_xPfi
.LCPI4_0:
	.long	0x30000000                      # float 4.65661287E-10
	.text
	.globl	_Z6make_xPfi
	.type	_Z6make_xPfi,@function
_Z6make_xPfi:                           # @_Z6make_xPfi
	.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
	movq	%rdi, (%rsp)                    # 8-byte Spill
	testl	%esi, %esi
	jle	.LBB4_5
# %bb.1:                                # %.preheader.lr.ph
	movl	%esi, %ebx
	movl	%esi, %r15d
	xorl	%r12d, %r12d
	xorl	%r13d, %r13d
.LBB4_2:                                # %.lr.ph
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB4_3 Depth 2
	movl	%r12d, %eax
	movq	(%rsp), %rcx                    # 8-byte Reload
	leaq	(%rcx,%rax,4), %rbp
	xorl	%r14d, %r14d
.LBB4_3:                                #   Parent Loop BB4_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	callq	rand
	movss	.LCPI4_0(%rip), %xmm1           # xmm1 = mem[0],zero,zero,zero
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	mulss	%xmm1, %xmm0
	movss	%xmm0, (%rbp,%r14,4)
	incq	%r14
	cmpq	%r14, %r15
	jne	.LBB4_3
# %bb.4:                                # %._crit_edge
                                        #   in Loop: Header=BB4_2 Depth=1
	incq	%r13
	addl	%ebx, %r12d
	cmpq	%r15, %r13
	jne	.LBB4_2
.LBB4_5:                                # %._crit_edge13
	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_end4:
	.size	_Z6make_xPfi, .Lfunc_end4-_Z6make_xPfi
	.cfi_endproc
                                        # -- End function
	.globl	_Z9make_zeroPfiiii              # -- Begin function _Z9make_zeroPfiiii
	.type	_Z9make_zeroPfiiii,@function
_Z9make_zeroPfiiii:                     # @_Z9make_zeroPfiiii
	.cfi_startproc
# %bb.0:
                                        # kill: def $ecx killed $ecx def $rcx
                                        # kill: def $edx killed $edx def $rdx
	testl	%ecx, %ecx
	jle	.LBB5_4
# %bb.1:                                # %.preheader.lr.ph
	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	%r8d, %ebx
	movl	%esi, %r14d
	movq	%rdi, %r15
	leal	(%rcx,%r14), %ebp
	addl	%edx, %ecx
	movl	%r8d, %r13d
	imull	%esi, %r13d
	leal	1(%rdx), %eax
	cmpl	%eax, %ecx
	cmovlel	%eax, %ecx
	movl	%edx, %eax
	notl	%eax
	addl	%ecx, %eax
	leaq	4(,%rax,4), %r12
	addl	%edx, %r13d
.LBB5_2:                                # %._crit_edge
                                        # =>This Inner Loop Header: Depth=1
	movslq	%r13d, %r13
	leaq	(%r15,%r13,4), %rdi
	xorl	%esi, %esi
	movq	%r12, %rdx
	callq	memset@PLT
	incl	%r14d
	addl	%ebx, %r13d
	cmpl	%ebp, %r14d
	jl	.LBB5_2
# %bb.3:
	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
	.cfi_restore %rbx
	.cfi_restore %r12
	.cfi_restore %r13
	.cfi_restore %r14
	.cfi_restore %r15
	.cfi_restore %rbp
.LBB5_4:                                # %._crit_edge16
	retq
.Lfunc_end5:
	.size	_Z9make_zeroPfiiii, .Lfunc_end5-_Z9make_zeroPfiiii
	.cfi_endproc
                                        # -- End function
	.globl	_Z6copy_xPfS_iiii               # -- Begin function _Z6copy_xPfS_iiii
	.type	_Z6copy_xPfS_iiii,@function
_Z6copy_xPfS_iiii:                      # @_Z6copy_xPfS_iiii
	.cfi_startproc
# %bb.0:
                                        # kill: def $r8d killed $r8d def $r8
                                        # kill: def $ecx killed $ecx def $rcx
                                        # kill: def $edx killed $edx def $rdx
	testl	%r8d, %r8d
	jle	.LBB6_6
# %bb.1:                                # %.preheader.lr.ph
	pushq	%r14
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset %rbx, -24
	.cfi_offset %r14, -16
	leal	(%r8,%rdx), %r10d
	leal	(%r8,%rcx), %r11d
	movslq	%ecx, %rax
	movslq	%r11d, %rcx
	movslq	%edx, %rdx
	movslq	%r9d, %r9
	movslq	%r10d, %r10
	movq	%r9, %r11
	imulq	%rdx, %r11
	leaq	(%rdi,%r11,4), %rdi
	shlq	$2, %r9
	xorl	%r11d, %r11d
.LBB6_2:                                # %.lr.ph
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB6_3 Depth 2
	movl	%r11d, %ebx
	movq	%rax, %r14
.LBB6_3:                                #   Parent Loop BB6_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movslq	%ebx, %rbx
	movss	(%rsi,%rbx,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, (%rdi,%r14,4)
	incq	%r14
	incl	%ebx
	cmpq	%rcx, %r14
	jl	.LBB6_3
# %bb.4:                                # %._crit_edge
                                        #   in Loop: Header=BB6_2 Depth=1
	incq	%rdx
	addq	%r9, %rdi
	addl	%r8d, %r11d
	cmpq	%r10, %rdx
	jl	.LBB6_2
# %bb.5:
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	.cfi_restore %rbx
	.cfi_restore %r14
.LBB6_6:                                # %._crit_edge22
	retq
.Lfunc_end6:
	.size	_Z6copy_xPfS_iiii, .Lfunc_end6-_Z6copy_xPfS_iiii
	.cfi_endproc
                                        # -- End function
	.globl	_Z7copy_2xPfS_iiii              # -- Begin function _Z7copy_2xPfS_iiii
	.type	_Z7copy_2xPfS_iiii,@function
_Z7copy_2xPfS_iiii:                     # @_Z7copy_2xPfS_iiii
	.cfi_startproc
# %bb.0:
                                        # kill: def $r8d killed $r8d def $r8
                                        # kill: def $ecx killed $ecx def $rcx
                                        # kill: def $edx killed $edx def $rdx
	testl	%r8d, %r8d
	jle	.LBB7_6
# %bb.1:                                # %.preheader.lr.ph
	pushq	%r14
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset %rbx, -24
	.cfi_offset %r14, -16
	leal	(%r8,%rdx), %r10d
	leal	(%r8,%rcx), %r11d
	movslq	%ecx, %rax
	movslq	%r11d, %rcx
	movslq	%edx, %rdx
	movslq	%r9d, %r9
	movslq	%r10d, %r10
	movq	%r9, %r11
	imulq	%rdx, %r11
	leaq	(%rdi,%r11,4), %rdi
	shlq	$2, %r9
	xorl	%r11d, %r11d
.LBB7_2:                                # %.lr.ph
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB7_3 Depth 2
	movl	%r11d, %ebx
	movq	%rax, %r14
.LBB7_3:                                #   Parent Loop BB7_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movslq	%ebx, %rbx
	movss	(%rsi,%rbx,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	addss	%xmm0, %xmm0
	movss	%xmm0, (%rdi,%r14,4)
	incq	%r14
	incl	%ebx
	cmpq	%rcx, %r14
	jl	.LBB7_3
# %bb.4:                                # %._crit_edge
                                        #   in Loop: Header=BB7_2 Depth=1
	incq	%rdx
	addq	%r9, %rdi
	addl	%r8d, %r11d
	cmpq	%r10, %rdx
	jl	.LBB7_2
# %bb.5:
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	.cfi_restore %rbx
	.cfi_restore %r14
.LBB7_6:                                # %._crit_edge22
	retq
.Lfunc_end7:
	.size	_Z7copy_2xPfS_iiii, .Lfunc_end7-_Z7copy_2xPfS_iiii
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0                          # -- Begin function _Z9copy_negxPfS_iiii
.LCPI8_0:
	.long	0x80000000                      # float -0
	.long	0x80000000                      # float -0
	.long	0x80000000                      # float -0
	.long	0x80000000                      # float -0
	.text
	.globl	_Z9copy_negxPfS_iiii
	.type	_Z9copy_negxPfS_iiii,@function
_Z9copy_negxPfS_iiii:                   # @_Z9copy_negxPfS_iiii
	.cfi_startproc
# %bb.0:
                                        # kill: def $r8d killed $r8d def $r8
                                        # kill: def $ecx killed $ecx def $rcx
                                        # kill: def $edx killed $edx def $rdx
	testl	%r8d, %r8d
	jle	.LBB8_6
# %bb.1:                                # %.preheader.lr.ph
	pushq	%r14
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset %rbx, -24
	.cfi_offset %r14, -16
	leal	(%r8,%rdx), %r10d
	leal	(%r8,%rcx), %r11d
	movslq	%ecx, %rax
	movslq	%r11d, %rcx
	movslq	%edx, %rdx
	movslq	%r9d, %r9
	movslq	%r10d, %r10
	movq	%r9, %r11
	imulq	%rdx, %r11
	leaq	(%rdi,%r11,4), %rdi
	shlq	$2, %r9
	xorl	%r11d, %r11d
	movaps	.LCPI8_0(%rip), %xmm0           # xmm0 = [-0.0E+0,-0.0E+0,-0.0E+0,-0.0E+0]
.LBB8_2:                                # %.lr.ph
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB8_3 Depth 2
	movl	%r11d, %ebx
	movq	%rax, %r14
.LBB8_3:                                #   Parent Loop BB8_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movslq	%ebx, %rbx
	movss	(%rsi,%rbx,4), %xmm1            # xmm1 = mem[0],zero,zero,zero
	xorps	%xmm0, %xmm1
	movss	%xmm1, (%rdi,%r14,4)
	incq	%r14
	incl	%ebx
	cmpq	%rcx, %r14
	jl	.LBB8_3
# %bb.4:                                # %._crit_edge
                                        #   in Loop: Header=BB8_2 Depth=1
	incq	%rdx
	addq	%r9, %rdi
	addl	%r8d, %r11d
	cmpq	%r10, %rdx
	jl	.LBB8_2
# %bb.5:
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	.cfi_restore %rbx
	.cfi_restore %r14
.LBB8_6:                                # %._crit_edge22
	retq
.Lfunc_end8:
	.size	_Z9copy_negxPfS_iiii, .Lfunc_end8-_Z9copy_negxPfS_iiii
	.cfi_endproc
                                        # -- End function
	.globl	_Z11make_resultPfi              # -- Begin function _Z11make_resultPfi
	.type	_Z11make_resultPfi,@function
_Z11make_resultPfi:                     # @_Z11make_resultPfi
	.cfi_startproc
# %bb.0:
	testl	%esi, %esi
	jle	.LBB9_11
# %bb.1:                                # %.preheader.lr.ph
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset %rbx, -16
	movl	%esi, %eax
	shrl	%eax
	movl	%esi, %ecx
	xorl	%edx, %edx
	xorl	%r8d, %r8d
.LBB9_2:                                # %.lr.ph
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB9_3 Depth 2
	movl	%edx, %r9d
	leaq	(%rdi,%r9,4), %r9
	movl	%r8d, %r10d
	imull	%esi, %r10d
	leaq	(%rdi,%r8,4), %r11
	xorl	%ebx, %ebx
.LBB9_3:                                #   Parent Loop BB9_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	cmpq	%rbx, %r8
	jne	.LBB9_7
# %bb.4:                                #   in Loop: Header=BB9_3 Depth=2
	cmpq	%rax, %r8
	jae	.LBB9_5
# %bb.6:                                #   in Loop: Header=BB9_3 Depth=2
	movl	$1065353216, (%r11,%r10,4)      # imm = 0x3F800000
	jmp	.LBB9_8
.LBB9_7:                                #   in Loop: Header=BB9_3 Depth=2
	movl	$0, (%r9,%rbx,4)
	jmp	.LBB9_8
.LBB9_5:                                #   in Loop: Header=BB9_3 Depth=2
	movl	$-1082130432, (%r11,%r10,4)     # imm = 0xBF800000
.LBB9_8:                                #   in Loop: Header=BB9_3 Depth=2
	incq	%rbx
	cmpq	%rbx, %rcx
	jne	.LBB9_3
# %bb.9:                                # %._crit_edge
                                        #   in Loop: Header=BB9_2 Depth=1
	incq	%r8
	addl	%esi, %edx
	cmpq	%rcx, %r8
	jne	.LBB9_2
# %bb.10:
	popq	%rbx
	.cfi_def_cfa_offset 8
	.cfi_restore %rbx
.LBB9_11:                               # %._crit_edge26
	retq
.Lfunc_end9:
	.size	_Z11make_resultPfi, .Lfunc_end9-_Z11make_resultPfi
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0                          # -- Begin function _Z8rothVerfPfS_i
.LCPI10_0:
	.long	0x7fffffff                      # float NaN
	.long	0x7fffffff                      # float NaN
	.long	0x7fffffff                      # float NaN
	.long	0x7fffffff                      # float NaN
	.text
	.globl	_Z8rothVerfPfS_i
	.type	_Z8rothVerfPfS_i,@function
_Z8rothVerfPfS_i:                       # @_Z8rothVerfPfS_i
	.cfi_startproc
# %bb.0:
	testl	%edx, %edx
	jle	.LBB10_1
# %bb.3:                                # %.preheader.lr.ph
	movl	%edx, %eax
	xorps	%xmm0, %xmm0
	xorl	%ecx, %ecx
	movaps	.LCPI10_0(%rip), %xmm1          # xmm1 = [NaN,NaN,NaN,NaN]
	xorl	%r8d, %r8d
.LBB10_4:                               # %.lr.ph
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB10_5 Depth 2
	movl	%ecx, %r10d
	leaq	(%rsi,%r10,4), %r9
	leaq	(%rdi,%r10,4), %r10
	xorl	%r11d, %r11d
.LBB10_5:                               #   Parent Loop BB10_4 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movss	(%r10,%r11,4), %xmm2            # xmm2 = mem[0],zero,zero,zero
	subss	(%r9,%r11,4), %xmm2
	andps	%xmm1, %xmm2
	addss	%xmm2, %xmm0
	incq	%r11
	cmpq	%r11, %rax
	jne	.LBB10_5
# %bb.6:                                # %._crit_edge
                                        #   in Loop: Header=BB10_4 Depth=1
	incq	%r8
	addl	%edx, %ecx
	cmpq	%rax, %r8
	jne	.LBB10_4
# %bb.2:                                # %._crit_edge22
	retq
.LBB10_1:
	xorps	%xmm0, %xmm0
	retq
.Lfunc_end10:
	.size	_Z8rothVerfPfS_i, .Lfunc_end10-_Z8rothVerfPfS_i
	.cfi_endproc
                                        # -- End function
	.globl	_Z9print_matPfi                 # -- Begin function _Z9print_matPfi
	.type	_Z9print_matPfi,@function
_Z9print_matPfi:                        # @_Z9print_matPfi
	.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
	movq	%rdi, (%rsp)                    # 8-byte Spill
	testl	%esi, %esi
	jle	.LBB11_5
# %bb.1:                                # %.preheader.lr.ph
	movl	%esi, %ebx
	movl	%esi, %r15d
	xorl	%r12d, %r12d
	xorl	%r13d, %r13d
.LBB11_2:                               # %.lr.ph
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB11_3 Depth 2
	movl	%r12d, %eax
	movq	(%rsp), %rcx                    # 8-byte Reload
	leaq	(%rcx,%rax,4), %rbp
	xorl	%r14d, %r14d
.LBB11_3:                               #   Parent Loop BB11_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	xorps	%xmm0, %xmm0
	cvtss2sd	(%rbp,%r14,4), %xmm0
	movl	$.L.str, %edi
	movb	$1, %al
	callq	printf
	incq	%r14
	cmpq	%r14, %r15
	jne	.LBB11_3
# %bb.4:                                # %._crit_edge
                                        #   in Loop: Header=BB11_2 Depth=1
	movl	$10, %edi
	callq	putchar@PLT
	incq	%r13
	addl	%ebx, %r12d
	cmpq	%r15, %r13
	jne	.LBB11_2
.LBB11_5:                               # %._crit_edge14
	movl	$10, %edi
	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
	jmp	putchar@PLT                     # TAILCALL
.Lfunc_end11:
	.size	_Z9print_matPfi, .Lfunc_end11-_Z9print_matPfi
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function main
.LCPI12_0:
	.long	0x30000000                      # float 4.65661287E-10
.LCPI12_1:
	.long	0x3f800000                      # float 1
.LCPI12_2:
	.long	0xbf800000                      # float -1
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0
.LCPI12_3:
	.long	0x80000000                      # float -0
	.long	0x80000000                      # float -0
	.long	0x80000000                      # float -0
	.long	0x80000000                      # float -0
.LCPI12_4:
	.long	0x7fffffff                      # float NaN
	.long	0x7fffffff                      # float NaN
	.long	0x7fffffff                      # float NaN
	.long	0x7fffffff                      # float NaN
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%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	$80, %rsp
	.cfi_def_cfa_offset 128
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movl	$100, %edi
	callq	srand
	leaq	8(%rsp), %rdi
	movl	$1600000000, %esi               # imm = 0x5F5E1000
	xorl	%edx, %edx
	callq	hipHostMalloc
	leaq	40(%rsp), %rdi
	movl	$1600000000, %esi               # imm = 0x5F5E1000
	xorl	%edx, %edx
	callq	hipHostMalloc
	leaq	32(%rsp), %rdi
	movl	$1600000000, %esi               # imm = 0x5F5E1000
	xorl	%edx, %edx
	callq	hipHostMalloc
	leaq	24(%rsp), %rdi
	movl	$1600000000, %esi               # imm = 0x5F5E1000
	xorl	%edx, %edx
	callq	hipHostMalloc
	leaq	72(%rsp), %rbx
	movl	$400000000, %esi                # imm = 0x17D78400
	movq	%rbx, %rdi
	xorl	%edx, %edx
	callq	hipHostMalloc
	movq	(%rbx), %rbx
	testq	%rbx, %rbx
	je	.LBB12_81
# %bb.1:
	cmpq	$0, 8(%rsp)
	je	.LBB12_81
# %bb.2:
	cmpq	$0, 40(%rsp)
	je	.LBB12_81
# %bb.3:
	cmpq	$0, 32(%rsp)
	je	.LBB12_81
# %bb.4:
	cmpq	$0, 24(%rsp)
	je	.LBB12_81
# %bb.5:                                # %.lr.ph.i.preheader
	xorl	%r14d, %r14d
.LBB12_6:                               # %.lr.ph.i
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB12_7 Depth 2
	xorl	%r15d, %r15d
.LBB12_7:                               #   Parent Loop BB12_6 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	callq	rand
	movss	.LCPI12_0(%rip), %xmm1          # xmm1 = mem[0],zero,zero,zero
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	mulss	%xmm1, %xmm0
	movss	%xmm0, (%rbx,%r15,4)
	incq	%r15
	cmpq	$10000, %r15                    # imm = 0x2710
	jne	.LBB12_7
# %bb.8:                                # %._crit_edge.i
                                        #   in Loop: Header=BB12_6 Depth=1
	incq	%r14
	addq	$40000, %rbx                    # imm = 0x9C40
	cmpq	$10000, %r14                    # imm = 0x2710
	jne	.LBB12_6
# %bb.9:                                # %_Z6make_xPfi.exit
	movq	8(%rsp), %r14
	xorl	%eax, %eax
	movss	.LCPI12_1(%rip), %xmm0          # xmm0 = mem[0],zero,zero,zero
	movq	%r14, %rcx
.LBB12_10:                              # %.lr.ph.i85
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB12_11 Depth 2
	xorl	%edx, %edx
.LBB12_11:                              #   Parent Loop BB12_10 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movaps	%xmm0, %xmm1
	cmpq	%rdx, %rax
	je	.LBB12_13
# %bb.12:                               #   in Loop: Header=BB12_11 Depth=2
	xorps	%xmm1, %xmm1
.LBB12_13:                              #   in Loop: Header=BB12_11 Depth=2
	movss	%xmm1, (%rcx,%rdx,4)
	incq	%rdx
	cmpq	$10000, %rdx                    # imm = 0x2710
	jne	.LBB12_11
# %bb.14:                               # %._crit_edge.i90
                                        #   in Loop: Header=BB12_10 Depth=1
	incq	%rax
	addq	$80000, %rcx                    # imm = 0x13880
	cmpq	$10000, %rax                    # imm = 0x2710
	jne	.LBB12_10
# %bb.15:                               # %_Z13make_identityPfiiii.exit
	movq	72(%rsp), %rbx
	leaq	40000(%r14), %rax
	xorl	%ecx, %ecx
	movq	%rbx, %rdx
.LBB12_16:                              # %.lr.ph.i91
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB12_17 Depth 2
	xorl	%esi, %esi
.LBB12_17:                              #   Parent Loop BB12_16 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movss	(%rdx,%rsi,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, (%rax,%rsi,4)
	incq	%rsi
	cmpq	$10000, %rsi                    # imm = 0x2710
	jne	.LBB12_17
# %bb.18:                               # %._crit_edge.i96
                                        #   in Loop: Header=BB12_16 Depth=1
	incq	%rcx
	addq	$40000, %rdx                    # imm = 0x9C40
	addq	$80000, %rax                    # imm = 0x13880
	cmpq	$10000, %rcx                    # imm = 0x2710
	jne	.LBB12_16
# %bb.19:                               # %._crit_edge.i97.preheader
	leaq	800000000(%r14), %r15
	xorl	%r12d, %r12d
.LBB12_20:                              # %._crit_edge.i97
                                        # =>This Inner Loop Header: Depth=1
	leaq	(%r15,%r12), %rdi
	movl	$40000, %edx                    # imm = 0x9C40
	xorl	%esi, %esi
	callq	memset@PLT
	addq	$80000, %r12                    # imm = 0x13880
	cmpq	$800000000, %r12                # imm = 0x2FAF0800
	jne	.LBB12_20
# %bb.21:                               # %.lr.ph.i98.preheader
	addq	$800040000, %r14                # imm = 0x2FAFA440
	movl	$10000, %eax                    # imm = 0x2710
	xorl	%ecx, %ecx
	movss	.LCPI12_1(%rip), %xmm0          # xmm0 = mem[0],zero,zero,zero
.LBB12_22:                              # %.lr.ph.i98
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB12_23 Depth 2
	xorl	%edx, %edx
.LBB12_23:                              #   Parent Loop BB12_22 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movaps	%xmm0, %xmm1
	cmpq	%rdx, %rcx
	je	.LBB12_25
# %bb.24:                               #   in Loop: Header=BB12_23 Depth=2
	xorps	%xmm1, %xmm1
.LBB12_25:                              #   in Loop: Header=BB12_23 Depth=2
	movss	%xmm1, (%r14,%rdx,4)
	incq	%rdx
	cmpq	$10000, %rdx                    # imm = 0x2710
	jne	.LBB12_23
# %bb.26:                               # %._crit_edge.i105
                                        #   in Loop: Header=BB12_22 Depth=1
	incq	%rax
	incq	%rcx
	addq	$80000, %r14                    # imm = 0x13880
	cmpq	$20000, %rax                    # imm = 0x4E20
	jne	.LBB12_22
# %bb.27:                               # %_Z13make_identityPfiiii.exit107
	movq	40(%rsp), %r14
	xorl	%eax, %eax
	movss	.LCPI12_1(%rip), %xmm0          # xmm0 = mem[0],zero,zero,zero
	movq	%r14, %rcx
.LBB12_28:                              # %.lr.ph.i108
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB12_29 Depth 2
	xorl	%edx, %edx
.LBB12_29:                              #   Parent Loop BB12_28 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movaps	%xmm0, %xmm1
	cmpq	%rdx, %rax
	je	.LBB12_31
# %bb.30:                               #   in Loop: Header=BB12_29 Depth=2
	xorps	%xmm1, %xmm1
.LBB12_31:                              #   in Loop: Header=BB12_29 Depth=2
	movss	%xmm1, (%rcx,%rdx,4)
	incq	%rdx
	cmpq	$10000, %rdx                    # imm = 0x2710
	jne	.LBB12_29
# %bb.32:                               # %._crit_edge.i115
                                        #   in Loop: Header=BB12_28 Depth=1
	incq	%rax
	addq	$80000, %rcx                    # imm = 0x13880
	cmpq	$10000, %rax                    # imm = 0x2710
	jne	.LBB12_28
# %bb.33:                               # %.lr.ph.i118.preheader
	leaq	40000(%r14), %rax
	xorl	%ecx, %ecx
	movq	%rbx, %rdx
.LBB12_34:                              # %.lr.ph.i118
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB12_35 Depth 2
	xorl	%esi, %esi
.LBB12_35:                              #   Parent Loop BB12_34 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movss	(%rdx,%rsi,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	addss	%xmm0, %xmm0
	movss	%xmm0, (%rax,%rsi,4)
	incq	%rsi
	cmpq	$10000, %rsi                    # imm = 0x2710
	jne	.LBB12_35
# %bb.36:                               # %._crit_edge.i124
                                        #   in Loop: Header=BB12_34 Depth=1
	incq	%rcx
	addq	$40000, %rdx                    # imm = 0x9C40
	addq	$80000, %rax                    # imm = 0x13880
	cmpq	$10000, %rcx                    # imm = 0x2710
	jne	.LBB12_34
# %bb.37:                               # %._crit_edge.i126.preheader
	leaq	800000000(%r14), %r15
	xorl	%r12d, %r12d
.LBB12_38:                              # %._crit_edge.i126
                                        # =>This Inner Loop Header: Depth=1
	leaq	(%r15,%r12), %rdi
	movl	$40000, %edx                    # imm = 0x9C40
	xorl	%esi, %esi
	callq	memset@PLT
	addq	$80000, %r12                    # imm = 0x13880
	cmpq	$800000000, %r12                # imm = 0x2FAF0800
	jne	.LBB12_38
# %bb.39:                               # %.lr.ph.i132.preheader
	addq	$800040000, %r14                # imm = 0x2FAFA440
	movl	$10000, %eax                    # imm = 0x2710
	xorl	%ecx, %ecx
	movss	.LCPI12_2(%rip), %xmm0          # xmm0 = mem[0],zero,zero,zero
.LBB12_40:                              # %.lr.ph.i132
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB12_41 Depth 2
	xorl	%edx, %edx
.LBB12_41:                              #   Parent Loop BB12_40 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movaps	%xmm0, %xmm1
	cmpq	%rdx, %rcx
	je	.LBB12_43
# %bb.42:                               #   in Loop: Header=BB12_41 Depth=2
	xorps	%xmm1, %xmm1
.LBB12_43:                              #   in Loop: Header=BB12_41 Depth=2
	movss	%xmm1, (%r14,%rdx,4)
	incq	%rdx
	cmpq	$10000, %rdx                    # imm = 0x2710
	jne	.LBB12_41
# %bb.44:                               # %._crit_edge.i139
                                        #   in Loop: Header=BB12_40 Depth=1
	incq	%rax
	incq	%rcx
	addq	$80000, %r14                    # imm = 0x13880
	cmpq	$20000, %rax                    # imm = 0x4E20
	jne	.LBB12_40
# %bb.45:                               # %_Z16make_negidentityPfiiii.exit
	movq	32(%rsp), %r14
	xorl	%eax, %eax
	movss	.LCPI12_1(%rip), %xmm0          # xmm0 = mem[0],zero,zero,zero
	movq	%r14, %rcx
.LBB12_46:                              # %.lr.ph.i141
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB12_47 Depth 2
	xorl	%edx, %edx
.LBB12_47:                              #   Parent Loop BB12_46 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movaps	%xmm0, %xmm1
	cmpq	%rdx, %rax
	je	.LBB12_49
# %bb.48:                               #   in Loop: Header=BB12_47 Depth=2
	xorps	%xmm1, %xmm1
.LBB12_49:                              #   in Loop: Header=BB12_47 Depth=2
	movss	%xmm1, (%rcx,%rdx,4)
	incq	%rdx
	cmpq	$10000, %rdx                    # imm = 0x2710
	jne	.LBB12_47
# %bb.50:                               # %._crit_edge.i148
                                        #   in Loop: Header=BB12_46 Depth=1
	incq	%rax
	addq	$80000, %rcx                    # imm = 0x13880
	cmpq	$10000, %rax                    # imm = 0x2710
	jne	.LBB12_46
# %bb.51:                               # %.lr.ph.i151.preheader
	leaq	40000(%r14), %rax
	xorl	%ecx, %ecx
	movaps	.LCPI12_3(%rip), %xmm0          # xmm0 = [-0.0E+0,-0.0E+0,-0.0E+0,-0.0E+0]
.LBB12_52:                              # %.lr.ph.i151
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB12_53 Depth 2
	xorl	%edx, %edx
.LBB12_53:                              #   Parent Loop BB12_52 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movss	(%rbx,%rdx,4), %xmm1            # xmm1 = mem[0],zero,zero,zero
	xorps	%xmm0, %xmm1
	movss	%xmm1, (%rax,%rdx,4)
	incq	%rdx
	cmpq	$10000, %rdx                    # imm = 0x2710
	jne	.LBB12_53
# %bb.54:                               # %._crit_edge.i157
                                        #   in Loop: Header=BB12_52 Depth=1
	incq	%rcx
	addq	$40000, %rbx                    # imm = 0x9C40
	addq	$80000, %rax                    # imm = 0x13880
	cmpq	$10000, %rcx                    # imm = 0x2710
	jne	.LBB12_52
# %bb.55:                               # %._crit_edge.i159.preheader
	leaq	800000000(%r14), %rbx
	xorl	%r15d, %r15d
.LBB12_56:                              # %._crit_edge.i159
                                        # =>This Inner Loop Header: Depth=1
	leaq	(%rbx,%r15), %rdi
	movl	$40000, %edx                    # imm = 0x9C40
	xorl	%esi, %esi
	callq	memset@PLT
	addq	$80000, %r15                    # imm = 0x13880
	cmpq	$800000000, %r15                # imm = 0x2FAF0800
	jne	.LBB12_56
# %bb.57:                               # %.lr.ph.i165.preheader
	addq	$800040000, %r14                # imm = 0x2FAFA440
	movl	$10000, %eax                    # imm = 0x2710
	xorl	%ecx, %ecx
	movss	.LCPI12_1(%rip), %xmm0          # xmm0 = mem[0],zero,zero,zero
.LBB12_58:                              # %.lr.ph.i165
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB12_59 Depth 2
	xorl	%edx, %edx
.LBB12_59:                              #   Parent Loop BB12_58 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movaps	%xmm0, %xmm1
	cmpq	%rdx, %rcx
	je	.LBB12_61
# %bb.60:                               #   in Loop: Header=BB12_59 Depth=2
	xorps	%xmm1, %xmm1
.LBB12_61:                              #   in Loop: Header=BB12_59 Depth=2
	movss	%xmm1, (%r14,%rdx,4)
	incq	%rdx
	cmpq	$10000, %rdx                    # imm = 0x2710
	jne	.LBB12_59
# %bb.62:                               # %._crit_edge.i172
                                        #   in Loop: Header=BB12_58 Depth=1
	incq	%rax
	incq	%rcx
	addq	$80000, %r14                    # imm = 0x13880
	cmpq	$20000, %rax                    # imm = 0x4E20
	jne	.LBB12_58
# %bb.63:                               # %_Z13make_identityPfiiii.exit174
	movq	24(%rsp), %rax
	xorl	%ecx, %ecx
	movq	%rax, %rdx
.LBB12_64:                              # %.lr.ph.i175
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB12_65 Depth 2
	imulq	$20000, %rcx, %rsi              # imm = 0x4E20
	leaq	(%rax,%rcx,4), %rdi
	xorl	%r8d, %r8d
.LBB12_65:                              #   Parent Loop BB12_64 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	cmpq	%r8, %rcx
	jne	.LBB12_69
# %bb.66:                               #   in Loop: Header=BB12_65 Depth=2
	cmpq	$10000, %rcx                    # imm = 0x2710
	jae	.LBB12_67
# %bb.68:                               #   in Loop: Header=BB12_65 Depth=2
	movl	$1065353216, (%rdi,%rsi,4)      # imm = 0x3F800000
	jmp	.LBB12_70
.LBB12_69:                              #   in Loop: Header=BB12_65 Depth=2
	movl	$0, (%rdx,%r8,4)
	jmp	.LBB12_70
.LBB12_67:                              #   in Loop: Header=BB12_65 Depth=2
	movl	$-1082130432, (%rdi,%rsi,4)     # imm = 0xBF800000
.LBB12_70:                              #   in Loop: Header=BB12_65 Depth=2
	incq	%r8
	cmpq	$20000, %r8                     # imm = 0x4E20
	jne	.LBB12_65
# %bb.71:                               # %._crit_edge.i181
                                        #   in Loop: Header=BB12_64 Depth=1
	incq	%rcx
	addq	$80000, %rdx                    # imm = 0x13880
	cmpq	$20000, %rcx                    # imm = 0x4E20
	jne	.LBB12_64
# %bb.72:                               # %_Z11make_resultPfi.exit
	movabsq	$5368709121250, %r14            # imm = 0x4E2000004E2
	movabsq	$68719476752, %rbx              # imm = 0x1000000010
	leaq	16(%rsp), %r13
	movl	$1600000000, %esi               # imm = 0x5F5E1000
	movq	%r13, %rdi
	callq	hipMalloc
	leaq	64(%rsp), %r12
	movl	$1600000000, %esi               # imm = 0x5F5E1000
	movq	%r12, %rdi
	callq	hipMalloc
	leaq	56(%rsp), %r15
	movl	$1600000000, %esi               # imm = 0x5F5E1000
	movq	%r15, %rdi
	callq	hipMalloc
	leaq	48(%rsp), %rdi
	movl	$1600000000, %esi               # imm = 0x5F5E1000
	callq	hipMalloc
	movq	(%r13), %rdi
	movq	8(%rsp), %rsi
	movl	$1600000000, %edx               # imm = 0x5F5E1000
	movl	$1, %ecx
	callq	hipMemcpy
	movq	(%r12), %rdi
	movq	40(%rsp), %rsi
	movl	$1600000000, %edx               # imm = 0x5F5E1000
	movl	$1, %ecx
	callq	hipMemcpy
	movq	(%r15), %rdi
	movq	32(%rsp), %rsi
	movl	$1600000000, %edx               # imm = 0x5F5E1000
	movl	$1, %ecx
	callq	hipMemcpy
	movq	%r14, %rdi
	movl	$1, %esi
	movq	%rbx, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB12_74
# %bb.73:
	movq	16(%rsp), %rdi
	movq	64(%rsp), %rsi
	movq	48(%rsp), %rdx
	movl	$20000, %ecx                    # imm = 0x4E20
	callq	_Z34__device_stub__gpu_matrix_multiplyPfS_S_i
.LBB12_74:
	callq	hipDeviceSynchronize
	movq	%r14, %rdi
	movl	$1, %esi
	movq	%rbx, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB12_76
# %bb.75:
	movq	48(%rsp), %rdi
	movq	56(%rsp), %rsi
	movq	16(%rsp), %rdx
	movl	$20000, %ecx                    # imm = 0x4E20
	callq	_Z34__device_stub__gpu_matrix_multiplyPfS_S_i
.LBB12_76:
	movq	8(%rsp), %rdi
	movq	16(%rsp), %rsi
	movl	$1600000000, %edx               # imm = 0x5F5E1000
	movl	$2, %ecx
	callq	hipMemcpy
	callq	hipDeviceSynchronize
	movq	8(%rsp), %rax
	xorps	%xmm0, %xmm0
	xorl	%ecx, %ecx
	movq	24(%rsp), %rdx
	movaps	.LCPI12_4(%rip), %xmm1          # xmm1 = [NaN,NaN,NaN,NaN]
	movl	$80000, %esi                    # imm = 0x13880
.LBB12_77:                              # %.lr.ph.i182
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB12_78 Depth 2
	xorl	%edi, %edi
.LBB12_78:                              #   Parent Loop BB12_77 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movss	(%rax,%rdi,4), %xmm2            # xmm2 = mem[0],zero,zero,zero
	subss	(%rdx,%rdi,4), %xmm2
	andps	%xmm1, %xmm2
	addss	%xmm2, %xmm0
	incq	%rdi
	cmpq	$20000, %rdi                    # imm = 0x4E20
	jne	.LBB12_78
# %bb.79:                               # %._crit_edge.i186
                                        #   in Loop: Header=BB12_77 Depth=1
	incq	%rcx
	addq	%rsi, %rdx
	addq	%rsi, %rax
	cmpq	$20000, %rcx                    # imm = 0x4E20
	jne	.LBB12_77
# %bb.80:                               # %_Z8rothVerfPfS_i.exit
	cvtss2sd	%xmm0, %xmm0
	movl	$.L.str.3, %edi
	movb	$1, %al
	callq	printf
	movq	16(%rsp), %rdi
	callq	hipFree
	movq	64(%rsp), %rdi
	callq	hipFree
	movq	56(%rsp), %rdi
	callq	hipFree
	movq	48(%rsp), %rdi
	callq	hipFree
	movq	8(%rsp), %rdi
	callq	hipHostFree
	movq	40(%rsp), %rdi
	callq	hipHostFree
	movq	32(%rsp), %rdi
	callq	hipHostFree
	movq	24(%rsp), %rdi
	callq	hipHostFree
	movq	72(%rsp), %rdi
	callq	hipHostFree
	xorl	%eax, %eax
	addq	$80, %rsp
	.cfi_def_cfa_offset 48
	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
.LBB12_81:
	.cfi_def_cfa_offset 128
	movl	$.Lstr, %edi
	callq	puts@PLT
	movl	$1, %edi
	callq	exit
.Lfunc_end12:
	.size	main, .Lfunc_end12-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	.LBB13_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB13_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z19gpu_matrix_multiplyPfS_S_i, %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_end13:
	.size	__hip_module_ctor, .Lfunc_end13-__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	.LBB14_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
.LBB14_2:
	retq
.Lfunc_end14:
	.size	__hip_module_dtor, .Lfunc_end14-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	_Z19gpu_matrix_multiplyPfS_S_i,@object # @_Z19gpu_matrix_multiplyPfS_S_i
	.section	.rodata,"a",@progbits
	.globl	_Z19gpu_matrix_multiplyPfS_S_i
	.p2align	3, 0x0
_Z19gpu_matrix_multiplyPfS_S_i:
	.quad	_Z34__device_stub__gpu_matrix_multiplyPfS_S_i
	.size	_Z19gpu_matrix_multiplyPfS_S_i, 8

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"%.2f\t"
	.size	.L.str, 6

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"Total Error: %f\n"
	.size	.L.str.3, 17

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z19gpu_matrix_multiplyPfS_S_i"
	.size	.L__unnamed_1, 31

	.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	"Matrix allocation error on host"
	.size	.Lstr, 32

	.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 _Z34__device_stub__gpu_matrix_multiplyPfS_S_i
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z19gpu_matrix_multiplyPfS_S_i
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z19gpu_matrix_multiplyPfS_S_i ; -- Begin function _Z19gpu_matrix_multiplyPfS_S_i
	.globl	_Z19gpu_matrix_multiplyPfS_S_i
	.p2align	8
	.type	_Z19gpu_matrix_multiplyPfS_S_i,@function
_Z19gpu_matrix_multiplyPfS_S_i:         ; @_Z19gpu_matrix_multiplyPfS_S_i
; %bb.0:
	s_clause 0x3
	s_load_b32 s3, s[0:1], 0x20
	s_load_b32 s2, s[0:1], 0x18
	s_load_b128 s[4:7], s[0:1], 0x0
	s_load_b64 s[0:1], s[0:1], 0x10
	v_bfe_u32 v6, v0, 10, 10
	v_and_b32_e32 v3, 0x3ff, v0
	s_mov_b32 s8, 0
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_lshl_add_u32 v4, s15, 4, v6
	v_lshl_add_u32 v0, s14, 4, v3
	s_waitcnt lgkmcnt(0)
	s_cmp_eq_u32 s3, 0
	s_cbranch_scc1 .LBB0_9
; %bb.1:                                ; %.lr.ph
	v_lshlrev_b32_e32 v5, 2, v3
	v_lshlrev_b32_e32 v7, 6, v6
	v_mad_u64_u32 v[1:2], null, v4, s2, v[3:4]
	s_mul_i32 s9, s2, s2
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_nc_u32_e32 v8, 0x400, v5
	v_add_nc_u32_e32 v9, v7, v5
	s_delay_alu instid0(VALU_DEP_2)
	v_dual_mov_b32 v5, 0 :: v_dual_add_nc_u32 v10, v8, v7
.LBB0_2:                                ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_7 Depth 2
	s_lshl_b32 s10, s8, 4
	s_mov_b32 s11, exec_lo
	s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_dual_mov_b32 v11, 0 :: v_dual_add_nc_u32 v2, s10, v1
	v_cmpx_gt_i32_e64 s9, v2
	s_cbranch_execz .LBB0_4
; %bb.3:                                ;   in Loop: Header=BB0_2 Depth=1
	v_ashrrev_i32_e32 v3, 31, v2
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[2:3], 2, v[2:3]
	v_add_co_u32 v2, vcc_lo, s4, v2
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v3, vcc_lo, s5, v3, vcc_lo
	global_load_b32 v11, v[2:3], off
.LBB0_4:                                ;   in Loop: Header=BB0_2 Depth=1
	s_or_b32 exec_lo, exec_lo, s11
	v_add_nc_u32_e32 v12, s10, v6
	s_mov_b32 s10, exec_lo
	s_waitcnt vmcnt(0)
	ds_store_b32 v9, v11
	v_mad_u64_u32 v[2:3], null, v12, s2, v[0:1]
	v_mov_b32_e32 v3, 0
	s_delay_alu instid0(VALU_DEP_2)
	v_cmpx_gt_i32_e64 s9, v2
	s_cbranch_execz .LBB0_6
; %bb.5:                                ;   in Loop: Header=BB0_2 Depth=1
	v_ashrrev_i32_e32 v3, 31, v2
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[2:3], 2, v[2:3]
	v_add_co_u32 v2, vcc_lo, s6, v2
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v3, vcc_lo, s7, v3, vcc_lo
	global_load_b32 v3, v[2:3], off
.LBB0_6:                                ;   in Loop: Header=BB0_2 Depth=1
	s_or_b32 exec_lo, exec_lo, s10
	v_mov_b32_e32 v2, v8
	s_mov_b32 s10, 0
	s_waitcnt vmcnt(0)
	ds_store_b32 v10, v3
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
.LBB0_7:                                ;   Parent Loop BB0_2 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	v_add_nc_u32_e32 v3, s10, v7
	s_add_i32 s10, s10, 4
	ds_load_b32 v11, v2
	ds_load_b32 v3, v3
	v_add_nc_u32_e32 v2, 64, v2
	s_cmp_eq_u32 s10, 64
	s_waitcnt lgkmcnt(0)
	v_fmac_f32_e32 v5, v3, v11
	s_cbranch_scc0 .LBB0_7
; %bb.8:                                ;   in Loop: Header=BB0_2 Depth=1
	s_add_i32 s8, s8, 1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_cmp_eq_u32 s8, s3
	s_barrier
	buffer_gl0_inv
	s_cbranch_scc0 .LBB0_2
	s_branch .LBB0_10
.LBB0_9:
	v_mov_b32_e32 v5, 0
.LBB0_10:                               ; %Flow63
	v_max_i32_e32 v1, v4, v0
	s_mov_b32 s3, exec_lo
	s_delay_alu instid0(VALU_DEP_1)
	v_cmpx_gt_i32_e64 s2, v1
	s_cbranch_execz .LBB0_12
; %bb.11:
	v_mad_u64_u32 v[1:2], null, v4, s2, v[0:1]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v2, 31, v1
	v_lshlrev_b64 v[0:1], 2, v[1:2]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v0, vcc_lo, s0, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s1, v1, vcc_lo
	global_store_b32 v[0:1], v5, off
.LBB0_12:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z19gpu_matrix_multiplyPfS_S_i
		.amdhsa_group_segment_fixed_size 2048
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 288
		.amdhsa_user_sgpr_count 14
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 1
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 1
		.amdhsa_next_free_vgpr 13
		.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	_Z19gpu_matrix_multiplyPfS_S_i, .Lfunc_end0-_Z19gpu_matrix_multiplyPfS_S_i
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 504
; NumSgprs: 18
; NumVgprs: 13
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 2048 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 13
; 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:         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: 2048
    .kernarg_segment_align: 8
    .kernarg_segment_size: 288
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z19gpu_matrix_multiplyPfS_S_i
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z19gpu_matrix_multiplyPfS_S_i.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     13
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
