// Assignment 1: ParallelSine
// CSCI 415: Networking and Parallel Computation
// Spring 2017
// Name(s): 
//
// Sine implementation derived from slides here: http://15418.courses.cs.cmu.edu/spring2016/lecture/basicarch


// standard imports
#include <stdio.h>
#include <math.h>
#include <iomanip>
#include <iostream>
#include <string>
#include <sys/time.h>

// problem size (vector length) N
static const int N = 12345678; //#of threads?

// Number of terms to use when approximating sine
static const int TERMS = 6; //# of blocks

// kernel function (CPU - Do not modify)
void sine_serial(float *input, float *output)
{
  int i;

  for (i=0; i<N; i++) {
      float value = input[i]; //0.1f * i ;i=(0-N)
      float numer = input[i] * input[i] * input[i]; //input^3
      int denom = 6; // 3! 
      int sign = -1; 
      //std::cout << input[i] << std::endl;
      for (int j=1; j<=TERMS;j++) 
      { 
         value += sign * numer / denom; 
         numer *= input[i] * input[i]; //(input^2 * input^3)*blockIdx.x
         denom *= (2*j+2) * (2*j+3); 
         sign *= -1; 
      } 
      output[i] = value;
      //std::cout << output[i] << std::endl;
    }
}


// kernel function (CUDA device)
// TODO: Implement your graphics kernel here. See assignment instructions for method information
__global__ void paralellSine(float *input, float *output)
{
	int idx = blockIdx.x * blockDim.x + threadIdx.x; //Proper indexing of elements.
	float value = input[idx];
	float numer = input[idx] * input[idx] * input[idx];
	int denom = 6;
	int sign = -1;

	for (int j=1; j<=TERMS; j++)
	{
		value += sign * numer/denom;
		numer *= input[idx] * input[idx];
		denom *= (2 * j + 2) * (2 * j + 3);
		sign *= -1;
	}
	output[idx] = value;


}

// BEGIN: timing and error checking routines (do not modify)

// Returns the current time in microseconds
long long start_timer() {
	struct timeval tv;
	gettimeofday(&tv, NULL);
	return tv.tv_sec * 1000000 + tv.tv_usec;
}


// Prints the time elapsed since the specified time
long long stop_timer(long long start_time, std::string name) {
	struct timeval tv;
	gettimeofday(&tv, NULL);
	long long end_time = tv.tv_sec * 1000000 + tv.tv_usec;
        std::cout << std::setprecision(5);	
	std::cout << name << ": " << ((float) (end_time - start_time)) / (1000 * 1000) << " sec\n";
	return end_time - start_time;
}

void checkErrors(const char label[])
{
  // we need to synchronise first to catch errors due to
  // asynchroneous operations that would otherwise
  // potentially go unnoticed

  cudaError_t err;

  err = cudaThreadSynchronize();
  if (err != cudaSuccess)
  {
    char *e = (char*) cudaGetErrorString(err);
    fprintf(stderr, "CUDA Error: %s (at %s)", e, label);
  }

  err = cudaGetLastError();
  if (err != cudaSuccess)
  {
    char *e = (char*) cudaGetErrorString(err);
    fprintf(stderr, "CUDA Error: %s (at %s)", e, label);
  }
}

// END: timing and error checking routines (do not modify)



int main (int argc, char **argv)
{
  //BEGIN: CPU implementation (do not modify)
  float *d_input;
  float *d_output;
  int size = N * sizeof(float);
  //Initialize data on CPU
  float *h_input = (float*)malloc(N*sizeof(float));
  int i;
  for (i=0; i<N; i++)
  {
    h_input[i] = 0.1f * i;
  }


  //Execute and time the CPU version
  long long CPU_start_time = start_timer();
  float *h_cpu_result = (float*)malloc(N*sizeof(float));
  sine_serial(h_input, h_cpu_result);
  long long CPU_time = stop_timer(CPU_start_time, "\nCPU Run Time");
  //END: CPU implementation (do not modify)


  long long GPU_Total_start = start_timer();

  long long GPU_Malloc_Start = start_timer();
  float *h_gpu_result = (float*)malloc(N*sizeof(float));
  cudaMalloc((void **) &d_input, size);
  cudaMalloc((void **) &d_output, size);
  long long GPU_Malloc = stop_timer(GPU_Malloc_Start, "\nGPU Memory Allocation");

  long long GPU_Memcpy_start = start_timer();
  cudaMemcpy(d_input, h_input,size, cudaMemcpyHostToDevice);
  cudaMemcpy(d_output,h_gpu_result, size, cudaMemcpyHostToDevice);
  long long GPU_Memcpy = stop_timer(GPU_Memcpy_start, "GPU Memory Copy to Device");

  long long GPU_start_time = start_timer();
  paralellSine <<< 12057,1024 >>> (d_input, d_output); //Blocks must be < # CUDA cores
  cudaThreadSynchronize();
  long long GPU_time = stop_timer(GPU_start_time, "GPU Kernel Run Time");

  long long GPU_MemcpytoHost_start = start_timer();
  cudaMemcpy(h_gpu_result, d_output, size, cudaMemcpyDeviceToHost);
  long long GPU_MemcpytoHost = stop_timer(GPU_MemcpytoHost_start, "GPU Memory Copy to Host");

  long long GPU_Time = stop_timer(GPU_Total_start, "GPU Total run time");

  // Checking to make sure the CPU and GPU results match - Do not modify
  int errorCount = 0;
  for (i=0; i<N; i++)
  {
    if (abs(h_cpu_result[i]-h_gpu_result[i]) > 1e-6)
      errorCount = errorCount + 1;
  }
  if (errorCount > 0)
    printf("\nResult comparison failed.\n");
  else
    printf("\nResult comparison passed.\n");

  // Cleaning up memory
  free(h_input);
  free(h_cpu_result);
  free(h_gpu_result);

  cudaFree(d_input);

  return 0;
}







	.file	"tmpxft_002c5670_00000000-6_ParallelSine.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB3922:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE3922:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z11sine_serialPfS_
	.type	_Z11sine_serialPfS_, @function
_Z11sine_serialPfS_:
.LFB3915:
	.cfi_startproc
	endbr64
	xorl	%eax, %eax
.L4:
	movss	(%rdi,%rax), %xmm0
	movl	$1, %edx
	orl	$-1, %r8d
	movl	$6, %ecx
	movaps	%xmm0, %xmm3
	mulss	%xmm0, %xmm3
	movaps	%xmm3, %xmm2
	mulss	%xmm0, %xmm2
.L3:
	cvtsi2ssl	%r8d, %xmm1
	incl	%edx
	negl	%r8d
	cvtsi2ssl	%ecx, %xmm4
	leal	1(%rdx,%rdx), %r9d
	imull	%edx, %r9d
	mulss	%xmm2, %xmm1
	imull	%r9d, %ecx
	mulss	%xmm3, %xmm2
	addl	%ecx, %ecx
	divss	%xmm4, %xmm1
	addss	%xmm1, %xmm0
	cmpl	$7, %edx
	jne	.L3
	movss	%xmm0, (%rsi,%rax)
	addq	$4, %rax
	cmpq	$49382712, %rax
	jne	.L4
	ret
	.cfi_endproc
.LFE3915:
	.size	_Z11sine_serialPfS_, .-_Z11sine_serialPfS_
	.globl	_Z11start_timerv
	.type	_Z11start_timerv, @function
