/**********************************************************************
 * DESCRIPTION:
 *   Serial Concurrent Wave Equation - C Version
 *   This program implements the concurrent wave equation
 *********************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>

#define MAXPOINTS 1000000
#define MAXSTEPS 1000000
#define MINPOINTS 20
#define PI  3.14159265
#define FAC 6.28318530

void check_param(void);
void init_line(void);
void update (void);
void printfinal (void);

int nsteps,                 	/* number of time steps */
    tpoints, 	     		/* total points along string */
    rcode;                  	/* generic return code */
float  values[MAXPOINTS+2], 	/* values at time t */
       oldval[MAXPOINTS+2], 	/* values at time (t-dt) */
       newval[MAXPOINTS+2]; 	/* values at time (t+dt) */

int threads_per_block;
float *values_d;

/**********************************************************************
 *	Handle errors function
 *********************************************************************/
static void HandleError( cudaError_t err,
                         const char *file,
                         const int line ) {
    if(err != cudaSuccess){
        printf("%s in %s at line %d\n", cudaGetErrorString( err ), file, line );
        exit( EXIT_FAILURE );
    }
}
#define HANDLE_ERROR( err ) (HandleError( err, __FILE__, __LINE__ ))

/**********************************************************************
 *	Checks input values from parameters
 *********************************************************************/
void check_param(void)
{
   char tchar[20];

   /* check number of points, number of iterations */
   while ((tpoints < MINPOINTS) || (tpoints > MAXPOINTS)) {
      printf("Enter number of points along vibrating string [%d-%d]: "
           ,MINPOINTS, MAXPOINTS);
      scanf("%s", tchar);
      tpoints = atoi(tchar);
      if ((tpoints < MINPOINTS) || (tpoints > MAXPOINTS))
         printf("Invalid. Please enter value between %d and %d\n", 
                 MINPOINTS, MAXPOINTS);
   }
   while ((nsteps < 1) || (nsteps > MAXSTEPS)) {
      printf("Enter number of time steps [1-%d]: ", MAXSTEPS);
      scanf("%s", tchar);
      nsteps = atoi(tchar);
      if ((nsteps < 1) || (nsteps > MAXSTEPS))
         printf("Invalid. Please enter value between 1 and %d\n", MAXSTEPS);
   }

   printf("Using points = %d, steps = %d\n", tpoints, nsteps);

}

/**********************************************************************
 *     Initialize points on line
 *********************************************************************/
void init_line(void)
{
   int i, j;
   float x, fac, k, tmp;

   /* Calculate initial values based on sine curve */
   fac = 2.0 * PI;
   k = 0.0; 
   tmp = tpoints - 1;
   for (j = 1; j <= tpoints; j++) {
      x = k/tmp;
      values[j] = sin (fac * x);
      k = k + 1.0;
   }

   /* Initialize old values array */
   for (i = 1; i <= tpoints; i++) 
      oldval[i] = values[i];
}

/**********************************************************************
 *      Calculate new values using wave equation
 *********************************************************************/
void do_math(int i)
{
   float dtime, c, dx, tau, sqtau;

   dtime = 0.3;
   c = 1.0;
   dx = 1.0;
   tau = (c * dtime / dx);
   sqtau = tau * tau;
   newval[i] = (2.0 * values[i]) - oldval[i] + (sqtau *  (-2.0)*values[i]);
}

/**********************************************************************
 *     Update all values along line a specified number of times
 *********************************************************************/
void update()
{
    int i, j;
    /* Update values for each time step */
    for (i = 1; i<= nsteps; i++) {
        /* Update points along line for this time step */
        for (j = 1; j <= tpoints; j++) {
            /* global endpoints */
            if ((j == 1) || (j  == tpoints))
                newval[j] = 0.0;
            else
                do_math(j);
        }

        /* Update old values with new values */
        for (j = 1; j <= tpoints; j++) {
            oldval[j] = values[j];
            values[j] = newval[j];
        }
    }
}

__global__ void cuda_update(float *values_d, const int tpoints, const int nsteps){
    int thread_id = (blockIdx.x * blockDim.x) + threadIdx.x;
    float new_val;
    float curr_val;
    float old_val;

    if(thread_id < tpoints){
        //init_line()
        float x           = (float)thread_id/(tpoints - 1);
        int residue_nstep = nsteps%4;
        curr_val          = __sinf(FAC * x);
        old_val           = curr_val;
        
        //update()
        /*
        for(int i = 0; i < nsteps; ++i){
            new_val = 1.82*curr_val-old_val;
            old_val = curr_val;
            curr_val= new_val;
        }
        */
        //unroll 4
        for(int i = 0; i < residue_nstep; ++i){
            new_val = 1.82*curr_val-old_val;
            old_val = curr_val;
            curr_val= new_val;
        }
        for(int i = residue_nstep; i < nsteps; i+=4){
            new_val = 1.82*curr_val-old_val;
            old_val = curr_val;
            curr_val= new_val;

            new_val = 1.82*curr_val-old_val;
            old_val = curr_val;
            curr_val= new_val;

            new_val = 1.82*curr_val-old_val;
            old_val = curr_val;
            curr_val= new_val;

            new_val = 1.82*curr_val-old_val;
            old_val = curr_val;
            curr_val= new_val;
        }

        values_d[thread_id] = curr_val;
    }
}

/**********************************************************************
 *     Print final results
 *********************************************************************/
void printfinal()
{
   int i;

   for (i = 1; i <= tpoints; i++) {
      printf("%6.4f ", values[i]);
      if (i%10 == 0)
         printf("\n");
   }
}

void printfinal_cuda(const int tpoints, float* values){
   int i;

   for (i = 0; i < tpoints; i++) {
      printf("%6.4f ", values[i]);
      if ((i+1)%10 == 0)
         printf("\n");
   }
}

// Print device properties
void PrintDevProp(cudaDeviceProp &devProp){
    printf("Major revision number:         %d\n",  devProp.major);
    printf("Minor revision number:         %d\n",  devProp.minor);
    printf("Name:                          %s\n",  devProp.name);
    printf("Total global memory:           %zu\n",  devProp.totalGlobalMem);
    printf("Total shared memory per block: %zu\n",  devProp.sharedMemPerBlock);
    printf("Total registers per block:     %d\n",  devProp.regsPerBlock);
    printf("Warp size:                     %d\n",  devProp.warpSize);
    printf("Maximum memory pitch:          %zu\n",  devProp.memPitch);
    printf("Maximum threads per block:     %d\n",  devProp.maxThreadsPerBlock);
    for (int i = 0; i < 3; ++i)
    printf("Maximum dimension %d of block: %d\n", i, devProp.maxThreadsDim[i]);
    for (int i = 0; i < 3; ++i)
    printf("Maximum dimension %d of grid:  %d\n", i, devProp.maxGridSize[i]);
    printf("Clock rate:                    %d\n",  devProp.clockRate);
    printf("Total constant memory:         %zu\n",  devProp.totalConstMem);
    printf("Texture alignment:             %zu\n",  devProp.textureAlignment);
    printf("Concurrent copy and execution: %s\n",  (devProp.deviceOverlap ? "Yes" : "No"));
    printf("Number of multiprocessors:     %d\n",  devProp.multiProcessorCount);
    printf("Kernel execution timeout:      %s\n",  (devProp.kernelExecTimeoutEnabled ? "Yes" : "No"));
    printf("Memory Clock Rate (KHz):       %d\n", devProp.memoryClockRate);
    printf("Memory Bus Width (bits):       %d\n", devProp.memoryBusWidth);
    printf("Peak Memory Bandwidth (GB/s):  %f\n\n", 2.0*devProp.memoryClockRate*(devProp.memoryBusWidth/8)/1.0e6);
    return;
}

/**********************************************************************
 *	Main program
 *********************************************************************/
int main(int argc, char *argv[])
{
    sscanf(argv[1],"%d",&tpoints);
    sscanf(argv[2],"%d",&nsteps);
    check_param();

    // Number of CUDA devices
    int devCount;
    int blocks_num;
    cudaDeviceProp devProp;

    cudaGetDeviceCount(&devCount);
    if(devCount==0){
        fprintf(stderr, "%s", "Error: No NVIDIA GPU device found!\n");
        return EXIT_FAILURE;
    }
 
    /*
    // Iterate through devices
    for (int i = 0; i < devCount; ++i)
    {
        // Get device properties
        printf("\nCUDA Device #%d\n", i);
        cudaDeviceProp devProp;
        if(cudaGetDeviceProperties(&devProp, i) == cudaSuccess){
            PrintDevProp(devProp);
        }
    }
    */

    //Set CUDA related parameters
    if(cudaGetDeviceProperties(&devProp, 0) == cudaSuccess){
        threads_per_block = devProp.maxThreadsPerBlock;
    }else{
        fprintf(stderr, "%s", "Error: Get GPU Property, maxThreadsPerBlock, fails.\n");
        return EXIT_FAILURE;
    }

    cudaSetDevice(0);
    blocks_num = (tpoints+threads_per_block-1)/threads_per_block;

    //Malloc mem in GPU for values_d
    HANDLE_ERROR(cudaMalloc((void**) &values_d, tpoints*sizeof(float)));

    //Initialization - already merged into kernel function
    printf("Initializing points on the line...\n");
    //init_line();

    //Update - kernel function
    printf("Updating all points for all time steps...\n");
    cuda_update<<<blocks_num, threads_per_block>>>(values_d, tpoints, nsteps);
    //Copy back from GPU to CPU
    HANDLE_ERROR(cudaMemcpy(values, values_d, tpoints*sizeof(float), cudaMemcpyDeviceToHost));

    //Print final results
    printf("Printing final results...\n");
    printfinal_cuda(tpoints, values);
    printf("\nDone.\n\n");
	
    return EXIT_SUCCESS;
}

	.file	"tmpxft_0029bf0e_00000000-6_cuda_wave.unroll_4.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2038:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2038:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"/home/ubuntu/Datasets/stackv2/train-structured/Coslate/Parallel_Programming/master/HW4/Parallel_CUDA/cuda_wave.unroll_4.cu"
