// Compile: nvcc -arch=sm_61 -std=c++11 assignment5-p2.cu -o assignment5-p2

#include <cmath>
#include <cstdint>
#include <iostream>
#include <sys/time.h>

#define THRESHOLD (0.000001)

#define SIZE1 4096
#define SIZE2 4097
#define ITER 100
#define BLOCK_SIZE 16

using namespace std;

#define gpuErrchk(ans) { gpuAssert((ans), __FILE__, __LINE__); }
inline void gpuAssert(cudaError_t code, const char *file, int line, bool abort=true) {
   if (code != cudaSuccess) {
      fprintf(stderr, "GPUassert: %s %s %d\n", cudaGetErrorString(code), file, line);
      if (abort) exit(code);
   }
}

__global__ void kernel1(double* A) {
  // SB: Write the first kernel here
  int j =  blockIdx.x*blockDim.x + threadIdx.x;
  if(j < SIZE1 - 1) {
    for (int k = 0; k < ITER; k++) {
      for (int i = 1; i < SIZE1; i++) {
        A[i*SIZE1 + j + 1] = A[(i - 1)*SIZE1 + j + 1] + A[i*SIZE1 + j + 1];
      }
    }
  }
}

__global__ void kernel2(double* A) {
  // SB: Write the second kernel here
  int j =  blockIdx.x*blockDim.x + threadIdx.x;
  if(j < SIZE2 - 1) {
    for (int k = 0; k < ITER; k++) {
      for (int i = 1; i < SIZE2; i++) {
        A[i*SIZE2 + j + 1] = A[(i - 1)*SIZE2 + j + 1] + A[i*SIZE2 + j + 1];
      }
    }
  }
}

__host__ void serial(double** A) {
  for (int k = 0; k < ITER; k++) {
    for (int i = 1; i < SIZE1; i++) {
      for (int j = 0; j < SIZE1 - 1; j++) {
        A[i][j + 1] = A[i - 1][j + 1] + A[i][j + 1];
      }
    }
  }
}

__host__ void check_result(double** w_ref, double* w_opt, uint64_t size) {
  double maxdiff = 0.0, this_diff = 0.0;
  int numdiffs = 0;

  for (uint64_t i = 0; i < size; i++) {
    for (uint64_t j = 0; j < size; j++) {
      this_diff = w_ref[i][j] - w_opt[i*size + j];
      if (fabs(this_diff) > THRESHOLD) {
        numdiffs++;
        if (this_diff > maxdiff)
          maxdiff = this_diff;
      }
    }
  }

  if (numdiffs > 0) {
    cout << numdiffs << " Diffs found over THRESHOLD " << THRESHOLD << "; Max Diff = " << maxdiff
         << endl;
  } else {
    cout << "No differences found between base and test versions" << endl;
  }
}

__host__ double rtclock() {
  struct timezone Tzp;
  struct timeval Tp;
  int stat;
  stat = gettimeofday(&Tp, &Tzp);
  if (stat != 0) {
    cout << "Error return from gettimeofday: " << stat << "\n";
  }
  return (Tp.tv_sec + Tp.tv_usec * 1.0e-6);
}

int main() {
  double** A_ser = new double*[SIZE1];
  double* A_k1 = new double[SIZE1*SIZE1];
  double* A_k2 = new double[SIZE2*SIZE2];
  
  for (int i = 0; i < SIZE1; i++) {
    A_ser[i] = new double[SIZE1];
  }

  for (int i = 0; i < SIZE1; i++) {
    for (int j = 0; j < SIZE1; j++) {
      A_ser[i][j] = i + j;
      A_k1[i*SIZE1 + j] = i + j;
    }
  }
  for (int i = 0; i < SIZE2; i++) {
    for (int j = 0; j < SIZE2; j++) {
      A_k2[i*SIZE2 + j] = i + j;
    }
  }

  double clkbegin, clkend;
  double t;

  clkbegin = rtclock();
  serial(A_ser);
  clkend = rtclock();
  t = clkend - clkbegin;
  cout << "Serial code on CPU: " << (1.0 * SIZE1 * SIZE1 * ITER / t / 1.0e9)
       << " GFLOPS; Time = " << t * 1000 << " msec" << endl;

  cudaEvent_t start, end;
  gpuErrchk( cudaEventCreate(&start) );
  gpuErrchk( cudaEventCreate(&end) );
  // SB: Write your first GPU kernel here
  
  double* A_k1_c;
  gpuErrchk( cudaMalloc((void**)&A_k1_c, SIZE1*SIZE1*sizeof(double)) );

  gpuErrchk( cudaEventRecord(start, 0) );
  gpuErrchk( cudaMemcpy(A_k1_c, A_k1, SIZE1*SIZE1*sizeof(double), cudaMemcpyHostToDevice) );
  kernel1<<<4, 1024>>>(A_k1_c);
  gpuErrchk( cudaPeekAtLastError() );
  gpuErrchk( cudaMemcpy(A_k1, A_k1_c, SIZE1*SIZE1*sizeof(double), cudaMemcpyDeviceToHost) );
  gpuErrchk( cudaEventRecord(end, 0) );

  gpuErrchk( cudaDeviceSynchronize() );

  float kernel_time = 0;
  gpuErrchk( cudaEventElapsedTime(&kernel_time, start, end) );
  check_result(A_ser, A_k1, SIZE1);
  cout << "Kernel 1 on GPU: " << (1.0 * SIZE1 * SIZE1 * ITER / t / 1.0e9)
       << " GFLOPS; Time = " << kernel_time << " msec" << endl;

  // SB: Write your second GPU kernel here
  
  double* A_k2_c;
  gpuErrchk( cudaMalloc((void**)&A_k2_c, SIZE2*SIZE2*sizeof(double)) );
  
  gpuErrchk( cudaEventRecord(start, 0) );
  gpuErrchk( cudaMemcpy(A_k2_c, A_k2, SIZE2*SIZE2*sizeof(double), cudaMemcpyHostToDevice) );
  kernel2<<<4, 1024>>>(A_k2_c);
  gpuErrchk( cudaPeekAtLastError() );
  gpuErrchk( cudaMemcpy(A_k2, A_k2_c, SIZE2*SIZE2*sizeof(double), cudaMemcpyDeviceToHost) );
  gpuErrchk( cudaEventRecord(end, 0) );

  gpuErrchk( cudaDeviceSynchronize() );

  kernel_time = 0;
  gpuErrchk( cudaEventElapsedTime(&kernel_time, start, end) );
  // check_result(A_ser, A_k2, SIZE1);
  cout << "Kernel 2 on GPU: " << (1.0 * SIZE2 * SIZE2 * ITER / t / 1.0e9)
       << " GFLOPS; Time = " << kernel_time << " msec" << endl;

  gpuErrchk( cudaFree(A_k1_c) );
  gpuErrchk( cudaFree(A_k2_c) );
  
  free(A_ser);
  free(A_k1);
  free(A_k2);
  return EXIT_SUCCESS;
}

	.file	"tmpxft_003233b4_00000000-6_p2.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB3642:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE3642:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.align 2
	.type	_ZNSolsEPFRSoS_E.isra.0, @function
_ZNSolsEPFRSoS_E.isra.0:
.LFB4301:
	.cfi_startproc
	jmp	*%rsi
	.cfi_endproc
.LFE4301:
	.size	_ZNSolsEPFRSoS_E.isra.0, .-_ZNSolsEPFRSoS_E.isra.0
	.section	.rodata._Z9gpuAssert9cudaErrorPKcib.str1.1,"aMS",@progbits,1
.LC0:
	.string	"GPUassert: %s %s %d\n"
	.section	.text._Z9gpuAssert9cudaErrorPKcib,"axG",@progbits,_Z9gpuAssert9cudaErrorPKcib,comdat
	.weak	_Z9gpuAssert9cudaErrorPKcib
	.type	_Z9gpuAssert9cudaErrorPKcib, @function
