#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/resource.h>

#define NewArray(Type, N) ((Type *)(malloc(N*sizeof(Type))))

#define cudaTry(cudaStatus) _cudaTry(cudaStatus, __FILE__, __LINE__)

void _cudaTry(cudaError_t cudaStatus, const char *fileName, int lineNumber) {
  if(cudaStatus != cudaSuccess) {
    fprintf(stderr, "%s in %s line %d\n",
        cudaGetErrorString(cudaStatus), fileName, lineNumber);
    exit(1);
  }
}


__global__ void f_kernel(uint n, uint m, float *x, float *xm) {
  uint i = blockIdx.x*blockDim.x + threadIdx.x; // nvcc built-ins
  if(i < n) {
    float a = 5.0/2.0;
    float y = x[i];
    for(uint j = 0; j < m; j++) {
      y = a*(y*y*y - y);
    }
    xm[i] = y;
  }
}

void f(float *x, float *xm, uint n, uint m) {
  int size = n*sizeof(float);
  float *dev_x, *dev_xm;

  cudaTry(cudaMalloc((void**)(&dev_x), size));
  cudaTry(cudaMalloc((void**)(&dev_xm), size));
  cudaTry(cudaMemcpy(dev_x, x, size, cudaMemcpyHostToDevice));

  f_kernel<<<ceil(n/256.0),256>>>(n, m, dev_x, dev_xm);

  cudaTry(cudaMemcpy(xm, dev_xm, size, cudaMemcpyDeviceToHost));
  cudaTry(cudaFree(dev_x));
  cudaTry(cudaFree(dev_xm));
}

void f_cpu(float *x, float *xm, uint n, uint m) {
  float a = 5.0/2.0;
  for(uint i = 0; i < n; i++) {
    float y = x[i];
    for(uint j = 0; j < m; j++)
      y = a*(y*y*y - y);
    x[i] = y;
  }
}

void f_test(uint n, uint m, int gpu_flag) {
  float *x, *xm;
  struct rusage r0, r1;

  x = NewArray(float, n);
  xm = NewArray(float, n);
  for(uint i = 0; i < n; i++)
    x[i] = (1.0+i)/(n+1);
  getrusage(RUSAGE_SELF, &r0);
  if(gpu_flag) f(x, xm, n, m);
  else f_cpu(x, xm, n, m);
  getrusage(RUSAGE_SELF, &r1);
  double t_elapsed =   (r1.ru_utime.tv_sec - r0.ru_utime.tv_sec)
                     + 1e-6*(r1.ru_utime.tv_usec - r0.ru_utime.tv_usec);
  printf("f%s(n, ...): t_elapsed = %10.3e, throughput = %10.3e\n",
         gpu_flag ? "" : "_cpu", t_elapsed, n*m/t_elapsed);
}

__global__ void saxpy_kernel(uint n, float a, float *x, float *y) {
  uint i = blockIdx.x*blockDim.x + threadIdx.x; // nvcc built-ins
  if(i < n) {
    float yi = y[i];
    float xi = x[i];
    float out;
    //for (int j=0; j<10; j++) {
      out = a*xi + yi;
    //}
    y[i] = out;
  }
}

void saxpy(uint n, float a, float *x, float *y) {
  int size = n*sizeof(float);
  float *dev_x, *dev_y; // will be allocated on the GPU.

  cudaTry(cudaMalloc((void**)(&dev_x), size));
  cudaTry(cudaMalloc((void**)(&dev_y), size));
  cudaTry(cudaMemcpy(dev_x, x, size, cudaMemcpyHostToDevice));
  cudaTry(cudaMemcpy(dev_y, y, size, cudaMemcpyHostToDevice));

  saxpy_kernel<<<ceil(n/256.0),256>>>(n, a, dev_x, dev_y);

  cudaTry(cudaMemcpy(y, dev_y, size, cudaMemcpyDeviceToHost));
  cudaTry(cudaFree(dev_x));
  cudaTry(cudaFree(dev_y));
}

void saxpy_cpu(uint n, float a, float *x, float *y) {
  for (int i=0; i< n; i++) {
    float yi = y[i];
    float xi = x[i];
    float out;
    //for (int j = 0; j<10; j++) {
      out = a*xi + yi;
    //}
    y[i] = out;
  }
}

void saxpy_test(uint n, float a, int gpu_flag) {
  float *x, *y;
  struct rusage r0, r1;

  x = NewArray(float, n);
  y = NewArray(float, n);
  for(uint i = 0; i < n; i++) {
    x[i] = i;
    y[i] = i*i;
  }
  getrusage(RUSAGE_SELF, &r0);
  if(gpu_flag) saxpy(n, a, x, y);
  else saxpy_cpu(n, a, x, y);
  getrusage(RUSAGE_SELF, &r1);
  double t_elapsed =   (r1.ru_utime.tv_sec - r0.ru_utime.tv_sec)
                     + 1e-6*(r1.ru_utime.tv_usec - r0.ru_utime.tv_usec);
  printf("saxpy%s(n, ...): t_elapsed = %10.3e\n",
         gpu_flag ? "" : "_cpu", t_elapsed);
}


// f_main: for command lines of the form
//   hw4 f n m
// or
//   hw4 f_cpu n m
void f_main(int argc, char **argv, int gpu_flag) {
  uint n, m;
  if(argc != 4) {
    fprintf(stderr, "usage: hw4 %s n m\n", argv[1]);
    exit(1);
  }
  n = strtoul(argv[2], NULL, 10);
  m = strtoul(argv[3], NULL, 10);
  f_test(n, m, gpu_flag);
}

// saxpy_main: for command lines of the form
//   hw4 saxpy n [a]
// or
//   hw4 saxpy n [a]
// The parameter 'a' is optional.  If omitted, we set a=3.0.
void saxpy_main(int argc, char **argv, int gpu_flag) {
  int n;
  float a;
  if((argc < 3) || (4 < argc)) {
    fprintf(stderr, "usage: hw4 saxpy n [a]\n");
    exit(1);
  }
  n = strtoul(argv[2], NULL, 10);
  if(argc >= 4) a = atof(argv[3]);
  else a = 3.0;
  saxpy_test(n, a, gpu_flag);
}

int main(int argc, char **argv) {
  if(argc < 2) {
    fprintf(stderr, "usage: hw4 testName testArgs\n");
    exit(1);
  }
  if(strcmp(argv[1], "f") == 0) f_main(argc, argv, true);
  else if(strcmp(argv[1], "f_cpu") == 0) f_main(argc, argv, false);
  else if(strcmp(argv[1], "saxpy") == 0) saxpy_main(argc, argv, true);
  else if(strcmp(argv[1], "saxpy_cpu") == 0) saxpy_main(argc, argv, false);
  else {
    fprintf(stderr, "hw4, unrecognized test case: %s\n", argv[1]);
    exit(1);
  }
  exit(0);
}

	.file	"tmpxft_003a49c4_00000000-6_hw4.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2039:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2039:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%s in %s line %d\n"
	.text
	.globl	_Z8_cudaTry9cudaErrorPKci
	.type	_Z8_cudaTry9cudaErrorPKci, @function
_Z8_cudaTry9cudaErrorPKci:
.LFB2027:
	.cfi_startproc
	endbr64
	testl	%edi, %edi
	je	.L2
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	%edx, 12(%rsp)
	movq	%rsi, (%rsp)
	call	cudaGetErrorString@PLT
	movq	stderr(%rip), %rdi
	movq	(%rsp), %r8
	leaq	.LC0(%rip), %rdx
	movl	12(%rsp), %r9d
	movq	%rax, %rcx
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	movl	$1, %edi
	call	exit@PLT
.L2:
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2027:
	.size	_Z8_cudaTry9cudaErrorPKci, .-_Z8_cudaTry9cudaErrorPKci
	.globl	_Z5f_cpuPfS_jj
	.type	_Z5f_cpuPfS_jj, @function
_Z5f_cpuPfS_jj:
.LFB2029:
	.cfi_startproc
	endbr64
	movss	.LC1(%rip), %xmm2
	xorl	%eax, %eax
.L9:
	cmpl	%edx, %eax
	jnb	.L13
	movss	(%rdi,%rax,4), %xmm0
	xorl	%esi, %esi
.L10:
	cmpl	%ecx, %esi
	je	.L14
	movaps	%xmm0, %xmm1
	incl	%esi
	mulss	%xmm0, %xmm1
	mulss	%xmm0, %xmm1
	subss	%xmm0, %xmm1
	movaps	%xmm1, %xmm0
	mulss	%xmm2, %xmm0
	jmp	.L10
.L14:
	movss	%xmm0, (%rdi,%rax,4)
	incq	%rax
	jmp	.L9
.L13:
	ret
	.cfi_endproc