.LC1:
	.string	"%s in %s at line %d\n"
	.text
	.type	_ZL11HandleError9cudaErrorPKci.part.0.constprop.0, @function
_ZL11HandleError9cudaErrorPKci.part.0.constprop.0:
.LFB2180:
	.cfi_startproc
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	%esi, 12(%rsp)
	call	cudaGetErrorString@PLT
	movl	12(%rsp), %r8d
	movl	$2, %edi
	leaq	.LC0(%rip), %rcx
	movq	%rax, %rdx
	leaq	.LC1(%rip), %rsi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$1, %edi
	call	exit@PLT
	.cfi_endproc
.LFE2180:
	.size	_ZL11HandleError9cudaErrorPKci.part.0.constprop.0, .-_ZL11HandleError9cudaErrorPKci.part.0.constprop.0
	.section	.rodata.str1.1
.LC2:
	.string	"Enter number of points along vibrating string [%d-%d]: "
.LC3:
	.string	"%s"
.LC4:
	.string	"Invalid. Please enter value between %d and %d\n"
.LC5:
	.string	"Enter number of time steps [1-%d]: "
.LC6:
	.string	"Invalid. Please enter value between 1 and %d\n"
.LC7:
	.string	"Using points = %d, steps = %d\n"
	.text
	.globl	_Z11check_paramv
	.type	_Z11check_paramv, @function