_Z9gpuAssert9cudaErrorPKcib:
.LFB3635:
	.cfi_startproc
	endbr64
	testl	%edi, %edi
	je	.L9
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movl	%ecx, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	movl	%edi, %ebx
	subq	$24, %rsp
	.cfi_def_cfa_offset 48
	movl	%edx, 12(%rsp)
	movq	%rsi, (%rsp)
	call	cudaGetErrorString@PLT
	movl	12(%rsp), %r9d
	movq	(%rsp), %r8
	leaq	.LC0(%rip), %rdx
	movq	stderr(%rip), %rdi
	movq	%rax, %rcx
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	testb	%bpl, %bpl
	je	.L3
	movl	%ebx, %edi
	call	exit@PLT
.L3:
	addq	$24, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
.L9:
	.cfi_restore 3
	.cfi_restore 6
	ret
	.cfi_endproc
.LFE3635:
	.size	_Z9gpuAssert9cudaErrorPKcib, .-_Z9gpuAssert9cudaErrorPKcib
	.text
	.globl	_Z6serialPPd
	.type	_Z6serialPPd, @function
_Z6serialPPd:
.LFB3636:
	.cfi_startproc
	endbr64
	movl	$100, %ecx
.L14:
	xorl	%edx, %edx
.L18:
	movq	(%rdi,%rdx), %r8
	movq	8(%rdi,%rdx), %rsi
	movl	$8, %eax
.L15:
	movsd	(%rsi,%rax), %xmm0
	addsd	(%r8,%rax), %xmm0
	movsd	%xmm0, (%rsi,%rax)
	addq	$8, %rax
	cmpq	$32768, %rax
	jne	.L15
	addq	$8, %rdx
	cmpq	$32760, %rdx
	jne	.L18
	decl	%ecx
	jne	.L14
	ret
	.cfi_endproc
.LFE3636:
	.size	_Z6serialPPd, .-_Z6serialPPd
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC4:
	.string	" Diffs found over THRESHOLD "
.LC5:
	.string	"; Max Diff = "
.LC6:
	.string	"No differences found between base and test versions"
	.text
	.globl	_Z12check_resultPPdS_m
	.type	_Z12check_resultPPdS_m, @function
_Z12check_resultPPdS_m:
.LFB3637:
	.cfi_startproc
	endbr64
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movq	%rsi, %r8
	xorl	%r9d, %r9d
	xorl	%ecx, %ecx
	movq	.LC2(%rip), %xmm2
	movsd	.LC3(%rip), %xmm3
	xorl	%esi, %esi
	xorps	%xmm1, %xmm1
.L21:
	cmpq	%rdx, %rcx
	je	.L25
	movq	(%rdi,%rcx,8), %r11
	leaq	(%r8,%r9,8), %r10
	xorl	%eax, %eax
.L24:
	movsd	(%r11,%rax,8), %xmm0
	subsd	(%r10,%rax,8), %xmm0
	movaps	%xmm0, %xmm4
	andps	%xmm2, %xmm4
	comisd	%xmm3, %xmm4
	jbe	.L22
	maxsd	%xmm1, %xmm0
	incl	%esi
	movaps	%xmm0, %xmm1
.L22:
	incq	%rax
	cmpq	%rax, %rdx
	jne	.L24
	incq	%rcx
	addq	%rdx, %r9
	jmp	.L21