_Z11start_timerv:
.LFB3916:
	.cfi_startproc
	endbr64
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	xorl	%esi, %esi
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rdi
	call	gettimeofday@PLT
	imulq	$1000000, 8(%rsp), %rax
	addq	16(%rsp), %rax
	movq	24(%rsp), %rdx
	subq	%fs:40, %rdx
	je	.L9
	call	__stack_chk_fail@PLT
.L9:
	addq	$40, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3916:
	.size	_Z11start_timerv, .-_Z11start_timerv
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	": "
.LC2:
	.string	" sec\n"
	.text
	.globl	_Z10stop_timerxNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
	.type	_Z10stop_timerxNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE, @function
_Z10stop_timerxNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE:
.LFB3917:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movq	%rsi, %r12
	xorl	%esi, %esi
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movq	%rdi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	subq	$32, %rsp
	.cfi_def_cfa_offset 64
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rdi
	call	gettimeofday@PLT
	movq	_ZSt4cout(%rip), %rax
	leaq	_ZSt4cout(%rip), %rdi
	movq	%r12, %rsi
	imulq	$1000000, 8(%rsp), %rbx
	addq	16(%rsp), %rbx
	movq	-24(%rax), %rax
	subq	%rbp, %rbx
	movq	$5, 8(%rdi,%rax)
	call	_ZStlsIcSt11char_traitsIcESaIcEERSt13basic_ostreamIT_T0_ES7_RKNSt7__cxx1112basic_stringIS4_S5_T1_EE@PLT
	leaq	.LC0(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	cvtsi2ssq	%rbx, %xmm0
	divss	.LC1(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	movq	%rax, %rdi
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	leaq	.LC2(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	je	.L12
	call	__stack_chk_fail@PLT
.L12:
	addq	$32, %rsp
	.cfi_def_cfa_offset 32
	movq	%rbx, %rax
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3917:
	.size	_Z10stop_timerxNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE, .-_Z10stop_timerxNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
	.section	.rodata.str1.1
.LC3:
	.string	"CUDA Error: %s (at %s)"
	.text
	.globl	_Z11checkErrorsPKc
	.type	_Z11checkErrorsPKc, @function
_Z11checkErrorsPKc:
.LFB3918:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	movq	%rdi, %rbx
	call	cudaThreadSynchronize@PLT
	testl	%eax, %eax
	je	.L15
	movl	%eax, %edi
	call	cudaGetErrorString@PLT
	movq	stderr(%rip), %rdi
	movq	%rbx, %r8
	leaq	.LC3(%rip), %rdx
	movq	%rax, %rcx
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
.L15:
	call	cudaGetLastError@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L14
	call	cudaGetErrorString@PLT
	movq	stderr(%rip), %rdi
	movq	%rbx, %r8
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	movq	%rax, %rcx
	leaq	.LC3(%rip), %rdx
	movl	$2, %esi
	xorl	%eax, %eax
	jmp	__fprintf_chk@PLT
.L14:
	.cfi_restore_state
	popq	%rbx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3918:
	.size	_Z11checkErrorsPKc, .-_Z11checkErrorsPKc
	.globl	_Z34__device_stub__Z12paralellSinePfS_PfS_
	.type	_Z34__device_stub__Z12paralellSinePfS_PfS_, @function
_Z34__device_stub__Z12paralellSinePfS_PfS_:
.LFB3944:
	.cfi_startproc
	endbr64
	subq	$120, %rsp
	.cfi_def_cfa_offset 128
	movq	%rdi, 8(%rsp)
	leaq	32(%rsp), %rcx
	leaq	24(%rsp), %rdx
	movq	%rsi, (%rsp)
	leaq	40(%rsp), %rdi
	leaq	52(%rsp), %rsi
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rax
	movl	$1, 48(%rsp)
	movq	%rax, 88(%rsp)
	movq	%rsp, %rax
	movq	%rax, 96(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 40(%rsp)
	movq	%rax, 52(%rsp)
	movl	$1, 60(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L21
	pushq	32(%rsp)
	.cfi_def_cfa_offset 136
	leaq	_Z12paralellSinePfS_(%rip), %rdi
	pushq	32(%rsp)
	.cfi_def_cfa_offset 144
	movq	68(%rsp), %rcx
	movl	76(%rsp), %r8d
	movq	56(%rsp), %rsi
	movl	64(%rsp), %edx
	leaq	104(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 136
	popq	%rdx
	.cfi_def_cfa_offset 128
.L21:
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L23
	call	__stack_chk_fail@PLT
.L23:
	addq	$120, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3944:
	.size	_Z34__device_stub__Z12paralellSinePfS_PfS_, .-_Z34__device_stub__Z12paralellSinePfS_PfS_
	.globl	_Z12paralellSinePfS_
	.type	_Z12paralellSinePfS_, @function
_Z12paralellSinePfS_:
.LFB3945:
	.cfi_startproc
	endbr64
	jmp	_Z34__device_stub__Z12paralellSinePfS_PfS_
	.cfi_endproc
.LFE3945:
	.size	_Z12paralellSinePfS_, .-_Z12paralellSinePfS_
	.section	.rodata.str1.1
.LC4:
	.string	"_Z12paralellSinePfS_"
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB3947:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	pushq	$0
	.cfi_def_cfa_offset 24
	xorl	%r9d, %r9d
	orl	$-1, %r8d
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC4(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z12paralellSinePfS_(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFunction@PLT
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rdx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE3947:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.rodata._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_.str1.1,"aMS",@progbits,1
.LC5:
	.string	"basic_string: construction from null is not valid"
	.section	.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_,"axG",@progbits,_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC5IS3_EEPKcRKS3_,comdat
	.align 2
	.weak	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_
	.type	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_, @function
_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_:
.LFB4266:
	.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
	subq	$16, %rsp
	.cfi_def_cfa_offset 48
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	leaq	16(%rdi), %rax
	movq	%rax, (%rdi)
	testq	%rsi, %rsi
	jne	.L29
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L34
	leaq	.LC5(%rip), %rdi
	call	_ZSt19__throw_logic_errorPKc@PLT
.L29:
	movq	%rdi, %rbx
	movq	%rsi, %rdi
	movq	%rsi, %rbp
	call	strlen@PLT
	movq	%rax, (%rsp)
	leaq	0(%rbp,%rax), %r12
	cmpq	$15, %rax
	jbe	.L31
	movq	%rsp, %rsi
	xorl	%edx, %edx
	movq	%rbx, %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_createERmm@PLT
	movq	%rax, (%rbx)
	movq	(%rsp), %rax
	movq	%rax, 16(%rbx)
.L31:
	movq	(%rbx), %rdi
	movq	%r12, %rdx
	movq	%rbp, %rsi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE13_S_copy_charsEPcPKcS7_@PLT
	movq	(%rsp), %rax
	movq	(%rbx), %rdx
	movq	%rax, 8(%rbx)
	movb	$0, (%rdx,%rax)
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	je	.L32
.L34:
	call	__stack_chk_fail@PLT
.L32:
	addq	$16, %rsp
	.cfi_def_cfa_offset 32
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE4266:
	.size	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_, .-_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_
	.weak	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1IS3_EEPKcRKS3_
	.set	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1IS3_EEPKcRKS3_,_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_
	.section	.rodata.str1.1
.LC7:
	.string	"\nCPU Run Time"
.LC8:
	.string	"\nGPU Memory Allocation"
.LC9:
	.string	"GPU Memory Copy to Device"
.LC10:
	.string	"GPU Kernel Run Time"
.LC11:
	.string	"GPU Memory Copy to Host"
.LC12:
	.string	"GPU Total run time"
.LC15:
	.string	"\nResult comparison failed.\n"
.LC16:
	.string	"\nResult comparison passed.\n"
	.section	.text.startup
	.globl	main
	.type	main, @function
main:
.LFB3919:
	.cfi_startproc
	.cfi_personality 0x9b,DW.ref.__gxx_personality_v0
	.cfi_lsda 0x1b,.LLSDA3919
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	$49382712, %edi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$104, %rsp
	.cfi_def_cfa_offset 160
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	xorl	%eax, %eax
	call	malloc@PLT
	movss	.LC6(%rip), %xmm1
	movq	%rax, %rbp
	xorl	%eax, %eax
.L36:
	cvtsi2ssl	%eax, %xmm0
	mulss	%xmm1, %xmm0
	movss	%xmm0, 0(%rbp,%rax,4)
	incq	%rax
	cmpq	$12345678, %rax
	jne	.L36
	call	_Z11start_timerv
	movl	$49382712, %edi
	leaq	44(%rsp), %r12
	movq	%rax, %rbx
	call	malloc@PLT
	movq	%rbp, %rdi
	movq	%rax, %rsi
	movq	%rax, %r13
	call	_Z11sine_serialPfS_
	leaq	56(%rsp), %rax
	leaq	.LC7(%rip), %rsi
	movq	%r12, %rdx
	movq	%rax, %rdi
	movq	%rax, 8(%rsp)
.LEHB0:
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1IS3_EEPKcRKS3_
.LEHE0:
	movq	8(%rsp), %rsi
	movq	%rbx, %rdi
.LEHB1:
	call	_Z10stop_timerxNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
.LEHE1:
	movq	8(%rsp), %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT
	call	_Z11start_timerv
	movq	%rax, %r14
	call	_Z11start_timerv
	movl	$49382712, %edi
	movq	%rax, %r15
	call	malloc@PLT
	leaq	16(%rsp), %rdi
	movl	$49382712, %esi
	movq	%rax, %rbx
.LEHB2:
	call	cudaMalloc@PLT
	leaq	24(%rsp), %rdi
	movl	$49382712, %esi
	call	cudaMalloc@PLT
	movq	8(%rsp), %rdi
	leaq	.LC8(%rip), %rsi
	movq	%r12, %rdx
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1IS3_EEPKcRKS3_
.LEHE2:
	movq	8(%rsp), %rsi
	movq	%r15, %rdi
.LEHB3:
	call	_Z10stop_timerxNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
.LEHE3:
	movq	8(%rsp), %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT
	call	_Z11start_timerv
	movq	16(%rsp), %rdi
	movl	$1, %ecx
	movq	%rbp, %rsi
	movl	$49382712, %edx
	movq	%rax, %r15
.LEHB4:
	call	cudaMemcpy@PLT
	movq	24(%rsp), %rdi
	movl	$1, %ecx
	movq	%rbx, %rsi
	movl	$49382712, %edx
	call	cudaMemcpy@PLT
	movq	8(%rsp), %rdi
	leaq	.LC9(%rip), %rsi
	movq	%r12, %rdx
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1IS3_EEPKcRKS3_
.LEHE4:
	movq	8(%rsp), %rsi
	movq	%r15, %rdi
.LEHB5:
	call	_Z10stop_timerxNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
.LEHE5:
	movq	8(%rsp), %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT
	call	_Z11start_timerv
	movl	$4194305, %edx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	salq	$10, %rdx
	movl	$1, %ecx
	movl	$1, %esi
	movq	%rax, %r15
	movabsq	$4294979353, %rdi
	movq	%rdx, 44(%rsp)
	movl	$1, 52(%rsp)
.LEHB6:
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L37
	movq	24(%rsp), %rsi
	movq	16(%rsp), %rdi
	call	_Z34__device_stub__Z12paralellSinePfS_PfS_
.L37:
	call	cudaThreadSynchronize@PLT
	movq	8(%rsp), %rdi
	leaq	.LC10(%rip), %rsi
	movq	%r12, %rdx
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1IS3_EEPKcRKS3_
.LEHE6:
	movq	8(%rsp), %rsi
	movq	%r15, %rdi
.LEHB7:
	call	_Z10stop_timerxNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
.LEHE7:
	movq	8(%rsp), %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT
	call	_Z11start_timerv
	movq	24(%rsp), %rsi
	movl	$2, %ecx
	movq	%rbx, %rdi
	movl	$49382712, %edx
	movq	%rax, %r15
.LEHB8:
	call	cudaMemcpy@PLT
	movq	8(%rsp), %rdi
	leaq	.LC11(%rip), %rsi
	movq	%r12, %rdx
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1IS3_EEPKcRKS3_
.LEHE8:
	movq	8(%rsp), %rsi
	movq	%r15, %rdi
.LEHB9:
	call	_Z10stop_timerxNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
.LEHE9:
	movq	8(%rsp), %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT
	movq	8(%rsp), %rdi
	leaq	.LC12(%rip), %rsi
	movq	%r12, %rdx
.LEHB10:
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1IS3_EEPKcRKS3_
.LEHE10:
	movq	8(%rsp), %rsi
	movq	%r14, %rdi
.LEHB11:
	call	_Z10stop_timerxNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
.LEHE11:
	movq	8(%rsp), %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT
	movsd	.LC14(%rip), %xmm2
	xorl	%eax, %eax
	xorl	%edx, %edx
	movss	.LC13(%rip), %xmm1
.L40:
	movss	0(%r13,%rax), %xmm0
	subss	(%rbx,%rax), %xmm0
	andps	%xmm1, %xmm0
	cvtss2sd	%xmm0, %xmm0
	comisd	%xmm2, %xmm0
	jbe	.L38
	incl	%edx
.L38:
	addq	$4, %rax
	cmpq	$49382712, %rax
	jne	.L40
	leaq	.LC15(%rip), %rsi
	testl	%edx, %edx
	jg	.L67
	leaq	.LC16(%rip), %rsi
.L67:
	movl	$2, %edi
	xorl	%eax, %eax
.LEHB12:
	call	__printf_chk@PLT
	movq	%rbp, %rdi
	call	free@PLT
	movq	%r13, %rdi
	call	free@PLT
	movq	%rbx, %rdi
	call	free@PLT
	movq	16(%rsp), %rdi
	call	cudaFree@PLT
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	je	.L55
	jmp	.L65
.L56:
	endbr64
	jmp	.L69
.L57:
	endbr64
	jmp	.L69
.L58:
	endbr64
	jmp	.L69
.L59:
	endbr64
	jmp	.L69
.L60:
	endbr64
	jmp	.L69
.L61:
	endbr64
.L69:
	movq	%rax, %rbx
.L53:
	movq	8(%rsp), %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L65
	movq	%rbx, %rdi
	call	_Unwind_Resume@PLT
.LEHE12:
.L65:
	call	__stack_chk_fail@PLT
.L55:
	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
.LFE3919:
	.globl	__gxx_personality_v0
	.section	.gcc_except_table,"a",@progbits
.LLSDA3919:
	.byte	0xff
	.byte	0xff
	.byte	0x1
	.uleb128 .LLSDACSE3919-.LLSDACSB3919
.LLSDACSB3919:
	.uleb128 .LEHB0-.LFB3919
	.uleb128 .LEHE0-.LEHB0
	.uleb128 0
	.uleb128 0
	.uleb128 .LEHB1-.LFB3919
	.uleb128 .LEHE1-.LEHB1
	.uleb128 .L56-.LFB3919
	.uleb128 0
	.uleb128 .LEHB2-.LFB3919
	.uleb128 .LEHE2-.LEHB2
	.uleb128 0
	.uleb128 0
	.uleb128 .LEHB3-.LFB3919
	.uleb128 .LEHE3-.LEHB3
	.uleb128 .L57-.LFB3919
	.uleb128 0
	.uleb128 .LEHB4-.LFB3919
	.uleb128 .LEHE4-.LEHB4
	.uleb128 0
	.uleb128 0
	.uleb128 .LEHB5-.LFB3919
	.uleb128 .LEHE5-.LEHB5
	.uleb128 .L58-.LFB3919
	.uleb128 0
	.uleb128 .LEHB6-.LFB3919
	.uleb128 .LEHE6-.LEHB6
	.uleb128 0
	.uleb128 0
	.uleb128 .LEHB7-.LFB3919
	.uleb128 .LEHE7-.LEHB7
	.uleb128 .L59-.LFB3919
	.uleb128 0
	.uleb128 .LEHB8-.LFB3919
	.uleb128 .LEHE8-.LEHB8
	.uleb128 0
	.uleb128 0
	.uleb128 .LEHB9-.LFB3919
	.uleb128 .LEHE9-.LEHB9
	.uleb128 .L60-.LFB3919
	.uleb128 0
	.uleb128 .LEHB10-.LFB3919
	.uleb128 .LEHE10-.LEHB10
	.uleb128 0
	.uleb128 0
	.uleb128 .LEHB11-.LFB3919
	.uleb128 .LEHE11-.LEHB11
	.uleb128 .L61-.LFB3919
	.uleb128 0
	.uleb128 .LEHB12-.LFB3919
	.uleb128 .LEHE12-.LEHB12
	.uleb128 0
	.uleb128 0
.LLSDACSE3919:
	.section	.text.startup
	.size	main, .-main
	.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	1232348160
	.align 4
.LC6:
	.long	1036831949
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC13:
	.long	2147483647
	.long	0
	.long	0
	.long	0
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC14:
	.long	-1598689907
	.long	1051772663
	.hidden	DW.ref.__gxx_personality_v0
	.weak	DW.ref.__gxx_personality_v0
	.section	.data.rel.local.DW.ref.__gxx_personality_v0,"awG",@progbits,DW.ref.__gxx_personality_v0,comdat
	.align 8
	.type	DW.ref.__gxx_personality_v0, @object
	.size	DW.ref.__gxx_personality_v0, 8
DW.ref.__gxx_personality_v0:
	.quad	__gxx_personality_v0
	.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:

// Assignment 1: ParallelSine
// CSCI 415: Networking and Parallel Computation
// Spring 2017
// Name(s): 
//
// Sine implementation derived from slides here: http://15418.courses.cs.cmu.edu/spring2016/lecture/basicarch


// standard imports

#include <hip/hip_runtime.h>
#include <stdio.h>
#include <math.h>
#include <iomanip>
#include <iostream>
#include <string>
#include <sys/time.h>

// problem size (vector length) N
static const int N = 12345678; //#of threads?

// Number of terms to use when approximating sine
static const int TERMS = 6; //# of blocks

// kernel function (CPU - Do not modify)
void sine_serial(float *input, float *output)
{
  int i;

  for (i=0; i<N; i++) {
      float value = input[i]; //0.1f * i ;i=(0-N)
      float numer = input[i] * input[i] * input[i]; //input^3
      int denom = 6; // 3! 
      int sign = -1; 
      //std::cout << input[i] << std::endl;
      for (int j=1; j<=TERMS;j++) 
      { 
         value += sign * numer / denom; 
         numer *= input[i] * input[i]; //(input^2 * input^3)*blockIdx.x
         denom *= (2*j+2) * (2*j+3); 
         sign *= -1; 
      } 
      output[i] = value;
      //std::cout << output[i] << std::endl;
    }
}


// kernel function (CUDA device)
// TODO: Implement your graphics kernel here. See assignment instructions for method information
__global__ void paralellSine(float *input, float *output)
{
	int idx = blockIdx.x * blockDim.x + threadIdx.x; //Proper indexing of elements.
	float value = input[idx];
	float numer = input[idx] * input[idx] * input[idx];
	int denom = 6;
	int sign = -1;

	for (int j=1; j<=TERMS; j++)
	{
		value += sign * numer/denom;
		numer *= input[idx] * input[idx];
		denom *= (2 * j + 2) * (2 * j + 3);
		sign *= -1;
	}
	output[idx] = value;


}

// BEGIN: timing and error checking routines (do not modify)

// Returns the current time in microseconds
long long start_timer() {
	struct timeval tv;
	gettimeofday(&tv, NULL);
	return tv.tv_sec * 1000000 + tv.tv_usec;
}


// Prints the time elapsed since the specified time
long long stop_timer(long long start_time, std::string name) {
	struct timeval tv;
	gettimeofday(&tv, NULL);
	long long end_time = tv.tv_sec * 1000000 + tv.tv_usec;
        std::cout << std::setprecision(5);	
	std::cout << name << ": " << ((float) (end_time - start_time)) / (1000 * 1000) << " sec\n";
	return end_time - start_time;
}

void checkErrors(const char label[])
{
  // we need to synchronise first to catch errors due to
  // asynchroneous operations that would otherwise
  // potentially go unnoticed

  hipError_t err;

  err = hipDeviceSynchronize();
  if (err != hipSuccess)
  {
    char *e = (char*) hipGetErrorString(err);
    fprintf(stderr, "CUDA Error: %s (at %s)", e, label);
  }

  err = hipGetLastError();
  if (err != hipSuccess)
  {
    char *e = (char*) hipGetErrorString(err);
    fprintf(stderr, "CUDA Error: %s (at %s)", e, label);
  }
}

// END: timing and error checking routines (do not modify)



int main (int argc, char **argv)
{
  //BEGIN: CPU implementation (do not modify)
  float *d_input;
  float *d_output;
  int size = N * sizeof(float);
  //Initialize data on CPU
  float *h_input = (float*)malloc(N*sizeof(float));
  int i;
  for (i=0; i<N; i++)
  {
    h_input[i] = 0.1f * i;
  }


  //Execute and time the CPU version
  long long CPU_start_time = start_timer();
  float *h_cpu_result = (float*)malloc(N*sizeof(float));
  sine_serial(h_input, h_cpu_result);
  long long CPU_time = stop_timer(CPU_start_time, "\nCPU Run Time");
  //END: CPU implementation (do not modify)


  long long GPU_Total_start = start_timer();

  long long GPU_Malloc_Start = start_timer();
  float *h_gpu_result = (float*)malloc(N*sizeof(float));
  hipMalloc((void **) &d_input, size);
  hipMalloc((void **) &d_output, size);
  long long GPU_Malloc = stop_timer(GPU_Malloc_Start, "\nGPU Memory Allocation");

  long long GPU_Memcpy_start = start_timer();
  hipMemcpy(d_input, h_input,size, hipMemcpyHostToDevice);
  hipMemcpy(d_output,h_gpu_result, size, hipMemcpyHostToDevice);
  long long GPU_Memcpy = stop_timer(GPU_Memcpy_start, "GPU Memory Copy to Device");

  long long GPU_start_time = start_timer();
  paralellSine <<< 12057,1024 >>> (d_input, d_output); //Blocks must be < # CUDA cores
  hipDeviceSynchronize();
  long long GPU_time = stop_timer(GPU_start_time, "GPU Kernel Run Time");

  long long GPU_MemcpytoHost_start = start_timer();
  hipMemcpy(h_gpu_result, d_output, size, hipMemcpyDeviceToHost);
  long long GPU_MemcpytoHost = stop_timer(GPU_MemcpytoHost_start, "GPU Memory Copy to Host");

  long long GPU_Time = stop_timer(GPU_Total_start, "GPU Total run time");

  // Checking to make sure the CPU and GPU results match - Do not modify
  int errorCount = 0;
  for (i=0; i<N; i++)
  {
    if (abs(h_cpu_result[i]-h_gpu_result[i]) > 1e-6)
      errorCount = errorCount + 1;
  }
  if (errorCount > 0)
    printf("\nResult comparison failed.\n");
  else
    printf("\nResult comparison passed.\n");

  // Cleaning up memory
  free(h_input);
  free(h_cpu_result);
  free(h_gpu_result);

  hipFree(d_input);

  return 0;
}







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

                                        # End of file scope inline assembly
	.globl	_Z11sine_serialPfS_             # -- Begin function _Z11sine_serialPfS_
	.type	_Z11sine_serialPfS_,@function
_Z11sine_serialPfS_:                    # @_Z11sine_serialPfS_
	.cfi_startproc
# %bb.0:
	xorl	%eax, %eax
.LBB0_1:                                # =>This Loop Header: Depth=1
                                        #     Child Loop BB0_2 Depth 2
	movss	(%rdi,%rax,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	movaps	%xmm0, %xmm1
	mulss	%xmm0, %xmm1
	movaps	%xmm0, %xmm2
	mulss	%xmm1, %xmm2
	movl	$6, %ecx
	movl	$-1, %edx
	movl	$5, %r8d
.LBB0_2:                                #   Parent Loop BB0_1 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	xorps	%xmm3, %xmm3
	cvtsi2ss	%edx, %xmm3
	mulss	%xmm2, %xmm3
	xorps	%xmm4, %xmm4
	cvtsi2ss	%ecx, %xmm4
	divss	%xmm4, %xmm3
	addss	%xmm3, %xmm0
	mulss	%xmm1, %xmm2
	leal	-1(%r8), %r9d
	imull	%r8d, %ecx
	imull	%r9d, %ecx
	negl	%edx
	addl	$2, %r8d
	cmpl	$17, %r8d
	jne	.LBB0_2
# %bb.3:                                #   in Loop: Header=BB0_1 Depth=1
	movss	%xmm0, (%rsi,%rax,4)
	incq	%rax
	cmpq	$12345678, %rax                 # imm = 0xBC614E
	jne	.LBB0_1
# %bb.4:
	retq
.Lfunc_end0:
	.size	_Z11sine_serialPfS_, .Lfunc_end0-_Z11sine_serialPfS_
	.cfi_endproc
                                        # -- End function
	.globl	_Z27__device_stub__paralellSinePfS_ # -- Begin function _Z27__device_stub__paralellSinePfS_
	.type	_Z27__device_stub__paralellSinePfS_,@function
_Z27__device_stub__paralellSinePfS_:    # @_Z27__device_stub__paralellSinePfS_
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$80, %rsp
	.cfi_def_cfa_offset 128
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	24(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	16(%rsp), %rcx
	movq	%rsi, (%rcx)
	leaq	64(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	leaq	48(%rsp), %r14
	leaq	32(%rsp), %r15
	leaq	8(%rsp), %r12
	movq	%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	$_Z12paralellSinePfS_, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$96, %rsp
	.cfi_adjust_cfa_offset -96
	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	_Z27__device_stub__paralellSinePfS_, .Lfunc_end1-_Z27__device_stub__paralellSinePfS_
	.cfi_endproc
                                        # -- End function
	.globl	_Z11start_timerv                # -- Begin function _Z11start_timerv
	.type	_Z11start_timerv,@function
_Z11start_timerv:                       # @_Z11start_timerv
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$16, %rsp
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -16
	movq	%rsp, %rbx
	movq	%rbx, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	imulq	$1000000, (%rbx), %rax          # imm = 0xF4240
	addq	8(%rbx), %rax
	addq	$16, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end2:
	.size	_Z11start_timerv, .Lfunc_end2-_Z11start_timerv
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function _Z10stop_timerxNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
.LCPI3_0:
	.long	0x49742400                      # float 1.0E+6
	.text
	.globl	_Z10stop_timerxNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
	.type	_Z10stop_timerxNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE,@function
_Z10stop_timerxNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE: # @_Z10stop_timerxNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
	.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
	subq	$24, %rsp
	.cfi_def_cfa_offset 64
	.cfi_offset %rbx, -40
	.cfi_offset %r12, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rsi, %r15
	movq	%rdi, %r14
	leaq	8(%rsp), %rbx
	movq	%rbx, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	imulq	$1000000, (%rbx), %r12          # imm = 0xF4240
	movq	8(%rbx), %rbx
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rax
	movq	$5, _ZSt4cout+8(%rax)
	movq	(%r15), %rsi
	movq	8(%r15), %rdx
	movl	$_ZSt4cout, %edi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	%rax, %r15
	movl	$.L.str, %esi
	movl	$2, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	subq	%r14, %rbx
	addq	%r12, %rbx
	cvtsi2ss	%rbx, %xmm0
	divss	.LCPI3_0(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	movq	%r15, %rdi
	callq	_ZNSo9_M_insertIdEERSoT_
	movl	$.L.str.1, %esi
	movl	$5, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	%rbx, %rax
	addq	$24, %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
	retq
.Lfunc_end3:
	.size	_Z10stop_timerxNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE, .Lfunc_end3-_Z10stop_timerxNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
	.cfi_endproc
                                        # -- End function
	.globl	_Z11checkErrorsPKc              # -- Begin function _Z11checkErrorsPKc
	.type	_Z11checkErrorsPKc,@function
_Z11checkErrorsPKc:                     # @_Z11checkErrorsPKc
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset %rbx, -16
	movq	%rdi, %rbx
	callq	hipDeviceSynchronize
	testl	%eax, %eax
	jne	.LBB4_1
.LBB4_2:
	callq	hipGetLastError
	testl	%eax, %eax
	jne	.LBB4_4
# %bb.3:
	popq	%rbx
	.cfi_def_cfa_offset 8
	retq
.LBB4_1:
	.cfi_def_cfa_offset 16
	movl	%eax, %edi
	callq	hipGetErrorString
	movq	stderr(%rip), %rdi
	movl	$.L.str.2, %esi
	movq	%rax, %rdx
	movq	%rbx, %rcx
	xorl	%eax, %eax
	callq	fprintf
	jmp	.LBB4_2
.LBB4_4:
	movl	%eax, %edi
	callq	hipGetErrorString
	movq	stderr(%rip), %rdi
	movl	$.L.str.2, %esi
	movq	%rax, %rdx
	movq	%rbx, %rcx
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	fprintf                         # TAILCALL
.Lfunc_end4:
	.size	_Z11checkErrorsPKc, .Lfunc_end4-_Z11checkErrorsPKc
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function main
.LCPI5_0:
	.long	0x3dcccccd                      # float 0.100000001
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0
.LCPI5_1:
	.long	0x7fffffff                      # float NaN
	.long	0x7fffffff                      # float NaN
	.long	0x7fffffff                      # float NaN
	.long	0x7fffffff                      # float NaN
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0
.LCPI5_2:
	.quad	0x3eb0c6f7a0b5ed8d              # double 9.9999999999999995E-7
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
.Lfunc_begin0:
	.cfi_startproc
	.cfi_personality 3, __gxx_personality_v0
	.cfi_lsda 3, .Lexception0
# %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	$232, %rsp
	.cfi_def_cfa_offset 288
	.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	$49382712, %edi                 # imm = 0x2F18538
	callq	malloc
	movq	%rax, %rbx
	xorl	%eax, %eax
	movss	.LCPI5_0(%rip), %xmm0           # xmm0 = mem[0],zero,zero,zero
.LBB5_1:                                # =>This Inner Loop Header: Depth=1
	xorps	%xmm1, %xmm1
	cvtsi2ss	%eax, %xmm1
	mulss	%xmm0, %xmm1
	movss	%xmm1, (%rbx,%rax,4)
	incq	%rax
	cmpq	$12345678, %rax                 # imm = 0xBC614E
	jne	.LBB5_1
# %bb.2:                                # %_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_.exit
	leaq	16(%rsp), %r14
	movq	%r14, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	imulq	$1000000, (%r14), %r15          # imm = 0xF4240
	addq	8(%r14), %r15
	movl	$49382712, %edi                 # imm = 0x2F18538
	callq	malloc
	movq	%rax, %r14
	movq	%rbx, %rdi
	movq	%rax, %rsi
	callq	_Z11sine_serialPfS_
	leaq	216(%rsp), %r13
	movq	%r13, -16(%r13)
	leaq	200(%rsp), %r12
	movl	$.L.str.3, %esi
	movl	$.L.str.3+13, %edx
	movq	%r12, %rdi
	callq	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag
.Ltmp0:
	movq	%r15, %rdi
	movq	%r12, %rsi
	callq	_Z10stop_timerxNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
.Ltmp1:
# %bb.3:
	movq	200(%rsp), %rdi
	cmpq	%r13, %rdi
	je	.LBB5_5
# %bb.4:                                # %_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE11_M_is_localEv.exit.i.i
	callq	_ZdlPv
.LBB5_5:                                # %_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev.exit
	leaq	16(%rsp), %r15
	movq	%r15, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	imulq	$1000000, (%r15), %rax          # imm = 0xF4240
	addq	8(%r15), %rax
	movq	%rax, 32(%rsp)                  # 8-byte Spill
	leaq	16(%rsp), %r15
	movq	%r15, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	imulq	$1000000, (%r15), %r13          # imm = 0xF4240
	addq	8(%r15), %r13
	movl	$49382712, %edi                 # imm = 0x2F18538
	callq	malloc
	movq	%rax, %r15
	leaq	8(%rsp), %rdi
	movl	$49382712, %esi                 # imm = 0x2F18538
	callq	hipMalloc
	movq	%rsp, %rdi
	movl	$49382712, %esi                 # imm = 0x2F18538
	callq	hipMalloc
	leaq	184(%rsp), %r12
	movq	%r12, -16(%r12)
	leaq	168(%rsp), %rbp
	movl	$.L.str.4, %esi
	movl	$.L.str.4+22, %edx
	movq	%rbp, %rdi
	callq	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag
.Ltmp3:
	movq	%r13, %rdi
	movq	%rbp, %rsi
	callq	_Z10stop_timerxNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
.Ltmp4:
# %bb.6:
	movq	168(%rsp), %rdi
	cmpq	%r12, %rdi
	je	.LBB5_8
# %bb.7:                                # %_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE11_M_is_localEv.exit.i.i68
	callq	_ZdlPv
.LBB5_8:                                # %_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev.exit70
	leaq	16(%rsp), %rbp
	movq	%rbp, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	imulq	$1000000, (%rbp), %r13          # imm = 0xF4240
	addq	8(%rbp), %r13
	movq	8(%rsp), %rdi
	movl	$49382712, %edx                 # imm = 0x2F18538
	movq	%rbx, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	movq	(%rsp), %rdi
	movl	$49382712, %edx                 # imm = 0x2F18538
	movq	%r15, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	leaq	152(%rsp), %r12
	movq	%r12, -16(%r12)
	leaq	136(%rsp), %rbp
	movl	$.L.str.5, %esi
	movl	$.L.str.5+25, %edx
	movq	%rbp, %rdi
	callq	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag
.Ltmp6:
	movq	%r13, %rdi
	movq	%rbp, %rsi
	callq	_Z10stop_timerxNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
.Ltmp7:
# %bb.9:
	movq	136(%rsp), %rdi
	cmpq	%r12, %rdi
	je	.LBB5_11
# %bb.10:                               # %_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE11_M_is_localEv.exit.i.i72
	callq	_ZdlPv
.LBB5_11:                               # %_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev.exit74
	leaq	16(%rsp), %rbp
	movq	%rbp, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	imulq	$1000000, (%rbp), %r13          # imm = 0xF4240
	addq	8(%rbp), %r13
	movabsq	$4294968320, %rdx               # imm = 0x100000400
	leaq	11033(%rdx), %rdi
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB5_13
# %bb.12:
	movq	8(%rsp), %rdi
	movq	(%rsp), %rsi
	callq	_Z27__device_stub__paralellSinePfS_
.LBB5_13:                               # %_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_.exit84
	callq	hipDeviceSynchronize
	leaq	120(%rsp), %r12
	movq	%r12, -16(%r12)
	leaq	104(%rsp), %rbp
	movl	$.L.str.6, %esi
	movl	$.L.str.6+19, %edx
	movq	%rbp, %rdi
	callq	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag
.Ltmp9:
	movq	%r13, %rdi
	movq	%rbp, %rsi
	callq	_Z10stop_timerxNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
.Ltmp10:
# %bb.14:
	movq	104(%rsp), %rdi
	cmpq	%r12, %rdi
	je	.LBB5_16
# %bb.15:                               # %_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE11_M_is_localEv.exit.i.i85
	callq	_ZdlPv
.LBB5_16:                               # %_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev.exit87
	leaq	16(%rsp), %r13
	movq	%r13, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	imulq	$1000000, (%r13), %rbp          # imm = 0xF4240
	addq	8(%r13), %rbp
	movq	(%rsp), %rsi
	movl	$49382712, %edx                 # imm = 0x2F18538
	movq	%r15, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	leaq	88(%rsp), %r12
	movq	%r12, -16(%r12)
	leaq	72(%rsp), %r13
	movl	$.L.str.7, %esi
	movl	$.L.str.7+23, %edx
	movq	%r13, %rdi
	callq	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag
.Ltmp12:
	movq	%rbp, %rdi
	movq	%r13, %rsi
	callq	_Z10stop_timerxNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
.Ltmp13:
# %bb.17:
	movq	72(%rsp), %rdi
	cmpq	%r12, %rdi
	je	.LBB5_19
# %bb.18:                               # %_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE11_M_is_localEv.exit.i.i89
	callq	_ZdlPv
.LBB5_19:                               # %_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev.exit91
	leaq	56(%rsp), %r12
	movq	%r12, -16(%r12)
	leaq	40(%rsp), %r13
	movl	$.L.str.8, %esi
	movl	$.L.str.8+18, %edx
	movq	%r13, %rdi
	callq	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag
.Ltmp15:
	movq	32(%rsp), %rdi                  # 8-byte Reload
	movq	%r13, %rsi
	callq	_Z10stop_timerxNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
.Ltmp16:
# %bb.20:
	movq	40(%rsp), %rdi
	cmpq	%r12, %rdi
	je	.LBB5_22
# %bb.21:                               # %_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE11_M_is_localEv.exit.i.i93
	callq	_ZdlPv
.LBB5_22:                               # %_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev.exit95.preheader
	xorl	%eax, %eax
	movaps	.LCPI5_1(%rip), %xmm0           # xmm0 = [NaN,NaN,NaN,NaN]
	movsd	.LCPI5_2(%rip), %xmm1           # xmm1 = mem[0],zero
	xorl	%ecx, %ecx
.LBB5_23:                               # %_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev.exit95
                                        # =>This Inner Loop Header: Depth=1
	movss	(%r14,%rax,4), %xmm2            # xmm2 = mem[0],zero,zero,zero
	subss	(%r15,%rax,4), %xmm2
	andps	%xmm0, %xmm2
	cvtss2sd	%xmm2, %xmm2
	xorl	%edx, %edx
	ucomisd	%xmm1, %xmm2
	seta	%dl
	addl	%edx, %ecx
	incq	%rax
	cmpq	$12345678, %rax                 # imm = 0xBC614E
	jne	.LBB5_23
# %bb.24:
	testl	%ecx, %ecx
	movl	$.Lstr, %eax
	movl	$.Lstr.1, %edi
	cmoveq	%rax, %rdi
	callq	puts@PLT
	movq	%rbx, %rdi
	callq	free
	movq	%r14, %rdi
	callq	free
	movq	%r15, %rdi
	callq	free
	movq	8(%rsp), %rdi
	callq	hipFree
	xorl	%eax, %eax
	addq	$232, %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_33:
	.cfi_def_cfa_offset 288
.Ltmp17:
	movq	%rax, %rbx
	movq	40(%rsp), %rdi
	jmp	.LBB5_29
.LBB5_32:
.Ltmp14:
	movq	%rax, %rbx
	movq	72(%rsp), %rdi
	jmp	.LBB5_29
.LBB5_31:
.Ltmp11:
	movq	%rax, %rbx
	movq	104(%rsp), %rdi
	jmp	.LBB5_29
.LBB5_30:
.Ltmp8:
	movq	%rax, %rbx
	movq	136(%rsp), %rdi
	jmp	.LBB5_29
.LBB5_28:
.Ltmp5:
	movq	%rax, %rbx
	movq	168(%rsp), %rdi
.LBB5_29:
	cmpq	%r12, %rdi
	je	.LBB5_27
.LBB5_26:                               # %_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE11_M_is_localEv.exit.i.i75
	callq	_ZdlPv
.LBB5_27:                               # %_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev.exit77
	movq	%rbx, %rdi
	callq	_Unwind_Resume@PLT
.LBB5_25:
.Ltmp2:
	movq	%rax, %rbx
	movq	200(%rsp), %rdi
	cmpq	%r13, %rdi
	jne	.LBB5_26
	jmp	.LBB5_27
.Lfunc_end5:
	.size	main, .Lfunc_end5-main
	.cfi_endproc
	.section	.gcc_except_table,"a",@progbits
	.p2align	2, 0x0
GCC_except_table5:
.Lexception0:
	.byte	255                             # @LPStart Encoding = omit
	.byte	255                             # @TType Encoding = omit
	.byte	1                               # Call site Encoding = uleb128
	.uleb128 .Lcst_end0-.Lcst_begin0
.Lcst_begin0:
	.uleb128 .Lfunc_begin0-.Lfunc_begin0    # >> Call Site 1 <<
	.uleb128 .Ltmp0-.Lfunc_begin0           #   Call between .Lfunc_begin0 and .Ltmp0
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp0-.Lfunc_begin0           # >> Call Site 2 <<
	.uleb128 .Ltmp1-.Ltmp0                  #   Call between .Ltmp0 and .Ltmp1
	.uleb128 .Ltmp2-.Lfunc_begin0           #     jumps to .Ltmp2
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp1-.Lfunc_begin0           # >> Call Site 3 <<
	.uleb128 .Ltmp3-.Ltmp1                  #   Call between .Ltmp1 and .Ltmp3
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp3-.Lfunc_begin0           # >> Call Site 4 <<
	.uleb128 .Ltmp4-.Ltmp3                  #   Call between .Ltmp3 and .Ltmp4
	.uleb128 .Ltmp5-.Lfunc_begin0           #     jumps to .Ltmp5
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp4-.Lfunc_begin0           # >> Call Site 5 <<
	.uleb128 .Ltmp6-.Ltmp4                  #   Call between .Ltmp4 and .Ltmp6
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp6-.Lfunc_begin0           # >> Call Site 6 <<
	.uleb128 .Ltmp7-.Ltmp6                  #   Call between .Ltmp6 and .Ltmp7
	.uleb128 .Ltmp8-.Lfunc_begin0           #     jumps to .Ltmp8
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp7-.Lfunc_begin0           # >> Call Site 7 <<
	.uleb128 .Ltmp9-.Ltmp7                  #   Call between .Ltmp7 and .Ltmp9
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp9-.Lfunc_begin0           # >> Call Site 8 <<
	.uleb128 .Ltmp10-.Ltmp9                 #   Call between .Ltmp9 and .Ltmp10
	.uleb128 .Ltmp11-.Lfunc_begin0          #     jumps to .Ltmp11
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp10-.Lfunc_begin0          # >> Call Site 9 <<
	.uleb128 .Ltmp12-.Ltmp10                #   Call between .Ltmp10 and .Ltmp12
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp12-.Lfunc_begin0          # >> Call Site 10 <<
	.uleb128 .Ltmp13-.Ltmp12                #   Call between .Ltmp12 and .Ltmp13
	.uleb128 .Ltmp14-.Lfunc_begin0          #     jumps to .Ltmp14
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp13-.Lfunc_begin0          # >> Call Site 11 <<
	.uleb128 .Ltmp15-.Ltmp13                #   Call between .Ltmp13 and .Ltmp15
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp15-.Lfunc_begin0          # >> Call Site 12 <<
	.uleb128 .Ltmp16-.Ltmp15                #   Call between .Ltmp15 and .Ltmp16
	.uleb128 .Ltmp17-.Lfunc_begin0          #     jumps to .Ltmp17
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp16-.Lfunc_begin0          # >> Call Site 13 <<
	.uleb128 .Lfunc_end5-.Ltmp16            #   Call between .Ltmp16 and .Lfunc_end5
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
.Lcst_end0:
	.p2align	2, 0x0
                                        # -- End function
	.section	.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag,"axG",@progbits,_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag,comdat
	.weak	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag # -- Begin function _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag
	.p2align	1, 0x90
	.type	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag,@function
_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag: # @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag
	.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
	movq	%rdx, %r14
	movq	%rsi, %r15
	movq	%rdi, %rbx
	subq	%rsi, %r14
	movq	%r14, (%rsp)
	cmpq	$15, %r14
	jbe	.LBB6_1
# %bb.2:
	movq	%rsp, %r12
	movq	%rbx, %rdi
	movq	%r12, %rsi
	xorl	%edx, %edx
	callq	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_createERmm
	movq	%rax, (%rbx)
	movq	(%r12), %rcx
	movq	%rcx, 16(%rbx)
	jmp	.LBB6_3
.LBB6_1:                                # %._crit_edge
	movq	(%rbx), %rax
.LBB6_3:
	testq	%r14, %r14
	je	.LBB6_7
# %bb.4:
	cmpq	$1, %r14
	jne	.LBB6_6
# %bb.5:
	movb	(%r15), %cl
	movb	%cl, (%rax)
	jmp	.LBB6_7
.LBB6_6:
	movq	%rax, %rdi
	movq	%r15, %rsi
	movq	%r14, %rdx
	callq	memcpy@PLT
.LBB6_7:                                # %_ZZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tagEN6_GuardD2Ev.exit
	movq	(%rsp), %rax
	movq	%rax, 8(%rbx)
	movq	(%rbx), %rcx
	movb	$0, (%rcx,%rax)
	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
	retq
.Lfunc_end6:
	.size	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag, .Lfunc_end6-_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag
	.cfi_endproc
                                        # -- End function
	.text
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	jne	.LBB7_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB7_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z12paralellSinePfS_, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$__hip_module_dtor, %edi
	addq	$40, %rsp
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end7:
	.size	__hip_module_ctor, .Lfunc_end7-__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	.LBB8_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
.LBB8_2:
	retq
.Lfunc_end8:
	.size	__hip_module_dtor, .Lfunc_end8-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	_Z12paralellSinePfS_,@object    # @_Z12paralellSinePfS_
	.section	.rodata,"a",@progbits
	.globl	_Z12paralellSinePfS_
	.p2align	3, 0x0
_Z12paralellSinePfS_:
	.quad	_Z27__device_stub__paralellSinePfS_
	.size	_Z12paralellSinePfS_, 8

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	": "
	.size	.L.str, 3

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	" sec\n"
	.size	.L.str.1, 6

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"CUDA Error: %s (at %s)"
	.size	.L.str.2, 23

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"\nCPU Run Time"
	.size	.L.str.3, 14

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"\nGPU Memory Allocation"
	.size	.L.str.4, 23

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"GPU Memory Copy to Device"
	.size	.L.str.5, 26

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"GPU Kernel Run Time"
	.size	.L.str.6, 20

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"GPU Memory Copy to Host"
	.size	.L.str.7, 24

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"GPU Total run time"
	.size	.L.str.8, 19

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z12paralellSinePfS_"
	.size	.L__unnamed_1, 21

	.type	__hip_fatbin_wrapper,@object    # @__hip_fatbin_wrapper
	.section	.hipFatBinSegment,"a",@progbits
	.p2align	3, 0x0
__hip_fatbin_wrapper:
	.long	1212764230                      # 0x48495046
	.long	1                               # 0x1
	.quad	__hip_fatbin
	.quad	0
	.size	__hip_fatbin_wrapper, 24

	.type	__hip_gpubin_handle,@object     # @__hip_gpubin_handle
	.local	__hip_gpubin_handle
	.comm	__hip_gpubin_handle,8,8
	.section	.init_array,"aw",@init_array
	.p2align	3, 0x0
	.quad	__hip_module_ctor
	.type	__hip_cuid_,@object             # @__hip_cuid_
	.bss
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               # 0x0
	.size	__hip_cuid_, 1

	.type	.Lstr,@object                   # @str
	.section	.rodata.str1.1,"aMS",@progbits,1
.Lstr:
	.asciz	"\nResult comparison passed."
	.size	.Lstr, 27

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"\nResult comparison failed."
	.size	.Lstr.1, 27

	.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 _Z27__device_stub__paralellSinePfS_
	.addrsig_sym __gxx_personality_v0
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Unwind_Resume
	.addrsig_sym _Z12paralellSinePfS_
	.addrsig_sym _ZSt4cout
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z12paralellSinePfS_    ; -- Begin function _Z12paralellSinePfS_
	.globl	_Z12paralellSinePfS_
	.p2align	8
	.type	_Z12paralellSinePfS_,@function
_Z12paralellSinePfS_:                   ; @_Z12paralellSinePfS_
; %bb.0:
	s_clause 0x1
	s_load_b32 s4, s[0:1], 0x1c
	s_load_b128 s[0:3], s[0:1], 0x0
	s_waitcnt lgkmcnt(0)
	s_and_b32 s4, s4, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s15, s4, v[0:1]
	s_mov_b32 s4, 6
	v_ashrrev_i32_e32 v2, 31, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[0:1], 2, v[1:2]
	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
	s_mov_b32 s0, -1
	s_mov_b32 s1, 5
	global_load_b32 v2, v[2:3], off
	s_waitcnt vmcnt(0)
	v_mul_f32_e32 v3, v2, v2
	s_delay_alu instid0(VALU_DEP_1)
	v_mul_f32_e32 v4, v2, v3
.LBB0_1:                                ; =>This Inner Loop Header: Depth=1
	v_cvt_f32_i32_e32 v5, s0
	v_cvt_f32_i32_e32 v6, s4
	s_add_i32 s5, s1, -1
	s_mul_i32 s4, s1, s4
	s_add_i32 s1, s1, 2
	v_dual_mul_f32 v5, v4, v5 :: v_dual_mul_f32 v4, v3, v4
	s_sub_i32 s0, 0, s0
	s_cmp_eq_u32 s1, 17
	s_mul_i32 s4, s4, s5
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_div_scale_f32 v7, null, v6, v6, v5
	v_rcp_f32_e32 v8, v7
	s_waitcnt_depctr 0xfff
	v_fma_f32 v9, -v7, v8, 1.0
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_fmac_f32_e32 v8, v9, v8
	v_div_scale_f32 v10, vcc_lo, v5, v6, v5
	v_mul_f32_e32 v9, v10, v8
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f32 v11, -v7, v9, v10
	v_fmac_f32_e32 v9, v11, v8
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f32 v7, -v7, v9, v10
	v_div_fmas_f32 v7, v7, v8, v9
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_div_fixup_f32 v5, v7, v6, v5
	v_add_f32_e32 v2, v2, v5
	s_cbranch_scc0 .LBB0_1
; %bb.2:
	v_add_co_u32 v0, vcc_lo, s2, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s3, v1, vcc_lo
	global_store_b32 v[0:1], v2, off
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z12paralellSinePfS_
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 272
		.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 12
		.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	_Z12paralellSinePfS_, .Lfunc_end0-_Z12paralellSinePfS_
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 288
; NumSgprs: 18
; NumVgprs: 12
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 12
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

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

	.end_amdgpu_metadata