_Z11check_paramv:
.LFB2028:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	leaq	.LC2(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	subq	$40, %rsp
	.cfi_def_cfa_offset 64
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
.L6:
	movl	tpoints(%rip), %eax
	subl	$20, %eax
	cmpl	$999980, %eax
	jbe	.L16
	movl	$1000000, %ecx
	movl	$20, %edx
	movq	%rbp, %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	leaq	4(%rsp), %rbx
	call	__printf_chk@PLT
	movq	%rbx, %rsi
	leaq	.LC3(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc23_scanf@PLT
	movq	%rbx, %rdi
	call	atoi@PLT
	movl	%eax, tpoints(%rip)
	subl	$20, %eax
	cmpl	$999980, %eax
	jbe	.L6
	movl	$1000000, %ecx
	movl	$20, %edx
	leaq	.LC4(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	jmp	.L6
.L16:
	leaq	.LC5(%rip), %rbp
.L9:
	movl	nsteps(%rip), %ecx
	leal	-1(%rcx), %eax
	cmpl	$999999, %eax
	jbe	.L17
	movl	$1000000, %edx
	movq	%rbp, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	4(%rsp), %rbx
	leaq	.LC3(%rip), %rdi
	xorl	%eax, %eax
	movq	%rbx, %rsi
	call	__isoc23_scanf@PLT
	movq	%rbx, %rdi
	call	atoi@PLT
	movl	%eax, nsteps(%rip)
	decl	%eax
	cmpl	$999999, %eax
	jbe	.L9
	movl	$1000000, %edx
	leaq	.LC6(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L9
.L17:
	movl	tpoints(%rip), %edx
	xorl	%eax, %eax
	movl	$2, %edi
	leaq	.LC7(%rip), %rsi
	call	__printf_chk@PLT
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	je	.L11
	call	__stack_chk_fail@PLT
.L11:
	addq	$40, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2028:
	.size	_Z11check_paramv, .-_Z11check_paramv
	.globl	_Z9init_linev
	.type	_Z9init_linev, @function
_Z9init_linev:
.LFB2029:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	xorps	%xmm1, %xmm1
	leaq	values(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	xorl	%ebx, %ebx
	subq	$16, %rsp
	.cfi_def_cfa_offset 48
	movl	tpoints(%rip), %ebp
	leal	-1(%rbp), %eax
	cvtsi2ssl	%eax, %xmm2
	movss	%xmm2, 8(%rsp)
.L19:
	incq	%rbx
	cmpl	%ebx, %ebp
	jl	.L24
	movaps	%xmm1, %xmm0
	divss	8(%rsp), %xmm0
	movss	%xmm1, 12(%rsp)
	mulss	.LC9(%rip), %xmm0
	call	sinf@PLT
	movss	12(%rsp), %xmm1
	addss	.LC10(%rip), %xmm1
	movss	%xmm0, (%r12,%rbx,4)
	jmp	.L19
.L24:
	xorl	%eax, %eax
	leaq	oldval(%rip), %rdx
	leaq	values(%rip), %rcx
.L21:
	incq	%rax
	cmpl	%eax, %ebp
	jl	.L25
	movss	(%rcx,%rax,4), %xmm0
	movss	%xmm0, (%rdx,%rax,4)
	jmp	.L21
.L25:
	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
.LFE2029:
	.size	_Z9init_linev, .-_Z9init_linev
	.globl	_Z7do_mathi
	.type	_Z7do_mathi, @function
_Z7do_mathi:
.LFB2030:
	.cfi_startproc
	endbr64
	movslq	%edi, %rdi
	leaq	values(%rip), %rax
	cvtss2sd	(%rax,%rdi,4), %xmm1
	movaps	%xmm1, %xmm0
	leaq	oldval(%rip), %rax
	addsd	%xmm1, %xmm0
	mulsd	.LC11(%rip), %xmm1
	cvtss2sd	(%rax,%rdi,4), %xmm2
	leaq	newval(%rip), %rax
	subsd	%xmm2, %xmm0
	addsd	%xmm1, %xmm0
	cvtsd2ss	%xmm0, %xmm0
	movss	%xmm0, (%rax,%rdi,4)
	ret
	.cfi_endproc
.LFE2030:
	.size	_Z7do_mathi, .-_Z7do_mathi
	.globl	_Z6updatev
	.type	_Z6updatev, @function
_Z6updatev:
.LFB2031:
	.cfi_startproc
	endbr64
	movl	$1, %ecx
	leaq	newval(%rip), %r8
.L28:
	cmpl	%ecx, nsteps(%rip)
	jl	.L38
	movl	$1, %edx
.L35:
	movl	tpoints(%rip), %esi
	movl	%edx, %edi
	cmpl	%edx, %esi
	jl	.L39
	cmpl	$1, %edx
	je	.L37
	cmpl	%edi, %esi
	jne	.L29
.L37:
	movl	$0x00000000, (%r8,%rdx,4)
	jmp	.L31
.L29:
	call	_Z7do_mathi
.L31:
	incq	%rdx
	jmp	.L35
.L39:
	xorl	%eax, %eax
	leaq	oldval(%rip), %rdi
	leaq	values(%rip), %rdx
.L33:
	incq	%rax
	cmpl	%eax, %esi
	jl	.L40
	movss	(%rdx,%rax,4), %xmm0
	movss	%xmm0, (%rdi,%rax,4)
	movss	(%r8,%rax,4), %xmm0
	movss	%xmm0, (%rdx,%rax,4)
	jmp	.L33
.L40:
	incl	%ecx
	jmp	.L28
.L38:
	ret
	.cfi_endproc
.LFE2031:
	.size	_Z6updatev, .-_Z6updatev
	.section	.rodata.str1.1
.LC12:
	.string	"%6.4f "
.LC13:
	.string	"\n"
	.text
	.globl	_Z10printfinalv
	.type	_Z10printfinalv, @function
_Z10printfinalv:
.LFB2032:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	leaq	values(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movl	$1, %ebx
.L42:
	cmpl	%ebx, tpoints(%rip)
	movl	%ebx, %ebp
	jl	.L46
	leaq	.LC12(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	cvtss2sd	(%r12,%rbx,4), %xmm0
	call	__printf_chk@PLT
	movl	%ebp, %eax
	movl	$10, %ecx
	cltd
	idivl	%ecx
	testl	%edx, %edx
	jne	.L43
	leaq	.LC13(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L43:
	incq	%rbx
	jmp	.L42
.L46:
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2032:
	.size	_Z10printfinalv, .-_Z10printfinalv
	.globl	_Z15printfinal_cudaiPf
	.type	_Z15printfinal_cudaiPf, @function
_Z15printfinal_cudaiPf:
.LFB2033:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	.LC12(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	movq	%rsi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	movl	%edi, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	xorl	%ebx, %ebx
	pushq	%rdx
	.cfi_def_cfa_offset 48
.L48:
	cmpl	%ebx, %ebp
	jle	.L52
	movq	%r13, %rsi
	movl	$2, %edi
	movb	$1, %al
	cvtss2sd	(%r12,%rbx,4), %xmm0
	call	__printf_chk@PLT
	leal	1(%rbx), %eax
	movl	$10, %ecx
	cltd
	idivl	%ecx
	testl	%edx, %edx
	jne	.L49
	leaq	.LC13(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L49:
	incq	%rbx
	jmp	.L48
.L52:
	popq	%rax
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2033:
	.size	_Z15printfinal_cudaiPf, .-_Z15printfinal_cudaiPf
	.section	.rodata.str1.1
.LC14:
	.string	"Yes"
.LC15:
	.string	"No"
.LC16:
	.string	"Major revision number:         %d\n"
.LC17:
	.string	"Minor revision number:         %d\n"
.LC18:
	.string	"Name:                          %s\n"
.LC19:
	.string	"Total global memory:           %zu\n"
.LC20:
	.string	"Total shared memory per block: %zu\n"
.LC21:
	.string	"Total registers per block:     %d\n"
.LC22:
	.string	"Warp size:                     %d\n"
.LC23:
	.string	"Maximum memory pitch:          %zu\n"
.LC24:
	.string	"Maximum threads per block:     %d\n"
.LC25:
	.string	"Maximum dimension %d of block: %d\n"
.LC26:
	.string	"Maximum dimension %d of grid:  %d\n"
.LC27:
	.string	"Clock rate:                    %d\n"
.LC28:
	.string	"Total constant memory:         %zu\n"
.LC29:
	.string	"Texture alignment:             %zu\n"
.LC30:
	.string	"Concurrent copy and execution: %s\n"
.LC31:
	.string	"Number of multiprocessors:     %d\n"
.LC32:
	.string	"Kernel execution timeout:      %s\n"
.LC33:
	.string	"Memory Clock Rate (KHz):       %d\n"
.LC34:
	.string	"Memory Bus Width (bits):       %d\n"
.LC36:
	.string	"Peak Memory Bandwidth (GB/s):  %f\n\n"
	.text
	.globl	_Z12PrintDevPropR14cudaDeviceProp
	.type	_Z12PrintDevPropR14cudaDeviceProp, @function
_Z12PrintDevPropR14cudaDeviceProp:
.LFB2034:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	leaq	.LC16(%rip), %rsi
	xorl	%eax, %eax
	leaq	.LC25(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	xorl	%ebp, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movl	360(%rdi), %edx
	movq	%rdi, %rbx
	movl	$2, %edi
	call	__printf_chk@PLT
	movl	364(%rbx), %edx
	leaq	.LC17(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	movq	%rbx, %rdx
	movl	$2, %edi
	xorl	%eax, %eax
	leaq	.LC18(%rip), %rsi
	call	__printf_chk@PLT
	movq	288(%rbx), %rdx
	leaq	.LC19(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	movq	296(%rbx), %rdx
	leaq	.LC20(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	movl	304(%rbx), %edx
	leaq	.LC21(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	movl	308(%rbx), %edx
	leaq	.LC22(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	movq	312(%rbx), %rdx
	leaq	.LC23(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	movl	320(%rbx), %edx
	leaq	.LC24(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
.L54:
	movl	324(%rbx,%rbp,4), %ecx
	movl	%ebp, %edx
	movq	%r12, %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	incq	%rbp
	call	__printf_chk@PLT
	cmpq	$3, %rbp
	jne	.L54
	xorl	%ebp, %ebp
	leaq	.LC26(%rip), %r12
.L55:
	movl	336(%rbx,%rbp,4), %ecx
	movl	%ebp, %edx
	movq	%r12, %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	incq	%rbp
	call	__printf_chk@PLT
	cmpq	$3, %rbp
	jne	.L55
	movl	348(%rbx), %edx
	leaq	.LC27(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	leaq	.LC14(%rip), %r12
	leaq	.LC15(%rip), %rbp
	call	__printf_chk@PLT
	movq	352(%rbx), %rdx
	leaq	.LC28(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	movq	368(%rbx), %rdx
	leaq	.LC29(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	cmpl	$0, 384(%rbx)
	movq	%r12, %rdx
	leaq	.LC30(%rip), %rsi
	cmove	%rbp, %rdx
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	388(%rbx), %edx
	leaq	.LC31(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	cmpl	$0, 392(%rbx)
	movq	%r12, %rdx
	leaq	.LC32(%rip), %rsi
	cmove	%rbp, %rdx
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	608(%rbx), %edx
	leaq	.LC33(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	movl	612(%rbx), %edx
	leaq	.LC34(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	movl	612(%rbx), %eax
	movl	$8, %ecx
	cvtsi2sdl	608(%rbx), %xmm0
	leaq	.LC36(%rip), %rsi
	popq	%rbx
	.cfi_def_cfa_offset 24
	movl	$2, %edi
	popq	%rbp
	.cfi_def_cfa_offset 16
	cltd
	popq	%r12
	.cfi_def_cfa_offset 8
	idivl	%ecx
	addsd	%xmm0, %xmm0
	cvtsi2sdl	%eax, %xmm1
	movb	$1, %al
	mulsd	%xmm1, %xmm0
	divsd	.LC35(%rip), %xmm0
	jmp	__printf_chk@PLT
	.cfi_endproc
.LFE2034:
	.size	_Z12PrintDevPropR14cudaDeviceProp, .-_Z12PrintDevPropR14cudaDeviceProp
	.globl	_Z33__device_stub__Z11cuda_updatePfiiPfii
	.type	_Z33__device_stub__Z11cuda_updatePfiiPfii, @function
_Z33__device_stub__Z11cuda_updatePfiiPfii:
.LFB2060:
	.cfi_startproc
	endbr64
	subq	$120, %rsp
	.cfi_def_cfa_offset 128
	movq	%rdi, 8(%rsp)
	leaq	24(%rsp), %rcx
	leaq	32(%rsp), %rdi
	movl	%esi, 4(%rsp)
	leaq	44(%rsp), %rsi
	movl	%edx, (%rsp)
	leaq	16(%rsp), %rdx
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rax
	movl	$1, 40(%rsp)
	movq	%rax, 80(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 88(%rsp)
	movq	%rsp, %rax
	movq	%rax, 96(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 32(%rsp)
	movq	%rax, 44(%rsp)
	movl	$1, 52(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L63
	pushq	24(%rsp)
	.cfi_def_cfa_offset 136
	leaq	_Z11cuda_updatePfii(%rip), %rdi
	pushq	24(%rsp)
	.cfi_def_cfa_offset 144
	movq	60(%rsp), %rcx
	movl	68(%rsp), %r8d
	movq	48(%rsp), %rsi
	movl	56(%rsp), %edx
	leaq	96(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 136
	popq	%rdx
	.cfi_def_cfa_offset 128
.L63:
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L65
	call	__stack_chk_fail@PLT
.L65:
	addq	$120, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2060:
	.size	_Z33__device_stub__Z11cuda_updatePfiiPfii, .-_Z33__device_stub__Z11cuda_updatePfiiPfii
	.globl	_Z11cuda_updatePfii
	.type	_Z11cuda_updatePfii, @function
_Z11cuda_updatePfii:
.LFB2061:
	.cfi_startproc
	endbr64
	jmp	_Z33__device_stub__Z11cuda_updatePfiiPfii
	.cfi_endproc
.LFE2061:
	.size	_Z11cuda_updatePfii, .-_Z11cuda_updatePfii
	.section	.rodata.str1.1
.LC37:
	.string	"%d"
.LC38:
	.string	"Error: No NVIDIA GPU device found!\n"
.LC39:
	.string	"Initializing points on the line...\n"
.LC40:
	.string	"Updating all points for all time steps...\n"
.LC41:
	.string	"Error: Get GPU Property, maxThreadsPerBlock, fails.\n"
.LC42:
	.string	"Printing final results...\n"
.LC43:
	.string	"\nDone.\n\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2035:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	leaq	.LC37(%rip), %rbp
	leaq	tpoints(%rip), %rdx
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	movq	%rsi, %rbx
	subq	$1080, %rsp
	.cfi_def_cfa_offset 1104
	movq	8(%rsi), %rdi
	movq	%rbp, %rsi
	movq	%fs:40, %rax
	movq	%rax, 1064(%rsp)
	xorl	%eax, %eax
	call	__isoc23_sscanf@PLT
	movq	16(%rbx), %rdi
	movq	%rbp, %rsi
	xorl	%eax, %eax
	leaq	nsteps(%rip), %rdx
	call	__isoc23_sscanf@PLT
	call	_Z11check_paramv
	leaq	4(%rsp), %rdi
	call	cudaGetDeviceCount@PLT
	cmpl	$0, 4(%rsp)
	leaq	.LC38(%rip), %rcx
	je	.L82
	xorl	%esi, %esi
	leaq	32(%rsp), %rdi
	call	cudaGetDeviceProperties_v2@PLT
	testl	%eax, %eax
	jne	.L71
	movl	352(%rsp), %eax
	xorl	%edi, %edi
	movl	%eax, threads_per_block(%rip)
	call	cudaSetDevice@PLT
	movslq	tpoints(%rip), %rsi
	movl	threads_per_block(%rip), %ecx
	leaq	values_d(%rip), %rdi
	leal	-1(%rsi,%rcx), %eax
	salq	$2, %rsi
	cltd
	idivl	%ecx
	movl	%eax, %ebx
	call	cudaMalloc@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L72
	movq	1064(%rsp), %rax
	subq	%fs:40, %rax
	movl	$282, %esi
	je	.L84
	jmp	.L85
.L72:
	leaq	.LC39(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	.LC40(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	%ebx, 8(%rsp)
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	threads_per_block(%rip), %eax
	movl	%eax, 20(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 24(%rsp)
	movl	28(%rsp), %ecx
	movq	%rax, 12(%rsp)
	movq	20(%rsp), %rdx
	movq	8(%rsp), %rdi
	movl	16(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L74
	movl	nsteps(%rip), %edx
	movl	tpoints(%rip), %esi
	movq	values_d(%rip), %rdi
	call	_Z33__device_stub__Z11cuda_updatePfiiPfii
	jmp	.L74
.L71:
	leaq	.LC41(%rip), %rcx
.L82:
	movq	stderr(%rip), %rdi
	leaq	.LC3(%rip), %rdx
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	movl	$1, %eax
	jmp	.L68
.L74:
	movslq	tpoints(%rip), %rdx
	movq	values_d(%rip), %rsi
	movl	$2, %ecx
	leaq	values(%rip), %rbx
	movq	%rbx, %rdi
	salq	$2, %rdx
	call	cudaMemcpy@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L77
	movq	1064(%rsp), %rax
	subq	%fs:40, %rax
	movl	$292, %esi
	jne	.L85
.L84:
	call	_ZL11HandleError9cudaErrorPKci.part.0.constprop.0
.L77:
	leaq	.LC42(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	tpoints(%rip), %edi
	movq	%rbx, %rsi
	call	_Z15printfinal_cudaiPf
	leaq	.LC43(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	xorl	%eax, %eax
.L68:
	movq	1064(%rsp), %rdx
	subq	%fs:40, %rdx
	je	.L79
.L85:
	call	__stack_chk_fail@PLT
.L79:
	addq	$1080, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2035:
	.size	main, .-main
	.section	.rodata.str1.1
.LC44:
	.string	"_Z11cuda_updatePfii"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2063:
	.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	.LC44(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z11cuda_updatePfii(%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
.LFE2063:
	.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
	.globl	values_d
	.bss
	.align 8
	.type	values_d, @object
	.size	values_d, 8
values_d:
	.zero	8
	.globl	threads_per_block
	.align 4
	.type	threads_per_block, @object
	.size	threads_per_block, 4
threads_per_block:
	.zero	4
	.globl	newval
	.align 32
	.type	newval, @object
	.size	newval, 4000008
newval:
	.zero	4000008
	.globl	oldval
	.align 32
	.type	oldval, @object
	.size	oldval, 4000008
oldval:
	.zero	4000008
	.globl	values
	.align 32
	.type	values, @object
	.size	values, 4000008
values:
	.zero	4000008
	.globl	rcode
	.align 4
	.type	rcode, @object
	.size	rcode, 4
rcode:
	.zero	4
	.globl	tpoints
	.align 4
	.type	tpoints, @object
	.size	tpoints, 4
tpoints:
	.zero	4
	.globl	nsteps
	.align 4
	.type	nsteps, @object
	.size	nsteps, 4
nsteps:
	.zero	4
	.section	.rodata.cst4,"aM",@progbits,4
	.align 4
.LC9:
	.long	1086918619
	.align 4
.LC10:
	.long	1065353216
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC11:
	.long	-2147483648
	.long	-1077474755
	.align 8
.LC35:
	.long	0
	.long	1093567616
	.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:

/**********************************************************************
 * DESCRIPTION:
 *   Serial Concurrent Wave Equation - C Version
 *   This program implements the concurrent wave equation
 *********************************************************************/

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

#define MAXPOINTS 1000000
#define MAXSTEPS 1000000
#define MINPOINTS 20
#define PI  3.14159265
#define FAC 6.28318530

void check_param(void);
void init_line(void);
void update (void);
void printfinal (void);

int nsteps,                 	/* number of time steps */
    tpoints, 	     		/* total points along string */
    rcode;                  	/* generic return code */
float  values[MAXPOINTS+2], 	/* values at time t */
       oldval[MAXPOINTS+2], 	/* values at time (t-dt) */
       newval[MAXPOINTS+2]; 	/* values at time (t+dt) */

int threads_per_block;
float *values_d;

/**********************************************************************
 *	Handle errors function
 *********************************************************************/
static void HandleError( hipError_t err,
                         const char *file,
                         const int line ) {
    if(err != hipSuccess){
        printf("%s in %s at line %d\n", hipGetErrorString( err ), file, line );
        exit( EXIT_FAILURE );
    }
}
#define HANDLE_ERROR( err ) (HandleError( err, __FILE__, __LINE__ ))

/**********************************************************************
 *	Checks input values from parameters
 *********************************************************************/
void check_param(void)
{
   char tchar[20];

   /* check number of points, number of iterations */
   while ((tpoints < MINPOINTS) || (tpoints > MAXPOINTS)) {
      printf("Enter number of points along vibrating string [%d-%d]: "
           ,MINPOINTS, MAXPOINTS);
      scanf("%s", tchar);
      tpoints = atoi(tchar);
      if ((tpoints < MINPOINTS) || (tpoints > MAXPOINTS))
         printf("Invalid. Please enter value between %d and %d\n", 
                 MINPOINTS, MAXPOINTS);
   }
   while ((nsteps < 1) || (nsteps > MAXSTEPS)) {
      printf("Enter number of time steps [1-%d]: ", MAXSTEPS);
      scanf("%s", tchar);
      nsteps = atoi(tchar);
      if ((nsteps < 1) || (nsteps > MAXSTEPS))
         printf("Invalid. Please enter value between 1 and %d\n", MAXSTEPS);
   }

   printf("Using points = %d, steps = %d\n", tpoints, nsteps);

}

/**********************************************************************
 *     Initialize points on line
 *********************************************************************/
void init_line(void)
{
   int i, j;
   float x, fac, k, tmp;

   /* Calculate initial values based on sine curve */
   fac = 2.0 * PI;
   k = 0.0; 
   tmp = tpoints - 1;
   for (j = 1; j <= tpoints; j++) {
      x = k/tmp;
      values[j] = sin (fac * x);
      k = k + 1.0;
   }

   /* Initialize old values array */
   for (i = 1; i <= tpoints; i++) 
      oldval[i] = values[i];
}

/**********************************************************************
 *      Calculate new values using wave equation
 *********************************************************************/
void do_math(int i)
{
   float dtime, c, dx, tau, sqtau;

   dtime = 0.3;
   c = 1.0;
   dx = 1.0;
   tau = (c * dtime / dx);
   sqtau = tau * tau;
   newval[i] = (2.0 * values[i]) - oldval[i] + (sqtau *  (-2.0)*values[i]);
}

/**********************************************************************
 *     Update all values along line a specified number of times
 *********************************************************************/
void update()
{
    int i, j;
    /* Update values for each time step */
    for (i = 1; i<= nsteps; i++) {
        /* Update points along line for this time step */
        for (j = 1; j <= tpoints; j++) {
            /* global endpoints */
            if ((j == 1) || (j  == tpoints))
                newval[j] = 0.0;
            else
                do_math(j);
        }

        /* Update old values with new values */
        for (j = 1; j <= tpoints; j++) {
            oldval[j] = values[j];
            values[j] = newval[j];
        }
    }
}

__global__ void cuda_update(float *values_d, const int tpoints, const int nsteps){
    int thread_id = (blockIdx.x * blockDim.x) + threadIdx.x;
    float new_val;
    float curr_val;
    float old_val;

    if(thread_id < tpoints){
        //init_line()
        float x           = (float)thread_id/(tpoints - 1);
        int residue_nstep = nsteps%4;
        curr_val          = __sinf(FAC * x);
        old_val           = curr_val;
        
        //update()
        /*
        for(int i = 0; i < nsteps; ++i){
            new_val = 1.82*curr_val-old_val;
            old_val = curr_val;
            curr_val= new_val;
        }
        */
        //unroll 4
        for(int i = 0; i < residue_nstep; ++i){
            new_val = 1.82*curr_val-old_val;
            old_val = curr_val;
            curr_val= new_val;
        }
        for(int i = residue_nstep; i < nsteps; i+=4){
            new_val = 1.82*curr_val-old_val;
            old_val = curr_val;
            curr_val= new_val;

            new_val = 1.82*curr_val-old_val;
            old_val = curr_val;
            curr_val= new_val;

            new_val = 1.82*curr_val-old_val;
            old_val = curr_val;
            curr_val= new_val;

            new_val = 1.82*curr_val-old_val;
            old_val = curr_val;
            curr_val= new_val;
        }

        values_d[thread_id] = curr_val;
    }
}

/**********************************************************************
 *     Print final results
 *********************************************************************/
void printfinal()
{
   int i;

   for (i = 1; i <= tpoints; i++) {
      printf("%6.4f ", values[i]);
      if (i%10 == 0)
         printf("\n");
   }
}

void printfinal_cuda(const int tpoints, float* values){
   int i;

   for (i = 0; i < tpoints; i++) {
      printf("%6.4f ", values[i]);
      if ((i+1)%10 == 0)
         printf("\n");
   }
}

// Print device properties
void PrintDevProp(hipDeviceProp_t &devProp){
    printf("Major revision number:         %d\n",  devProp.major);
    printf("Minor revision number:         %d\n",  devProp.minor);
    printf("Name:                          %s\n",  devProp.name);
    printf("Total global memory:           %zu\n",  devProp.totalGlobalMem);
    printf("Total shared memory per block: %zu\n",  devProp.sharedMemPerBlock);
    printf("Total registers per block:     %d\n",  devProp.regsPerBlock);
    printf("Warp size:                     %d\n",  devProp.warpSize);
    printf("Maximum memory pitch:          %zu\n",  devProp.memPitch);
    printf("Maximum threads per block:     %d\n",  devProp.maxThreadsPerBlock);
    for (int i = 0; i < 3; ++i)
    printf("Maximum dimension %d of block: %d\n", i, devProp.maxThreadsDim[i]);
    for (int i = 0; i < 3; ++i)
    printf("Maximum dimension %d of grid:  %d\n", i, devProp.maxGridSize[i]);
    printf("Clock rate:                    %d\n",  devProp.clockRate);
    printf("Total constant memory:         %zu\n",  devProp.totalConstMem);
    printf("Texture alignment:             %zu\n",  devProp.textureAlignment);
    printf("Concurrent copy and execution: %s\n",  (devProp.deviceOverlap ? "Yes" : "No"));
    printf("Number of multiprocessors:     %d\n",  devProp.multiProcessorCount);
    printf("Kernel execution timeout:      %s\n",  (devProp.kernelExecTimeoutEnabled ? "Yes" : "No"));
    printf("Memory Clock Rate (KHz):       %d\n", devProp.memoryClockRate);
    printf("Memory Bus Width (bits):       %d\n", devProp.memoryBusWidth);
    printf("Peak Memory Bandwidth (GB/s):  %f\n\n", 2.0*devProp.memoryClockRate*(devProp.memoryBusWidth/8)/1.0e6);
    return;
}

/**********************************************************************
 *	Main program
 *********************************************************************/
int main(int argc, char *argv[])
{
    sscanf(argv[1],"%d",&tpoints);
    sscanf(argv[2],"%d",&nsteps);
    check_param();

    // Number of CUDA devices
    int devCount;
    int blocks_num;
    hipDeviceProp_t devProp;

    hipGetDeviceCount(&devCount);
    if(devCount==0){
        fprintf(stderr, "%s", "Error: No NVIDIA GPU device found!\n");
        return EXIT_FAILURE;
    }
 
    /*
    // Iterate through devices
    for (int i = 0; i < devCount; ++i)
    {
        // Get device properties
        printf("\nCUDA Device #%d\n", i);
        cudaDeviceProp devProp;
        if(cudaGetDeviceProperties(&devProp, i) == cudaSuccess){
            PrintDevProp(devProp);
        }
    }
    */

    //Set CUDA related parameters
    if(hipGetDeviceProperties(&devProp, 0) == hipSuccess){
        threads_per_block = devProp.maxThreadsPerBlock;
    }else{
        fprintf(stderr, "%s", "Error: Get GPU Property, maxThreadsPerBlock, fails.\n");
        return EXIT_FAILURE;
    }

    hipSetDevice(0);
    blocks_num = (tpoints+threads_per_block-1)/threads_per_block;

    //Malloc mem in GPU for values_d
    HANDLE_ERROR(hipMalloc((void**) &values_d, tpoints*sizeof(float)));

    //Initialization - already merged into kernel function
    printf("Initializing points on the line...\n");
    //init_line();

    //Update - kernel function
    printf("Updating all points for all time steps...\n");
    cuda_update<<<blocks_num, threads_per_block>>>(values_d, tpoints, nsteps);
    //Copy back from GPU to CPU
    HANDLE_ERROR(hipMemcpy(values, values_d, tpoints*sizeof(float), hipMemcpyDeviceToHost));

    //Print final results
    printf("Printing final results...\n");
    printfinal_cuda(tpoints, values);
    printf("\nDone.\n\n");
	
    return EXIT_SUCCESS;
}

	.text
	.file	"cuda_wave.unroll_4.hip"
	.globl	_Z11check_paramv                # -- Begin function _Z11check_paramv
	.type	_Z11check_paramv,@function
_Z11check_paramv:                       # @_Z11check_paramv
	.cfi_startproc
# %bb.0:
	pushq	%r14
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	subq	$24, %rsp
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -24
	.cfi_offset %r14, -16
	movl	tpoints(%rip), %eax
	leal	-1000001(%rax), %ecx
	cmpl	$-999982, %ecx                  # imm = 0xFFF0BDD2
	ja	.LBB0_3
# %bb.1:
	movq	%rsp, %rbx
.LBB0_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movl	$.L.str, %edi
	movl	$20, %esi
	movl	$1000000, %edx                  # imm = 0xF4240
	xorl	%eax, %eax
	callq	printf
	movl	$.L.str.1, %edi
	movq	%rbx, %rsi
	xorl	%eax, %eax
	callq	__isoc23_scanf
	movq	%rbx, %rdi
	callq	atoi
                                        # kill: def $eax killed $eax def $rax
	movl	%eax, tpoints(%rip)
	leal	-1000001(%rax), %ecx
	cmpl	$-999982, %ecx                  # imm = 0xFFF0BDD2
	ja	.LBB0_3
# %bb.9:                                #   in Loop: Header=BB0_2 Depth=1
	movl	$.L.str.2, %edi
	movl	$20, %esi
	movl	$1000000, %edx                  # imm = 0xF4240
	xorl	%eax, %eax
	callq	printf
	movl	tpoints(%rip), %eax
	leal	-1000001(%rax), %ecx
	cmpl	$-999981, %ecx                  # imm = 0xFFF0BDD3
	jb	.LBB0_2
.LBB0_3:                                # %.preheader
	movl	nsteps(%rip), %edx
	movl	$-1000001, %r14d                # imm = 0xFFF0BDBF
	leal	(%rdx,%r14), %ecx
	cmpl	%r14d, %ecx
	ja	.LBB0_8
# %bb.4:
	movq	%rsp, %rbx
.LBB0_5:                                # %.lr.ph4
                                        # =>This Inner Loop Header: Depth=1
	movl	$.L.str.3, %edi
	movl	$1000000, %esi                  # imm = 0xF4240
	xorl	%eax, %eax
	callq	printf
	movl	$.L.str.1, %edi
	movq	%rbx, %rsi
	xorl	%eax, %eax
	callq	__isoc23_scanf
	movq	%rbx, %rdi
	callq	atoi
	movl	%eax, %edx
	movl	%eax, nsteps(%rip)
	leal	(%rdx,%r14), %eax
	cmpl	%r14d, %eax
	ja	.LBB0_7
# %bb.6:                                #   in Loop: Header=BB0_5 Depth=1
	movl	$.L.str.4, %edi
	movl	$1000000, %esi                  # imm = 0xF4240
	xorl	%eax, %eax
	callq	printf
	movl	nsteps(%rip), %edx
	leal	-1000001(%rdx), %eax
	cmpl	$-1000000, %eax                 # imm = 0xFFF0BDC0
	jb	.LBB0_5
.LBB0_7:                                # %._crit_edge.loopexit
	movl	tpoints(%rip), %eax
.LBB0_8:                                # %._crit_edge
	movl	$.L.str.5, %edi
	movl	%eax, %esi
                                        # kill: def $edx killed $edx killed $rdx
	xorl	%eax, %eax
	callq	printf
	addq	$24, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_Z11check_paramv, .Lfunc_end0-_Z11check_paramv
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function _Z9init_linev
.LCPI1_0:
	.long	0x40c90fdb                      # float 6.28318548
.LCPI1_1:
	.long	0x3f800000                      # float 1
	.text
	.globl	_Z9init_linev
	.type	_Z9init_linev,@function
_Z9init_linev:                          # @_Z9init_linev
	.cfi_startproc
# %bb.0:
	movl	tpoints(%rip), %eax
	testl	%eax, %eax
	jle	.LBB1_4
# %bb.1:                                # %.lr.ph.preheader
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$16, %rsp
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -16
	decl	%eax
	cvtsi2ss	%eax, %xmm0
	movss	%xmm0, 12(%rsp)                 # 4-byte Spill
	xorps	%xmm0, %xmm0
	xorl	%ebx, %ebx
.LBB1_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movss	%xmm0, 8(%rsp)                  # 4-byte Spill
	movss	8(%rsp), %xmm0                  # 4-byte Reload
                                        # xmm0 = mem[0],zero,zero,zero
	divss	12(%rsp), %xmm0                 # 4-byte Folded Reload
	mulss	.LCPI1_0(%rip), %xmm0
	callq	sinf
	movss	%xmm0, values+4(,%rbx,4)
	movss	8(%rsp), %xmm0                  # 4-byte Reload
                                        # xmm0 = mem[0],zero,zero,zero
	addss	.LCPI1_1(%rip), %xmm0
	movslq	tpoints(%rip), %rax
	incq	%rbx
	cmpq	%rax, %rbx
	jl	.LBB1_2
# %bb.3:                                # %.preheader
	movl	%eax, %edx
	testl	%edx, %edx
	leaq	16(%rsp), %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	.cfi_restore %rbx
	jle	.LBB1_4
# %bb.5:                                # %.lr.ph19.preheader
	shlq	$2, %rdx
	movl	$oldval+4, %edi
	movl	$values+4, %esi
	jmp	memcpy@PLT                      # TAILCALL
.LBB1_4:                                # %._crit_edge
	retq
.Lfunc_end1:
	.size	_Z9init_linev, .Lfunc_end1-_Z9init_linev
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z7do_mathi
.LCPI2_0:
	.quad	0xbfc70a3d80000000              # double -0.18000000715255737
	.text
	.globl	_Z7do_mathi
	.type	_Z7do_mathi,@function
_Z7do_mathi:                            # @_Z7do_mathi
	.cfi_startproc
# %bb.0:
	movslq	%edi, %rax
	cvtss2sd	values(,%rax,4), %xmm0
	movaps	%xmm0, %xmm1
	cvtss2sd	oldval(,%rax,4), %xmm2
	addsd	%xmm0, %xmm1
	subsd	%xmm2, %xmm1
	mulsd	.LCPI2_0(%rip), %xmm0
	addsd	%xmm1, %xmm0
	cvtsd2ss	%xmm0, %xmm0
	movss	%xmm0, newval(,%rax,4)
	retq
.Lfunc_end2:
	.size	_Z7do_mathi, .Lfunc_end2-_Z7do_mathi
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z6updatev
.LCPI3_0:
	.quad	0xbfc70a3d80000000              # double -0.18000000715255737
	.text
	.globl	_Z6updatev
	.type	_Z6updatev,@function
_Z6updatev:                             # @_Z6updatev
	.cfi_startproc
# %bb.0:
	movl	nsteps(%rip), %eax
	testl	%eax, %eax
	jle	.LBB3_12
# %bb.1:                                # %.preheader18.lr.ph
	movl	tpoints(%rip), %ecx
	leal	1(%rcx), %edx
	leaq	-4(,%rcx,4), %rsi
	leaq	-4(,%rdx,4), %rdi
	shlq	$2, %rdx
	movl	$1, %r8d
	movsd	.LCPI3_0(%rip), %xmm0           # xmm0 = mem[0],zero
.LBB3_2:                                # %.preheader18
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB3_4 Depth 2
                                        #     Child Loop BB3_10 Depth 2
	testl	%ecx, %ecx
	jle	.LBB3_11
# %bb.3:                                # %.lr.ph.preheader
                                        #   in Loop: Header=BB3_2 Depth=1
	xorl	%r9d, %r9d
.LBB3_4:                                # %.lr.ph
                                        #   Parent Loop BB3_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	xorps	%xmm1, %xmm1
	testq	%r9, %r9
	je	.LBB3_7
# %bb.5:                                # %.lr.ph
                                        #   in Loop: Header=BB3_4 Depth=2
	cmpq	%r9, %rsi
	je	.LBB3_7
# %bb.6:                                #   in Loop: Header=BB3_4 Depth=2
	xorps	%xmm1, %xmm1
	cvtss2sd	values+4(%r9), %xmm1
	movaps	%xmm1, %xmm2
	addsd	%xmm1, %xmm2
	xorps	%xmm3, %xmm3
	cvtss2sd	oldval+4(%r9), %xmm3
	subsd	%xmm3, %xmm2
	mulsd	%xmm0, %xmm1
	addsd	%xmm2, %xmm1
	cvtsd2ss	%xmm1, %xmm1
.LBB3_7:                                #   in Loop: Header=BB3_4 Depth=2
	movss	%xmm1, newval+4(%r9)
	addq	$4, %r9
	cmpq	%r9, %rdi
	jne	.LBB3_4
# %bb.8:                                # %.preheader
                                        #   in Loop: Header=BB3_2 Depth=1
	testl	%ecx, %ecx
	jle	.LBB3_11
# %bb.9:                                # %.lr.ph23.preheader
                                        #   in Loop: Header=BB3_2 Depth=1
	movl	$4, %r9d
.LBB3_10:                               # %.lr.ph23
                                        #   Parent Loop BB3_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movss	values(%r9), %xmm1              # xmm1 = mem[0],zero,zero,zero
	movss	%xmm1, oldval(%r9)
	movss	newval(%r9), %xmm1              # xmm1 = mem[0],zero,zero,zero
	movss	%xmm1, values(%r9)
	addq	$4, %r9
	cmpq	%r9, %rdx
	jne	.LBB3_10
.LBB3_11:                               # %._crit_edge
                                        #   in Loop: Header=BB3_2 Depth=1
	leal	1(%r8), %r9d
	cmpl	%eax, %r8d
	movl	%r9d, %r8d
	jne	.LBB3_2
.LBB3_12:                               # %._crit_edge26
	retq
.Lfunc_end3:
	.size	_Z6updatev, .Lfunc_end3-_Z6updatev
	.cfi_endproc
                                        # -- End function
	.globl	_Z26__device_stub__cuda_updatePfii # -- Begin function _Z26__device_stub__cuda_updatePfii
	.type	_Z26__device_stub__cuda_updatePfii,@function
_Z26__device_stub__cuda_updatePfii:     # @_Z26__device_stub__cuda_updatePfii
	.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	$96, %rsp
	.cfi_def_cfa_offset 144
	.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	4(%rsp), %rcx
	movl	%esi, (%rcx)
	movq	%rsp, %rsi
	movl	%edx, (%rsi)
	leaq	64(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	movq	%rsi, 16(%rbx)
	leaq	48(%rsp), %r14
	leaq	32(%rsp), %r15
	leaq	16(%rsp), %r12
	leaq	8(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z11cuda_updatePfii, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$112, %rsp
	.cfi_adjust_cfa_offset -112
	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_end4:
	.size	_Z26__device_stub__cuda_updatePfii, .Lfunc_end4-_Z26__device_stub__cuda_updatePfii
	.cfi_endproc
                                        # -- End function
	.globl	_Z10printfinalv                 # -- Begin function _Z10printfinalv
	.type	_Z10printfinalv,@function
_Z10printfinalv:                        # @_Z10printfinalv
	.cfi_startproc
# %bb.0:
	cmpl	$0, tpoints(%rip)
	jle	.LBB5_6
# %bb.1:                                # %.lr.ph.preheader
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.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 %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	$1, %ebx
	xorl	%r14d, %r14d
	movl	$3435973837, %r15d              # imm = 0xCCCCCCCD
.LBB5_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movl	%ebx, %eax
	imulq	%r15, %rax
	shrq	$35, %rax
	leal	(%rax,%rax,4), %eax
	leal	-1(,%rax,2), %ebp
	xorps	%xmm0, %xmm0
	cvtss2sd	values+4(,%r14,4), %xmm0
	movl	$.L.str.6, %edi
	movb	$1, %al
	callq	printf
	cmpl	%r14d, %ebp
	jne	.LBB5_4
# %bb.3:                                #   in Loop: Header=BB5_2 Depth=1
	movl	$10, %edi
	callq	putchar@PLT
.LBB5_4:                                #   in Loop: Header=BB5_2 Depth=1
	movslq	tpoints(%rip), %rax
	incq	%r14
	incl	%ebx
	cmpq	%rax, %r14
	jl	.LBB5_2
# %bb.5:
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	.cfi_restore %rbx
	.cfi_restore %r14
	.cfi_restore %r15
	.cfi_restore %rbp
.LBB5_6:                                # %._crit_edge
	retq
.Lfunc_end5:
	.size	_Z10printfinalv, .Lfunc_end5-_Z10printfinalv
	.cfi_endproc
                                        # -- End function
	.globl	_Z15printfinal_cudaiPf          # -- Begin function _Z15printfinal_cudaiPf
	.type	_Z15printfinal_cudaiPf,@function
_Z15printfinal_cudaiPf:                 # @_Z15printfinal_cudaiPf
	.cfi_startproc
# %bb.0:
	testl	%edi, %edi
	jle	.LBB6_6
# %bb.1:                                # %.lr.ph.preheader
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	pushq	%rax
	.cfi_def_cfa_offset 64
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rsi, %rbx
	movl	%edi, %r14d
	shlq	$2, %r14
	movl	$-1, %ebp
	movl	$1, %r15d
	xorl	%r12d, %r12d
.LBB6_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movl	%r15d, %eax
	movl	$3435973837, %ecx               # imm = 0xCCCCCCCD
	imulq	%rcx, %rax
	shrq	$35, %rax
	leal	(%rax,%rax,4), %r13d
	addl	%r13d, %r13d
	xorps	%xmm0, %xmm0
	cvtss2sd	(%rbx,%r12), %xmm0
	movl	$.L.str.6, %edi
	movb	$1, %al
	callq	printf
	addl	%ebp, %r13d
	jne	.LBB6_4
# %bb.3:                                #   in Loop: Header=BB6_2 Depth=1
	movl	$10, %edi
	callq	putchar@PLT
.LBB6_4:                                #   in Loop: Header=BB6_2 Depth=1
	addq	$4, %r12
	decl	%ebp
	incl	%r15d
	cmpq	%r12, %r14
	jne	.LBB6_2
# %bb.5:
	addq	$8, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	.cfi_restore %rbx
	.cfi_restore %r12
	.cfi_restore %r13
	.cfi_restore %r14
	.cfi_restore %r15
	.cfi_restore %rbp
.LBB6_6:                                # %._crit_edge
	retq
.Lfunc_end6:
	.size	_Z15printfinal_cudaiPf, .Lfunc_end6-_Z15printfinal_cudaiPf
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z12PrintDevPropR20hipDeviceProp_tR0600
.LCPI7_0:
	.quad	0x412e848000000000              # double 1.0E+6
	.text
	.globl	_Z12PrintDevPropR20hipDeviceProp_tR0600
	.type	_Z12PrintDevPropR20hipDeviceProp_tR0600,@function
_Z12PrintDevPropR20hipDeviceProp_tR0600: # @_Z12PrintDevPropR20hipDeviceProp_tR0600
	.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	%rdi, %rbx
	movl	360(%rdi), %esi
	movl	$.L.str.8, %edi
	xorl	%eax, %eax
	callq	printf
	movl	364(%rbx), %esi
	movl	$.L.str.9, %edi
	xorl	%eax, %eax
	callq	printf
	movl	$.L.str.10, %edi
	movq	%rbx, %rsi
	xorl	%eax, %eax
	callq	printf
	movq	288(%rbx), %rsi
	movl	$.L.str.11, %edi
	xorl	%eax, %eax
	callq	printf
	movq	296(%rbx), %rsi
	movl	$.L.str.12, %edi
	xorl	%eax, %eax
	callq	printf
	movl	304(%rbx), %esi
	movl	$.L.str.13, %edi
	xorl	%eax, %eax
	callq	printf
	movl	308(%rbx), %esi
	movl	$.L.str.14, %edi
	xorl	%eax, %eax
	callq	printf
	movq	312(%rbx), %rsi
	movl	$.L.str.15, %edi
	xorl	%eax, %eax
	callq	printf
	movl	320(%rbx), %esi
	movl	$.L.str.16, %edi
	xorl	%eax, %eax
	callq	printf
	xorl	%r14d, %r14d
.LBB7_1:                                # =>This Inner Loop Header: Depth=1
	movl	324(%rbx,%r14,4), %edx
	movl	$.L.str.17, %edi
	movl	%r14d, %esi
	xorl	%eax, %eax
	callq	printf
	incq	%r14
	cmpq	$3, %r14
	jne	.LBB7_1
# %bb.2:                                # %.preheader.preheader
	xorl	%r14d, %r14d
.LBB7_3:                                # %.preheader
                                        # =>This Inner Loop Header: Depth=1
	movl	336(%rbx,%r14,4), %edx
	movl	$.L.str.18, %edi
	movl	%r14d, %esi
	xorl	%eax, %eax
	callq	printf
	incq	%r14
	cmpq	$3, %r14
	jne	.LBB7_3
# %bb.4:
	movl	348(%rbx), %esi
	movl	$.L.str.19, %edi
	xorl	%eax, %eax
	callq	printf
	movq	352(%rbx), %rsi
	movl	$.L.str.20, %edi
	xorl	%eax, %eax
	callq	printf
	movq	368(%rbx), %rsi
	movl	$.L.str.21, %edi
	xorl	%eax, %eax
	callq	printf
	cmpl	$0, 384(%rbx)
	movl	$.L.str.24, %r15d
	movl	$.L.str.23, %r14d
	movl	$.L.str.23, %esi
	cmoveq	%r15, %rsi
	movl	$.L.str.22, %edi
	xorl	%eax, %eax
	callq	printf
	movl	388(%rbx), %esi
	movl	$.L.str.25, %edi
	xorl	%eax, %eax
	callq	printf
	cmpl	$0, 392(%rbx)
	cmoveq	%r15, %r14
	movl	$.L.str.26, %edi
	movq	%r14, %rsi
	xorl	%eax, %eax
	callq	printf
	movl	608(%rbx), %esi
	movl	$.L.str.27, %edi
	xorl	%eax, %eax
	callq	printf
	movl	612(%rbx), %esi
	movl	$.L.str.28, %edi
	xorl	%eax, %eax
	callq	printf
	cvtsi2sdl	608(%rbx), %xmm1
	movl	612(%rbx), %eax
	leal	7(%rax), %ecx
	testl	%eax, %eax
	cmovnsl	%eax, %ecx
	sarl	$3, %ecx
	cvtsi2sd	%ecx, %xmm0
	addsd	%xmm1, %xmm1
	mulsd	%xmm1, %xmm0
	divsd	.LCPI7_0(%rip), %xmm0
	movl	$.L.str.29, %edi
	movb	$1, %al
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	jmp	printf                          # TAILCALL
.Lfunc_end7:
	.size	_Z12PrintDevPropR20hipDeviceProp_tR0600, .Lfunc_end7-_Z12PrintDevPropR20hipDeviceProp_tR0600
	.cfi_endproc
                                        # -- End function
	.globl	main                            # -- Begin function main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%r14
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	subq	$1480, %rsp                     # imm = 0x5C8
	.cfi_def_cfa_offset 1504
	.cfi_offset %rbx, -24
	.cfi_offset %r14, -16
	movq	%rsi, %rbx
	movq	8(%rsi), %rdi
	movl	$.L.str.30, %esi
	movl	$tpoints, %edx
	xorl	%eax, %eax
	callq	__isoc23_sscanf
	movq	16(%rbx), %rdi
	movl	$.L.str.30, %esi
	movl	$nsteps, %edx
	xorl	%eax, %eax
	callq	__isoc23_sscanf
	callq	_Z11check_paramv
	leaq	4(%rsp), %rbx
	movq	%rbx, %rdi
	callq	hipGetDeviceCount
	cmpl	$0, (%rbx)
	je	.LBB8_1
# %bb.3:
	leaq	8(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipGetDevicePropertiesR0600
	testl	%eax, %eax
	jne	.LBB8_8
# %bb.4:
	movl	328(%rsp), %eax
	movl	%eax, threads_per_block(%rip)
	xorl	%ebx, %ebx
	xorl	%edi, %edi
	callq	hipSetDevice
	movslq	tpoints(%rip), %rsi
	movl	threads_per_block(%rip), %ecx
	leal	(%rsi,%rcx), %eax
	decl	%eax
	cltd
	idivl	%ecx
	movl	%eax, %r14d
	shlq	$2, %rsi
	movl	$values_d, %edi
	callq	hipMalloc
	movl	%eax, %edi
	movl	$284, %esi                      # imm = 0x11C
	callq	_ZL11HandleError10hipError_tPKci
	movl	$.Lstr, %edi
	callq	puts@PLT
	movl	$.Lstr.1, %edi
	callq	puts@PLT
	movl	threads_per_block(%rip), %edx
	btsq	$32, %r14
	btsq	$32, %rdx
	movq	%r14, %rdi
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB8_6
# %bb.5:
	movq	values_d(%rip), %rdi
	movl	tpoints(%rip), %esi
	movl	nsteps(%rip), %edx
	callq	_Z26__device_stub__cuda_updatePfii
.LBB8_6:
	movq	values_d(%rip), %rsi
	movslq	tpoints(%rip), %rdx
	shlq	$2, %rdx
	movl	$values, %edi
	movl	$2, %ecx
	callq	hipMemcpy
	movl	%eax, %edi
	movl	$294, %esi                      # imm = 0x126
	callq	_ZL11HandleError10hipError_tPKci
	movl	$.Lstr.2, %edi
	callq	puts@PLT
	movl	tpoints(%rip), %edi
	movl	$values, %esi
	callq	_Z15printfinal_cudaiPf
	movl	$.Lstr.3, %edi
	callq	puts@PLT
.LBB8_7:
	movl	%ebx, %eax
	addq	$1480, %rsp                     # imm = 0x5C8
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	retq
.LBB8_1:
	.cfi_def_cfa_offset 1504
	movq	stderr(%rip), %rsi
	movl	$.L.str.31, %edi
	jmp	.LBB8_2
.LBB8_8:
	movq	stderr(%rip), %rsi
	movl	$.L.str.32, %edi
.LBB8_2:
	callq	fputs@PLT
	movl	$1, %ebx
	jmp	.LBB8_7
.Lfunc_end8:
	.size	main, .Lfunc_end8-main
	.cfi_endproc
                                        # -- End function
	.type	_ZL11HandleError10hipError_tPKci,@function # -- Begin function _ZL11HandleError10hipError_tPKci
_ZL11HandleError10hipError_tPKci:       # @_ZL11HandleError10hipError_tPKci
	.cfi_startproc
# %bb.0:
	testl	%edi, %edi
	jne	.LBB9_2
# %bb.1:
	retq
.LBB9_2:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset %rbx, -16
	movl	%esi, %ebx
	callq	hipGetErrorString
	movl	$.L.str.38, %edi
	movl	$.L.str.33, %edx
	movq	%rax, %rsi
	movl	%ebx, %ecx
	xorl	%eax, %eax
	callq	printf
	movl	$1, %edi
	callq	exit
.Lfunc_end9:
	.size	_ZL11HandleError10hipError_tPKci, .Lfunc_end9-_ZL11HandleError10hipError_tPKci
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	jne	.LBB10_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB10_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z11cuda_updatePfii, %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_end10:
	.size	__hip_module_ctor, .Lfunc_end10-__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	.LBB11_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
.LBB11_2:
	retq
.Lfunc_end11:
	.size	__hip_module_dtor, .Lfunc_end11-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	nsteps,@object                  # @nsteps
	.bss
	.globl	nsteps
	.p2align	2, 0x0
nsteps:
	.long	0                               # 0x0
	.size	nsteps, 4

	.type	tpoints,@object                 # @tpoints
	.globl	tpoints
	.p2align	2, 0x0
tpoints:
	.long	0                               # 0x0
	.size	tpoints, 4

	.type	rcode,@object                   # @rcode
	.globl	rcode
	.p2align	2, 0x0
rcode:
	.long	0                               # 0x0
	.size	rcode, 4

	.type	values,@object                  # @values
	.globl	values
	.p2align	4, 0x0
values:
	.zero	4000008
	.size	values, 4000008

	.type	oldval,@object                  # @oldval
	.globl	oldval
	.p2align	4, 0x0
oldval:
	.zero	4000008
	.size	oldval, 4000008

	.type	newval,@object                  # @newval
	.globl	newval
	.p2align	4, 0x0
newval:
	.zero	4000008
	.size	newval, 4000008

	.type	threads_per_block,@object       # @threads_per_block
	.globl	threads_per_block
	.p2align	2, 0x0
threads_per_block:
	.long	0                               # 0x0
	.size	threads_per_block, 4

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

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"Enter number of points along vibrating string [%d-%d]: "
	.size	.L.str, 56

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"%s"
	.size	.L.str.1, 3

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"Invalid. Please enter value between %d and %d\n"
	.size	.L.str.2, 47

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"Enter number of time steps [1-%d]: "
	.size	.L.str.3, 36

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"Invalid. Please enter value between 1 and %d\n"
	.size	.L.str.4, 46

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"Using points = %d, steps = %d\n"
	.size	.L.str.5, 31

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

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

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"Major revision number:         %d\n"
	.size	.L.str.8, 35

	.type	.L.str.9,@object                # @.str.9
.L.str.9:
	.asciz	"Minor revision number:         %d\n"
	.size	.L.str.9, 35

	.type	.L.str.10,@object               # @.str.10
.L.str.10:
	.asciz	"Name:                          %s\n"
	.size	.L.str.10, 35

	.type	.L.str.11,@object               # @.str.11
.L.str.11:
	.asciz	"Total global memory:           %zu\n"
	.size	.L.str.11, 36

	.type	.L.str.12,@object               # @.str.12
.L.str.12:
	.asciz	"Total shared memory per block: %zu\n"
	.size	.L.str.12, 36

	.type	.L.str.13,@object               # @.str.13
.L.str.13:
	.asciz	"Total registers per block:     %d\n"
	.size	.L.str.13, 35

	.type	.L.str.14,@object               # @.str.14
.L.str.14:
	.asciz	"Warp size:                     %d\n"
	.size	.L.str.14, 35

	.type	.L.str.15,@object               # @.str.15
.L.str.15:
	.asciz	"Maximum memory pitch:          %zu\n"
	.size	.L.str.15, 36

	.type	.L.str.16,@object               # @.str.16
.L.str.16:
	.asciz	"Maximum threads per block:     %d\n"
	.size	.L.str.16, 35

	.type	.L.str.17,@object               # @.str.17
.L.str.17:
	.asciz	"Maximum dimension %d of block: %d\n"
	.size	.L.str.17, 35

	.type	.L.str.18,@object               # @.str.18
.L.str.18:
	.asciz	"Maximum dimension %d of grid:  %d\n"
	.size	.L.str.18, 35

	.type	.L.str.19,@object               # @.str.19
.L.str.19:
	.asciz	"Clock rate:                    %d\n"
	.size	.L.str.19, 35

	.type	.L.str.20,@object               # @.str.20
.L.str.20:
	.asciz	"Total constant memory:         %zu\n"
	.size	.L.str.20, 36

	.type	.L.str.21,@object               # @.str.21
.L.str.21:
	.asciz	"Texture alignment:             %zu\n"
	.size	.L.str.21, 36

	.type	.L.str.22,@object               # @.str.22
.L.str.22:
	.asciz	"Concurrent copy and execution: %s\n"
	.size	.L.str.22, 35

	.type	.L.str.23,@object               # @.str.23
.L.str.23:
	.asciz	"Yes"
	.size	.L.str.23, 4

	.type	.L.str.24,@object               # @.str.24
.L.str.24:
	.asciz	"No"
	.size	.L.str.24, 3

	.type	.L.str.25,@object               # @.str.25
.L.str.25:
	.asciz	"Number of multiprocessors:     %d\n"
	.size	.L.str.25, 35

	.type	.L.str.26,@object               # @.str.26
.L.str.26:
	.asciz	"Kernel execution timeout:      %s\n"
	.size	.L.str.26, 35

	.type	.L.str.27,@object               # @.str.27
.L.str.27:
	.asciz	"Memory Clock Rate (KHz):       %d\n"
	.size	.L.str.27, 35

	.type	.L.str.28,@object               # @.str.28
.L.str.28:
	.asciz	"Memory Bus Width (bits):       %d\n"
	.size	.L.str.28, 35

	.type	.L.str.29,@object               # @.str.29
.L.str.29:
	.asciz	"Peak Memory Bandwidth (GB/s):  %f\n\n"
	.size	.L.str.29, 36

	.type	.L.str.30,@object               # @.str.30
.L.str.30:
	.asciz	"%d"
	.size	.L.str.30, 3

	.type	.L.str.31,@object               # @.str.31
.L.str.31:
	.asciz	"Error: No NVIDIA GPU device found!\n"
	.size	.L.str.31, 36

	.type	.L.str.32,@object               # @.str.32
.L.str.32:
	.asciz	"Error: Get GPU Property, maxThreadsPerBlock, fails.\n"
	.size	.L.str.32, 53

	.type	.L.str.33,@object               # @.str.33
.L.str.33:
	.asciz	"/home/ubuntu/Datasets/stackv2/train-structured-repos-hip-sm89/Coslate/Parallel_Programming/master/HW4/Parallel_CUDA/cuda_wave.unroll_4.hip"
	.size	.L.str.33, 139

	.type	.L.str.38,@object               # @.str.38
.L.str.38:
	.asciz	"%s in %s at line %d\n"
	.size	.L.str.38, 21

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z11cuda_updatePfii"
	.size	.L__unnamed_1, 20

	.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	"Initializing points on the line..."
	.size	.Lstr, 35

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"Updating all points for all time steps..."
	.size	.Lstr.1, 42

	.type	.Lstr.2,@object                 # @str.2
.Lstr.2:
	.asciz	"Printing final results..."
	.size	.Lstr.2, 26

	.type	.Lstr.3,@object                 # @str.3
.Lstr.3:
	.asciz	"\nDone.\n"
	.size	.Lstr.3, 8

	.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 _Z26__device_stub__cuda_updatePfii
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym nsteps
	.addrsig_sym tpoints
	.addrsig_sym values
	.addrsig_sym values_d
	.addrsig_sym _Z11cuda_updatePfii
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z11cuda_updatePfii     ; -- Begin function _Z11cuda_updatePfii
	.globl	_Z11cuda_updatePfii
	.p2align	8
	.type	_Z11cuda_updatePfii,@function
_Z11cuda_updatePfii:                    ; @_Z11cuda_updatePfii
; %bb.0:
	s_clause 0x1
	s_load_b32 s4, s[0:1], 0x1c
	s_load_b64 s[2:3], s[0:1], 0x8
	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, exec_lo
	v_cmpx_gt_i32_e64 s2, v1
	s_cbranch_execz .LBB0_9
; %bb.1:
	s_add_i32 s2, s2, -1
	v_cvt_f32_i32_e32 v0, v1
	v_cvt_f32_i32_e32 v2, s2
	s_mov_b32 s4, 0x53c8d4f1
	s_mov_b32 s5, 0x401921fb
	s_ashr_i32 s2, s3, 31
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_2) | instid1(SALU_CYCLE_1)
	s_lshr_b32 s2, s2, 30
	v_div_scale_f32 v3, null, v2, v2, v0
	s_add_i32 s2, s3, s2
	s_and_b32 s2, s2, -4
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(SALU_CYCLE_1)
	v_rcp_f32_e32 v4, v3
	s_sub_i32 s2, s3, s2
	s_cmp_lt_i32 s2, 1
	s_waitcnt_depctr 0xfff
	v_fma_f32 v5, -v3, v4, 1.0
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_fmac_f32_e32 v4, v5, v4
	v_div_scale_f32 v5, vcc_lo, v0, v2, v0
	v_mul_f32_e32 v6, v5, v4
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f32 v7, -v3, v6, v5
	v_fmac_f32_e32 v6, v7, v4
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f32 v3, -v3, v6, v5
	v_div_fmas_f32 v3, v3, v4, v6
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_div_fixup_f32 v0, v3, v2, v0
	v_cvt_f64_f32_e32 v[2:3], v0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_f64 v[2:3], v[2:3], s[4:5]
	v_cvt_f32_f64_e32 v0, v[2:3]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_f32_e32 v0, 0.15915494, v0
	v_sin_f32_e32 v0, v0
	s_cbranch_scc1 .LBB0_4
; %bb.2:
	s_waitcnt_depctr 0xfff
	v_mov_b32_e32 v3, v0
	s_mov_b32 s4, 0x51eb851f
	s_mov_b32 s5, 0x3ffd1eb8
	s_mov_b32 s6, s2
.LBB0_3:                                ; %.lr.ph
                                        ; =>This Inner Loop Header: Depth=1
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_mov_b32_e32 v2, v0
	v_cvt_f64_f32_e32 v[6:7], v3
	s_add_i32 s6, s6, -1
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	s_cmp_eq_u32 s6, 0
	v_cvt_f64_f32_e32 v[4:5], v2
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[3:4], v[4:5], s[4:5], -v[6:7]
	v_cvt_f32_f64_e32 v0, v[3:4]
	v_mov_b32_e32 v3, v2
	s_cbranch_scc0 .LBB0_3
	s_branch .LBB0_5
.LBB0_4:
	s_waitcnt_depctr 0xfff
	v_mov_b32_e32 v2, v0
.LBB0_5:                                ; %.preheader
	s_cmp_ge_i32 s2, s3
	s_cbranch_scc1 .LBB0_8
; %bb.6:
	s_mov_b32 s4, 0x51eb851f
	s_mov_b32 s5, 0x3ffd1eb8
.LBB0_7:                                ; %.lr.ph51
                                        ; =>This Inner Loop Header: Depth=1
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(SALU_CYCLE_1)
	v_cvt_f64_f32_e32 v[3:4], v0
	v_cvt_f64_f32_e32 v[5:6], v2
	s_add_i32 s2, s2, 4
	s_cmp_ge_i32 s2, s3
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[5:6], v[3:4], s[4:5], -v[5:6]
	v_cvt_f32_f64_e32 v0, v[5:6]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cvt_f64_f32_e32 v[5:6], v0
	v_fma_f64 v[2:3], v[5:6], s[4:5], -v[3:4]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cvt_f32_f64_e32 v0, v[2:3]
	v_cvt_f64_f32_e32 v[3:4], v0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[5:6], v[3:4], s[4:5], -v[5:6]
	v_cvt_f32_f64_e32 v2, v[5:6]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cvt_f64_f32_e32 v[5:6], v2
	v_fma_f64 v[3:4], v[5:6], s[4:5], -v[3:4]
	s_delay_alu instid0(VALU_DEP_1)
	v_cvt_f32_f64_e32 v0, v[3:4]
	s_cbranch_scc0 .LBB0_7
.LBB0_8:                                ; %Flow66
	s_load_b64 s[0:1], s[0:1], 0x0
	v_ashrrev_i32_e32 v2, 31, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[1:2], 2, v[1:2]
	s_waitcnt lgkmcnt(0)
	v_add_co_u32 v1, vcc_lo, s0, v1
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v2, vcc_lo, s1, v2, vcc_lo
	global_store_b32 v[1:2], v0, off
.LBB0_9:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z11cuda_updatePfii
		.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 8
		.amdhsa_next_free_sgpr 16
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end0:
	.size	_Z11cuda_updatePfii, .Lfunc_end0-_Z11cuda_updatePfii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 536
; NumSgprs: 18
; NumVgprs: 8
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 8
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_
	.amdgpu_metadata
---
amdhsa.kernels:
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .offset:         8
        .size:           4
        .value_kind:     by_value
      - .offset:         12
        .size:           4
        .value_kind:     by_value
      - .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:           _Z11cuda_updatePfii
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z11cuda_updatePfii.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     8
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