.L25:
	testl	%esi, %esi
	movsd	%xmm1, 8(%rsp)
	leaq	_ZSt4cout(%rip), %rdi
	jle	.L26
	call	_ZNSolsEi@PLT
	leaq	.LC4(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movsd	.LC3(%rip), %xmm0
	movq	%rax, %rdi
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	leaq	.LC5(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movsd	8(%rsp), %xmm1
	movq	%rax, %rdi
	movaps	%xmm1, %xmm0
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	jmp	.L31
.L26:
	leaq	.LC6(%rip), %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
.L31:
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	addq	$24, %rsp
	.cfi_def_cfa_offset 8
	jmp	_ZNSolsEPFRSoS_E.isra.0
	.cfi_endproc
.LFE3637:
	.size	_Z12check_resultPPdS_m, .-_Z12check_resultPPdS_m
	.section	.rodata.str1.1
.LC7:
	.string	"Error return from gettimeofday: "
.LC8:
	.string	"\n"
	.text
	.globl	_Z7rtclockv
	.type	_Z7rtclockv, @function
_Z7rtclockv:
.LFB3638:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	subq	$32, %rsp
	.cfi_def_cfa_offset 48
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rsi
	leaq	8(%rsp), %rdi
	call	gettimeofday@PLT
	testl	%eax, %eax
	je	.L33
	leaq	.LC7(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	movl	%eax, %ebx
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	%ebx, %esi
	movq	%rax, %rdi
	call	_ZNSolsEi@PLT
	leaq	.LC8(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
.L33:
	cvtsi2sdq	16(%rsp), %xmm0
	mulsd	.LC3(%rip), %xmm0
	cvtsi2sdq	8(%rsp), %xmm1
	addsd	%xmm1, %xmm0
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	je	.L34
	call	__stack_chk_fail@PLT
.L34:
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3638:
	.size	_Z7rtclockv, .-_Z7rtclockv
	.globl	_Z26__device_stub__Z7kernel1PdPd
	.type	_Z26__device_stub__Z7kernel1PdPd, @function
_Z26__device_stub__Z7kernel1PdPd:
.LFB3664:
	.cfi_startproc
	endbr64
	subq	$104, %rsp
	.cfi_def_cfa_offset 112
	movq	%rdi, 8(%rsp)
	leaq	24(%rsp), %rcx
	leaq	16(%rsp), %rdx
	leaq	44(%rsp), %rsi
	leaq	32(%rsp), %rdi
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rax
	movl	$1, 40(%rsp)
	movq	%rax, 80(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 32(%rsp)
	movq	%rax, 44(%rsp)
	movl	$1, 52(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L39
	pushq	24(%rsp)
	.cfi_def_cfa_offset 120
	leaq	_Z7kernel1Pd(%rip), %rdi
	pushq	24(%rsp)
	.cfi_def_cfa_offset 128
	movq	60(%rsp), %rcx
	movl	68(%rsp), %r8d
	movq	48(%rsp), %rsi
	movl	56(%rsp), %edx
	leaq	96(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 120
	popq	%rdx
	.cfi_def_cfa_offset 112
.L39:
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	je	.L41
	call	__stack_chk_fail@PLT
.L41:
	addq	$104, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3664:
	.size	_Z26__device_stub__Z7kernel1PdPd, .-_Z26__device_stub__Z7kernel1PdPd
	.globl	_Z7kernel1Pd
	.type	_Z7kernel1Pd, @function
_Z7kernel1Pd:
.LFB3665:
	.cfi_startproc
	endbr64
	jmp	_Z26__device_stub__Z7kernel1PdPd
	.cfi_endproc
.LFE3665:
	.size	_Z7kernel1Pd, .-_Z7kernel1Pd
	.globl	_Z26__device_stub__Z7kernel2PdPd
	.type	_Z26__device_stub__Z7kernel2PdPd, @function
_Z26__device_stub__Z7kernel2PdPd:
.LFB3666:
	.cfi_startproc
	endbr64
	subq	$104, %rsp
	.cfi_def_cfa_offset 112
	movq	%rdi, 8(%rsp)
	leaq	24(%rsp), %rcx
	leaq	16(%rsp), %rdx
	leaq	44(%rsp), %rsi
	leaq	32(%rsp), %rdi
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rax
	movl	$1, 40(%rsp)
	movq	%rax, 80(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 32(%rsp)
	movq	%rax, 44(%rsp)
	movl	$1, 52(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L44
	pushq	24(%rsp)
	.cfi_def_cfa_offset 120
	leaq	_Z7kernel2Pd(%rip), %rdi
	pushq	24(%rsp)
	.cfi_def_cfa_offset 128
	movq	60(%rsp), %rcx
	movl	68(%rsp), %r8d
	movq	48(%rsp), %rsi
	movl	56(%rsp), %edx
	leaq	96(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 120
	popq	%rdx
	.cfi_def_cfa_offset 112
.L44:
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	je	.L46
	call	__stack_chk_fail@PLT
.L46:
	addq	$104, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3666:
	.size	_Z26__device_stub__Z7kernel2PdPd, .-_Z26__device_stub__Z7kernel2PdPd
	.globl	_Z7kernel2Pd
	.type	_Z7kernel2Pd, @function
_Z7kernel2Pd:
.LFB3667:
	.cfi_startproc
	endbr64
	jmp	_Z26__device_stub__Z7kernel2PdPd
	.cfi_endproc
.LFE3667:
	.size	_Z7kernel2Pd, .-_Z7kernel2Pd
	.section	.rodata.str1.1
.LC9:
	.string	"Serial code on CPU: "
.LC12:
	.string	" GFLOPS; Time = "
.LC14:
	.string	" msec"
.LC15:
	.string	"/home/ubuntu/Datasets/stackv2/train-structured/hritwik567/CS698L/master/assign5/submission/problem2/p2.cu"
.LC17:
	.string	"Kernel 1 on GPU: "
.LC18:
	.string	"Kernel 2 on GPU: "
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB3639:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	$32768, %edi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	xorl	%r13d, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$104, %rsp
	.cfi_def_cfa_offset 160
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	xorl	%eax, %eax
	call	_Znam@PLT
	movl	$134217728, %edi
	movq	%rax, %rbp
	call	_Znam@PLT
	movl	$134283272, %edi
	movq	%rax, %rbx
	call	_Znam@PLT
	movq	%rax, %r12
.L50:
	movl	$32768, %edi
	call	_Znam@PLT
	movq	%rax, 0(%rbp,%r13,8)
	incq	%r13
	cmpq	$4096, %r13
	jne	.L50
	xorl	%edx, %edx
.L51:
	movq	%rdx, %rcx
	movq	0(%rbp,%rdx,8), %rdi
	movl	%edx, %esi
	xorl	%eax, %eax
	salq	$15, %rcx
	addq	%rbx, %rcx
.L52:
	leal	(%rsi,%rax), %r8d
	cvtsi2sdl	%r8d, %xmm0
	movsd	%xmm0, (%rdi,%rax,8)
	movsd	%xmm0, (%rcx,%rax,8)
	incq	%rax
	cmpq	$4096, %rax
	jne	.L52
	incq	%rdx
	cmpq	$4096, %rdx
	jne	.L51
	movq	%r12, %rcx
	xorl	%edx, %edx
.L53:
	xorl	%eax, %eax
.L54:
	leal	(%rdx,%rax), %esi
	cvtsi2sdl	%esi, %xmm0
	movsd	%xmm0, (%rcx,%rax,8)
	incq	%rax
	cmpq	$4097, %rax
	jne	.L54
	incl	%edx
	addq	$32776, %rcx
	cmpl	$4097, %edx
	jne	.L53
	call	_Z7rtclockv
	movq	%rbp, %rdi
	leaq	_ZSt4cout(%rip), %r14
	leaq	.LC12(%rip), %r13
	movsd	%xmm0, (%rsp)
	call	_Z6serialPPd
	call	_Z7rtclockv
	subsd	(%rsp), %xmm0
	leaq	.LC9(%rip), %rsi
	movq	%r14, %rdi
	movsd	%xmm0, (%rsp)
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movsd	.LC10(%rip), %xmm0
	divsd	(%rsp), %xmm0
	divsd	.LC11(%rip), %xmm0
	movq	%rax, %rdi
	movsd	%xmm0, 8(%rsp)
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	movq	%r13, %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movsd	(%rsp), %xmm0
	mulsd	.LC13(%rip), %xmm0
	movq	%rax, %rdi
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	leaq	.LC14(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	leaq	32(%rsp), %rdi
	call	cudaEventCreate@PLT
	movl	$1, %ecx
	movl	$125, %edx
	leaq	.LC15(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	leaq	40(%rsp), %rdi
	call	cudaEventCreate@PLT
	movl	$1, %ecx
	movl	$126, %edx
	leaq	.LC15(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	leaq	48(%rsp), %rdi
	movl	$134217728, %esi
	call	cudaMalloc@PLT
	movl	$1, %ecx
	movl	$130, %edx
	leaq	.LC15(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	movq	32(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movl	$1, %ecx
	movl	$132, %edx
	leaq	.LC15(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	movq	48(%rsp), %rdi
	movl	$1, %ecx
	movq	%rbx, %rsi
	movl	$134217728, %edx
	call	cudaMemcpy@PLT
	movl	$1, %ecx
	movl	$133, %edx
	leaq	.LC15(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	movl	$4194305, %edx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	$1073741825, %edi
	salq	$10, %rdx
	movl	$1, %ecx
	movl	$1, %esi
	salq	$2, %rdi
	movq	%rdx, 76(%rsp)
	movl	$1, 84(%rsp)
	movq	%rdi, 64(%rsp)
	movl	$1, 72(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L56
	movq	48(%rsp), %rdi
	call	_Z26__device_stub__Z7kernel1PdPd
.L56:
	call	cudaPeekAtLastError@PLT
	movl	$1, %ecx
	movl	$135, %edx
	leaq	.LC15(%rip), %rsi
	movl	%eax, %edi
	leaq	28(%rsp), %r15
	call	_Z9gpuAssert9cudaErrorPKcib
	movq	48(%rsp), %rsi
	movl	$2, %ecx
	movq	%rbx, %rdi
	movl	$134217728, %edx
	call	cudaMemcpy@PLT
	movl	$1, %ecx
	movl	$136, %edx
	leaq	.LC15(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	movq	40(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movl	$1, %ecx
	movl	$137, %edx
	leaq	.LC15(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	call	cudaDeviceSynchronize@PLT
	movl	$1, %ecx
	movl	$139, %edx
	leaq	.LC15(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	movq	40(%rsp), %rdx
	movq	%r15, %rdi
	movq	32(%rsp), %rsi
	movl	$0x00000000, 28(%rsp)
	call	cudaEventElapsedTime@PLT
	movl	$1, %ecx
	movl	$142, %edx
	leaq	.LC15(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	movl	$4096, %edx
	movq	%rbx, %rsi
	movq	%rbp, %rdi
	call	_Z12check_resultPPdS_m
	leaq	.LC17(%rip), %rsi
	movq	%r14, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movsd	8(%rsp), %xmm0
	movq	%rax, %rdi
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	movq	%r13, %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	cvtss2sd	28(%rsp), %xmm0
	movq	%rax, %rdi
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	leaq	.LC14(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	leaq	56(%rsp), %rdi
	movl	$134283272, %esi
	call	cudaMalloc@PLT
	movl	$1, %ecx
	movl	$150, %edx
	leaq	.LC15(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	movq	32(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movl	$1, %ecx
	movl	$152, %edx
	leaq	.LC15(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	movq	56(%rsp), %rdi
	movl	$1, %ecx
	movq	%r12, %rsi
	movl	$134283272, %edx
	call	cudaMemcpy@PLT
	movl	$1, %ecx
	movl	$153, %edx
	leaq	.LC15(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	movl	$4194305, %edx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	$1073741825, %edi
	salq	$10, %rdx
	movl	$1, %ecx
	movl	$1, %esi
	salq	$2, %rdi
	movq	%rdx, 76(%rsp)
	movl	$1, 84(%rsp)
	movq	%rdi, 64(%rsp)
	movl	$1, 72(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L57
	movq	56(%rsp), %rdi
	call	_Z26__device_stub__Z7kernel2PdPd
.L57:
	call	cudaPeekAtLastError@PLT
	movl	$1, %ecx
	movl	$155, %edx
	leaq	.LC15(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	movq	56(%rsp), %rsi
	movl	$2, %ecx
	movq	%r12, %rdi
	movl	$134283272, %edx
	call	cudaMemcpy@PLT
	movl	$1, %ecx
	movl	$156, %edx
	leaq	.LC15(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	movq	40(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movl	$1, %ecx
	movl	$157, %edx
	leaq	.LC15(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	call	cudaDeviceSynchronize@PLT
	movl	$1, %ecx
	movl	$159, %edx
	leaq	.LC15(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	movq	40(%rsp), %rdx
	movq	%r15, %rdi
	movq	32(%rsp), %rsi
	movl	$0x00000000, 28(%rsp)
	call	cudaEventElapsedTime@PLT
	movl	$1, %ecx
	movl	$162, %edx
	leaq	.LC15(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	leaq	.LC18(%rip), %rsi
	movq	%r14, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movsd	.LC19(%rip), %xmm0
	divsd	(%rsp), %xmm0
	divsd	.LC11(%rip), %xmm0
	movq	%rax, %rdi
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	movq	%r13, %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	cvtss2sd	28(%rsp), %xmm0
	movq	%rax, %rdi
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	leaq	.LC14(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	movq	48(%rsp), %rdi
	call	cudaFree@PLT
	movl	$1, %ecx
	movl	$167, %edx
	leaq	.LC15(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	movq	56(%rsp), %rdi
	call	cudaFree@PLT
	movl	$1, %ecx
	movl	$168, %edx
	leaq	.LC15(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	movq	%rbp, %rdi
	call	free@PLT
	movq	%rbx, %rdi
	call	free@PLT
	movq	%r12, %rdi
	call	free@PLT
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	je	.L58
	call	__stack_chk_fail@PLT
.L58:
	addq	$104, %rsp
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3639:
	.size	main, .-main
	.section	.rodata.str1.1
.LC20:
	.string	"_Z7kernel2Pd"
.LC21:
	.string	"_Z7kernel1Pd"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB3669:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -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	.LC20(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z7kernel2Pd(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r9d, %r9d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC21(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z7kernel1Pd(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 40
	pushq	$0
	.cfi_def_cfa_offset 48
	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	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE3669:
	.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.cst16,"aM",@progbits,16
	.align 16
.LC2:
	.long	-1
	.long	2147483647
	.long	0
	.long	0
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC3:
	.long	-1598689907
	.long	1051772663
	.align 8
.LC10:
	.long	0
	.long	1104740352
	.align 8
.LC11:
	.long	0
	.long	1104006501
	.align 8
.LC13:
	.long	0
	.long	1083129856
	.align 8
.LC19:
	.long	419430400
	.long	1104741152
	.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:

// Compile: nvcc -arch=sm_61 -std=c++11 assignment5-p2.cu -o assignment5-p2


#include <hip/hip_runtime.h>
#include <cmath>
#include <cstdint>
#include <iostream>
#include <sys/time.h>

#define THRESHOLD (0.000001)

#define SIZE1 4096
#define SIZE2 4097
#define ITER 100
#define BLOCK_SIZE 16

using namespace std;

#define gpuErrchk(ans) { gpuAssert((ans), __FILE__, __LINE__); }
inline void gpuAssert(hipError_t code, const char *file, int line, bool abort=true) {
   if (code != hipSuccess) {
      fprintf(stderr, "GPUassert: %s %s %d\n", hipGetErrorString(code), file, line);
      if (abort) exit(code);
   }
}

__global__ void kernel1(double* A) {
  // SB: Write the first kernel here
  int j =  blockIdx.x*blockDim.x + threadIdx.x;
  if(j < SIZE1 - 1) {
    for (int k = 0; k < ITER; k++) {
      for (int i = 1; i < SIZE1; i++) {
        A[i*SIZE1 + j + 1] = A[(i - 1)*SIZE1 + j + 1] + A[i*SIZE1 + j + 1];
      }
    }
  }
}

__global__ void kernel2(double* A) {
  // SB: Write the second kernel here
  int j =  blockIdx.x*blockDim.x + threadIdx.x;
  if(j < SIZE2 - 1) {
    for (int k = 0; k < ITER; k++) {
      for (int i = 1; i < SIZE2; i++) {
        A[i*SIZE2 + j + 1] = A[(i - 1)*SIZE2 + j + 1] + A[i*SIZE2 + j + 1];
      }
    }
  }
}

__host__ void serial(double** A) {
  for (int k = 0; k < ITER; k++) {
    for (int i = 1; i < SIZE1; i++) {
      for (int j = 0; j < SIZE1 - 1; j++) {
        A[i][j + 1] = A[i - 1][j + 1] + A[i][j + 1];
      }
    }
  }
}

__host__ void check_result(double** w_ref, double* w_opt, uint64_t size) {
  double maxdiff = 0.0, this_diff = 0.0;
  int numdiffs = 0;

  for (uint64_t i = 0; i < size; i++) {
    for (uint64_t j = 0; j < size; j++) {
      this_diff = w_ref[i][j] - w_opt[i*size + j];
      if (fabs(this_diff) > THRESHOLD) {
        numdiffs++;
        if (this_diff > maxdiff)
          maxdiff = this_diff;
      }
    }
  }

  if (numdiffs > 0) {
    cout << numdiffs << " Diffs found over THRESHOLD " << THRESHOLD << "; Max Diff = " << maxdiff
         << endl;
  } else {
    cout << "No differences found between base and test versions" << endl;
  }
}

__host__ double rtclock() {
  struct timezone Tzp;
  struct timeval Tp;
  int stat;
  stat = gettimeofday(&Tp, &Tzp);
  if (stat != 0) {
    cout << "Error return from gettimeofday: " << stat << "\n";
  }
  return (Tp.tv_sec + Tp.tv_usec * 1.0e-6);
}

int main() {
  double** A_ser = new double*[SIZE1];
  double* A_k1 = new double[SIZE1*SIZE1];
  double* A_k2 = new double[SIZE2*SIZE2];
  
  for (int i = 0; i < SIZE1; i++) {
    A_ser[i] = new double[SIZE1];
  }

  for (int i = 0; i < SIZE1; i++) {
    for (int j = 0; j < SIZE1; j++) {
      A_ser[i][j] = i + j;
      A_k1[i*SIZE1 + j] = i + j;
    }
  }
  for (int i = 0; i < SIZE2; i++) {
    for (int j = 0; j < SIZE2; j++) {
      A_k2[i*SIZE2 + j] = i + j;
    }
  }

  double clkbegin, clkend;
  double t;

  clkbegin = rtclock();
  serial(A_ser);
  clkend = rtclock();
  t = clkend - clkbegin;
  cout << "Serial code on CPU: " << (1.0 * SIZE1 * SIZE1 * ITER / t / 1.0e9)
       << " GFLOPS; Time = " << t * 1000 << " msec" << endl;

  hipEvent_t start, end;
  gpuErrchk( hipEventCreate(&start) );
  gpuErrchk( hipEventCreate(&end) );
  // SB: Write your first GPU kernel here
  
  double* A_k1_c;
  gpuErrchk( hipMalloc((void**)&A_k1_c, SIZE1*SIZE1*sizeof(double)) );

  gpuErrchk( hipEventRecord(start, 0) );
  gpuErrchk( hipMemcpy(A_k1_c, A_k1, SIZE1*SIZE1*sizeof(double), hipMemcpyHostToDevice) );
  kernel1<<<4, 1024>>>(A_k1_c);
  gpuErrchk( hipPeekAtLastError() );
  gpuErrchk( hipMemcpy(A_k1, A_k1_c, SIZE1*SIZE1*sizeof(double), hipMemcpyDeviceToHost) );
  gpuErrchk( hipEventRecord(end, 0) );

  gpuErrchk( hipDeviceSynchronize() );

  float kernel_time = 0;
  gpuErrchk( hipEventElapsedTime(&kernel_time, start, end) );
  check_result(A_ser, A_k1, SIZE1);
  cout << "Kernel 1 on GPU: " << (1.0 * SIZE1 * SIZE1 * ITER / t / 1.0e9)
       << " GFLOPS; Time = " << kernel_time << " msec" << endl;

  // SB: Write your second GPU kernel here
  
  double* A_k2_c;
  gpuErrchk( hipMalloc((void**)&A_k2_c, SIZE2*SIZE2*sizeof(double)) );
  
  gpuErrchk( hipEventRecord(start, 0) );
  gpuErrchk( hipMemcpy(A_k2_c, A_k2, SIZE2*SIZE2*sizeof(double), hipMemcpyHostToDevice) );
  kernel2<<<4, 1024>>>(A_k2_c);
  gpuErrchk( hipPeekAtLastError() );
  gpuErrchk( hipMemcpy(A_k2, A_k2_c, SIZE2*SIZE2*sizeof(double), hipMemcpyDeviceToHost) );
  gpuErrchk( hipEventRecord(end, 0) );

  gpuErrchk( hipDeviceSynchronize() );

  kernel_time = 0;
  gpuErrchk( hipEventElapsedTime(&kernel_time, start, end) );
  // check_result(A_ser, A_k2, SIZE1);
  cout << "Kernel 2 on GPU: " << (1.0 * SIZE2 * SIZE2 * ITER / t / 1.0e9)
       << " GFLOPS; Time = " << kernel_time << " msec" << endl;

  gpuErrchk( hipFree(A_k1_c) );
  gpuErrchk( hipFree(A_k2_c) );
  
  free(A_ser);
  free(A_k1);
  free(A_k2);
  return EXIT_SUCCESS;
}

	.text
	.file	"p2.hip"
                                        # Start of file scope inline assembly
	.globl	_ZSt21ios_base_library_initv

                                        # End of file scope inline assembly
	.globl	_Z22__device_stub__kernel1Pd    # -- Begin function _Z22__device_stub__kernel1Pd
	.type	_Z22__device_stub__kernel1Pd,@function
_Z22__device_stub__kernel1Pd:           # @_Z22__device_stub__kernel1Pd
	.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	$64, %rsp
	.cfi_def_cfa_offset 112
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	24(%rsp), %rax
	movq	%rdi, (%rax)
	movq	%rsp, %rbx
	movq	%rax, (%rbx)
	leaq	48(%rsp), %r14
	leaq	32(%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	$_Z7kernel1Pd, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$80, %rsp
	.cfi_adjust_cfa_offset -80
	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_end0:
	.size	_Z22__device_stub__kernel1Pd, .Lfunc_end0-_Z22__device_stub__kernel1Pd
	.cfi_endproc
                                        # -- End function
	.globl	_Z22__device_stub__kernel2Pd    # -- Begin function _Z22__device_stub__kernel2Pd
	.type	_Z22__device_stub__kernel2Pd,@function
_Z22__device_stub__kernel2Pd:           # @_Z22__device_stub__kernel2Pd
	.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	$64, %rsp
	.cfi_def_cfa_offset 112
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	24(%rsp), %rax
	movq	%rdi, (%rax)
	movq	%rsp, %rbx
	movq	%rax, (%rbx)
	leaq	48(%rsp), %r14
	leaq	32(%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	$_Z7kernel2Pd, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$80, %rsp
	.cfi_adjust_cfa_offset -80
	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	_Z22__device_stub__kernel2Pd, .Lfunc_end1-_Z22__device_stub__kernel2Pd
	.cfi_endproc
                                        # -- End function
	.globl	_Z6serialPPd                    # -- Begin function _Z6serialPPd
	.type	_Z6serialPPd,@function
_Z6serialPPd:                           # @_Z6serialPPd
	.cfi_startproc
# %bb.0:
	xorl	%eax, %eax
.LBB2_1:                                # %.preheader16
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB2_2 Depth 2
                                        #       Child Loop BB2_3 Depth 3
	movl	$1, %ecx
.LBB2_2:                                # %.preheader
                                        #   Parent Loop BB2_1 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB2_3 Depth 3
	movq	-8(%rdi,%rcx,8), %rdx
	movq	(%rdi,%rcx,8), %rsi
	movl	$1, %r8d
.LBB2_3:                                #   Parent Loop BB2_1 Depth=1
                                        #     Parent Loop BB2_2 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movsd	(%rdx,%r8,8), %xmm0             # xmm0 = mem[0],zero
	addsd	(%rsi,%r8,8), %xmm0
	movsd	%xmm0, (%rsi,%r8,8)
	incq	%r8
	cmpq	$4096, %r8                      # imm = 0x1000
	jne	.LBB2_3
# %bb.4:                                #   in Loop: Header=BB2_2 Depth=2
	incq	%rcx
	cmpq	$4096, %rcx                     # imm = 0x1000
	jne	.LBB2_2
# %bb.5:                                #   in Loop: Header=BB2_1 Depth=1
	incl	%eax
	cmpl	$100, %eax
	jne	.LBB2_1
# %bb.6:
	retq
.Lfunc_end2:
	.size	_Z6serialPPd, .Lfunc_end2-_Z6serialPPd
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0                          # -- Begin function _Z12check_resultPPdS_m
.LCPI3_0:
	.quad	0x7fffffffffffffff              # double NaN
	.quad	0x7fffffffffffffff              # double NaN
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0
.LCPI3_1:
	.quad	0x3eb0c6f7a0b5ed8d              # double 9.9999999999999995E-7
	.text
	.globl	_Z12check_resultPPdS_m
	.type	_Z12check_resultPPdS_m,@function
_Z12check_resultPPdS_m:                 # @_Z12check_resultPPdS_m
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$16, %rsp
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -16
	testq	%rdx, %rdx
	je	.LBB3_10
# %bb.1:                                # %.preheader.preheader
	leaq	(,%rdx,8), %rcx
	xorpd	%xmm4, %xmm4
	xorl	%r8d, %r8d
	movapd	.LCPI3_0(%rip), %xmm0           # xmm0 = [NaN,NaN]
	movsd	.LCPI3_1(%rip), %xmm1           # xmm1 = mem[0],zero
	xorl	%eax, %eax
.LBB3_2:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB3_3 Depth 2
	movq	(%rdi,%r8,8), %r9
	xorl	%r10d, %r10d
.LBB3_3:                                #   Parent Loop BB3_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movsd	(%r9,%r10,8), %xmm2             # xmm2 = mem[0],zero
	subsd	(%rsi,%r10,8), %xmm2
	movapd	%xmm2, %xmm3
	andpd	%xmm0, %xmm3
	ucomisd	%xmm1, %xmm3
	jbe	.LBB3_6
# %bb.4:                                #   in Loop: Header=BB3_3 Depth=2
	incl	%eax
	ucomisd	%xmm4, %xmm2
	jbe	.LBB3_6
# %bb.5:                                #   in Loop: Header=BB3_3 Depth=2
	movapd	%xmm2, %xmm4
.LBB3_6:                                #   in Loop: Header=BB3_3 Depth=2
	incq	%r10
	cmpq	%r10, %rdx
	jne	.LBB3_3
# %bb.7:                                #   in Loop: Header=BB3_2 Depth=1
	incq	%r8
	addq	%rcx, %rsi
	cmpq	%rdx, %r8
	jne	.LBB3_2
# %bb.8:                                # %._crit_edge
	testl	%eax, %eax
	jle	.LBB3_10
# %bb.9:
	movl	$_ZSt4cout, %edi
	movl	%eax, %esi
	movsd	%xmm4, 8(%rsp)                  # 8-byte Spill
	callq	_ZNSolsEi
	movq	%rax, %rbx
	movl	$.L.str, %esi
	movl	$28, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movsd	.LCPI3_1(%rip), %xmm0           # xmm0 = mem[0],zero
	movq	%rbx, %rdi
	callq	_ZNSo9_M_insertIdEERSoT_
	movq	%rax, %rbx
	movl	$.L.str.1, %esi
	movl	$13, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	%rbx, %rdi
	movsd	8(%rsp), %xmm0                  # 8-byte Reload
                                        # xmm0 = mem[0],zero
	callq	_ZNSo9_M_insertIdEERSoT_
	movq	%rax, %rbx
	jmp	.LBB3_11
.LBB3_10:                               # %._crit_edge.thread
	movl	$_ZSt4cout, %ebx
	movl	$_ZSt4cout, %edi
	movl	$.L.str.2, %esi
	movl	$51, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.LBB3_11:
	movq	(%rbx), %rax
	movq	-24(%rax), %rdi
	addq	%rbx, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movq	%rbx, %rdi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	addq	$16, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	_ZNSo5flushEv                   # TAILCALL
.Lfunc_end3:
	.size	_Z12check_resultPPdS_m, .Lfunc_end3-_Z12check_resultPPdS_m
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z7rtclockv
.LCPI4_0:
	.quad	0x3eb0c6f7a0b5ed8d              # double 9.9999999999999995E-7
	.text
	.globl	_Z7rtclockv
	.type	_Z7rtclockv,@function
_Z7rtclockv:                            # @_Z7rtclockv
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$32, %rsp
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -16
	leaq	8(%rsp), %rdi
	leaq	24(%rsp), %rsi
	callq	gettimeofday
	testl	%eax, %eax
	je	.LBB4_2
# %bb.1:
	movl	%eax, %ebx
	movl	$_ZSt4cout, %edi
	movl	$.L.str.3, %esi
	movl	$32, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	$_ZSt4cout, %edi
	movl	%ebx, %esi
	callq	_ZNSolsEi
	movl	$.L.str.4, %esi
	movl	$1, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.LBB4_2:
	cvtsi2sdq	8(%rsp), %xmm1
	cvtsi2sdq	16(%rsp), %xmm0
	mulsd	.LCPI4_0(%rip), %xmm0
	addsd	%xmm1, %xmm0
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end4:
	.size	_Z7rtclockv, .Lfunc_end4-_Z7rtclockv
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI5_0:
	.quad	0x41d9000000000000              # double 1677721600
.LCPI5_1:
	.quad	0x41cdcd6500000000              # double 1.0E+9
.LCPI5_2:
	.quad	0x408f400000000000              # double 1000
.LCPI5_3:
	.quad	0x41d9032019000000              # double 1678540900
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	.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	$32768, %edi                    # imm = 0x8000
	callq	_Znam
	movq	%rax, %rbx
	movl	$134217728, %edi                # imm = 0x8000000
	callq	_Znam
	movq	%rax, %r14
	movl	$134283272, %edi                # imm = 0x8010008
	callq	_Znam
	movq	%rax, %r15
	xorl	%r12d, %r12d
.LBB5_1:                                # =>This Inner Loop Header: Depth=1
	movl	$32768, %edi                    # imm = 0x8000
	callq	_Znam
	movq	%rax, (%rbx,%r12,8)
	incq	%r12
	cmpq	$4096, %r12                     # imm = 0x1000
	jne	.LBB5_1
# %bb.2:                                # %.preheader102.preheader
	xorl	%eax, %eax
	movq	%r14, %rcx
.LBB5_3:                                # %.preheader102
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB5_4 Depth 2
	movq	(%rbx,%rax,8), %rdx
	xorl	%esi, %esi
.LBB5_4:                                #   Parent Loop BB5_3 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	leal	(%rax,%rsi), %edi
	xorps	%xmm0, %xmm0
	cvtsi2sd	%edi, %xmm0
	movsd	%xmm0, (%rdx,%rsi,8)
	movsd	%xmm0, (%rcx,%rsi,8)
	incq	%rsi
	cmpq	$4096, %rsi                     # imm = 0x1000
	jne	.LBB5_4
# %bb.5:                                #   in Loop: Header=BB5_3 Depth=1
	incq	%rax
	addq	$32768, %rcx                    # imm = 0x8000
	cmpq	$4096, %rax                     # imm = 0x1000
	jne	.LBB5_3
# %bb.6:                                # %.preheader.preheader
	xorl	%eax, %eax
	movq	%r15, %rcx
.LBB5_7:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB5_8 Depth 2
	xorl	%edx, %edx
.LBB5_8:                                #   Parent Loop BB5_7 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	leal	(%rax,%rdx), %esi
	xorps	%xmm0, %xmm0
	cvtsi2sd	%esi, %xmm0
	movsd	%xmm0, (%rcx,%rdx,8)
	incq	%rdx
	cmpq	$4097, %rdx                     # imm = 0x1001
	jne	.LBB5_8
# %bb.9:                                #   in Loop: Header=BB5_7 Depth=1
	incq	%rax
	addq	$32776, %rcx                    # imm = 0x8008
	cmpq	$4097, %rax                     # imm = 0x1001
	jne	.LBB5_7
# %bb.10:
	xorl	%ebp, %ebp
	callq	_Z7rtclockv
	movsd	%xmm0, 8(%rsp)                  # 8-byte Spill
.LBB5_11:                               # %.preheader16.i
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB5_12 Depth 2
                                        #       Child Loop BB5_13 Depth 3
	movl	$1, %eax
.LBB5_12:                               # %.preheader.i
                                        #   Parent Loop BB5_11 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB5_13 Depth 3
	movq	-8(%rbx,%rax,8), %rcx
	movq	(%rbx,%rax,8), %rdx
	movl	$1, %esi
.LBB5_13:                               #   Parent Loop BB5_11 Depth=1
                                        #     Parent Loop BB5_12 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movsd	(%rcx,%rsi,8), %xmm0            # xmm0 = mem[0],zero
	addsd	(%rdx,%rsi,8), %xmm0
	movsd	%xmm0, (%rdx,%rsi,8)
	incq	%rsi
	cmpq	$4096, %rsi                     # imm = 0x1000
	jne	.LBB5_13
# %bb.14:                               #   in Loop: Header=BB5_12 Depth=2
	incq	%rax
	cmpq	$4096, %rax                     # imm = 0x1000
	jne	.LBB5_12
# %bb.15:                               #   in Loop: Header=BB5_11 Depth=1
	incl	%ebp
	cmpl	$100, %ebp
	jne	.LBB5_11
# %bb.16:                               # %_Z6serialPPd.exit
	callq	_Z7rtclockv
	subsd	8(%rsp), %xmm0                  # 8-byte Folded Reload
	movsd	%xmm0, 8(%rsp)                  # 8-byte Spill
	movl	$_ZSt4cout, %edi
	movl	$.L.str.5, %esi
	movl	$20, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movsd	.LCPI5_0(%rip), %xmm0           # xmm0 = mem[0],zero
	divsd	8(%rsp), %xmm0                  # 8-byte Folded Reload
	divsd	.LCPI5_1(%rip), %xmm0
	movl	$_ZSt4cout, %edi
	movsd	%xmm0, 48(%rsp)                 # 8-byte Spill
	callq	_ZNSo9_M_insertIdEERSoT_
	movq	%rax, %r12
	movl	$.L.str.6, %esi
	movl	$16, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movsd	.LCPI5_2(%rip), %xmm0           # xmm0 = mem[0],zero
	mulsd	8(%rsp), %xmm0                  # 8-byte Folded Reload
	movq	%r12, %rdi
	callq	_ZNSo9_M_insertIdEERSoT_
	movq	%rax, %r12
	movl	$.L.str.7, %esi
	movl	$5, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	(%r12), %rax
	movq	-24(%rax), %rdi
	addq	%r12, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movq	%r12, %rdi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	leaq	40(%rsp), %rdi
	callq	hipEventCreate
	testl	%eax, %eax
	jne	.LBB5_17
# %bb.19:                               # %_Z9gpuAssert10hipError_tPKcib.exit
	leaq	32(%rsp), %rdi
	callq	hipEventCreate
	testl	%eax, %eax
	jne	.LBB5_20
# %bb.21:                               # %_Z9gpuAssert10hipError_tPKcib.exit55
	leaq	24(%rsp), %rdi
	movl	$134217728, %esi                # imm = 0x8000000
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB5_22
# %bb.23:                               # %_Z9gpuAssert10hipError_tPKcib.exit57
	movq	40(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	testl	%eax, %eax
	jne	.LBB5_24
# %bb.25:                               # %_Z9gpuAssert10hipError_tPKcib.exit59
	movq	24(%rsp), %rdi
	movl	$134217728, %edx                # imm = 0x8000000
	movq	%r14, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB5_26
# %bb.27:                               # %_Z9gpuAssert10hipError_tPKcib.exit61
	movabsq	$4294967300, %r13               # imm = 0x100000004
	leaq	1020(%r13), %r12
	movq	%r13, %rdi
	movl	$1, %esi
	movq	%r12, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB5_29
# %bb.28:
	movq	24(%rsp), %rdi
	callq	_Z22__device_stub__kernel1Pd
.LBB5_29:
	callq	hipPeekAtLastError
	testl	%eax, %eax
	jne	.LBB5_30
# %bb.31:                               # %_Z9gpuAssert10hipError_tPKcib.exit63
	movq	24(%rsp), %rsi
	movl	$134217728, %edx                # imm = 0x8000000
	movq	%r14, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB5_32
# %bb.33:                               # %_Z9gpuAssert10hipError_tPKcib.exit65
	movq	32(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	testl	%eax, %eax
	jne	.LBB5_34
# %bb.35:                               # %_Z9gpuAssert10hipError_tPKcib.exit67
	callq	hipDeviceSynchronize
	testl	%eax, %eax
	jne	.LBB5_36
# %bb.37:                               # %_Z9gpuAssert10hipError_tPKcib.exit69
	leaq	4(%rsp), %rdi
	movl	$0, (%rdi)
	movq	40(%rsp), %rsi
	movq	32(%rsp), %rdx
	callq	hipEventElapsedTime
	testl	%eax, %eax
	jne	.LBB5_38
# %bb.39:                               # %_Z9gpuAssert10hipError_tPKcib.exit71
	movl	$4096, %edx                     # imm = 0x1000
	movq	%rbx, %rdi
	movq	%r14, %rsi
	callq	_Z12check_resultPPdS_m
	movl	$_ZSt4cout, %edi
	movl	$.L.str.9, %esi
	movl	$17, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	$_ZSt4cout, %edi
	movsd	48(%rsp), %xmm0                 # 8-byte Reload
                                        # xmm0 = mem[0],zero
	callq	_ZNSo9_M_insertIdEERSoT_
	movq	%rax, %rbp
	movl	$.L.str.6, %esi
	movl	$16, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	xorps	%xmm0, %xmm0
	cvtss2sd	4(%rsp), %xmm0
	movq	%rbp, %rdi
	callq	_ZNSo9_M_insertIdEERSoT_
	movq	%rax, %rbp
	movl	$.L.str.7, %esi
	movl	$5, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	(%rbp), %rax
	movq	-24(%rax), %rdi
	addq	%rbp, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movq	%rbp, %rdi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	leaq	16(%rsp), %rdi
	movl	$134283272, %esi                # imm = 0x8010008
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB5_40
# %bb.41:                               # %_Z9gpuAssert10hipError_tPKcib.exit73
	movq	40(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	testl	%eax, %eax
	jne	.LBB5_42
# %bb.43:                               # %_Z9gpuAssert10hipError_tPKcib.exit75
	movq	16(%rsp), %rdi
	movl	$134283272, %edx                # imm = 0x8010008
	movq	%r15, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB5_44
# %bb.45:                               # %_Z9gpuAssert10hipError_tPKcib.exit77
	movq	%r13, %rdi
	movl	$1, %esi
	movq	%r12, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB5_47
# %bb.46:
	movq	16(%rsp), %rdi
	callq	_Z22__device_stub__kernel2Pd
.LBB5_47:
	callq	hipPeekAtLastError
	testl	%eax, %eax
	jne	.LBB5_48
# %bb.49:                               # %_Z9gpuAssert10hipError_tPKcib.exit79
	movq	16(%rsp), %rsi
	movl	$134283272, %edx                # imm = 0x8010008
	movq	%r15, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB5_50
# %bb.51:                               # %_Z9gpuAssert10hipError_tPKcib.exit81
	movq	32(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	testl	%eax, %eax
	jne	.LBB5_52
# %bb.53:                               # %_Z9gpuAssert10hipError_tPKcib.exit83
	callq	hipDeviceSynchronize
	testl	%eax, %eax
	jne	.LBB5_54
# %bb.55:                               # %_Z9gpuAssert10hipError_tPKcib.exit85
	leaq	4(%rsp), %rdi
	movl	$0, (%rdi)
	movq	40(%rsp), %rsi
	movq	32(%rsp), %rdx
	callq	hipEventElapsedTime
	testl	%eax, %eax
	jne	.LBB5_56
# %bb.57:                               # %_Z9gpuAssert10hipError_tPKcib.exit87
	movl	$_ZSt4cout, %edi
	movl	$.L.str.10, %esi
	movl	$17, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movsd	.LCPI5_3(%rip), %xmm0           # xmm0 = mem[0],zero
	divsd	8(%rsp), %xmm0                  # 8-byte Folded Reload
	divsd	.LCPI5_1(%rip), %xmm0
	movl	$_ZSt4cout, %edi
	callq	_ZNSo9_M_insertIdEERSoT_
	movq	%rax, %r12
	movl	$.L.str.6, %esi
	movl	$16, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	xorps	%xmm0, %xmm0
	cvtss2sd	4(%rsp), %xmm0
	movq	%r12, %rdi
	callq	_ZNSo9_M_insertIdEERSoT_
	movq	%rax, %r12
	movl	$.L.str.7, %esi
	movl	$5, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	(%r12), %rax
	movq	-24(%rax), %rdi
	addq	%r12, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movq	%r12, %rdi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movq	24(%rsp), %rdi
	callq	hipFree
	testl	%eax, %eax
	jne	.LBB5_58
# %bb.59:                               # %_Z9gpuAssert10hipError_tPKcib.exit89
	movq	16(%rsp), %rdi
	callq	hipFree
	testl	%eax, %eax
	jne	.LBB5_60
# %bb.61:                               # %_Z9gpuAssert10hipError_tPKcib.exit91
	movq	%rbx, %rdi
	callq	free
	movq	%r14, %rdi
	callq	free
	movq	%r15, %rdi
	callq	free
	xorl	%eax, %eax
	addq	$56, %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
.LBB5_17:
	.cfi_def_cfa_offset 112
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.11, %esi
	movl	$.L.str.8, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$127, %r8d
	jmp	.LBB5_18
.LBB5_20:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.11, %esi
	movl	$.L.str.8, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$128, %r8d
	jmp	.LBB5_18
.LBB5_22:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.11, %esi
	movl	$.L.str.8, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$132, %r8d
	jmp	.LBB5_18
.LBB5_24:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.11, %esi
	movl	$.L.str.8, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$134, %r8d
	jmp	.LBB5_18
.LBB5_26:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.11, %esi
	movl	$.L.str.8, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$135, %r8d
	jmp	.LBB5_18
.LBB5_30:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.11, %esi
	movl	$.L.str.8, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$137, %r8d
	jmp	.LBB5_18
.LBB5_32:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.11, %esi
	movl	$.L.str.8, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$138, %r8d
	jmp	.LBB5_18
.LBB5_34:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.11, %esi
	movl	$.L.str.8, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$139, %r8d
	jmp	.LBB5_18
.LBB5_36:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.11, %esi
	movl	$.L.str.8, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$141, %r8d
	jmp	.LBB5_18
.LBB5_38:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.11, %esi
	movl	$.L.str.8, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$144, %r8d
	jmp	.LBB5_18
.LBB5_40:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.11, %esi
	movl	$.L.str.8, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$152, %r8d
	jmp	.LBB5_18
.LBB5_42:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.11, %esi
	movl	$.L.str.8, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$154, %r8d
	jmp	.LBB5_18
.LBB5_44:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.11, %esi
	movl	$.L.str.8, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$155, %r8d
	jmp	.LBB5_18
.LBB5_48:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.11, %esi
	movl	$.L.str.8, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$157, %r8d
	jmp	.LBB5_18
.LBB5_50:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.11, %esi
	movl	$.L.str.8, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$158, %r8d
	jmp	.LBB5_18
.LBB5_52:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.11, %esi
	movl	$.L.str.8, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$159, %r8d
	jmp	.LBB5_18
.LBB5_54:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.11, %esi
	movl	$.L.str.8, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$161, %r8d
	jmp	.LBB5_18
.LBB5_56:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.11, %esi
	movl	$.L.str.8, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$164, %r8d
	jmp	.LBB5_18
.LBB5_58:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.11, %esi
	movl	$.L.str.8, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$169, %r8d
	jmp	.LBB5_18
.LBB5_60:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.11, %esi
	movl	$.L.str.8, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$170, %r8d
.LBB5_18:
	xorl	%eax, %eax
	callq	fprintf
	movl	%ebp, %edi
	callq	exit
.Lfunc_end5:
	.size	main, .Lfunc_end5-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:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$32, %rsp
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -16
	movq	__hip_gpubin_handle(%rip), %rbx
	testq	%rbx, %rbx
	jne	.LBB6_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB6_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z7kernel1Pd, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z7kernel2Pd, %esi
	movl	$.L__unnamed_2, %edx
	movl	$.L__unnamed_2, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$__hip_module_dtor, %edi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end6:
	.size	__hip_module_ctor, .Lfunc_end6-__hip_module_ctor
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_dtor
	.type	__hip_module_dtor,@function
__hip_module_dtor:                      # @__hip_module_dtor
	.cfi_startproc
# %bb.0:
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	je	.LBB7_2
# %bb.1:
	pushq	%rax
	.cfi_def_cfa_offset 16
	callq	__hipUnregisterFatBinary
	movq	$0, __hip_gpubin_handle(%rip)
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
.LBB7_2:
	retq
.Lfunc_end7:
	.size	__hip_module_dtor, .Lfunc_end7-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	_Z7kernel1Pd,@object            # @_Z7kernel1Pd
	.section	.rodata,"a",@progbits
	.globl	_Z7kernel1Pd
	.p2align	3, 0x0
_Z7kernel1Pd:
	.quad	_Z22__device_stub__kernel1Pd
	.size	_Z7kernel1Pd, 8

	.type	_Z7kernel2Pd,@object            # @_Z7kernel2Pd
	.globl	_Z7kernel2Pd
	.p2align	3, 0x0
_Z7kernel2Pd:
	.quad	_Z22__device_stub__kernel2Pd
	.size	_Z7kernel2Pd, 8

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	" Diffs found over THRESHOLD "
	.size	.L.str, 29

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"; Max Diff = "
	.size	.L.str.1, 14

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"No differences found between base and test versions"
	.size	.L.str.2, 52

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"Error return from gettimeofday: "
	.size	.L.str.3, 33

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

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"Serial code on CPU: "
	.size	.L.str.5, 21

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	" GFLOPS; Time = "
	.size	.L.str.6, 17

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	" msec"
	.size	.L.str.7, 6

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"/home/ubuntu/Datasets/stackv2/train-structured-repos-hip-sm89/hritwik567/CS698L/master/assign5/submission/problem2/p2.hip"
	.size	.L.str.8, 122

	.type	.L.str.9,@object                # @.str.9
.L.str.9:
	.asciz	"Kernel 1 on GPU: "
	.size	.L.str.9, 18

	.type	.L.str.10,@object               # @.str.10
.L.str.10:
	.asciz	"Kernel 2 on GPU: "
	.size	.L.str.10, 18

	.type	.L.str.11,@object               # @.str.11
.L.str.11:
	.asciz	"GPUassert: %s %s %d\n"
	.size	.L.str.11, 21

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z7kernel1Pd"
	.size	.L__unnamed_1, 13

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z7kernel2Pd"
	.size	.L__unnamed_2, 13

	.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

	.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 _Z22__device_stub__kernel1Pd
	.addrsig_sym _Z22__device_stub__kernel2Pd
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z7kernel1Pd
	.addrsig_sym _Z7kernel2Pd
	.addrsig_sym _ZSt4cout
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z7kernel1Pd            ; -- Begin function _Z7kernel1Pd
	.globl	_Z7kernel1Pd
	.p2align	8
	.type	_Z7kernel1Pd,@function
_Z7kernel1Pd:                           ; @_Z7kernel1Pd
; %bb.0:
	s_load_b32 s2, s[0:1], 0x14
	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_i32_e32 0xfff, v1
	s_cbranch_execz .LBB0_5
; %bb.1:                                ; %.preheader16
	s_load_b64 s[0:1], s[0:1], 0x0
	s_mov_b32 s2, 0
	s_waitcnt lgkmcnt(0)
	s_add_u32 s0, s0, 8
	s_addc_u32 s1, s1, 0
.LBB0_2:                                ; %.preheader
                                        ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_3 Depth 2
	s_mov_b32 s3, 0
.LBB0_3:                                ;   Parent Loop BB0_2 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(SALU_CYCLE_1)
	v_add_nc_u32_e32 v2, s3, v1
	s_addk_i32 s3, 0x1000
	s_cmp_eq_u32 s3, 0xfff000
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_add_nc_u32_e32 v4, 0x1000, v2
	v_ashrrev_i32_e32 v3, 31, v2
	v_ashrrev_i32_e32 v5, 31, v4
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_lshlrev_b64 v[2:3], 3, v[2:3]
	v_lshlrev_b64 v[4:5], 3, v[4:5]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_co_u32 v2, vcc_lo, s0, v2
	v_add_co_ci_u32_e32 v3, vcc_lo, s1, v3, vcc_lo
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_add_co_u32 v4, vcc_lo, s0, v4
	v_add_co_ci_u32_e32 v5, vcc_lo, s1, v5, vcc_lo
	s_clause 0x1
	global_load_b64 v[2:3], v[2:3], off
	global_load_b64 v[6:7], v[4:5], off
	s_waitcnt vmcnt(0)
	v_add_f64 v[2:3], v[2:3], v[6:7]
	global_store_b64 v[4:5], v[2:3], off
	s_cbranch_scc0 .LBB0_3
; %bb.4:                                ;   in Loop: Header=BB0_2 Depth=1
	s_add_i32 s2, s2, 1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_cmpk_eq_i32 s2, 0x64
	s_cbranch_scc0 .LBB0_2
.LBB0_5:                                ; %.loopexit
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z7kernel1Pd
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 264
		.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	_Z7kernel1Pd, .Lfunc_end0-_Z7kernel1Pd
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 240
; 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
	.protected	_Z7kernel2Pd            ; -- Begin function _Z7kernel2Pd
	.globl	_Z7kernel2Pd
	.p2align	8
	.type	_Z7kernel2Pd,@function
_Z7kernel2Pd:                           ; @_Z7kernel2Pd
; %bb.0:
	s_load_b32 s2, s[0:1], 0x14
	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_i32_e32 0x1000, v1
	s_cbranch_execz .LBB1_5
; %bb.1:                                ; %.preheader16
	s_load_b64 s[0:1], s[0:1], 0x0
	s_mov_b32 s2, 0
	s_waitcnt lgkmcnt(0)
	s_add_u32 s0, s0, 8
	s_addc_u32 s1, s1, 0
.LBB1_2:                                ; %.preheader
                                        ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB1_3 Depth 2
	s_mov_b32 s3, 0
.LBB1_3:                                ;   Parent Loop BB1_2 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(SALU_CYCLE_1)
	v_add_nc_u32_e32 v2, s3, v1
	s_addk_i32 s3, 0x1001
	s_cmp_eq_u32 s3, 0x1001000
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_add_nc_u32_e32 v4, 0x1001, v2
	v_ashrrev_i32_e32 v3, 31, v2
	v_ashrrev_i32_e32 v5, 31, v4
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_lshlrev_b64 v[2:3], 3, v[2:3]
	v_lshlrev_b64 v[4:5], 3, v[4:5]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_co_u32 v2, vcc_lo, s0, v2
	v_add_co_ci_u32_e32 v3, vcc_lo, s1, v3, vcc_lo
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_add_co_u32 v4, vcc_lo, s0, v4
	v_add_co_ci_u32_e32 v5, vcc_lo, s1, v5, vcc_lo
	s_clause 0x1
	global_load_b64 v[2:3], v[2:3], off
	global_load_b64 v[6:7], v[4:5], off
	s_waitcnt vmcnt(0)
	v_add_f64 v[2:3], v[2:3], v[6:7]
	global_store_b64 v[4:5], v[2:3], off
	s_cbranch_scc0 .LBB1_3
; %bb.4:                                ;   in Loop: Header=BB1_2 Depth=1
	s_add_i32 s2, s2, 1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_cmpk_eq_i32 s2, 0x64
	s_cbranch_scc0 .LBB1_2
.LBB1_5:                                ; %.loopexit
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z7kernel2Pd
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 264
		.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_end1:
	.size	_Z7kernel2Pd, .Lfunc_end1-_Z7kernel2Pd
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 240
; 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
      - .offset:         8
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         12
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         16
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         20
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         22
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         24
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         26
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         28
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         30
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         48
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         56
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         64
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         72
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 264
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z7kernel1Pd
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z7kernel1Pd.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     8
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .offset:         8
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         12
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         16
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         20
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         22
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         24
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         26
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         28
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         30
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         48
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         56
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         64
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         72
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 264
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z7kernel2Pd
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z7kernel2Pd.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