.LFE2029:
	.size	_Z5f_cpuPfS_jj, .-_Z5f_cpuPfS_jj
	.globl	_Z9saxpy_cpujfPfS_
	.type	_Z9saxpy_cpujfPfS_, @function
_Z9saxpy_cpujfPfS_:
.LFB2032:
	.cfi_startproc
	endbr64
	xorl	%eax, %eax
.L16:
	cmpl	%edi, %eax
	jnb	.L18
	movss	(%rsi,%rax,4), %xmm1
	mulss	%xmm0, %xmm1
	addss	(%rdx,%rax,4), %xmm1
	movss	%xmm1, (%rdx,%rax,4)
	incq	%rax
	jmp	.L16
.L18:
	ret
	.cfi_endproc
.LFE2032:
	.size	_Z9saxpy_cpujfPfS_, .-_Z9saxpy_cpujfPfS_
	.globl	_Z31__device_stub__Z8f_kerneljjPfS_jjPfS_
	.type	_Z31__device_stub__Z8f_kerneljjPfS_jjPfS_, @function
_Z31__device_stub__Z8f_kerneljjPfS_jjPfS_:
.LFB2061:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movl	%edi, 28(%rsp)
	leaq	56(%rsp), %rdi
	movl	%esi, 24(%rsp)
	leaq	68(%rsp), %rsi
	movq	%rdx, 16(%rsp)
	leaq	40(%rsp), %rdx
	movq	%rcx, 8(%rsp)
	leaq	48(%rsp), %rcx
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	28(%rsp), %rax
	movl	$1, 64(%rsp)
	movq	%rax, 104(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	8(%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	.L19
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z8f_kerneljjPfS_(%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
.L19:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L21
	call	__stack_chk_fail@PLT
.L21:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2061:
	.size	_Z31__device_stub__Z8f_kerneljjPfS_jjPfS_, .-_Z31__device_stub__Z8f_kerneljjPfS_jjPfS_
	.globl	_Z8f_kerneljjPfS_
	.type	_Z8f_kerneljjPfS_, @function
_Z8f_kerneljjPfS_:
.LFB2062:
	.cfi_startproc
	endbr64
	jmp	_Z31__device_stub__Z8f_kerneljjPfS_jjPfS_
	.cfi_endproc
.LFE2062:
	.size	_Z8f_kerneljjPfS_, .-_Z8f_kerneljjPfS_
	.section	.rodata.str1.1
.LC2:
	.string	"/home/ubuntu/Datasets/stackv2/train-structured/d4l3k/cs418/master/hw4/hw4.cu"
	.text
	.globl	_Z1fPfS_jj
	.type	_Z1fPfS_jj, @function
_Z1fPfS_jj:
.LFB2028:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movq	%rdi, %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movl	%ecx, %r14d
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%rsi, %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movl	%edx, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	leal	0(,%rdx,4), %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movslq	%ebp, %rbp
	leaq	.LC2(%rip), %rbx
	movq	%rbp, %rsi
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rdi
	call	cudaMalloc@PLT
	movl	$35, %edx
	movq	%rbx, %rsi
	movl	%eax, %edi
	call	_Z8_cudaTry9cudaErrorPKci
	leaq	8(%rsp), %rdi
	movq	%rbp, %rsi
	call	cudaMalloc@PLT
	movl	$36, %edx
	movq	%rbx, %rsi
	movl	%eax, %edi
	call	_Z8_cudaTry9cudaErrorPKci
	movq	(%rsp), %rdi
	movq	%rbp, %rdx
	movq	%r15, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movl	$37, %edx
	movq	%rbx, %rsi
	movl	%eax, %edi
	call	_Z8_cudaTry9cudaErrorPKci
	movl	%r12d, %eax
	cvtsi2sdq	%rax, %xmm0
	mulsd	.LC3(%rip), %xmm0
	call	ceil@PLT
	movl	$16777217, %edx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	cvttsd2siq	%xmm0, %rax
	salq	$8, %rdx
	movl	$1, %ecx
	movl	%eax, 16(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 20(%rsp)
	movq	16(%rsp), %rdi
	movl	24(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L27
	movq	8(%rsp), %rcx
	movq	(%rsp), %rdx
	movl	%r14d, %esi
	movl	%r12d, %edi
	call	_Z31__device_stub__Z8f_kerneljjPfS_jjPfS_
.L27:
	movq	8(%rsp), %rsi
	movl	$2, %ecx
	movq	%rbp, %rdx
	movq	%r13, %rdi
	call	cudaMemcpy@PLT
	movl	$41, %edx
	movq	%rbx, %rsi
	movl	%eax, %edi
	call	_Z8_cudaTry9cudaErrorPKci
	movq	(%rsp), %rdi
	call	cudaFree@PLT
	movl	$42, %edx
	movq	%rbx, %rsi
	movl	%eax, %edi
	call	_Z8_cudaTry9cudaErrorPKci
	movq	8(%rsp), %rdi
	call	cudaFree@PLT
	movl	$43, %edx
	movq	%rbx, %rsi
	movl	%eax, %edi
	call	_Z8_cudaTry9cudaErrorPKci
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	je	.L28
	call	__stack_chk_fail@PLT
.L28:
	addq	$56, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2028:
	.size	_Z1fPfS_jj, .-_Z1fPfS_jj
	.section	.rodata.str1.1
.LC4:
	.string	""
.LC5:
	.string	"_cpu"
.LC8:
	.string	"f%s(n, ...): t_elapsed = %10.3e, throughput = %10.3e\n"
	.text
	.globl	_Z6f_testjji
	.type	_Z6f_testjji, @function
_Z6f_testjji:
.LFB2030:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	movl	%edi, %r14d
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	movl	%edx, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	movl	%esi, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	movq	%r14, %rbx
	salq	$2, %r14
	movq	%r14, %rdi
	subq	$304, %rsp
	.cfi_def_cfa_offset 352
	movq	%fs:40, %rax
	movq	%rax, 296(%rsp)
	xorl	%eax, %eax
	call	malloc@PLT
	movq	%r14, %rdi
	movq	%rax, %r12
	call	malloc@PLT
	movsd	.LC6(%rip), %xmm1
	leal	1(%rbx), %edx
	movq	%rax, %r14
	xorl	%eax, %eax
.L31:
	cmpl	%ebx, %eax
	jnb	.L45
	movl	%eax, %ecx
	cvtsi2sdq	%rdx, %xmm2
	cvtsi2sdq	%rcx, %xmm0
	addsd	%xmm1, %xmm0
	divsd	%xmm2, %xmm0
	cvtsd2ss	%xmm0, %xmm0
	movss	%xmm0, (%r12,%rax,4)
	incq	%rax
	jmp	.L31
.L45:
	leaq	8(%rsp), %rsi
	xorl	%edi, %edi
	call	getrusage@PLT
	movl	%ebp, %ecx
	movl	%ebx, %edx
	movq	%r14, %rsi
	movq	%r12, %rdi
	testl	%r13d, %r13d
	je	.L37
	call	_Z1fPfS_jj
	jmp	.L38
.L37:
	call	_Z5f_cpuPfS_jj
.L38:
	xorl	%edi, %edi
	imull	%ebp, %ebx
	leaq	152(%rsp), %rsi
	call	getrusage@PLT
	movq	160(%rsp), %rax
	subq	16(%rsp), %rax
	leaq	.LC5(%rip), %rdx
	cvtsi2sdq	%rax, %xmm0
	movq	152(%rsp), %rax
	subq	8(%rsp), %rax
	testl	%r13d, %r13d
	mulsd	.LC7(%rip), %xmm0
	cvtsi2sdq	%rax, %xmm1
	movl	$2, %edi
	leaq	.LC4(%rip), %rax
	leaq	.LC8(%rip), %rsi
	cmovne	%rax, %rdx
	movb	$2, %al
	addsd	%xmm1, %xmm0
	cvtsi2sdq	%rbx, %xmm1
	divsd	%xmm0, %xmm1
	call	__printf_chk@PLT
	movq	296(%rsp), %rax
	subq	%fs:40, %rax
	je	.L42
	call	__stack_chk_fail@PLT
.L42:
	addq	$304, %rsp
	.cfi_def_cfa_offset 48
	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	_Z6f_testjji, .-_Z6f_testjji
	.section	.rodata.str1.1
.LC9:
	.string	"usage: hw4 %s n m\n"
	.text
	.globl	_Z6f_mainiPPci
	.type	_Z6f_mainiPPci, @function
_Z6f_mainiPPci:
.LFB2034:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movq	%rsi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	cmpl	$4, %edi
	je	.L47
	movq	8(%rsi), %rcx
	movq	stderr(%rip), %rdi
	movl	$2, %esi
	xorl	%eax, %eax
	leaq	.LC9(%rip), %rdx
	call	__fprintf_chk@PLT
	movl	$1, %edi
	call	exit@PLT
.L47:
	movq	16(%rsi), %rdi
	movl	%edx, %r12d
	xorl	%esi, %esi
	movl	$10, %edx
	call	__isoc23_strtoul@PLT
	movq	24(%rbp), %rdi
	movl	$10, %edx
	xorl	%esi, %esi
	movq	%rax, %rbx
	call	__isoc23_strtoul@PLT
	movl	%r12d, %edx
	movl	%ebx, %edi
	popq	%rbx
	.cfi_def_cfa_offset 24
	movl	%eax, %esi
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	jmp	_Z6f_testjji
	.cfi_endproc
.LFE2034:
	.size	_Z6f_mainiPPci, .-_Z6f_mainiPPci
	.globl	_Z36__device_stub__Z12saxpy_kerneljfPfS_jfPfS_
	.type	_Z36__device_stub__Z12saxpy_kerneljfPfS_jfPfS_, @function
_Z36__device_stub__Z12saxpy_kerneljfPfS_jfPfS_:
.LFB2063:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movl	%edi, 28(%rsp)
	leaq	48(%rsp), %rcx
	leaq	56(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	68(%rsp), %rsi
	movq	%rdx, 8(%rsp)
	leaq	40(%rsp), %rdx
	movss	%xmm0, 24(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	28(%rsp), %rax
	movl	$1, 64(%rsp)
	movq	%rax, 104(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	8(%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	.L49
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z12saxpy_kerneljfPfS_(%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
.L49:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L51
	call	__stack_chk_fail@PLT
.L51:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2063:
	.size	_Z36__device_stub__Z12saxpy_kerneljfPfS_jfPfS_, .-_Z36__device_stub__Z12saxpy_kerneljfPfS_jfPfS_
	.globl	_Z12saxpy_kerneljfPfS_
	.type	_Z12saxpy_kerneljfPfS_, @function
_Z12saxpy_kerneljfPfS_:
.LFB2064:
	.cfi_startproc
	endbr64
	jmp	_Z36__device_stub__Z12saxpy_kerneljfPfS_jfPfS_
	.cfi_endproc
.LFE2064:
	.size	_Z12saxpy_kerneljfPfS_, .-_Z12saxpy_kerneljfPfS_
	.globl	_Z5saxpyjfPfS_
	.type	_Z5saxpyjfPfS_, @function
_Z5saxpyjfPfS_:
.LFB2031:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movd	%xmm0, %r15d
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movq	%rsi, %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%rdx, %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movl	%edi, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	leal	0(,%rdi,4), %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movslq	%ebp, %rbp
	leaq	.LC2(%rip), %rbx
	movq	%rbp, %rsi
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rdi
	call	cudaMalloc@PLT
	movl	$91, %edx
	movq	%rbx, %rsi
	movl	%eax, %edi
	call	_Z8_cudaTry9cudaErrorPKci
	leaq	8(%rsp), %rdi
	movq	%rbp, %rsi
	call	cudaMalloc@PLT
	movl	$92, %edx
	movq	%rbx, %rsi
	movl	%eax, %edi
	call	_Z8_cudaTry9cudaErrorPKci
	movq	(%rsp), %rdi
	movq	%rbp, %rdx
	movq	%r14, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movl	$93, %edx
	movq	%rbx, %rsi
	movl	%eax, %edi
	call	_Z8_cudaTry9cudaErrorPKci
	movq	8(%rsp), %rdi
	movq	%rbp, %rdx
	movq	%r13, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movl	$94, %edx
	movq	%rbx, %rsi
	movl	%eax, %edi
	call	_Z8_cudaTry9cudaErrorPKci
	movl	%r12d, %eax
	cvtsi2sdq	%rax, %xmm0
	mulsd	.LC3(%rip), %xmm0
	call	ceil@PLT
	movl	$16777217, %edx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	cvttsd2siq	%xmm0, %rax
	salq	$8, %rdx
	movl	$1, %ecx
	movl	%eax, 16(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 20(%rsp)
	movq	16(%rsp), %rdi
	movl	24(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L57
	movq	8(%rsp), %rdx
	movq	(%rsp), %rsi
	movd	%r15d, %xmm0
	movl	%r12d, %edi
	call	_Z36__device_stub__Z12saxpy_kerneljfPfS_jfPfS_
.L57:
	movq	8(%rsp), %rsi
	movl	$2, %ecx
	movq	%rbp, %rdx
	movq	%r13, %rdi
	call	cudaMemcpy@PLT
	movl	$98, %edx
	movq	%rbx, %rsi
	movl	%eax, %edi
	call	_Z8_cudaTry9cudaErrorPKci
	movq	(%rsp), %rdi
	call	cudaFree@PLT
	movl	$99, %edx
	movq	%rbx, %rsi
	movl	%eax, %edi
	call	_Z8_cudaTry9cudaErrorPKci
	movq	8(%rsp), %rdi
	call	cudaFree@PLT
	movl	$100, %edx
	movq	%rbx, %rsi
	movl	%eax, %edi
	call	_Z8_cudaTry9cudaErrorPKci
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	je	.L58
	call	__stack_chk_fail@PLT
.L58:
	addq	$56, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2031:
	.size	_Z5saxpyjfPfS_, .-_Z5saxpyjfPfS_
	.section	.rodata.str1.1
.LC10:
	.string	"saxpy%s(n, ...): t_elapsed = %10.3e\n"
	.text
	.globl	_Z10saxpy_testjfi
	.type	_Z10saxpy_testjfi, @function
_Z10saxpy_testjfi:
.LFB2033:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	movd	%xmm0, %r14d
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	movl	%edi, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	movl	%esi, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	movq	%r13, %rbx
	salq	$2, %r13
	movq	%r13, %rdi
	subq	$320, %rsp
	.cfi_def_cfa_offset 368
	movq	%fs:40, %rax
	movq	%rax, 312(%rsp)
	xorl	%eax, %eax
	call	malloc@PLT
	movq	%r13, %rdi
	movq	%rax, %rbp
	call	malloc@PLT
	xorl	%ecx, %ecx
	movq	%rax, %rdx
.L61:
	cmpl	%ebx, %ecx
	jnb	.L73
	movl	%ecx, %eax
	cvtsi2ssq	%rax, %xmm0
	movl	%ecx, %eax
	imull	%ecx, %eax
	movss	%xmm0, 0(%rbp,%rcx,4)
	cvtsi2ssq	%rax, %xmm0
	movss	%xmm0, (%rdx,%rcx,4)
	incq	%rcx
	jmp	.L61
.L73:
	xorl	%edi, %edi
	leaq	24(%rsp), %rsi
	movq	%rdx, 8(%rsp)
	call	getrusage@PLT
	testl	%r12d, %r12d
	movq	8(%rsp), %rdx
	movq	%rbp, %rsi
	movd	%r14d, %xmm0
	movl	%ebx, %edi
	je	.L67
	call	_Z5saxpyjfPfS_
	jmp	.L68
.L67:
	call	_Z9saxpy_cpujfPfS_
.L68:
	xorl	%edi, %edi
	leaq	168(%rsp), %rsi
	call	getrusage@PLT
	movq	176(%rsp), %rax
	subq	32(%rsp), %rax
	leaq	.LC5(%rip), %rdx
	cvtsi2sdq	%rax, %xmm0
	movq	168(%rsp), %rax
	subq	24(%rsp), %rax
	testl	%r12d, %r12d
	mulsd	.LC7(%rip), %xmm0
	cvtsi2sdq	%rax, %xmm1
	movl	$2, %edi
	leaq	.LC4(%rip), %rax
	leaq	.LC10(%rip), %rsi
	cmovne	%rax, %rdx
	movb	$1, %al
	addsd	%xmm1, %xmm0
	call	__printf_chk@PLT
	movq	312(%rsp), %rax
	subq	%fs:40, %rax
	je	.L70
	call	__stack_chk_fail@PLT
.L70:
	addq	$320, %rsp
	.cfi_def_cfa_offset 48
	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
.LFE2033:
	.size	_Z10saxpy_testjfi, .-_Z10saxpy_testjfi
	.section	.rodata.str1.1
.LC12:
	.string	"usage: hw4 saxpy n [a]\n"
	.text
	.globl	_Z10saxpy_mainiPPci
	.type	_Z10saxpy_mainiPPci, @function
_Z10saxpy_mainiPPci:
.LFB2035:
	.cfi_startproc
	endbr64
	leal	-3(%rdi), %eax
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	pushq	%rcx
	.cfi_def_cfa_offset 48
	cmpl	$1, %eax
	jbe	.L75
	movq	stderr(%rip), %rdi
	leaq	.LC12(%rip), %rdx
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	movl	$1, %edi
	call	exit@PLT
.L75:
	movl	%edi, %r12d
	movq	16(%rsi), %rdi
	movq	%rsi, %rbp
	movl	%edx, %r13d
	xorl	%esi, %esi
	movl	$10, %edx
	call	__isoc23_strtoul@PLT
	movss	.LC11(%rip), %xmm0
	movq	%rax, %rbx
	cmpl	$4, %r12d
	jne	.L76
	movq	24(%rbp), %rdi
	call	atof@PLT
	cvtsd2ss	%xmm0, %xmm0
.L76:
	popq	%rax
	.cfi_def_cfa_offset 40
	movl	%r13d, %esi
	movl	%ebx, %edi
	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
	jmp	_Z10saxpy_testjfi
	.cfi_endproc
.LFE2035:
	.size	_Z10saxpy_mainiPPci, .-_Z10saxpy_mainiPPci
	.section	.rodata.str1.1
.LC13:
	.string	"usage: hw4 testName testArgs\n"
.LC14:
	.string	"f"
.LC15:
	.string	"f_cpu"
.LC16:
	.string	"saxpy"
.LC17:
	.string	"saxpy_cpu"
.LC18:
	.string	"hw4, unrecognized test case: %s\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2036:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	cmpl	$1, %edi
	jg	.L80
	movq	stderr(%rip), %rdi
	leaq	.LC13(%rip), %rdx
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	jmp	.L89
.L80:
	movq	8(%rsi), %r12
	movl	%edi, %ebx
	movq	%rsi, %rbp
	leaq	.LC14(%rip), %rsi
	movq	%r12, %rdi
	call	strcmp@PLT
	movl	$1, %edx
	testl	%eax, %eax
	je	.L88
	leaq	.LC15(%rip), %rsi
	movq	%r12, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L83
	xorl	%edx, %edx
.L88:
	movq	%rbp, %rsi
	movl	%ebx, %edi
	call	_Z6f_mainiPPci
	jmp	.L82
.L83:
	leaq	.LC16(%rip), %rsi
	movq	%r12, %rdi
	call	strcmp@PLT
	movl	$1, %edx
	testl	%eax, %eax
	je	.L87
	leaq	.LC17(%rip), %rsi
	movq	%r12, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L85
	xorl	%edx, %edx
.L87:
	movq	%rbp, %rsi
	movl	%ebx, %edi
	call	_Z10saxpy_mainiPPci
	jmp	.L82
.L85:
	movq	stderr(%rip), %rdi
	movq	%r12, %rcx
	movl	$2, %esi
	xorl	%eax, %eax
	leaq	.LC18(%rip), %rdx
	call	__fprintf_chk@PLT
.L89:
	movl	$1, %edi
.L90:
	call	exit@PLT
.L82:
	xorl	%edi, %edi
	jmp	.L90
	.cfi_endproc
.LFE2036:
	.size	main, .-main
	.section	.rodata.str1.1
.LC19:
	.string	"_Z12saxpy_kerneljfPfS_"
.LC20:
	.string	"_Z8f_kerneljjPfS_"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2066:
	.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	.LC19(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z12saxpy_kerneljfPfS_(%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	.LC20(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z8f_kerneljjPfS_(%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
.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
.LC1:
	.long	1075838976
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC3:
	.long	0
	.long	1064304640
	.align 8
.LC6:
	.long	0
	.long	1072693248
	.align 8
.LC7:
	.long	-1598689907
	.long	1051772663
	.section	.rodata.cst4
	.align 4
.LC11:
	.long	1077936128
	.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 <string.h>
#include <sys/resource.h>

#define NewArray(Type, N) ((Type *)(malloc(N*sizeof(Type))))

#define cudaTry(cudaStatus) _cudaTry(cudaStatus, __FILE__, __LINE__)

void _cudaTry(hipError_t cudaStatus, const char *fileName, int lineNumber) {
  if(cudaStatus != hipSuccess) {
    fprintf(stderr, "%s in %s line %d\n",
        hipGetErrorString(cudaStatus), fileName, lineNumber);
    exit(1);
  }
}


__global__ void f_kernel(uint n, uint m, float *x, float *xm) {
  uint i = blockIdx.x*blockDim.x + threadIdx.x; // nvcc built-ins
  if(i < n) {
    float a = 5.0/2.0;
    float y = x[i];
    for(uint j = 0; j < m; j++) {
      y = a*(y*y*y - y);
    }
    xm[i] = y;
  }
}

void f(float *x, float *xm, uint n, uint m) {
  int size = n*sizeof(float);
  float *dev_x, *dev_xm;

  cudaTry(hipMalloc((void**)(&dev_x), size));
  cudaTry(hipMalloc((void**)(&dev_xm), size));
  cudaTry(hipMemcpy(dev_x, x, size, hipMemcpyHostToDevice));

  f_kernel<<<ceil(n/256.0),256>>>(n, m, dev_x, dev_xm);

  cudaTry(hipMemcpy(xm, dev_xm, size, hipMemcpyDeviceToHost));
  cudaTry(hipFree(dev_x));
  cudaTry(hipFree(dev_xm));
}

void f_cpu(float *x, float *xm, uint n, uint m) {
  float a = 5.0/2.0;
  for(uint i = 0; i < n; i++) {
    float y = x[i];
    for(uint j = 0; j < m; j++)
      y = a*(y*y*y - y);
    x[i] = y;
  }
}

void f_test(uint n, uint m, int gpu_flag) {
  float *x, *xm;
  struct rusage r0, r1;

  x = NewArray(float, n);
  xm = NewArray(float, n);
  for(uint i = 0; i < n; i++)
    x[i] = (1.0+i)/(n+1);
  getrusage(RUSAGE_SELF, &r0);
  if(gpu_flag) f(x, xm, n, m);
  else f_cpu(x, xm, n, m);
  getrusage(RUSAGE_SELF, &r1);
  double t_elapsed =   (r1.ru_utime.tv_sec - r0.ru_utime.tv_sec)
                     + 1e-6*(r1.ru_utime.tv_usec - r0.ru_utime.tv_usec);
  printf("f%s(n, ...): t_elapsed = %10.3e, throughput = %10.3e\n",
         gpu_flag ? "" : "_cpu", t_elapsed, n*m/t_elapsed);
}

__global__ void saxpy_kernel(uint n, float a, float *x, float *y) {
  uint i = blockIdx.x*blockDim.x + threadIdx.x; // nvcc built-ins
  if(i < n) {
    float yi = y[i];
    float xi = x[i];
    float out;
    //for (int j=0; j<10; j++) {
      out = a*xi + yi;
    //}
    y[i] = out;
  }
}

void saxpy(uint n, float a, float *x, float *y) {
  int size = n*sizeof(float);
  float *dev_x, *dev_y; // will be allocated on the GPU.

  cudaTry(hipMalloc((void**)(&dev_x), size));
  cudaTry(hipMalloc((void**)(&dev_y), size));
  cudaTry(hipMemcpy(dev_x, x, size, hipMemcpyHostToDevice));
  cudaTry(hipMemcpy(dev_y, y, size, hipMemcpyHostToDevice));

  saxpy_kernel<<<ceil(n/256.0),256>>>(n, a, dev_x, dev_y);

  cudaTry(hipMemcpy(y, dev_y, size, hipMemcpyDeviceToHost));
  cudaTry(hipFree(dev_x));
  cudaTry(hipFree(dev_y));
}

void saxpy_cpu(uint n, float a, float *x, float *y) {
  for (int i=0; i< n; i++) {
    float yi = y[i];
    float xi = x[i];
    float out;
    //for (int j = 0; j<10; j++) {
      out = a*xi + yi;
    //}
    y[i] = out;
  }
}

void saxpy_test(uint n, float a, int gpu_flag) {
  float *x, *y;
  struct rusage r0, r1;

  x = NewArray(float, n);
  y = NewArray(float, n);
  for(uint i = 0; i < n; i++) {
    x[i] = i;
    y[i] = i*i;
  }
  getrusage(RUSAGE_SELF, &r0);
  if(gpu_flag) saxpy(n, a, x, y);
  else saxpy_cpu(n, a, x, y);
  getrusage(RUSAGE_SELF, &r1);
  double t_elapsed =   (r1.ru_utime.tv_sec - r0.ru_utime.tv_sec)
                     + 1e-6*(r1.ru_utime.tv_usec - r0.ru_utime.tv_usec);
  printf("saxpy%s(n, ...): t_elapsed = %10.3e\n",
         gpu_flag ? "" : "_cpu", t_elapsed);
}


// f_main: for command lines of the form
//   hw4 f n m
// or
//   hw4 f_cpu n m
void f_main(int argc, char **argv, int gpu_flag) {
  uint n, m;
  if(argc != 4) {
    fprintf(stderr, "usage: hw4 %s n m\n", argv[1]);
    exit(1);
  }
  n = strtoul(argv[2], NULL, 10);
  m = strtoul(argv[3], NULL, 10);
  f_test(n, m, gpu_flag);
}

// saxpy_main: for command lines of the form
//   hw4 saxpy n [a]
// or
//   hw4 saxpy n [a]
// The parameter 'a' is optional.  If omitted, we set a=3.0.
void saxpy_main(int argc, char **argv, int gpu_flag) {
  int n;
  float a;
  if((argc < 3) || (4 < argc)) {
    fprintf(stderr, "usage: hw4 saxpy n [a]\n");
    exit(1);
  }
  n = strtoul(argv[2], NULL, 10);
  if(argc >= 4) a = atof(argv[3]);
  else a = 3.0;
  saxpy_test(n, a, gpu_flag);
}

int main(int argc, char **argv) {
  if(argc < 2) {
    fprintf(stderr, "usage: hw4 testName testArgs\n");
    exit(1);
  }
  if(strcmp(argv[1], "f") == 0) f_main(argc, argv, true);
  else if(strcmp(argv[1], "f_cpu") == 0) f_main(argc, argv, false);
  else if(strcmp(argv[1], "saxpy") == 0) saxpy_main(argc, argv, true);
  else if(strcmp(argv[1], "saxpy_cpu") == 0) saxpy_main(argc, argv, false);
  else {
    fprintf(stderr, "hw4, unrecognized test case: %s\n", argv[1]);
    exit(1);
  }
  exit(0);
}

	.text
	.file	"hw4.hip"
	.globl	_Z8_cudaTry10hipError_tPKci     # -- Begin function _Z8_cudaTry10hipError_tPKci
	.type	_Z8_cudaTry10hipError_tPKci,@function
_Z8_cudaTry10hipError_tPKci:            # @_Z8_cudaTry10hipError_tPKci
	.cfi_startproc
# %bb.0:
	testl	%edi, %edi
	jne	.LBB0_2
# %bb.1:
	retq
.LBB0_2:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movl	%edx, %ebx
	movq	%rsi, %r14
	movq	stderr(%rip), %r15
	callq	hipGetErrorString
	movl	$.L.str, %esi
	movq	%r15, %rdi
	movq	%rax, %rdx
	movq	%r14, %rcx
	movl	%ebx, %r8d
	xorl	%eax, %eax
	callq	fprintf
	movl	$1, %edi
	callq	exit
.Lfunc_end0:
	.size	_Z8_cudaTry10hipError_tPKci, .Lfunc_end0-_Z8_cudaTry10hipError_tPKci
	.cfi_endproc
                                        # -- End function
	.globl	_Z23__device_stub__f_kerneljjPfS_ # -- Begin function _Z23__device_stub__f_kerneljjPfS_
	.type	_Z23__device_stub__f_kerneljjPfS_,@function
_Z23__device_stub__f_kerneljjPfS_:      # @_Z23__device_stub__f_kerneljjPfS_
	.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	12(%rsp), %rax
	movl	%edi, (%rax)
	leaq	8(%rsp), %rdi
	movl	%esi, (%rdi)
	leaq	40(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	32(%rsp), %rdx
	movq	%rcx, (%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	24(%rsp), %r12
	leaq	16(%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	$_Z8f_kerneljjPfS_, %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	_Z23__device_stub__f_kerneljjPfS_, .Lfunc_end1-_Z23__device_stub__f_kerneljjPfS_
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z1fPfS_jj
.LCPI2_0:
	.quad	0x3f70000000000000              # double 0.00390625
	.text
	.globl	_Z1fPfS_jj
	.type	_Z1fPfS_jj,@function
_Z1fPfS_jj:                             # @_Z1fPfS_jj
	.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	$24, %rsp
	.cfi_def_cfa_offset 80
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%ecx, %ebp
	movl	%edx, %r15d
	movq	%rsi, %rbx
	movq	%rdi, %r12
	leal	(,%r15,4), %eax
	movslq	%eax, %r14
	leaq	16(%rsp), %r13
	movq	%r13, %rdi
	movq	%r14, %rsi
	callq	hipMalloc
	movl	$.L.str.1, %esi
	movl	%eax, %edi
	movl	$37, %edx
	callq	_Z8_cudaTry10hipError_tPKci
	leaq	8(%rsp), %rdi
	movq	%r14, %rsi
	callq	hipMalloc
	movl	$.L.str.1, %esi
	movl	%eax, %edi
	movl	$38, %edx
	callq	_Z8_cudaTry10hipError_tPKci
	movq	(%r13), %rdi
	movq	%r12, %rsi
	movq	%r14, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movl	$.L.str.1, %esi
	movl	%eax, %edi
	movl	$39, %edx
	callq	_Z8_cudaTry10hipError_tPKci
	movl	%r15d, %eax
	cvtsi2sd	%rax, %xmm0
	mulsd	.LCPI2_0(%rip), %xmm0
	callq	ceil@PLT
	cvttsd2si	%xmm0, %rax
	movl	%eax, %edi
	btsq	$32, %rdi
	movabsq	$4294967296, %rdx               # imm = 0x100000000
	orq	$256, %rdx                      # imm = 0x100
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB2_2
# %bb.1:
	movq	16(%rsp), %rdx
	movq	8(%rsp), %rcx
	movl	%r15d, %edi
	movl	%ebp, %esi
	callq	_Z23__device_stub__f_kerneljjPfS_
.LBB2_2:
	movq	8(%rsp), %rsi
	movq	%rbx, %rdi
	movq	%r14, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	movl	$.L.str.1, %esi
	movl	%eax, %edi
	movl	$43, %edx
	callq	_Z8_cudaTry10hipError_tPKci
	movq	16(%rsp), %rdi
	callq	hipFree
	movl	$.L.str.1, %esi
	movl	%eax, %edi
	movl	$44, %edx
	callq	_Z8_cudaTry10hipError_tPKci
	movq	8(%rsp), %rdi
	callq	hipFree
	movl	$.L.str.1, %esi
	movl	%eax, %edi
	movl	$45, %edx
	callq	_Z8_cudaTry10hipError_tPKci
	addq	$24, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end2:
	.size	_Z1fPfS_jj, .Lfunc_end2-_Z1fPfS_jj
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function _Z5f_cpuPfS_jj
.LCPI3_0:
	.long	0x40200000                      # float 2.5
	.text
	.globl	_Z5f_cpuPfS_jj
	.type	_Z5f_cpuPfS_jj,@function
_Z5f_cpuPfS_jj:                         # @_Z5f_cpuPfS_jj
	.cfi_startproc
# %bb.0:
	testl	%edx, %edx
	je	.LBB3_4
# %bb.1:                                # %.lr.ph21
	movl	%edx, %eax
	xorl	%edx, %edx
	movss	.LCPI3_0(%rip), %xmm0           # xmm0 = mem[0],zero,zero,zero
.LBB3_2:                                # =>This Loop Header: Depth=1
                                        #     Child Loop BB3_5 Depth 2
	movss	(%rdi,%rdx,4), %xmm1            # xmm1 = mem[0],zero,zero,zero
	movl	%ecx, %esi
	testl	%ecx, %ecx
	je	.LBB3_3
.LBB3_5:                                # %.lr.ph
                                        #   Parent Loop BB3_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movaps	%xmm1, %xmm2
	mulss	%xmm1, %xmm2
	mulss	%xmm1, %xmm2
	subss	%xmm1, %xmm2
	mulss	%xmm0, %xmm2
	movaps	%xmm2, %xmm1
	decl	%esi
	jne	.LBB3_5
.LBB3_3:                                # %._crit_edge
                                        #   in Loop: Header=BB3_2 Depth=1
	movss	%xmm1, (%rdi,%rdx,4)
	incq	%rdx
	cmpq	%rax, %rdx
	jne	.LBB3_2
.LBB3_4:                                # %._crit_edge22
	retq
.Lfunc_end3:
	.size	_Z5f_cpuPfS_jj, .Lfunc_end3-_Z5f_cpuPfS_jj
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z6f_testjji
.LCPI4_0:
	.quad	0x3ff0000000000000              # double 1
.LCPI4_2:
	.quad	0x3eb0c6f7a0b5ed8d              # double 9.9999999999999995E-7
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0
.LCPI4_1:
	.long	0x40200000                      # float 2.5
	.text
	.globl	_Z6f_testjji
	.type	_Z6f_testjji,@function
_Z6f_testjji:                           # @_Z6f_testjji
	.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	$296, %rsp                      # imm = 0x128
	.cfi_def_cfa_offset 352
	.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	%edx, %ebp
	movl	%esi, %ebx
	movl	%edi, %r14d
	movl	%edi, %r13d
	leaq	(,%r13,4), %r12
	movq	%r12, %rdi
	callq	malloc
	movq	%rax, %r15
	movq	%r12, %rdi
	callq	malloc
	movq	%rax, %r12
	testl	%r14d, %r14d
	je	.LBB4_5
# %bb.1:                                # %.lr.ph
	leal	1(%r14), %eax
	cvtsi2sd	%rax, %xmm0
	xorl	%eax, %eax
	movsd	.LCPI4_0(%rip), %xmm1           # xmm1 = mem[0],zero
.LBB4_2:                                # =>This Inner Loop Header: Depth=1
	movl	%eax, %ecx
	xorps	%xmm2, %xmm2
	cvtsi2sd	%rcx, %xmm2
	addsd	%xmm1, %xmm2
	divsd	%xmm0, %xmm2
	cvtsd2ss	%xmm2, %xmm2
	movss	%xmm2, (%r15,%rax,4)
	incq	%rax
	cmpq	%rax, %r13
	jne	.LBB4_2
# %bb.3:                                # %._crit_edge
	leaq	8(%rsp), %rsi
	xorl	%edi, %edi
	callq	getrusage
	testl	%ebp, %ebp
	jne	.LBB4_4
# %bb.7:
	movl	$.L.str.4, %r12d
	testl	%r14d, %r14d
	je	.LBB4_11
# %bb.8:                                # %.lr.ph21.i
	xorl	%eax, %eax
	movss	.LCPI4_1(%rip), %xmm0           # xmm0 = mem[0],zero,zero,zero
.LBB4_9:                                # =>This Loop Header: Depth=1
                                        #     Child Loop BB4_12 Depth 2
	movss	(%r15,%rax,4), %xmm1            # xmm1 = mem[0],zero,zero,zero
	movl	%ebx, %ecx
	testl	%ebx, %ebx
	je	.LBB4_10
.LBB4_12:                               # %.lr.ph.i
                                        #   Parent Loop BB4_9 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movaps	%xmm1, %xmm2
	mulss	%xmm1, %xmm2
	mulss	%xmm1, %xmm2
	subss	%xmm1, %xmm2
	mulss	%xmm0, %xmm2
	movaps	%xmm2, %xmm1
	decl	%ecx
	jne	.LBB4_12
.LBB4_10:                               # %._crit_edge.i
                                        #   in Loop: Header=BB4_9 Depth=1
	movss	%xmm1, (%r15,%rax,4)
	incq	%rax
	cmpq	%r13, %rax
	jne	.LBB4_9
	jmp	.LBB4_11
.LBB4_5:                                # %._crit_edge.thread
	leaq	8(%rsp), %rsi
	xorl	%edi, %edi
	callq	getrusage
	testl	%ebp, %ebp
	je	.LBB4_6
.LBB4_4:
	movq	%r15, %rdi
	movq	%r12, %rsi
	movl	%r14d, %edx
	movl	%ebx, %ecx
	callq	_Z1fPfS_jj
	movl	$.L.str.3, %r12d
.LBB4_11:                               # %_Z5f_cpuPfS_jj.exit
	leaq	152(%rsp), %r15
	xorl	%edi, %edi
	movq	%r15, %rsi
	callq	getrusage
	movq	(%r15), %rax
	movq	8(%r15), %rcx
	subq	8(%rsp), %rax
	xorps	%xmm1, %xmm1
	cvtsi2sd	%rax, %xmm1
	subq	16(%rsp), %rcx
	xorps	%xmm0, %xmm0
	cvtsi2sd	%rcx, %xmm0
	mulsd	.LCPI4_2(%rip), %xmm0
	addsd	%xmm1, %xmm0
	imull	%r14d, %ebx
	xorps	%xmm1, %xmm1
	cvtsi2sd	%rbx, %xmm1
	divsd	%xmm0, %xmm1
	movl	$.L.str.2, %edi
	movq	%r12, %rsi
	movb	$2, %al
	callq	printf
	addq	$296, %rsp                      # imm = 0x128
	.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
.LBB4_6:
	.cfi_def_cfa_offset 352
	movl	$.L.str.4, %r12d
	jmp	.LBB4_11
.Lfunc_end4:
	.size	_Z6f_testjji, .Lfunc_end4-_Z6f_testjji
	.cfi_endproc
                                        # -- End function
	.globl	_Z27__device_stub__saxpy_kerneljfPfS_ # -- Begin function _Z27__device_stub__saxpy_kerneljfPfS_
	.type	_Z27__device_stub__saxpy_kerneljfPfS_,@function
_Z27__device_stub__saxpy_kerneljfPfS_:  # @_Z27__device_stub__saxpy_kerneljfPfS_
	.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	12(%rsp), %rax
	movl	%edi, (%rax)
	leaq	8(%rsp), %rcx
	movss	%xmm0, (%rcx)
	leaq	40(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	32(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	movq	%rdi, 16(%rbx)
	movq	%rsi, 24(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	24(%rsp), %r12
	leaq	16(%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	$_Z12saxpy_kerneljfPfS_, %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_end5:
	.size	_Z27__device_stub__saxpy_kerneljfPfS_, .Lfunc_end5-_Z27__device_stub__saxpy_kerneljfPfS_
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z5saxpyjfPfS_
.LCPI6_0:
	.quad	0x3f70000000000000              # double 0.00390625
	.text
	.globl	_Z5saxpyjfPfS_
	.type	_Z5saxpyjfPfS_,@function
_Z5saxpyjfPfS_:                         # @_Z5saxpyjfPfS_
	.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	$24, %rsp
	.cfi_def_cfa_offset 80
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rdx, %rbx
	movq	%rsi, %r12
	movss	%xmm0, 12(%rsp)                 # 4-byte Spill
	movl	%edi, %r15d
	leal	(,%r15,4), %eax
	movslq	%eax, %r14
	leaq	16(%rsp), %r13
	movq	%r13, %rdi
	movq	%r14, %rsi
	callq	hipMalloc
	movl	$.L.str.1, %esi
	movl	%eax, %edi
	movl	$93, %edx
	callq	_Z8_cudaTry10hipError_tPKci
	movq	%rsp, %rbp
	movq	%rbp, %rdi
	movq	%r14, %rsi
	callq	hipMalloc
	movl	$.L.str.1, %esi
	movl	%eax, %edi
	movl	$94, %edx
	callq	_Z8_cudaTry10hipError_tPKci
	movq	(%r13), %rdi
	movq	%r12, %rsi
	movq	%r14, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movl	$.L.str.1, %esi
	movl	%eax, %edi
	movl	$95, %edx
	callq	_Z8_cudaTry10hipError_tPKci
	movq	(%rbp), %rdi
	movq	%rbx, %rsi
	movq	%r14, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movl	$.L.str.1, %esi
	movl	%eax, %edi
	movl	$96, %edx
	callq	_Z8_cudaTry10hipError_tPKci
	movl	%r15d, %eax
	xorps	%xmm0, %xmm0
	cvtsi2sd	%rax, %xmm0
	mulsd	.LCPI6_0(%rip), %xmm0
	callq	ceil@PLT
	cvttsd2si	%xmm0, %rax
	movl	%eax, %edi
	btsq	$32, %rdi
	movabsq	$4294967296, %rdx               # imm = 0x100000000
	orq	$256, %rdx                      # imm = 0x100
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB6_2
# %bb.1:
	movq	16(%rsp), %rsi
	movq	(%rsp), %rdx
	movl	%r15d, %edi
	movss	12(%rsp), %xmm0                 # 4-byte Reload
                                        # xmm0 = mem[0],zero,zero,zero
	callq	_Z27__device_stub__saxpy_kerneljfPfS_
.LBB6_2:
	movq	(%rsp), %rsi
	movq	%rbx, %rdi
	movq	%r14, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	movl	$.L.str.1, %esi
	movl	%eax, %edi
	movl	$100, %edx
	callq	_Z8_cudaTry10hipError_tPKci
	movq	16(%rsp), %rdi
	callq	hipFree
	movl	$.L.str.1, %esi
	movl	%eax, %edi
	movl	$101, %edx
	callq	_Z8_cudaTry10hipError_tPKci
	movq	(%rsp), %rdi
	callq	hipFree
	movl	$.L.str.1, %esi
	movl	%eax, %edi
	movl	$102, %edx
	callq	_Z8_cudaTry10hipError_tPKci
	addq	$24, %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_end6:
	.size	_Z5saxpyjfPfS_, .Lfunc_end6-_Z5saxpyjfPfS_
	.cfi_endproc
                                        # -- End function
	.globl	_Z9saxpy_cpujfPfS_              # -- Begin function _Z9saxpy_cpujfPfS_
	.type	_Z9saxpy_cpujfPfS_,@function
_Z9saxpy_cpujfPfS_:                     # @_Z9saxpy_cpujfPfS_
	.cfi_startproc
# %bb.0:
	testl	%edi, %edi
	je	.LBB7_3
# %bb.1:                                # %.lr.ph.preheader
	movl	%edi, %eax
	xorl	%ecx, %ecx
.LBB7_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movss	(%rsi,%rcx,4), %xmm1            # xmm1 = mem[0],zero,zero,zero
	mulss	%xmm0, %xmm1
	addss	(%rdx,%rcx,4), %xmm1
	movss	%xmm1, (%rdx,%rcx,4)
	incq	%rcx
	cmpq	%rcx, %rax
	jne	.LBB7_2
.LBB7_3:                                # %._crit_edge
	retq
.Lfunc_end7:
	.size	_Z9saxpy_cpujfPfS_, .Lfunc_end7-_Z9saxpy_cpujfPfS_
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z10saxpy_testjfi
.LCPI8_0:
	.quad	0x3eb0c6f7a0b5ed8d              # double 9.9999999999999995E-7
	.text
	.globl	_Z10saxpy_testjfi
	.type	_Z10saxpy_testjfi,@function
_Z10saxpy_testjfi:                      # @_Z10saxpy_testjfi
	.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	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$304, %rsp                      # imm = 0x130
	.cfi_def_cfa_offset 352
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%esi, %r15d
	movss	%xmm0, 12(%rsp)                 # 4-byte Spill
	movl	%edi, %ebp
	movl	%edi, %r12d
	leaq	(,%r12,4), %r14
	movq	%r14, %rdi
	callq	malloc
	movq	%rax, %rbx
	movq	%r14, %rdi
	callq	malloc
	movq	%rax, %r14
	testl	%ebp, %ebp
	je	.LBB8_5
# %bb.1:                                # %.lr.ph.preheader
	xorl	%eax, %eax
.LBB8_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movl	%eax, %ecx
	xorps	%xmm0, %xmm0
	cvtsi2ss	%rcx, %xmm0
	movl	%eax, %ecx
	imull	%ecx, %ecx
	xorps	%xmm1, %xmm1
	cvtsi2ss	%rcx, %xmm1
	movss	%xmm0, (%rbx,%rax,4)
	movss	%xmm1, (%r14,%rax,4)
	incq	%rax
	cmpq	%rax, %r12
	jne	.LBB8_2
# %bb.3:                                # %._crit_edge
	leaq	16(%rsp), %rsi
	xorl	%edi, %edi
	callq	getrusage
	testl	%r15d, %r15d
	jne	.LBB8_4
# %bb.7:
	movl	$.L.str.4, %r15d
	testl	%ebp, %ebp
	je	.LBB8_10
# %bb.8:                                # %.lr.ph.i.preheader
	xorl	%eax, %eax
	movss	12(%rsp), %xmm1                 # 4-byte Reload
                                        # xmm1 = mem[0],zero,zero,zero
.LBB8_9:                                # %.lr.ph.i
                                        # =>This Inner Loop Header: Depth=1
	movss	(%rbx,%rax,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	mulss	%xmm1, %xmm0
	addss	(%r14,%rax,4), %xmm0
	movss	%xmm0, (%r14,%rax,4)
	incq	%rax
	cmpq	%rax, %r12
	jne	.LBB8_9
	jmp	.LBB8_10
.LBB8_5:                                # %._crit_edge.thread
	leaq	16(%rsp), %rsi
	xorl	%edi, %edi
	callq	getrusage
	testl	%r15d, %r15d
	je	.LBB8_6
.LBB8_4:
	movl	%ebp, %edi
	movss	12(%rsp), %xmm0                 # 4-byte Reload
                                        # xmm0 = mem[0],zero,zero,zero
	movq	%rbx, %rsi
	movq	%r14, %rdx
	callq	_Z5saxpyjfPfS_
	movl	$.L.str.3, %r15d
.LBB8_10:                               # %_Z9saxpy_cpujfPfS_.exit
	leaq	160(%rsp), %rbx
	xorl	%edi, %edi
	movq	%rbx, %rsi
	callq	getrusage
	movq	(%rbx), %rax
	movq	8(%rbx), %rcx
	subq	16(%rsp), %rax
	xorps	%xmm1, %xmm1
	cvtsi2sd	%rax, %xmm1
	subq	24(%rsp), %rcx
	xorps	%xmm0, %xmm0
	cvtsi2sd	%rcx, %xmm0
	mulsd	.LCPI8_0(%rip), %xmm0
	addsd	%xmm1, %xmm0
	movl	$.L.str.5, %edi
	movq	%r15, %rsi
	movb	$1, %al
	callq	printf
	addq	$304, %rsp                      # imm = 0x130
	.cfi_def_cfa_offset 48
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.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
.LBB8_6:
	.cfi_def_cfa_offset 352
	movl	$.L.str.4, %r15d
	jmp	.LBB8_10
.Lfunc_end8:
	.size	_Z10saxpy_testjfi, .Lfunc_end8-_Z10saxpy_testjfi
	.cfi_endproc
                                        # -- End function
	.globl	_Z6f_mainiPPci                  # -- Begin function _Z6f_mainiPPci
	.type	_Z6f_mainiPPci,@function
_Z6f_mainiPPci:                         # @_Z6f_mainiPPci
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rsi, %r14
	cmpl	$4, %edi
	jne	.LBB9_1
# %bb.2:
	movl	%edx, %ebx
	movq	16(%r14), %rdi
	xorl	%esi, %esi
	movl	$10, %edx
	callq	__isoc23_strtoul
	movq	%rax, %r15
	movq	24(%r14), %rdi
	xorl	%esi, %esi
	movl	$10, %edx
	callq	__isoc23_strtoul
	movl	%r15d, %edi
	movl	%eax, %esi
	movl	%ebx, %edx
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	jmp	_Z6f_testjji                    # TAILCALL
.LBB9_1:
	.cfi_def_cfa_offset 32
	movq	stderr(%rip), %rdi
	movq	8(%r14), %rdx
	movl	$.L.str.6, %esi
	xorl	%eax, %eax
	callq	fprintf
	movl	$1, %edi
	callq	exit
.Lfunc_end9:
	.size	_Z6f_mainiPPci, .Lfunc_end9-_Z6f_mainiPPci
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function _Z10saxpy_mainiPPci
.LCPI10_0:
	.long	0x40400000                      # float 3
	.text
	.globl	_Z10saxpy_mainiPPci
	.type	_Z10saxpy_mainiPPci,@function
_Z10saxpy_mainiPPci:                    # @_Z10saxpy_mainiPPci
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r12
	.cfi_def_cfa_offset 32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	pushq	%rax
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -40
	.cfi_offset %r12, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movl	%edi, %r12d
	leal	-5(%r12), %eax
	cmpl	$-3, %eax
	jbe	.LBB10_5
# %bb.1:
	movl	%edx, %ebx
	movq	%rsi, %r14
	movq	16(%rsi), %rdi
	xorl	%esi, %esi
	movl	$10, %edx
	callq	__isoc23_strtoul
	movq	%rax, %r15
	cmpl	$4, %r12d
	jb	.LBB10_2
# %bb.3:
	movq	24(%r14), %rdi
	callq	atof
	cvtsd2ss	%xmm0, %xmm0
	jmp	.LBB10_4
.LBB10_2:
	movss	.LCPI10_0(%rip), %xmm0          # xmm0 = mem[0],zero,zero,zero
.LBB10_4:
	movl	%r15d, %edi
	movl	%ebx, %esi
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	jmp	_Z10saxpy_testjfi               # TAILCALL
.LBB10_5:
	.cfi_def_cfa_offset 48
	movq	stderr(%rip), %rcx
	movl	$.L.str.7, %edi
	movl	$23, %esi
	movl	$1, %edx
	callq	fwrite@PLT
	movl	$1, %edi
	callq	exit
.Lfunc_end10:
	.size	_Z10saxpy_mainiPPci, .Lfunc_end10-_Z10saxpy_mainiPPci
	.cfi_endproc
                                        # -- End function
	.globl	main                            # -- Begin function main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %rbp, -16
	cmpl	$1, %edi
	jg	.LBB11_3
# %bb.1:
	movq	stderr(%rip), %rcx
	movl	$.L.str.8, %edi
	movl	$29, %esi
	movl	$1, %edx
	callq	fwrite@PLT
.LBB11_2:
	movl	$1, %edi
	callq	exit
.LBB11_3:
	movq	%rsi, %rbx
	movl	%edi, %ebp
	movq	8(%rsi), %r14
	movl	$.L.str.9, %esi
	movq	%r14, %rdi
	callq	strcmp
	testl	%eax, %eax
	jne	.LBB11_6
# %bb.4:
	movl	%ebp, %edi
	movq	%rbx, %rsi
	movl	$1, %edx
	jmp	.LBB11_5
.LBB11_6:
	movl	$.L.str.10, %esi
	movq	%r14, %rdi
	callq	strcmp
	testl	%eax, %eax
	jne	.LBB11_8
# %bb.7:
	movl	%ebp, %edi
	movq	%rbx, %rsi
	xorl	%edx, %edx
.LBB11_5:
	callq	_Z6f_mainiPPci
.LBB11_13:
	xorl	%edi, %edi
	callq	exit
.LBB11_8:
	movl	$.L.str.11, %esi
	movq	%r14, %rdi
	callq	strcmp
	testl	%eax, %eax
	jne	.LBB11_10
# %bb.9:
	movl	%ebp, %edi
	movq	%rbx, %rsi
	movl	$1, %edx
	jmp	.LBB11_12
.LBB11_10:
	movl	$.L.str.12, %esi
	movq	%r14, %rdi
	callq	strcmp
	testl	%eax, %eax
	jne	.LBB11_14
# %bb.11:
	movl	%ebp, %edi
	movq	%rbx, %rsi
	xorl	%edx, %edx
.LBB11_12:
	callq	_Z10saxpy_mainiPPci
	jmp	.LBB11_13
.LBB11_14:
	movq	stderr(%rip), %rdi
	movl	$.L.str.13, %esi
	movq	%r14, %rdx
	xorl	%eax, %eax
	callq	fprintf
	jmp	.LBB11_2
.Lfunc_end11:
	.size	main, .Lfunc_end11-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	.LBB12_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB12_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z8f_kerneljjPfS_, %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	$_Z12saxpy_kerneljfPfS_, %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_end12:
	.size	__hip_module_ctor, .Lfunc_end12-__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	.LBB13_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
.LBB13_2:
	retq
.Lfunc_end13:
	.size	__hip_module_dtor, .Lfunc_end13-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"%s in %s line %d\n"
	.size	.L.str, 18

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

	.type	.L.str.1,@object                # @.str.1
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.1:
	.asciz	"/home/ubuntu/Datasets/stackv2/train-structured-repos-hip-sm89/d4l3k/cs418/master/hw4/hw4.hip"
	.size	.L.str.1, 93

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"f%s(n, ...): t_elapsed = %10.3e, throughput = %10.3e\n"
	.size	.L.str.2, 54

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.zero	1
	.size	.L.str.3, 1

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"_cpu"
	.size	.L.str.4, 5

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

	.type	.L.str.5,@object                # @.str.5
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.5:
	.asciz	"saxpy%s(n, ...): t_elapsed = %10.3e\n"
	.size	.L.str.5, 37

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"usage: hw4 %s n m\n"
	.size	.L.str.6, 19

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"usage: hw4 saxpy n [a]\n"
	.size	.L.str.7, 24

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"usage: hw4 testName testArgs\n"
	.size	.L.str.8, 30

	.type	.L.str.9,@object                # @.str.9
.L.str.9:
	.asciz	"f"
	.size	.L.str.9, 2

	.type	.L.str.10,@object               # @.str.10
.L.str.10:
	.asciz	"f_cpu"
	.size	.L.str.10, 6

	.type	.L.str.11,@object               # @.str.11
.L.str.11:
	.asciz	"saxpy"
	.size	.L.str.11, 6

	.type	.L.str.12,@object               # @.str.12
.L.str.12:
	.asciz	"saxpy_cpu"
	.size	.L.str.12, 10

	.type	.L.str.13,@object               # @.str.13
.L.str.13:
	.asciz	"hw4, unrecognized test case: %s\n"
	.size	.L.str.13, 33

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z8f_kerneljjPfS_"
	.size	.L__unnamed_1, 18

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z12saxpy_kerneljfPfS_"
	.size	.L__unnamed_2, 23

	.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 _Z23__device_stub__f_kerneljjPfS_
	.addrsig_sym _Z27__device_stub__saxpy_kerneljfPfS_
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z8f_kerneljjPfS_
	.addrsig_sym _Z12saxpy_kerneljfPfS_
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z8f_kerneljjPfS_       ; -- Begin function _Z8f_kerneljjPfS_
	.globl	_Z8f_kerneljjPfS_
	.p2align	8
	.type	_Z8f_kerneljjPfS_,@function
_Z8f_kerneljjPfS_:                      ; @_Z8f_kerneljjPfS_
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x24
	s_load_b64 s[4:5], s[0:1], 0x0
	s_waitcnt lgkmcnt(0)
	s_and_b32 s2, s2, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s15, s2, v[0:1]
	s_mov_b32 s2, exec_lo
	v_cmpx_gt_u32_e64 s4, v1
	s_cbranch_execz .LBB0_5
; %bb.1:
	s_load_b128 s[0:3], s[0:1], 0x8
	v_mov_b32_e32 v2, 0
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[0:1], 2, v[1:2]
	s_waitcnt lgkmcnt(0)
	v_add_co_u32 v2, vcc_lo, s0, v0
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v3, vcc_lo, s1, v1, vcc_lo
	global_load_b32 v2, v[2:3], off
.LBB0_2:                                ; =>This Inner Loop Header: Depth=1
	s_cmp_eq_u32 s5, 0
	s_cbranch_scc1 .LBB0_4
; %bb.3:                                ; %.lr.ph
                                        ;   in Loop: Header=BB0_2 Depth=1
	s_waitcnt vmcnt(0)
	v_mul_f32_e32 v3, v2, v2
	s_add_i32 s5, s5, -1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f32 v2, v2, v3, -v2
	v_mul_f32_e32 v2, 0x40200000, v2
	s_branch .LBB0_2
.LBB0_4:                                ; %Flow31
	v_add_co_u32 v0, vcc_lo, s2, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s3, v1, vcc_lo
	s_waitcnt vmcnt(0)
	global_store_b32 v[0:1], v2, off
.LBB0_5:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z8f_kerneljjPfS_
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 280
		.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 4
		.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	_Z8f_kerneljjPfS_, .Lfunc_end0-_Z8f_kerneljjPfS_
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 192
; NumSgprs: 18
; NumVgprs: 4
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 4
; 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	_Z12saxpy_kerneljfPfS_  ; -- Begin function _Z12saxpy_kerneljfPfS_
	.globl	_Z12saxpy_kerneljfPfS_
	.p2align	8
	.type	_Z12saxpy_kerneljfPfS_,@function
_Z12saxpy_kerneljfPfS_:                 ; @_Z12saxpy_kerneljfPfS_
; %bb.0:
	s_clause 0x1
	s_load_b32 s4, s[0:1], 0x24
	s_load_b64 s[2:3], s[0:1], 0x0
	s_waitcnt lgkmcnt(0)
	s_and_b32 s4, s4, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s15, s4, v[0:1]
	v_cmp_gt_u32_e32 vcc_lo, s2, v1
	s_and_saveexec_b32 s2, vcc_lo
	s_cbranch_execz .LBB1_2
; %bb.1:
	s_load_b128 s[4:7], s[0:1], 0x8
	v_mov_b32_e32 v2, 0
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[0:1], 2, v[1:2]
	s_waitcnt lgkmcnt(0)
	v_add_co_u32 v2, vcc_lo, s6, v0
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v3, vcc_lo, s7, v1, vcc_lo
	v_add_co_u32 v0, vcc_lo, s4, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s5, v1, vcc_lo
	global_load_b32 v4, v[2:3], off
	global_load_b32 v0, v[0:1], off
	s_waitcnt vmcnt(0)
	v_fmac_f32_e32 v4, s3, v0
	global_store_b32 v[2:3], v4, off
.LBB1_2:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z12saxpy_kerneljfPfS_
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 280
		.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 5
		.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	_Z12saxpy_kerneljfPfS_, .Lfunc_end1-_Z12saxpy_kerneljfPfS_
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 156
; NumSgprs: 18
; NumVgprs: 5
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 5
; 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:
      - .offset:         0
        .size:           4
        .value_kind:     by_value
      - .offset:         4
        .size:           4
        .value_kind:     by_value
      - .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:     hidden_block_count_x
      - .offset:         28
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         32
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         36
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         38
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         40
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         42
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         44
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         46
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         64
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         88
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 280
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z8f_kerneljjPfS_
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z8f_kerneljjPfS_.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     4
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
  - .args:
      - .offset:         0
        .size:           4
        .value_kind:     by_value
      - .offset:         4
        .size:           4
        .value_kind:     by_value
      - .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:     hidden_block_count_x
      - .offset:         28
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         32
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         36
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         38
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         40
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         42
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         44
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         46
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         64
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         88
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 280
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z12saxpy_kerneljfPfS_
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z12saxpy_kerneljfPfS_.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     5
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
