#include <stdlib.h>

#include <stdio.h>

#include <cuda_runtime.h>

#include <sys/time.h>



#define NUM_STEPS    2048

#define BLOCK_SIZE   128

#define MAX_OPTIONS  1024

#define ELEMS_PER_THREAD (NUM_STEPS/BLOCK_SIZE)

/* at T_N = NUM_STEPS, there are (NUM_STEPS + 1) leaves*/



double cpuSecond( ) {

    double sec;

    struct timeval tp;

    gettimeofday(&tp, NULL);

    sec = (double) tp.tv_sec + (double) tp.tv_usec*1e-6;

    return sec;

}



// cumulative standard normal distribution

__device__ __host__ double CND(double d) {



    const double b  =  0.2316419;

    const double a1 =  0.31938153;

    const double a2 = -0.356563782;

    const double a3 =  1.781477937;

    const double a4 = -1.821255978;

    const double a5 =  1.330274429;



    const double rsqrt2pi  = 0.3989422804014327;

    double K = 1.0/(1.0 + b*abs(d));



    double ans;



    ans  = K*(a1 + K*(a2 + K*(a3 + K*(a4 + K*a5) ) ) );

    ans *= rsqrt2pi*exp(-d*d/2.0);

    if (d > 0) {

        ans = 1.0 - ans;

    }

    return ans;

}



__host__ double

BlackScholes(double S0, double X, double r, double v, double T) {



    double sqrtT = sqrt(T);

    double d1    = ( log(S0/X) + (r + 0.5*v*v)*T )/(v*sqrtT);

    double d2    = d1 - v*sqrtT;

    double expRT = exp(-r*T);

    double CE;



    CE = S0*CND(d1) - X*expRT*CND(d2);

    return CE;

}





/* CPU verion of the binomial model */

__host__ double 

binomial(double S, double X, double r, double v, double T, int N, double* V ) {

// S current stock price; X strike price; 

// r, v the risk-free interest rate and volatility;

// T the expiry (unit yr); N the number of time steps in the binomial model.

// V[N+1] is the array to do the iteration;

// In the end, V[0] stores the price of the call option



    double  dt    = T/(double) N;

    double  vdt   = v*sqrt(dt);

    double  u     = exp( vdt );

    double  d     = 1.0/u;

    double  disc  = exp( r * dt );       // discounting factor

    double  discr = 1.0/disc;

    double  pu    = (disc - d)/(u - d);  // risk-neutral/martingale probability

    double  pd    = 1.0 - pu;

    int     i, j;

    double  Si;                          // intermediate stock price in the node



    // initialize the CALL option value on expiry;

    for (i = 0; i <= N; i++) {

        Si   = S * exp( vdt*(2*i - N) );     	// S[0] lowest stock price at expiry. 

        V[i] = (Si - X > 0) ? (Si - X) : 0;     // Call option, use "max(X-Si, 0.0)" for puts  

    }



    // iterate backward of the binomial tree (j the time step).

    for (j = N-1; j >= 0; j--) {

        for (i = 0; i <= j; i++) {

            V[i] =  (pd * V[i] + pu * V[i+1]) * discr;

        }

    }



    return V[0];

}



/* 1D grid, and 1D block; blocksize << NUM_STEPS

   each block  deals with only one option 

   each thread deals with part of the binomial tree */

__global__ void

binomialGPUv5(double* Sptr, double* Xptr, double* Cptr,

              double r, double v, double T) {



    int     tx    = threadIdx.x;

    int     bx    = blockIdx.x;

    double  S     = Sptr[bx];

    double  X     = Xptr[bx];

    double  dt    = T/(double) NUM_STEPS;

    double  vdt   = v*sqrt(dt);

    double  u     = exp(vdt);

    double  d     = 1.0/u;

    double  disc  = exp( r * dt );       // discounting factor

    double  discr = 1.0/disc;

    double  pu    = (disc - d)/(u - d);  // risk-neutral/martingale probability

    double  pd    = 1.0 - pu;

    

    int     i, j, k;

    double  Si;



    double  call_loc[ELEMS_PER_THREAD + 1]; //local array

    __shared__ 

    double  call_bound[BLOCK_SIZE + 1];



    for (i = 0; i < ELEMS_PER_THREAD; i++) {

        k  = tx * ELEMS_PER_THREAD + i;

        Si = S * exp( vdt * (2*k - NUM_STEPS) );

        call_loc[i] =  (Si - X > 0) ? (Si - X) : 0;

    }



    if (tx == BLOCK_SIZE - 1) {

        Si = S * exp( vdt * NUM_STEPS);

        call_bound[BLOCK_SIZE] = (Si - X > 0) ? (Si - X) : 0;

    }

    call_bound[tx] = call_loc[0];

    __syncthreads();

    call_loc[ELEMS_PER_THREAD] = call_bound[tx + 1];

    __syncthreads();



    for (j = 0; j < (BLOCK_SIZE - tx)*ELEMS_PER_THREAD; j++) {



        for (i = 0; i < ELEMS_PER_THREAD; i++) {

            call_loc[i] =  (pd*call_loc[i] + pu*call_loc[i+1])*discr;

        }

        call_bound[tx] = call_loc[0];

        __syncthreads();

        call_loc[ELEMS_PER_THREAD] = call_bound[tx + 1];

        __syncthreads();  // must be there, otherwise, fail

    }



    if (tx == 0) {

        Cptr[bx] = call_loc[0];

    }

}



/* general uniform random number between [low, high] */

double UniRand(double low, double high) {



    double t = (double) rand() / (double) RAND_MAX;

    return (1.0 - t)*low + t*high;

}



/* test the GPU binomial model for European Call Pricing */

int main(int argc, char** argv) {



    int      OPT_N   = MAX_OPTIONS;

    double * Sptr_h;

    double * Sptr_d;

    double * Xptr_h;

    double * Xptr_d;

    double * Cptr_h;

    double * Cptr_d;

    double * Cptr_c;

    double * Cptr_b;  		// from the Black-Scholes model

    int      size = OPT_N*sizeof(double);    

    int      i;

  

    double * Vptr_h; // used by the CPU verions





    double   r = 0.02;  // risk-free rate

    double   v = 0.30;  // volatility

    double   T = 1.00;  // maturity



    cudaError_t error;

    double   tStart;

    double   tStop1, tStop2;



    double   sumDel = 0, sumRef = 0;



    Sptr_h = (double *) malloc(size); // input

    Xptr_h = (double *) malloc(size); // input

    Cptr_h = (double *) malloc(size); // CPU version output

    Cptr_c = (double *) malloc(size); // GPU version output

    Cptr_b = (double *) malloc(size); // CPU Black-Scholes output



    Vptr_h = (double *) malloc((NUM_STEPS+1)*sizeof(double));



    for (i = 0; i < OPT_N; i++) {

        Sptr_h[i] = UniRand(5.0, 30.0);

        Xptr_h[i] = UniRand(1.0, 40.0);

    }



    cudaMalloc( (void **) &Sptr_d, size);

    cudaMalloc( (void **) &Xptr_d, size);

    cudaMalloc( (void **) &Cptr_d, size);



    cudaMemcpy(Sptr_d, Sptr_h, size, cudaMemcpyHostToDevice);

    cudaMemcpy(Xptr_d, Xptr_h, size, cudaMemcpyHostToDevice);



    dim3 dimGrid(MAX_OPTIONS);

    dim3 dimBlock(BLOCK_SIZE);

 

    printf("Depth of the tree NUM_STEPS = %d\n", NUM_STEPS); 

    printf("grid structure: <<<%d, %d>>>\n", dimGrid.x, dimBlock.x);

    printf("Starting the GPU code...\n");



    tStart = cpuSecond();

    cudaDeviceSynchronize();

    binomialGPUv5<<<dimGrid, dimBlock>>>(Sptr_d, Xptr_d, Cptr_d, r, v, T);

    cudaMemcpy(Cptr_c, Cptr_d, size, cudaMemcpyDeviceToHost);   

    error = cudaPeekAtLastError();

    if (error != cudaSuccess) {

        printf("GPU code failed %s\n", cudaGetErrorString(error) ); 

        exit(-1);

    } else {

        tStop1 = cpuSecond() - tStart;

        printf("GPU code finished within %12.6f seconds\n", tStop1);

    }



    tStart = cpuSecond();

    for (i = 0; i < OPT_N; i++) {

        Cptr_h[i] = binomial(Sptr_h[i], Xptr_h[i], r, v, T, NUM_STEPS, Vptr_h);

    }

    tStop2  = cpuSecond() - tStart;

    printf("CPU code finished within %12.6f seconds\n", tStop2);

    printf("Speed up you got %8.2f\n", tStop2/tStop1);



    for (i = 0; i < OPT_N; i++) {

        Cptr_b[i] = BlackScholes(Sptr_h[i], Xptr_h[i], r, v, T);

    }



    printf("Compare the GPU and CPU binary model now...\n");

    for (i = 0; i < OPT_N; i++) {

        if ( abs( Cptr_h[i] - Cptr_c[i] ) > 1e-8 ) {

            printf("%d %8.2f %8.2f %12.6f %12.6f \n", i, Sptr_h[i], Xptr_h[i], Cptr_h[i], Cptr_c[i]);      

            printf("comparion failed\n");

	    exit(-1);

        } 

    }

    printf("passed comparison between GPU and CPU binomial model\n");



    printf("Compare the binary model with Black-Scholes model now...\n");

    for (i = 0; i < OPT_N; i++) {

        sumDel += abs( Cptr_h[i] - Cptr_b[i] ); 

        sumRef += Cptr_h[i];

    }

    if ( sumDel/sumRef > 1e-4 ) {

        printf("Black-Scholes VS Binomial comparison failed\n");

	exit(-1);

    } 

    printf("passed comparison between binomial and Black-Scholes model\n");



    printf("Here are outputs for the first 10 lines\n");

    for (i = 0; i < 10; i++) {

        printf("%8.2f, %8.2f, %10.4f, %10.4f, %10.4f\n", 

              Sptr_h[i], Xptr_h[i], Cptr_c[i], Cptr_h[i], Cptr_b[i]);

    }



    free(Sptr_h); free(Xptr_h); free(Cptr_h); free(Cptr_c); free(Cptr_b); free(Vptr_h);

    cudaFree(Sptr_d); cudaFree(Xptr_d); cudaFree(Cptr_d);

    cudaDeviceReset();



    return(0);

}



	.file	"tmpxft_002f6227_00000000-6_gpu.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2035:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2035:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z9cpuSecondv
	.type	_Z9cpuSecondv, @function
_Z9cpuSecondv:
.LFB2027:
	.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
	cvtsi2sdq	16(%rsp), %xmm0
	mulsd	.LC0(%rip), %xmm0
	cvtsi2sdq	8(%rsp), %xmm1
	addsd	%xmm1, %xmm0
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	je	.L3
	call	__stack_chk_fail@PLT
.L3:
	addq	$40, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2027:
	.size	_Z9cpuSecondv, .-_Z9cpuSecondv
	.globl	_Z3CNDd
	.type	_Z3CNDd, @function
_Z3CNDd:
.LFB2028:
	.cfi_startproc
	endbr64
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movaps	%xmm0, %xmm1
	andps	.LC1(%rip), %xmm0
	movsd	.LC3(%rip), %xmm2
	mulsd	.LC2(%rip), %xmm0
	movsd	%xmm1, 8(%rsp)
	movaps	%xmm2, %xmm3
	addsd	%xmm2, %xmm0
	divsd	%xmm0, %xmm3
	movsd	.LC4(%rip), %xmm0
	mulsd	%xmm3, %xmm0
	subsd	.LC5(%rip), %xmm0
	mulsd	%xmm3, %xmm0
	addsd	.LC6(%rip), %xmm0
	mulsd	%xmm3, %xmm0
	subsd	.LC7(%rip), %xmm0
	mulsd	%xmm3, %xmm0
	addsd	.LC8(%rip), %xmm0
	mulsd	%xmm3, %xmm0
	movsd	%xmm0, (%rsp)
	movaps	%xmm1, %xmm0
	xorps	.LC9(%rip), %xmm0
	mulsd	%xmm1, %xmm0
	mulsd	.LC10(%rip), %xmm0
	call	exp@PLT
	movsd	8(%rsp), %xmm1
	xorps	%xmm3, %xmm3
	mulsd	.LC11(%rip), %xmm0
	mulsd	(%rsp), %xmm0
	comisd	%xmm3, %xmm1
	jbe	.L6
	movsd	.LC3(%rip), %xmm2
	subsd	%xmm0, %xmm2
	movaps	%xmm2, %xmm0
.L6:
	addq	$24, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2028:
	.size	_Z3CNDd, .-_Z3CNDd
	.globl	_Z12BlackScholesddddd
	.type	_Z12BlackScholesddddd, @function
_Z12BlackScholesddddd:
.LFB2029:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	subq	$48, %rsp
	.cfi_def_cfa_offset 64
	movsd	%xmm0, (%rsp)
	movaps	%xmm4, %xmm0
	movsd	%xmm1, 8(%rsp)
	movsd	%xmm2, 40(%rsp)
	movsd	%xmm3, 32(%rsp)
	movsd	%xmm4, 24(%rsp)
	call	sqrt@PLT
	movsd	%xmm0, 16(%rsp)
	movsd	(%rsp), %xmm0
	divsd	8(%rsp), %xmm0
	call	log@PLT
	movsd	32(%rsp), %xmm3
	movsd	.LC10(%rip), %xmm5
	movsd	16(%rsp), %xmm1
	movsd	40(%rsp), %xmm2
	movaps	%xmm0, %xmm6
	mulsd	%xmm3, %xmm5
	movsd	24(%rsp), %xmm4
	mulsd	%xmm3, %xmm1
	mulsd	%xmm3, %xmm5
	movaps	%xmm1, %xmm0
	movaps	%xmm5, %xmm1
	addsd	%xmm2, %xmm1
	xorps	.LC9(%rip), %xmm2
	mulsd	%xmm4, %xmm2
	mulsd	%xmm4, %xmm1
	addsd	%xmm6, %xmm1
	divsd	%xmm0, %xmm1
	movaps	%xmm1, %xmm7
	movsd	%xmm1, 24(%rsp)
	subsd	%xmm0, %xmm7
	movaps	%xmm2, %xmm0
	movq	%xmm7, %rbx
	call	exp@PLT
	movsd	24(%rsp), %xmm1
	movsd	%xmm0, 16(%rsp)
	movaps	%xmm1, %xmm0
	call	_Z3CNDd
	movsd	(%rsp), %xmm1
	movsd	8(%rsp), %xmm6
	mulsd	16(%rsp), %xmm6
	mulsd	%xmm0, %xmm1
	movq	%rbx, %xmm0
	movsd	%xmm6, (%rsp)
	movsd	%xmm1, 24(%rsp)
	call	_Z3CNDd
	movsd	(%rsp), %xmm2
	movsd	24(%rsp), %xmm1
	addq	$48, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	mulsd	%xmm0, %xmm2
	subsd	%xmm2, %xmm1
	movaps	%xmm1, %xmm0
	ret
	.cfi_endproc
.LFE2029:
	.size	_Z12BlackScholesddddd, .-_Z12BlackScholesddddd
	.globl	_Z8binomialdddddiPd
	.type	_Z8binomialdddddiPd, @function
_Z8binomialdddddiPd:
.LFB2030:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	xorl	%r12d, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movq	%rsi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movl	%edi, %ebx
	subq	$64, %rsp
	.cfi_def_cfa_offset 96
	movsd	%xmm0, 24(%rsp)
	cvtsi2sdl	%edi, %xmm0
	movsd	%xmm1, 32(%rsp)
	movsd	%xmm2, 40(%rsp)
	movsd	%xmm3, 16(%rsp)
	divsd	%xmm0, %xmm4
	movaps	%xmm4, %xmm0
	movsd	%xmm4, 8(%rsp)
	call	sqrt@PLT
	mulsd	16(%rsp), %xmm0
	movsd	%xmm0, 16(%rsp)
	call	exp@PLT
	movsd	.LC3(%rip), %xmm3
	movsd	%xmm0, 56(%rsp)
	movaps	%xmm3, %xmm4
	divsd	%xmm0, %xmm4
	movsd	8(%rsp), %xmm0
	mulsd	40(%rsp), %xmm0
	movsd	%xmm4, 48(%rsp)
	call	exp@PLT
	movsd	48(%rsp), %xmm4
	movsd	56(%rsp), %xmm2
	movaps	%xmm0, %xmm1
	movsd	.LC3(%rip), %xmm3
	subsd	%xmm4, %xmm1
	subsd	%xmm4, %xmm2
	movaps	%xmm3, %xmm5
	divsd	%xmm0, %xmm5
	divsd	%xmm2, %xmm1
	movsd	%xmm5, 8(%rsp)
	subsd	%xmm1, %xmm3
.L14:
	cmpl	%r12d, %ebx
	jl	.L22
	leal	(%r12,%r12), %eax
	movsd	%xmm3, 48(%rsp)
	subl	%ebx, %eax
	movsd	%xmm1, 40(%rsp)
	cvtsi2sdl	%eax, %xmm0
	mulsd	16(%rsp), %xmm0
	call	exp@PLT
	mulsd	24(%rsp), %xmm0
	xorps	%xmm6, %xmm6
	movsd	40(%rsp), %xmm1
	subsd	32(%rsp), %xmm0
	movsd	48(%rsp), %xmm3
	comisd	%xmm6, %xmm0
	ja	.L15
	xorps	%xmm0, %xmm0
.L15:
	movsd	%xmm0, 0(%rbp,%r12,8)
	incq	%r12
	jmp	.L14
.L18:
	movsd	0(%rbp,%rax,8), %xmm0
	movsd	8(%rbp,%rax,8), %xmm2
	mulsd	%xmm3, %xmm0
	mulsd	%xmm1, %xmm2
	addsd	%xmm2, %xmm0
	mulsd	8(%rsp), %xmm0
	movsd	%xmm0, 0(%rbp,%rax,8)
	incq	%rax
	cmpl	%eax, %ebx
	jge	.L18
.L22:
	decl	%ebx
	testl	%ebx, %ebx
	js	.L23
	xorl	%eax, %eax
	jmp	.L18
.L23:
	movsd	0(%rbp), %xmm0
	addq	$64, %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
.LFE2030:
	.size	_Z8binomialdddddiPd, .-_Z8binomialdddddiPd
	.globl	_Z7UniRanddd
	.type	_Z7UniRanddd, @function
_Z7UniRanddd:
.LFB2031:
	.cfi_startproc
	endbr64
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movsd	%xmm0, (%rsp)
	movsd	%xmm1, 8(%rsp)
	call	rand@PLT
	movsd	.LC3(%rip), %xmm0
	cvtsi2sdl	%eax, %xmm1
	divsd	.LC13(%rip), %xmm1
	subsd	%xmm1, %xmm0
	mulsd	8(%rsp), %xmm1
	mulsd	(%rsp), %xmm0
	addq	$24, %rsp
	.cfi_def_cfa_offset 8
	addsd	%xmm1, %xmm0
	ret
	.cfi_endproc
.LFE2031:
	.size	_Z7UniRanddd, .-_Z7UniRanddd
	.globl	_Z40__device_stub__Z13binomialGPUv5PdS_S_dddPdS_S_ddd
	.type	_Z40__device_stub__Z13binomialGPUv5PdS_S_dddPdS_S_ddd, @function
_Z40__device_stub__Z13binomialGPUv5PdS_S_dddPdS_S_ddd:
.LFB2057:
	.cfi_startproc
	endbr64
	subq	$184, %rsp
	.cfi_def_cfa_offset 192
	movq	%rdi, 40(%rsp)
	leaq	64(%rsp), %rcx
	leaq	72(%rsp), %rdi
	movq	%rsi, 32(%rsp)
	leaq	84(%rsp), %rsi
	movq	%rdx, 24(%rsp)
	leaq	56(%rsp), %rdx
	movsd	%xmm0, 16(%rsp)
	movsd	%xmm1, 8(%rsp)
	movsd	%xmm2, (%rsp)
	movq	%fs:40, %rax
	movq	%rax, 168(%rsp)
	xorl	%eax, %eax
	leaq	40(%rsp), %rax
	movl	$1, 80(%rsp)
	movq	%rax, 120(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 128(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 136(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 144(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 152(%rsp)
	movq	%rsp, %rax
	movq	%rax, 160(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 72(%rsp)
	movq	%rax, 84(%rsp)
	movl	$1, 92(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L26
	pushq	64(%rsp)
	.cfi_def_cfa_offset 200
	leaq	_Z13binomialGPUv5PdS_S_ddd(%rip), %rdi
	pushq	64(%rsp)
	.cfi_def_cfa_offset 208
	movq	100(%rsp), %rcx
	movl	108(%rsp), %r8d
	movq	88(%rsp), %rsi
	movl	96(%rsp), %edx
	leaq	136(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 200
	popq	%rdx
	.cfi_def_cfa_offset 192
.L26:
	movq	168(%rsp), %rax
	subq	%fs:40, %rax
	je	.L28
	call	__stack_chk_fail@PLT
.L28:
	addq	$184, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2057:
	.size	_Z40__device_stub__Z13binomialGPUv5PdS_S_dddPdS_S_ddd, .-_Z40__device_stub__Z13binomialGPUv5PdS_S_dddPdS_S_ddd
	.globl	_Z13binomialGPUv5PdS_S_ddd
	.type	_Z13binomialGPUv5PdS_S_ddd, @function
_Z13binomialGPUv5PdS_S_ddd:
.LFB2058:
	.cfi_startproc
	endbr64
	jmp	_Z40__device_stub__Z13binomialGPUv5PdS_S_dddPdS_S_ddd
	.cfi_endproc
.LFE2058:
	.size	_Z13binomialGPUv5PdS_S_ddd, .-_Z13binomialGPUv5PdS_S_ddd
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC17:
	.string	"Depth of the tree NUM_STEPS = %d\n"
.LC18:
	.string	"grid structure: <<<%d, %d>>>\n"
.LC19:
	.string	"Starting the GPU code...\n"
.LC22:
	.string	"GPU code failed %s\n"
.LC23:
	.string	"GPU code finished within %12.6f seconds\n"
.LC24:
	.string	"CPU code finished within %12.6f seconds\n"
.LC25:
	.string	"Speed up you got %8.2f\n"
.LC26:
	.string	"Compare the GPU and CPU binary model now...\n"
.LC28:
	.string	"%d %8.2f %8.2f %12.6f %12.6f \n"
.LC29:
	.string	"comparion failed\n"
.LC30:
	.string	"passed comparison between GPU and CPU binomial model\n"
.LC31:
	.string	"Compare the binary model with Black-Scholes model now...\n"
.LC33:
	.string	"Black-Scholes VS Binomial comparison failed\n"
.LC34:
	.string	"passed comparison between binomial and Black-Scholes model\n"
.LC35:
	.string	"Here are outputs for the first 10 lines\n"
.LC36:
	.string	"%8.2f, %8.2f, %10.4f, %10.4f, %10.4f\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2032:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	$8192, %edi
	xorl	%r15d, %r15d
	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
	movl	$8192, %edi
	movq	%rax, %rbp
	call	malloc@PLT
	movl	$8192, %edi
	movq	%rax, %rbx
	call	malloc@PLT
	movl	$8192, %edi
	movq	%rax, %r12
	call	malloc@PLT
	movl	$8192, %edi
	movq	%rax, %r14
	call	malloc@PLT
	movl	$16392, %edi
	movq	%rax, %r13
	call	malloc@PLT
	movq	%rax, 8(%rsp)
.L32:
	movsd	.LC14(%rip), %xmm1
	movsd	.LC15(%rip), %xmm0
	call	_Z7UniRanddd
	movsd	.LC16(%rip), %xmm1
	movsd	%xmm0, 0(%rbp,%r15)
	movsd	.LC3(%rip), %xmm0
	call	_Z7UniRanddd
	movsd	%xmm0, (%rbx,%r15)
	addq	$8, %r15
	cmpq	$8192, %r15
	jne	.L32
	leaq	40(%rsp), %rdi
	movl	$8192, %esi
	call	cudaMalloc@PLT
	leaq	48(%rsp), %rdi
	movl	$8192, %esi
	call	cudaMalloc@PLT
	leaq	56(%rsp), %rdi
	movl	$8192, %esi
	call	cudaMalloc@PLT
	movq	40(%rsp), %rdi
	movl	$1, %ecx
	movq	%rbp, %rsi
	movl	$8192, %edx
	call	cudaMemcpy@PLT
	movq	48(%rsp), %rdi
	movl	$1, %ecx
	movq	%rbx, %rsi
	movl	$8192, %edx
	call	cudaMemcpy@PLT
	movl	$2048, %edx
	leaq	.LC17(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	movl	$128, %ecx
	movl	$1024, %edx
	xorl	%eax, %eax
	leaq	.LC18(%rip), %rsi
	movl	$2, %edi
	call	__printf_chk@PLT
	leaq	.LC19(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	call	_Z9cpuSecondv
	movsd	%xmm0, 16(%rsp)
	call	cudaDeviceSynchronize@PLT
	movl	$33554433, %edx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	$4194305, %edi
	salq	$7, %rdx
	movl	$1, %ecx
	movl	$1, %esi
	salq	$10, %rdi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L33
	movsd	.LC3(%rip), %xmm2
	movsd	.LC20(%rip), %xmm1
	movsd	.LC21(%rip), %xmm0
	movq	56(%rsp), %rdx
	movq	48(%rsp), %rsi
	movq	40(%rsp), %rdi
	call	_Z40__device_stub__Z13binomialGPUv5PdS_S_dddPdS_S_ddd
.L33:
	movq	56(%rsp), %rsi
	movq	%r14, %rdi
	movl	$2, %ecx
	movl	$8192, %edx
	call	cudaMemcpy@PLT
	call	cudaPeekAtLastError@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L34
	call	cudaGetErrorString@PLT
	leaq	.LC22(%rip), %rsi
	movl	$2, %edi
	movq	%rax, %rdx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L56
.L34:
	call	_Z9cpuSecondv
	subsd	16(%rsp), %xmm0
	movb	$1, %al
	xorl	%r15d, %r15d
	leaq	.LC23(%rip), %rsi
	movl	$2, %edi
	movsd	%xmm0, 16(%rsp)
	call	__printf_chk@PLT
	call	_Z9cpuSecondv
	movsd	%xmm0, 24(%rsp)
.L35:
	movsd	(%rbx,%r15), %xmm1
	movsd	0(%rbp,%r15), %xmm0
	movl	$2048, %edi
	movq	8(%rsp), %rsi
	movsd	.LC3(%rip), %xmm4
	movsd	.LC20(%rip), %xmm3
	movsd	.LC21(%rip), %xmm2
	call	_Z8binomialdddddiPd
	movsd	%xmm0, (%r12,%r15)
	addq	$8, %r15
	cmpq	$8192, %r15
	jne	.L35
	call	_Z9cpuSecondv
	subsd	24(%rsp), %xmm0
	movb	$1, %al
	xorl	%r15d, %r15d
	leaq	.LC24(%rip), %rsi
	movl	$2, %edi
	movsd	%xmm0, 24(%rsp)
	call	__printf_chk@PLT
	leaq	.LC25(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	movsd	24(%rsp), %xmm0
	divsd	16(%rsp), %xmm0
	call	__printf_chk@PLT
.L36:
	movsd	0(%rbp,%r15), %xmm0
	movsd	(%rbx,%r15), %xmm1
	movsd	.LC3(%rip), %xmm4
	movsd	.LC20(%rip), %xmm3
	movsd	.LC21(%rip), %xmm2
	call	_Z12BlackScholesddddd
	movsd	%xmm0, 0(%r13,%r15)
	addq	$8, %r15
	cmpq	$8192, %r15
	jne	.L36
	leaq	.LC26(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	.LC1(%rip), %xmm4
	movsd	.LC27(%rip), %xmm1
	xorl	%edx, %edx
.L39:
	movsd	(%r12,%rdx,8), %xmm2
	movsd	(%r14,%rdx,8), %xmm3
	movaps	%xmm2, %xmm0
	subsd	%xmm3, %xmm0
	andps	%xmm4, %xmm0
	comisd	%xmm1, %xmm0
	jbe	.L53
	movsd	0(%rbp,%rdx,8), %xmm0
	movsd	(%rbx,%rdx,8), %xmm1
	leaq	.LC28(%rip), %rsi
	movb	$4, %al
	movl	$2, %edi
	call	__printf_chk@PLT
	leaq	.LC29(%rip), %rsi
.L57:
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L56:
	orl	$-1, %edi
	call	exit@PLT
.L53:
	incq	%rdx
	cmpq	$1024, %rdx
	jne	.L39
	leaq	.LC30(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	.LC31(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	xorps	%xmm1, %xmm1
	movq	.LC1(%rip), %xmm4
	xorl	%eax, %eax
	movaps	%xmm1, %xmm0
.L40:
	movsd	(%r12,%rax), %xmm3
	movaps	%xmm3, %xmm2
	subsd	0(%r13,%rax), %xmm2
	addq	$8, %rax
	addsd	%xmm3, %xmm1
	andps	%xmm4, %xmm2
	addsd	%xmm2, %xmm0
	cmpq	$8192, %rax
	jne	.L40
	divsd	%xmm1, %xmm0
	leaq	.LC33(%rip), %rsi
	comisd	.LC32(%rip), %xmm0
	ja	.L57
	leaq	.LC34(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	xorl	%r15d, %r15d
	call	__printf_chk@PLT
	leaq	.LC35(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L43:
	movsd	0(%rbp,%r15), %xmm0
	movsd	0(%r13,%r15), %xmm4
	movb	$5, %al
	leaq	.LC36(%rip), %rsi
	movsd	(%r12,%r15), %xmm3
	movsd	(%r14,%r15), %xmm2
	movl	$2, %edi
	movsd	(%rbx,%r15), %xmm1
	addq	$8, %r15
	call	__printf_chk@PLT
	cmpq	$80, %r15
	jne	.L43
	movq	%rbp, %rdi
	call	free@PLT
	movq	%rbx, %rdi
	call	free@PLT
	movq	%r12, %rdi
	call	free@PLT
	movq	%r14, %rdi
	call	free@PLT
	movq	%r13, %rdi
	call	free@PLT
	movq	8(%rsp), %rdi
	call	free@PLT
	movq	40(%rsp), %rdi
	call	cudaFree@PLT
	movq	48(%rsp), %rdi
	call	cudaFree@PLT
	movq	56(%rsp), %rdi
	call	cudaFree@PLT
	call	cudaDeviceReset@PLT
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	je	.L44
	call	__stack_chk_fail@PLT
.L44:
	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
.LFE2032:
	.size	main, .-main
	.section	.rodata.str1.1
.LC37:
	.string	"_Z13binomialGPUv5PdS_S_ddd"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2060:
	.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	.LC37(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z13binomialGPUv5PdS_S_ddd(%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
.LFE2060:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC0:
	.long	-1598689907
	.long	1051772663
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC1:
	.long	-1
	.long	2147483647
	.long	0
	.long	0
	.section	.rodata.cst8
	.align 8
.LC2:
	.long	410062862
	.long	1070442097
	.align 8
.LC3:
	.long	0
	.long	1072693248
	.align 8
.LC4:
	.long	-688641725
	.long	1073039565
	.align 8
.LC5:
	.long	1324513488
	.long	1073554397
	.align 8
.LC6:
	.long	39804520
	.long	1073512687
	.align 8
.LC7:
	.long	-441961893
	.long	1071043056
	.align 8
.LC8:
	.long	982710508
	.long	1070887103
	.section	.rodata.cst16
	.align 16
.LC9:
	.long	0
	.long	-2147483648
	.long	0
	.long	0
	.section	.rodata.cst8
	.align 8
.LC10:
	.long	0
	.long	1071644672
	.align 8
.LC11:
	.long	869545553
	.long	1071220805
	.align 8
.LC13:
	.long	-4194304
	.long	1105199103
	.align 8
.LC14:
	.long	0
	.long	1077805056
	.align 8
.LC15:
	.long	0
	.long	1075052544
	.align 8
.LC16:
	.long	0
	.long	1078198272
	.align 8
.LC20:
	.long	858993459
	.long	1070805811
	.align 8
.LC21:
	.long	1202590843
	.long	1066695393
	.align 8
.LC27:
	.long	-500134854
	.long	1044740494
	.align 8
.LC32:
	.long	-350469331
	.long	1058682594
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

#include <stdlib.h>

#include <stdio.h>

#include <hip/hip_runtime.h>

#include <sys/time.h>



#define NUM_STEPS    2048

#define BLOCK_SIZE   128

#define MAX_OPTIONS  1024

#define ELEMS_PER_THREAD (NUM_STEPS/BLOCK_SIZE)

/* at T_N = NUM_STEPS, there are (NUM_STEPS + 1) leaves*/



double cpuSecond( ) {

    double sec;

    struct timeval tp;

    gettimeofday(&tp, NULL);

    sec = (double) tp.tv_sec + (double) tp.tv_usec*1e-6;

    return sec;

}



// cumulative standard normal distribution

__device__ __host__ double CND(double d) {



    const double b  =  0.2316419;

    const double a1 =  0.31938153;

    const double a2 = -0.356563782;

    const double a3 =  1.781477937;

    const double a4 = -1.821255978;

    const double a5 =  1.330274429;



    const double rsqrt2pi  = 0.3989422804014327;

    double K = 1.0/(1.0 + b*abs(d));



    double ans;



    ans  = K*(a1 + K*(a2 + K*(a3 + K*(a4 + K*a5) ) ) );

    ans *= rsqrt2pi*exp(-d*d/2.0);

    if (d > 0) {

        ans = 1.0 - ans;

    }

    return ans;

}



__host__ double

BlackScholes(double S0, double X, double r, double v, double T) {



    double sqrtT = sqrt(T);

    double d1    = ( log(S0/X) + (r + 0.5*v*v)*T )/(v*sqrtT);

    double d2    = d1 - v*sqrtT;

    double expRT = exp(-r*T);

    double CE;



    CE = S0*CND(d1) - X*expRT*CND(d2);

    return CE;

}





/* CPU verion of the binomial model */

__host__ double 

binomial(double S, double X, double r, double v, double T, int N, double* V ) {

// S current stock price; X strike price; 

// r, v the risk-free interest rate and volatility;

// T the expiry (unit yr); N the number of time steps in the binomial model.

// V[N+1] is the array to do the iteration;

// In the end, V[0] stores the price of the call option



    double  dt    = T/(double) N;

    double  vdt   = v*sqrt(dt);

    double  u     = exp( vdt );

    double  d     = 1.0/u;

    double  disc  = exp( r * dt );       // discounting factor

    double  discr = 1.0/disc;

    double  pu    = (disc - d)/(u - d);  // risk-neutral/martingale probability

    double  pd    = 1.0 - pu;

    int     i, j;

    double  Si;                          // intermediate stock price in the node



    // initialize the CALL option value on expiry;

    for (i = 0; i <= N; i++) {

        Si   = S * exp( vdt*(2*i - N) );     	// S[0] lowest stock price at expiry. 

        V[i] = (Si - X > 0) ? (Si - X) : 0;     // Call option, use "max(X-Si, 0.0)" for puts  

    }



    // iterate backward of the binomial tree (j the time step).

    for (j = N-1; j >= 0; j--) {

        for (i = 0; i <= j; i++) {

            V[i] =  (pd * V[i] + pu * V[i+1]) * discr;

        }

    }



    return V[0];

}



/* 1D grid, and 1D block; blocksize << NUM_STEPS

   each block  deals with only one option 

   each thread deals with part of the binomial tree */

__global__ void

binomialGPUv5(double* Sptr, double* Xptr, double* Cptr,

              double r, double v, double T) {



    int     tx    = threadIdx.x;

    int     bx    = blockIdx.x;

    double  S     = Sptr[bx];

    double  X     = Xptr[bx];

    double  dt    = T/(double) NUM_STEPS;

    double  vdt   = v*sqrt(dt);

    double  u     = exp(vdt);

    double  d     = 1.0/u;

    double  disc  = exp( r * dt );       // discounting factor

    double  discr = 1.0/disc;

    double  pu    = (disc - d)/(u - d);  // risk-neutral/martingale probability

    double  pd    = 1.0 - pu;

    

    int     i, j, k;

    double  Si;



    double  call_loc[ELEMS_PER_THREAD + 1]; //local array

    __shared__ 

    double  call_bound[BLOCK_SIZE + 1];



    for (i = 0; i < ELEMS_PER_THREAD; i++) {

        k  = tx * ELEMS_PER_THREAD + i;

        Si = S * exp( vdt * (2*k - NUM_STEPS) );

        call_loc[i] =  (Si - X > 0) ? (Si - X) : 0;

    }



    if (tx == BLOCK_SIZE - 1) {

        Si = S * exp( vdt * NUM_STEPS);

        call_bound[BLOCK_SIZE] = (Si - X > 0) ? (Si - X) : 0;

    }

    call_bound[tx] = call_loc[0];

    __syncthreads();

    call_loc[ELEMS_PER_THREAD] = call_bound[tx + 1];

    __syncthreads();



    for (j = 0; j < (BLOCK_SIZE - tx)*ELEMS_PER_THREAD; j++) {



        for (i = 0; i < ELEMS_PER_THREAD; i++) {

            call_loc[i] =  (pd*call_loc[i] + pu*call_loc[i+1])*discr;

        }

        call_bound[tx] = call_loc[0];

        __syncthreads();

        call_loc[ELEMS_PER_THREAD] = call_bound[tx + 1];

        __syncthreads();  // must be there, otherwise, fail

    }



    if (tx == 0) {

        Cptr[bx] = call_loc[0];

    }

}



/* general uniform random number between [low, high] */

double UniRand(double low, double high) {



    double t = (double) rand() / (double) RAND_MAX;

    return (1.0 - t)*low + t*high;

}



/* test the GPU binomial model for European Call Pricing */

int main(int argc, char** argv) {



    int      OPT_N   = MAX_OPTIONS;

    double * Sptr_h;

    double * Sptr_d;

    double * Xptr_h;

    double * Xptr_d;

    double * Cptr_h;

    double * Cptr_d;

    double * Cptr_c;

    double * Cptr_b;  		// from the Black-Scholes model

    int      size = OPT_N*sizeof(double);    

    int      i;

  

    double * Vptr_h; // used by the CPU verions





    double   r = 0.02;  // risk-free rate

    double   v = 0.30;  // volatility

    double   T = 1.00;  // maturity



    hipError_t error;

    double   tStart;

    double   tStop1, tStop2;



    double   sumDel = 0, sumRef = 0;



    Sptr_h = (double *) malloc(size); // input

    Xptr_h = (double *) malloc(size); // input

    Cptr_h = (double *) malloc(size); // CPU version output

    Cptr_c = (double *) malloc(size); // GPU version output

    Cptr_b = (double *) malloc(size); // CPU Black-Scholes output



    Vptr_h = (double *) malloc((NUM_STEPS+1)*sizeof(double));



    for (i = 0; i < OPT_N; i++) {

        Sptr_h[i] = UniRand(5.0, 30.0);

        Xptr_h[i] = UniRand(1.0, 40.0);

    }



    hipMalloc( (void **) &Sptr_d, size);

    hipMalloc( (void **) &Xptr_d, size);

    hipMalloc( (void **) &Cptr_d, size);



    hipMemcpy(Sptr_d, Sptr_h, size, hipMemcpyHostToDevice);

    hipMemcpy(Xptr_d, Xptr_h, size, hipMemcpyHostToDevice);



    dim3 dimGrid(MAX_OPTIONS);

    dim3 dimBlock(BLOCK_SIZE);

 

    printf("Depth of the tree NUM_STEPS = %d\n", NUM_STEPS); 

    printf("grid structure: <<<%d, %d>>>\n", dimGrid.x, dimBlock.x);

    printf("Starting the GPU code...\n");



    tStart = cpuSecond();

    hipDeviceSynchronize();

    binomialGPUv5<<<dimGrid, dimBlock>>>(Sptr_d, Xptr_d, Cptr_d, r, v, T);

    hipMemcpy(Cptr_c, Cptr_d, size, hipMemcpyDeviceToHost);   

    error = hipPeekAtLastError();

    if (error != hipSuccess) {

        printf("GPU code failed %s\n", hipGetErrorString(error) ); 

        exit(-1);

    } else {

        tStop1 = cpuSecond() - tStart;

        printf("GPU code finished within %12.6f seconds\n", tStop1);

    }



    tStart = cpuSecond();

    for (i = 0; i < OPT_N; i++) {

        Cptr_h[i] = binomial(Sptr_h[i], Xptr_h[i], r, v, T, NUM_STEPS, Vptr_h);

    }

    tStop2  = cpuSecond() - tStart;

    printf("CPU code finished within %12.6f seconds\n", tStop2);

    printf("Speed up you got %8.2f\n", tStop2/tStop1);



    for (i = 0; i < OPT_N; i++) {

        Cptr_b[i] = BlackScholes(Sptr_h[i], Xptr_h[i], r, v, T);

    }



    printf("Compare the GPU and CPU binary model now...\n");

    for (i = 0; i < OPT_N; i++) {

        if ( abs( Cptr_h[i] - Cptr_c[i] ) > 1e-8 ) {

            printf("%d %8.2f %8.2f %12.6f %12.6f \n", i, Sptr_h[i], Xptr_h[i], Cptr_h[i], Cptr_c[i]);      

            printf("comparion failed\n");

	    exit(-1);

        } 

    }

    printf("passed comparison between GPU and CPU binomial model\n");



    printf("Compare the binary model with Black-Scholes model now...\n");

    for (i = 0; i < OPT_N; i++) {

        sumDel += abs( Cptr_h[i] - Cptr_b[i] ); 

        sumRef += Cptr_h[i];

    }

    if ( sumDel/sumRef > 1e-4 ) {

        printf("Black-Scholes VS Binomial comparison failed\n");

	exit(-1);

    } 

    printf("passed comparison between binomial and Black-Scholes model\n");



    printf("Here are outputs for the first 10 lines\n");

    for (i = 0; i < 10; i++) {

        printf("%8.2f, %8.2f, %10.4f, %10.4f, %10.4f\n", 

              Sptr_h[i], Xptr_h[i], Cptr_c[i], Cptr_h[i], Cptr_b[i]);

    }



    free(Sptr_h); free(Xptr_h); free(Cptr_h); free(Cptr_c); free(Cptr_b); free(Vptr_h);

    hipFree(Sptr_d); hipFree(Xptr_d); hipFree(Cptr_d);

    hipDeviceReset();



    return(0);

}



	.text
	.file	"gpu.hip"
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z9cpuSecondv
.LCPI0_0:
	.quad	0x3eb0c6f7a0b5ed8d              # double 9.9999999999999995E-7
	.text
	.globl	_Z9cpuSecondv
	.type	_Z9cpuSecondv,@function
_Z9cpuSecondv:                          # @_Z9cpuSecondv
	.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
	cvtsi2sdq	(%rbx), %xmm1
	cvtsi2sdq	8(%rbx), %xmm0
	mulsd	.LCPI0_0(%rip), %xmm0
	addsd	%xmm1, %xmm0
	addq	$16, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_Z9cpuSecondv, .Lfunc_end0-_Z9cpuSecondv
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0                          # -- Begin function _Z3CNDd
.LCPI1_0:
	.quad	0x7fffffffffffffff              # double NaN
	.quad	0x7fffffffffffffff              # double NaN
.LCPI1_8:
	.quad	0x8000000000000000              # double -0
	.quad	0x8000000000000000              # double -0
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0
.LCPI1_1:
	.quad	0x3fcda6711871100e              # double 0.23164190000000001
.LCPI1_2:
	.quad	0x3ff0000000000000              # double 1
.LCPI1_3:
	.quad	0x3ff548cdd6f42943              # double 1.3302744289999999
.LCPI1_4:
	.quad	0xbffd23dd4ef278d0              # double -1.8212559779999999
.LCPI1_5:
	.quad	0x3ffc80ef025f5e68              # double 1.781477937
.LCPI1_6:
	.quad	0xbfd6d1f0e5a8325b              # double -0.356563782
.LCPI1_7:
	.quad	0x3fd470bf3a92f8ec              # double 0.31938153000000002
.LCPI1_9:
	.quad	0xbfe0000000000000              # double -0.5
.LCPI1_10:
	.quad	0x3fd9884533d43651              # double 0.3989422804014327
	.text
	.globl	_Z3CNDd
	.type	_Z3CNDd,@function
_Z3CNDd:                                # @_Z3CNDd
	.cfi_startproc
# %bb.0:
	subq	$56, %rsp
	.cfi_def_cfa_offset 64
	movapd	.LCPI1_0(%rip), %xmm2           # xmm2 = [NaN,NaN]
	andpd	%xmm0, %xmm2
	mulsd	.LCPI1_1(%rip), %xmm2
	movsd	.LCPI1_2(%rip), %xmm1           # xmm1 = mem[0],zero
	addsd	%xmm1, %xmm2
	divsd	%xmm2, %xmm1
	movsd	.LCPI1_3(%rip), %xmm2           # xmm2 = mem[0],zero
	mulsd	%xmm1, %xmm2
	addsd	.LCPI1_4(%rip), %xmm2
	mulsd	%xmm1, %xmm2
	addsd	.LCPI1_5(%rip), %xmm2
	mulsd	%xmm1, %xmm2
	addsd	.LCPI1_6(%rip), %xmm2
	mulsd	%xmm1, %xmm2
	addsd	.LCPI1_7(%rip), %xmm2
	mulsd	%xmm1, %xmm2
	movsd	%xmm2, 8(%rsp)                  # 8-byte Spill
	movapd	.LCPI1_8(%rip), %xmm2           # xmm2 = [-0.0E+0,-0.0E+0]
	movapd	%xmm0, 16(%rsp)                 # 16-byte Spill
	xorpd	%xmm0, %xmm2
	movapd	%xmm2, 32(%rsp)                 # 16-byte Spill
	mulsd	%xmm0, %xmm0
	mulsd	.LCPI1_9(%rip), %xmm0
	callq	exp
	mulsd	.LCPI1_10(%rip), %xmm0
	mulsd	8(%rsp), %xmm0                  # 8-byte Folded Reload
	movsd	.LCPI1_2(%rip), %xmm2           # xmm2 = mem[0],zero
	subsd	%xmm0, %xmm2
	movapd	32(%rsp), %xmm3                 # 16-byte Reload
	cmpltsd	16(%rsp), %xmm3                 # 16-byte Folded Reload
	movapd	%xmm3, %xmm1
	andnpd	%xmm0, %xmm1
	andpd	%xmm2, %xmm3
	orpd	%xmm1, %xmm3
	movapd	%xmm3, %xmm0
	addq	$56, %rsp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end1:
	.size	_Z3CNDd, .Lfunc_end1-_Z3CNDd
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z12BlackScholesddddd
.LCPI2_0:
	.quad	0x3fe0000000000000              # double 0.5
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0
.LCPI2_1:
	.quad	0x8000000000000000              # double -0
	.quad	0x8000000000000000              # double -0
	.text
	.globl	_Z12BlackScholesddddd
	.type	_Z12BlackScholesddddd,@function
_Z12BlackScholesddddd:                  # @_Z12BlackScholesddddd
	.cfi_startproc
# %bb.0:
	subq	$72, %rsp
	.cfi_def_cfa_offset 80
	movsd	%xmm3, 32(%rsp)                 # 8-byte Spill
	movaps	%xmm2, 48(%rsp)                 # 16-byte Spill
	movsd	%xmm1, 40(%rsp)                 # 8-byte Spill
	movsd	%xmm0, 24(%rsp)                 # 8-byte Spill
	xorpd	%xmm0, %xmm0
	ucomisd	%xmm0, %xmm4
	movsd	%xmm4, 8(%rsp)                  # 8-byte Spill
	jb	.LBB2_2
# %bb.1:
	xorps	%xmm0, %xmm0
	sqrtsd	%xmm4, %xmm0
	jmp	.LBB2_3
.LBB2_2:                                # %call.sqrt
	movapd	%xmm4, %xmm0
	callq	sqrt
.LBB2_3:                                # %.split
	movsd	%xmm0, 16(%rsp)                 # 8-byte Spill
	movsd	24(%rsp), %xmm0                 # 8-byte Reload
                                        # xmm0 = mem[0],zero
	divsd	40(%rsp), %xmm0                 # 8-byte Folded Reload
	callq	log
	movapd	%xmm0, %xmm4
	movsd	.LCPI2_0(%rip), %xmm2           # xmm2 = mem[0],zero
	movsd	32(%rsp), %xmm3                 # 8-byte Reload
                                        # xmm3 = mem[0],zero
	mulsd	%xmm3, %xmm2
	mulsd	%xmm3, %xmm2
	movapd	48(%rsp), %xmm0                 # 16-byte Reload
	addsd	%xmm0, %xmm2
	movsd	8(%rsp), %xmm1                  # 8-byte Reload
                                        # xmm1 = mem[0],zero
	mulsd	%xmm1, %xmm2
	addsd	%xmm2, %xmm4
	movsd	16(%rsp), %xmm2                 # 8-byte Reload
                                        # xmm2 = mem[0],zero
	mulsd	%xmm3, %xmm2
	divsd	%xmm2, %xmm4
	movsd	%xmm4, 16(%rsp)                 # 8-byte Spill
	subsd	%xmm2, %xmm4
	movsd	%xmm4, 32(%rsp)                 # 8-byte Spill
	xorpd	.LCPI2_1(%rip), %xmm0
	mulsd	%xmm1, %xmm0
	callq	exp
	movsd	%xmm0, 8(%rsp)                  # 8-byte Spill
	movsd	16(%rsp), %xmm0                 # 8-byte Reload
                                        # xmm0 = mem[0],zero
	callq	_Z3CNDd
	mulsd	24(%rsp), %xmm0                 # 8-byte Folded Reload
	movsd	%xmm0, 24(%rsp)                 # 8-byte Spill
	movsd	8(%rsp), %xmm0                  # 8-byte Reload
                                        # xmm0 = mem[0],zero
	mulsd	40(%rsp), %xmm0                 # 8-byte Folded Reload
	movsd	%xmm0, 8(%rsp)                  # 8-byte Spill
	movsd	32(%rsp), %xmm0                 # 8-byte Reload
                                        # xmm0 = mem[0],zero
	callq	_Z3CNDd
	mulsd	8(%rsp), %xmm0                  # 8-byte Folded Reload
	movsd	24(%rsp), %xmm1                 # 8-byte Reload
                                        # xmm1 = mem[0],zero
	subsd	%xmm0, %xmm1
	movapd	%xmm1, %xmm0
	addq	$72, %rsp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end2:
	.size	_Z12BlackScholesddddd, .Lfunc_end2-_Z12BlackScholesddddd
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z8binomialdddddiPd
.LCPI3_0:
	.quad	0x3ff0000000000000              # double 1
.LCPI3_1:
	.quad	0x0000000000000000              # double 0
	.text
	.globl	_Z8binomialdddddiPd
	.type	_Z8binomialdddddiPd,@function
_Z8binomialdddddiPd:                    # @_Z8binomialdddddiPd
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rsi, %rbx
	movl	%edi, %ebp
	movsd	%xmm2, (%rsp)                   # 8-byte Spill
	xorps	%xmm2, %xmm2
	cvtsi2sd	%edi, %xmm2
	divsd	%xmm2, %xmm4
	xorpd	%xmm2, %xmm2
	ucomisd	%xmm2, %xmm4
	movsd	%xmm1, 48(%rsp)                 # 8-byte Spill
	movsd	%xmm0, 40(%rsp)                 # 8-byte Spill
	movsd	%xmm4, 8(%rsp)                  # 8-byte Spill
	jb	.LBB3_2
# %bb.1:
	xorps	%xmm0, %xmm0
	sqrtsd	%xmm4, %xmm0
	jmp	.LBB3_3
.LBB3_2:                                # %call.sqrt
	movapd	%xmm4, %xmm0
	movsd	%xmm3, 16(%rsp)                 # 8-byte Spill
	callq	sqrt
	movsd	16(%rsp), %xmm3                 # 8-byte Reload
                                        # xmm3 = mem[0],zero
.LBB3_3:                                # %.split
	mulsd	%xmm3, %xmm0
	movsd	%xmm0, 16(%rsp)                 # 8-byte Spill
	callq	exp
	movsd	%xmm0, 32(%rsp)                 # 8-byte Spill
	movsd	8(%rsp), %xmm0                  # 8-byte Reload
                                        # xmm0 = mem[0],zero
	mulsd	(%rsp), %xmm0                   # 8-byte Folded Reload
	callq	exp
	testl	%ebp, %ebp
	js	.LBB3_7
# %bb.4:                                # %.lr.ph.preheader
	movsd	.LCPI3_0(%rip), %xmm2           # xmm2 = mem[0],zero
	movapd	%xmm2, %xmm1
	movsd	32(%rsp), %xmm4                 # 8-byte Reload
                                        # xmm4 = mem[0],zero
	divsd	%xmm4, %xmm1
	movapd	%xmm2, %xmm3
	divsd	%xmm0, %xmm3
	movsd	%xmm3, 24(%rsp)                 # 8-byte Spill
	subsd	%xmm1, %xmm0
	subsd	%xmm1, %xmm4
	divsd	%xmm4, %xmm0
	movsd	%xmm0, 8(%rsp)                  # 8-byte Spill
	subsd	%xmm0, %xmm2
	movsd	%xmm2, (%rsp)                   # 8-byte Spill
	movl	%ebp, %r14d
	movl	%ebp, %r15d
	negl	%r15d
	leaq	2(,%r14,2), %r12
	xorl	%r13d, %r13d
.LBB3_5:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	leal	(%r15,%r13), %eax
	xorps	%xmm0, %xmm0
	cvtsi2sd	%eax, %xmm0
	mulsd	16(%rsp), %xmm0                 # 8-byte Folded Reload
	callq	exp
	mulsd	40(%rsp), %xmm0                 # 8-byte Folded Reload
	subsd	48(%rsp), %xmm0                 # 8-byte Folded Reload
	maxsd	.LCPI3_1(%rip), %xmm0
	movsd	%xmm0, (%rbx,%r13,4)
	addq	$2, %r13
	cmpq	%r13, %r12
	jne	.LBB3_5
# %bb.6:                                # %.preheader46
	testl	%ebp, %ebp
	movsd	8(%rsp), %xmm3                  # 8-byte Reload
                                        # xmm3 = mem[0],zero
	movsd	(%rsp), %xmm4                   # 8-byte Reload
                                        # xmm4 = mem[0],zero
	movsd	24(%rsp), %xmm5                 # 8-byte Reload
                                        # xmm5 = mem[0],zero
	je	.LBB3_7
.LBB3_9:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB3_10 Depth 2
	movsd	(%rbx), %xmm0                   # xmm0 = mem[0],zero
	xorl	%eax, %eax
.LBB3_10:                               #   Parent Loop BB3_9 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	mulsd	%xmm4, %xmm0
	movsd	8(%rbx,%rax,8), %xmm1           # xmm1 = mem[0],zero
	movapd	%xmm3, %xmm2
	mulsd	%xmm1, %xmm2
	addsd	%xmm0, %xmm2
	mulsd	%xmm5, %xmm2
	movsd	%xmm2, (%rbx,%rax,8)
	leaq	1(%rax), %rcx
	movapd	%xmm1, %xmm0
	movq	%rcx, %rax
	cmpq	%rcx, %r14
	jne	.LBB3_10
# %bb.8:                                # %.loopexit
                                        #   in Loop: Header=BB3_9 Depth=1
	leaq	-1(%r14), %rax
	cmpq	$2, %r14
	movq	%rax, %r14
	jge	.LBB3_9
.LBB3_7:                                # %._crit_edge
	movsd	(%rbx), %xmm0                   # xmm0 = mem[0],zero
	addq	$56, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end3:
	.size	_Z8binomialdddddiPd, .Lfunc_end3-_Z8binomialdddddiPd
	.cfi_endproc
                                        # -- End function
	.globl	_Z28__device_stub__binomialGPUv5PdS_S_ddd # -- Begin function _Z28__device_stub__binomialGPUv5PdS_S_ddd
	.type	_Z28__device_stub__binomialGPUv5PdS_S_ddd,@function
_Z28__device_stub__binomialGPUv5PdS_S_ddd: # @_Z28__device_stub__binomialGPUv5PdS_S_ddd
	.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	$144, %rsp
	.cfi_def_cfa_offset 192
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	56(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	48(%rsp), %rcx
	movq	%rsi, (%rcx)
	leaq	40(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	32(%rsp), %rdx
	movsd	%xmm0, (%rdx)
	leaq	24(%rsp), %rdi
	movsd	%xmm1, (%rdi)
	leaq	16(%rsp), %r8
	movsd	%xmm2, (%r8)
	leaq	96(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	movq	%rdi, 32(%rbx)
	movq	%r8, 40(%rbx)
	leaq	80(%rsp), %r14
	leaq	64(%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	$_Z13binomialGPUv5PdS_S_ddd, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$160, %rsp
	.cfi_adjust_cfa_offset -160
	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	_Z28__device_stub__binomialGPUv5PdS_S_ddd, .Lfunc_end4-_Z28__device_stub__binomialGPUv5PdS_S_ddd
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z7UniRanddd
.LCPI5_0:
	.quad	0x41dfffffffc00000              # double 2147483647
.LCPI5_1:
	.quad	0x3ff0000000000000              # double 1
	.text
	.globl	_Z7UniRanddd
	.type	_Z7UniRanddd,@function
_Z7UniRanddd:                           # @_Z7UniRanddd
	.cfi_startproc
# %bb.0:
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movsd	%xmm1, 16(%rsp)                 # 8-byte Spill
	movsd	%xmm0, 8(%rsp)                  # 8-byte Spill
	callq	rand
	xorps	%xmm0, %xmm0
	cvtsi2sd	%eax, %xmm0
	divsd	.LCPI5_0(%rip), %xmm0
	movsd	.LCPI5_1(%rip), %xmm1           # xmm1 = mem[0],zero
	subsd	%xmm0, %xmm1
	mulsd	8(%rsp), %xmm1                  # 8-byte Folded Reload
	mulsd	16(%rsp), %xmm0                 # 8-byte Folded Reload
	addsd	%xmm1, %xmm0
	addq	$24, %rsp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end5:
	.size	_Z7UniRanddd, .Lfunc_end5-_Z7UniRanddd
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI6_0:
	.quad	0x41dfffffffc00000              # double 2147483647
.LCPI6_1:
	.quad	0x3ff0000000000000              # double 1
.LCPI6_2:
	.quad	0x4014000000000000              # double 5
.LCPI6_3:
	.quad	0x403e000000000000              # double 30
.LCPI6_4:
	.quad	0x4044000000000000              # double 40
.LCPI6_5:
	.quad	0x3eb0c6f7a0b5ed8d              # double 9.9999999999999995E-7
.LCPI6_6:
	.quad	0x3f947ae147ae147b              # double 0.02
.LCPI6_7:
	.quad	0x3fd3333333333333              # double 0.29999999999999999
.LCPI6_9:
	.quad	0x3e45798ee2308c3a              # double 1.0E-8
.LCPI6_10:
	.quad	0x3f1a36e2eb1c432d              # double 1.0E-4
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0
.LCPI6_8:
	.quad	0x7fffffffffffffff              # double NaN
	.quad	0x7fffffffffffffff              # double NaN
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$88, %rsp
	.cfi_def_cfa_offset 144
	.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	$8192, %edi                     # imm = 0x2000
	callq	malloc
	movq	%rax, %rbx
	movl	$8192, %edi                     # imm = 0x2000
	callq	malloc
	movq	%rax, %r14
	movl	$8192, %edi                     # imm = 0x2000
	callq	malloc
	movq	%rax, %r15
	movl	$8192, %edi                     # imm = 0x2000
	callq	malloc
	movq	%rax, 40(%rsp)                  # 8-byte Spill
	movl	$8192, %edi                     # imm = 0x2000
	callq	malloc
	movq	%rax, %r13
	movl	$16392, %edi                    # imm = 0x4008
	callq	malloc
	movq	%rax, 32(%rsp)                  # 8-byte Spill
	xorl	%ebp, %ebp
.LBB6_1:                                # =>This Inner Loop Header: Depth=1
	callq	rand
	xorps	%xmm0, %xmm0
	cvtsi2sd	%eax, %xmm0
	movsd	.LCPI6_0(%rip), %xmm1           # xmm1 = mem[0],zero
	divsd	%xmm1, %xmm0
	movsd	.LCPI6_1(%rip), %xmm1           # xmm1 = mem[0],zero
	subsd	%xmm0, %xmm1
	mulsd	.LCPI6_2(%rip), %xmm1
	mulsd	.LCPI6_3(%rip), %xmm0
	addsd	%xmm1, %xmm0
	movsd	%xmm0, (%rbx,%rbp,8)
	callq	rand
	xorps	%xmm0, %xmm0
	cvtsi2sd	%eax, %xmm0
	divsd	.LCPI6_0(%rip), %xmm0
	movsd	.LCPI6_1(%rip), %xmm1           # xmm1 = mem[0],zero
	subsd	%xmm0, %xmm1
	mulsd	.LCPI6_4(%rip), %xmm0
	addsd	%xmm1, %xmm0
	movsd	%xmm0, (%r14,%rbp,8)
	incq	%rbp
	cmpq	$1024, %rbp                     # imm = 0x400
	jne	.LBB6_1
# %bb.2:
	leaq	56(%rsp), %r12
	movl	$8192, %esi                     # imm = 0x2000
	movq	%r12, %rdi
	callq	hipMalloc
	leaq	48(%rsp), %rbp
	movl	$8192, %esi                     # imm = 0x2000
	movq	%rbp, %rdi
	callq	hipMalloc
	leaq	24(%rsp), %rdi
	movl	$8192, %esi                     # imm = 0x2000
	callq	hipMalloc
	movq	(%r12), %rdi
	movl	$8192, %edx                     # imm = 0x2000
	movq	%rbx, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	movq	(%rbp), %rdi
	movl	$8192, %edx                     # imm = 0x2000
	movq	%r14, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	movl	$.L.str, %edi
	movl	$2048, %esi                     # imm = 0x800
	xorl	%eax, %eax
	callq	printf
	movl	$.L.str.1, %edi
	movl	$1024, %esi                     # imm = 0x400
	movl	$128, %edx
	xorl	%eax, %eax
	callq	printf
	movl	$.Lstr, %edi
	callq	puts@PLT
	leaq	72(%rsp), %r12
	movq	%r12, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	xorps	%xmm0, %xmm0
	cvtsi2sdq	(%r12), %xmm0
	movsd	%xmm0, 16(%rsp)                 # 8-byte Spill
	xorps	%xmm0, %xmm0
	cvtsi2sdq	8(%r12), %xmm0
	movsd	%xmm0, 8(%rsp)                  # 8-byte Spill
	callq	hipDeviceSynchronize
	movabsq	$4294967424, %rdx               # imm = 0x100000080
	leaq	896(%rdx), %rdi
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB6_4
# %bb.3:
	movq	56(%rsp), %rdi
	movq	48(%rsp), %rsi
	movq	24(%rsp), %rdx
	movsd	.LCPI6_6(%rip), %xmm0           # xmm0 = mem[0],zero
	movsd	.LCPI6_7(%rip), %xmm1           # xmm1 = mem[0],zero
	movsd	.LCPI6_1(%rip), %xmm2           # xmm2 = mem[0],zero
	callq	_Z28__device_stub__binomialGPUv5PdS_S_ddd
.LBB6_4:
	movq	24(%rsp), %rsi
	movl	$8192, %edx                     # imm = 0x2000
	movq	40(%rsp), %rdi                  # 8-byte Reload
	movl	$2, %ecx
	callq	hipMemcpy
	callq	hipPeekAtLastError
	testl	%eax, %eax
	jne	.LBB6_21
# %bb.5:
	movsd	8(%rsp), %xmm0                  # 8-byte Reload
                                        # xmm0 = mem[0],zero
	mulsd	.LCPI6_5(%rip), %xmm0
	addsd	16(%rsp), %xmm0                 # 8-byte Folded Reload
	movsd	%xmm0, 8(%rsp)                  # 8-byte Spill
	xorl	%ebp, %ebp
	leaq	72(%rsp), %r12
	movq	%r12, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	xorps	%xmm1, %xmm1
	cvtsi2sdq	(%r12), %xmm1
	xorps	%xmm0, %xmm0
	cvtsi2sdq	8(%r12), %xmm0
	mulsd	.LCPI6_5(%rip), %xmm0
	addsd	%xmm1, %xmm0
	subsd	8(%rsp), %xmm0                  # 8-byte Folded Reload
	movl	$.L.str.4, %edi
	movsd	%xmm0, 16(%rsp)                 # 8-byte Spill
	movb	$1, %al
	callq	printf
	leaq	72(%rsp), %r12
	movq	%r12, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	movq	(%r12), %rax
	movq	%rax, 64(%rsp)                  # 8-byte Spill
	xorps	%xmm0, %xmm0
	cvtsi2sdq	8(%r12), %xmm0
	mulsd	.LCPI6_5(%rip), %xmm0
	movsd	%xmm0, 8(%rsp)                  # 8-byte Spill
	movq	32(%rsp), %r12                  # 8-byte Reload
.LBB6_6:                                # =>This Inner Loop Header: Depth=1
	movsd	(%rbx,%rbp,8), %xmm0            # xmm0 = mem[0],zero
	movsd	(%r14,%rbp,8), %xmm1            # xmm1 = mem[0],zero
	movsd	.LCPI6_6(%rip), %xmm2           # xmm2 = mem[0],zero
	movsd	.LCPI6_7(%rip), %xmm3           # xmm3 = mem[0],zero
	movsd	.LCPI6_1(%rip), %xmm4           # xmm4 = mem[0],zero
	movl	$2048, %edi                     # imm = 0x800
	movq	%r12, %rsi
	callq	_Z8binomialdddddiPd
	movsd	%xmm0, (%r15,%rbp,8)
	incq	%rbp
	cmpq	$1024, %rbp                     # imm = 0x400
	jne	.LBB6_6
# %bb.7:
	xorps	%xmm0, %xmm0
	cvtsi2sdq	64(%rsp), %xmm0         # 8-byte Folded Reload
	movsd	8(%rsp), %xmm1                  # 8-byte Reload
                                        # xmm1 = mem[0],zero
	addsd	%xmm0, %xmm1
	movsd	%xmm1, 8(%rsp)                  # 8-byte Spill
	xorl	%ebp, %ebp
	leaq	72(%rsp), %r12
	movq	%r12, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	xorps	%xmm1, %xmm1
	cvtsi2sdq	(%r12), %xmm1
	xorps	%xmm0, %xmm0
	cvtsi2sdq	8(%r12), %xmm0
	mulsd	.LCPI6_5(%rip), %xmm0
	addsd	%xmm1, %xmm0
	subsd	8(%rsp), %xmm0                  # 8-byte Folded Reload
	movsd	%xmm0, 8(%rsp)                  # 8-byte Spill
	movl	$.L.str.5, %edi
	movb	$1, %al
	callq	printf
	movsd	8(%rsp), %xmm0                  # 8-byte Reload
                                        # xmm0 = mem[0],zero
	divsd	16(%rsp), %xmm0                 # 8-byte Folded Reload
	movl	$.L.str.6, %edi
	movb	$1, %al
	callq	printf
.LBB6_8:                                # =>This Inner Loop Header: Depth=1
	movsd	(%rbx,%rbp,8), %xmm0            # xmm0 = mem[0],zero
	movsd	(%r14,%rbp,8), %xmm1            # xmm1 = mem[0],zero
	movsd	.LCPI6_6(%rip), %xmm2           # xmm2 = mem[0],zero
	movsd	.LCPI6_7(%rip), %xmm3           # xmm3 = mem[0],zero
	movsd	.LCPI6_1(%rip), %xmm4           # xmm4 = mem[0],zero
	callq	_Z12BlackScholesddddd
	movsd	%xmm0, (%r13,%rbp,8)
	incq	%rbp
	cmpq	$1024, %rbp                     # imm = 0x400
	jne	.LBB6_8
# %bb.9:
	movl	$.Lstr.1, %edi
	callq	puts@PLT
	xorl	%esi, %esi
	movsd	.LCPI6_9(%rip), %xmm0           # xmm0 = mem[0],zero
	movq	40(%rsp), %r12                  # 8-byte Reload
.LBB6_10:                               # =>This Inner Loop Header: Depth=1
	movsd	(%r15,%rsi,8), %xmm2            # xmm2 = mem[0],zero
	movsd	(%r12,%rsi,8), %xmm3            # xmm3 = mem[0],zero
	movapd	%xmm2, %xmm1
	subsd	%xmm3, %xmm1
	andpd	.LCPI6_8(%rip), %xmm1
	ucomisd	%xmm0, %xmm1
	ja	.LBB6_18
# %bb.11:                               #   in Loop: Header=BB6_10 Depth=1
	incq	%rsi
	cmpq	$1024, %rsi                     # imm = 0x400
	jne	.LBB6_10
# %bb.12:
	movl	$.Lstr.2, %edi
	callq	puts@PLT
	movl	$.Lstr.3, %edi
	callq	puts@PLT
	movapd	.LCPI6_8(%rip), %xmm3           # xmm3 = [NaN,NaN]
	xorpd	%xmm0, %xmm0
	xorl	%eax, %eax
	xorpd	%xmm1, %xmm1
.LBB6_13:                               # =>This Inner Loop Header: Depth=1
	movsd	(%r15,%rax,8), %xmm2            # xmm2 = mem[0],zero
	addsd	%xmm2, %xmm1
	subsd	(%r13,%rax,8), %xmm2
	andpd	%xmm3, %xmm2
	addsd	%xmm2, %xmm0
	incq	%rax
	cmpq	$1024, %rax                     # imm = 0x400
	jne	.LBB6_13
# %bb.14:
	divsd	%xmm1, %xmm0
	ucomisd	.LCPI6_10(%rip), %xmm0
	ja	.LBB6_22
# %bb.15:
	movl	$.Lstr.4, %edi
	callq	puts@PLT
	movl	$.Lstr.5, %edi
	callq	puts@PLT
	xorl	%ebp, %ebp
.LBB6_16:                               # =>This Inner Loop Header: Depth=1
	movsd	(%rbx,%rbp,8), %xmm0            # xmm0 = mem[0],zero
	movsd	(%r14,%rbp,8), %xmm1            # xmm1 = mem[0],zero
	movsd	(%r12,%rbp,8), %xmm2            # xmm2 = mem[0],zero
	movsd	(%r15,%rbp,8), %xmm3            # xmm3 = mem[0],zero
	movsd	(%r13,%rbp,8), %xmm4            # xmm4 = mem[0],zero
	movl	$.L.str.15, %edi
	movb	$5, %al
	callq	printf
	incq	%rbp
	cmpq	$10, %rbp
	jne	.LBB6_16
# %bb.17:
	movq	%rbx, %rdi
	callq	free
	movq	%r14, %rdi
	callq	free
	movq	%r15, %rdi
	callq	free
	movq	%r12, %rdi
	callq	free
	movq	%r13, %rdi
	callq	free
	movq	32(%rsp), %rdi                  # 8-byte Reload
	callq	free
	movq	56(%rsp), %rdi
	callq	hipFree
	movq	48(%rsp), %rdi
	callq	hipFree
	movq	24(%rsp), %rdi
	callq	hipFree
	callq	hipDeviceReset
	xorl	%eax, %eax
	addq	$88, %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
.LBB6_18:
	.cfi_def_cfa_offset 144
	movsd	(%rbx,%rsi,8), %xmm0            # xmm0 = mem[0],zero
	movsd	(%r14,%rsi,8), %xmm1            # xmm1 = mem[0],zero
	movl	$.L.str.8, %edi
                                        # kill: def $esi killed $esi killed $rsi
	movb	$4, %al
	callq	printf
	movl	$.Lstr.7, %edi
.LBB6_19:
	callq	puts@PLT
.LBB6_20:
	movl	$-1, %edi
	callq	exit
.LBB6_21:
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.3, %edi
	movq	%rax, %rsi
	xorl	%eax, %eax
	callq	printf
	jmp	.LBB6_20
.LBB6_22:
	movl	$.Lstr.6, %edi
	jmp	.LBB6_19
.Lfunc_end6:
	.size	main, .Lfunc_end6-main
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	jne	.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	$_Z13binomialGPUv5PdS_S_ddd, %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	_Z13binomialGPUv5PdS_S_ddd,@object # @_Z13binomialGPUv5PdS_S_ddd
	.section	.rodata,"a",@progbits
	.globl	_Z13binomialGPUv5PdS_S_ddd
	.p2align	3, 0x0
_Z13binomialGPUv5PdS_S_ddd:
	.quad	_Z28__device_stub__binomialGPUv5PdS_S_ddd
	.size	_Z13binomialGPUv5PdS_S_ddd, 8

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"Depth of the tree NUM_STEPS = %d\n"
	.size	.L.str, 34

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"grid structure: <<<%d, %d>>>\n"
	.size	.L.str.1, 30

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"GPU code failed %s\n"
	.size	.L.str.3, 20

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"GPU code finished within %12.6f seconds\n"
	.size	.L.str.4, 41

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"CPU code finished within %12.6f seconds\n"
	.size	.L.str.5, 41

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"Speed up you got %8.2f\n"
	.size	.L.str.6, 24

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"%d %8.2f %8.2f %12.6f %12.6f \n"
	.size	.L.str.8, 31

	.type	.L.str.15,@object               # @.str.15
.L.str.15:
	.asciz	"%8.2f, %8.2f, %10.4f, %10.4f, %10.4f\n"
	.size	.L.str.15, 38

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z13binomialGPUv5PdS_S_ddd"
	.size	.L__unnamed_1, 27

	.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	"Starting the GPU code..."
	.size	.Lstr, 25

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"Compare the GPU and CPU binary model now..."
	.size	.Lstr.1, 44

	.type	.Lstr.2,@object                 # @str.2
.Lstr.2:
	.asciz	"passed comparison between GPU and CPU binomial model"
	.size	.Lstr.2, 53

	.type	.Lstr.3,@object                 # @str.3
.Lstr.3:
	.asciz	"Compare the binary model with Black-Scholes model now..."
	.size	.Lstr.3, 57

	.type	.Lstr.4,@object                 # @str.4
.Lstr.4:
	.asciz	"passed comparison between binomial and Black-Scholes model"
	.size	.Lstr.4, 59

	.type	.Lstr.5,@object                 # @str.5
.Lstr.5:
	.asciz	"Here are outputs for the first 10 lines"
	.size	.Lstr.5, 40

	.type	.Lstr.6,@object                 # @str.6
.Lstr.6:
	.asciz	"Black-Scholes VS Binomial comparison failed"
	.size	.Lstr.6, 44

	.type	.Lstr.7,@object                 # @str.7
.Lstr.7:
	.asciz	"comparion failed"
	.size	.Lstr.7, 17

	.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 _Z28__device_stub__binomialGPUv5PdS_S_ddd
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z13binomialGPUv5PdS_S_ddd
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z13binomialGPUv5PdS_S_ddd ; -- Begin function _Z13binomialGPUv5PdS_S_ddd
	.globl	_Z13binomialGPUv5PdS_S_ddd
	.p2align	8
	.type	_Z13binomialGPUv5PdS_S_ddd,@function
_Z13binomialGPUv5PdS_S_ddd:             ; @_Z13binomialGPUv5PdS_S_ddd
; %bb.0:
	s_clause 0x1
	s_load_b128 s[8:11], s[0:1], 0x20
	s_load_b256 s[0:7], s[0:1], 0x0
	s_mov_b32 s12, s15
	s_ashr_i32 s13, s15, 31
	s_mov_b32 s14, 0xfefa39ef
	s_mov_b32 s16, 0x3b39803f
	s_mov_b32 s18, 0xfca7ab0c
	s_mov_b32 s20, 0x6a5dcb37
	s_mov_b32 s22, 0x623fde64
	s_mov_b32 s24, 0x7c89e6b0
	s_mov_b32 s26, 0x14761f6e
	s_mov_b32 s28, 0x1852b7b0
	s_mov_b32 s30, 0x11122322
	s_mov_b32 s34, 0x555502a1
	s_mov_b32 s36, 0x55555511
	s_mov_b32 s38, 11
	s_mov_b32 s15, 0xbfe62e42
	s_mov_b32 s17, 0xbc7abc9e
	s_mov_b32 s19, 0x3e928af3
	s_mov_b32 s21, 0x3e5ade15
	s_waitcnt lgkmcnt(0)
	v_ldexp_f64 v[1:2], s[10:11], -11
	s_lshl_b64 s[10:11], s[12:13], 3
	s_mov_b32 s23, 0x3ec71dee
	s_add_u32 s0, s0, s10
	s_addc_u32 s1, s1, s11
	s_add_u32 s12, s2, s10
	s_addc_u32 s13, s3, s11
	s_mov_b32 s25, 0x3efa0199
	s_mov_b32 s27, 0x3f2a01a0
	s_mov_b32 s29, 0x3f56c16c
	s_mov_b32 s31, 0x3f811111
	s_mov_b32 s35, 0x3fa55555
	s_mov_b32 s37, 0x3fc55555
	s_mov_b32 s39, 0x3fe00000
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_3) | instid1(VALU_DEP_1)
	v_cmp_gt_f64_e32 vcc_lo, 0x10000000, v[1:2]
	v_cndmask_b32_e64 v3, 0, 1, vcc_lo
	s_and_b32 s2, vcc_lo, exec_lo
	s_cselect_b32 s2, 0xffffff80, 0
	v_lshlrev_b32_e32 v3, 8, v3
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ldexp_f64 v[3:4], v[1:2], v3
	v_rsq_f64_e32 v[5:6], v[3:4]
	v_cmp_class_f64_e64 vcc_lo, v[3:4], 0x260
	s_waitcnt_depctr 0xfff
	v_mul_f64 v[7:8], v[3:4], v[5:6]
	v_mul_f64 v[5:6], v[5:6], 0.5
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[9:10], -v[5:6], v[7:8], 0.5
	v_fma_f64 v[7:8], v[7:8], v[9:10], v[7:8]
	v_fma_f64 v[5:6], v[5:6], v[9:10], v[5:6]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[9:10], -v[7:8], v[7:8], v[3:4]
	v_fma_f64 v[7:8], v[9:10], v[5:6], v[7:8]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[9:10], -v[7:8], v[7:8], v[3:4]
	v_fma_f64 v[5:6], v[9:10], v[5:6], v[7:8]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ldexp_f64 v[5:6], v[5:6], s2
	v_dual_cndmask_b32 v4, v6, v4 :: v_dual_cndmask_b32 v3, v5, v3
	v_lshl_add_u32 v5, v0, 5, 0xfffff800
	s_delay_alu instid0(VALU_DEP_2)
	v_mul_f64 v[3:4], v[3:4], s[8:9]
	s_load_b64 s[2:3], s[0:1], 0x0
	s_load_b64 s[8:9], s[12:13], 0x0
	s_mov_b32 s12, 0x652b82fe
	s_mov_b32 s13, 0x3ff71547
	s_mov_b32 s1, 0
.LBB0_1:                                ; =>This Inner Loop Header: Depth=1
	v_cvt_f64_i32_e32 v[6:7], v5
	v_add_nc_u32_e32 v5, 2, v5
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_f64 v[6:7], v[3:4], v[6:7]
	v_mul_f64 v[8:9], v[6:7], s[12:13]
	v_cmp_nlt_f64_e32 vcc_lo, 0x40900000, v[6:7]
	v_cmp_ngt_f64_e64 s0, 0xc090cc00, v[6:7]
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_rndne_f64_e32 v[8:9], v[8:9]
	v_fma_f64 v[10:11], v[8:9], s[14:15], v[6:7]
	v_cvt_i32_f64_e32 v14, v[8:9]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[10:11], v[8:9], s[16:17], v[10:11]
	v_fma_f64 v[12:13], v[10:11], s[20:21], s[18:19]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[12:13], v[10:11], v[12:13], s[22:23]
	v_fma_f64 v[12:13], v[10:11], v[12:13], s[24:25]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[12:13], v[10:11], v[12:13], s[26:27]
	v_fma_f64 v[12:13], v[10:11], v[12:13], s[28:29]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[12:13], v[10:11], v[12:13], s[30:31]
	v_fma_f64 v[12:13], v[10:11], v[12:13], s[34:35]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[12:13], v[10:11], v[12:13], s[36:37]
	v_fma_f64 v[12:13], v[10:11], v[12:13], s[38:39]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[12:13], v[10:11], v[12:13], 1.0
	v_fma_f64 v[8:9], v[10:11], v[12:13], 1.0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ldexp_f64 v[8:9], v[8:9], v14
	v_cndmask_b32_e32 v9, 0x7ff00000, v9, vcc_lo
	s_and_b32 vcc_lo, s0, vcc_lo
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_cndmask_b32_e32 v6, 0, v8, vcc_lo
	v_cndmask_b32_e64 v7, 0, v9, s0
	s_add_i32 s0, s1, 16
	s_add_i32 s1, s1, 8
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	s_cmpk_lg_i32 s1, 0x80
	s_waitcnt lgkmcnt(0)
	v_fma_f64 v[6:7], s[2:3], v[6:7], -s[8:9]
	v_max_f64 v[6:7], v[6:7], 0
	scratch_store_b64 off, v[6:7], s0
	s_cbranch_scc1 .LBB0_1
; %bb.2:
	s_mov_b32 s1, exec_lo
	v_cmpx_eq_u32_e32 0x7f, v0
	s_cbranch_execz .LBB0_4
; %bb.3:
	v_ldexp_f64 v[5:6], v[3:4], 11
	s_mov_b32 s12, 0x652b82fe
	s_mov_b32 s13, 0x3ff71547
	s_mov_b32 s14, 0x6a5dcb37
	s_mov_b32 s15, 0x3e5ade15
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_4) | instid1(VALU_DEP_3)
	v_mul_f64 v[7:8], v[5:6], s[12:13]
	s_mov_b32 s12, 0xfefa39ef
	s_mov_b32 s13, 0xbfe62e42
	v_cmp_nlt_f64_e32 vcc_lo, 0x40900000, v[5:6]
	v_cmp_ngt_f64_e64 s0, 0xc090cc00, v[5:6]
	v_rndne_f64_e32 v[7:8], v[7:8]
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_3) | instid1(VALU_DEP_2)
	v_fma_f64 v[9:10], v[7:8], s[12:13], v[5:6]
	s_mov_b32 s12, 0x3b39803f
	s_mov_b32 s13, 0xbc7abc9e
	v_cvt_i32_f64_e32 v13, v[7:8]
	v_fma_f64 v[9:10], v[7:8], s[12:13], v[9:10]
	s_mov_b32 s12, 0xfca7ab0c
	s_mov_b32 s13, 0x3e928af3
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	v_fma_f64 v[11:12], v[9:10], s[14:15], s[12:13]
	s_mov_b32 s12, 0x623fde64
	s_mov_b32 s13, 0x3ec71dee
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	v_fma_f64 v[11:12], v[9:10], v[11:12], s[12:13]
	s_mov_b32 s12, 0x7c89e6b0
	s_mov_b32 s13, 0x3efa0199
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	v_fma_f64 v[11:12], v[9:10], v[11:12], s[12:13]
	s_mov_b32 s12, 0x14761f6e
	s_mov_b32 s13, 0x3f2a01a0
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	v_fma_f64 v[11:12], v[9:10], v[11:12], s[12:13]
	s_mov_b32 s12, 0x1852b7b0
	s_mov_b32 s13, 0x3f56c16c
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	v_fma_f64 v[11:12], v[9:10], v[11:12], s[12:13]
	s_mov_b32 s12, 0x11122322
	s_mov_b32 s13, 0x3f811111
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	v_fma_f64 v[11:12], v[9:10], v[11:12], s[12:13]
	s_mov_b32 s12, 0x555502a1
	s_mov_b32 s13, 0x3fa55555
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	v_fma_f64 v[11:12], v[9:10], v[11:12], s[12:13]
	s_mov_b32 s12, 0x55555511
	s_mov_b32 s13, 0x3fc55555
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	v_fma_f64 v[11:12], v[9:10], v[11:12], s[12:13]
	s_mov_b32 s12, 11
	s_mov_b32 s13, 0x3fe00000
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	v_fma_f64 v[11:12], v[9:10], v[11:12], s[12:13]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[11:12], v[9:10], v[11:12], 1.0
	v_fma_f64 v[7:8], v[9:10], v[11:12], 1.0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ldexp_f64 v[7:8], v[7:8], v13
	v_cndmask_b32_e32 v8, 0x7ff00000, v8, vcc_lo
	s_and_b32 vcc_lo, s0, vcc_lo
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_3)
	v_cndmask_b32_e32 v5, 0, v7, vcc_lo
	v_mov_b32_e32 v7, 0
	v_cndmask_b32_e64 v6, 0, v8, s0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[5:6], v[5:6], s[2:3], -s[8:9]
	v_max_f64 v[5:6], v[5:6], 0
	ds_store_b64 v7, v[5:6] offset:1024
.LBB0_4:
	s_or_b32 exec_lo, exec_lo, s1
	scratch_load_b64 v[5:6], off, off offset:16
	v_lshlrev_b32_e32 v9, 3, v0
	s_mov_b32 s8, exec_lo
	s_waitcnt vmcnt(0)
	ds_store_b64 v9, v[5:6]
	s_waitcnt lgkmcnt(0)
	s_waitcnt_vscnt null, 0x0
	s_barrier
	buffer_gl0_inv
	ds_load_b64 v[5:6], v9 offset:8
	s_waitcnt lgkmcnt(0)
	scratch_store_b64 off, v[5:6], off offset:144
	s_waitcnt_vscnt null, 0x0
	s_barrier
	buffer_gl0_inv
	v_cmpx_gt_u32_e32 0x80, v0
	s_cbranch_execz .LBB0_9
; %bb.5:                                ; %.preheader.preheader
	s_mov_b32 s0, 0x652b82fe
	s_mov_b32 s1, 0x3ff71547
	s_mov_b32 s2, 0xfefa39ef
	v_mul_f64 v[5:6], v[3:4], s[0:1]
	s_mov_b32 s3, 0xbfe62e42
	s_mov_b32 s12, 0x3b39803f
	s_mov_b32 s13, 0xbc7abc9e
	s_mov_b32 s14, 0xfca7ab0c
	s_mov_b32 s16, 0x6a5dcb37
	s_mov_b32 s15, 0x3e928af3
	s_mov_b32 s17, 0x3e5ade15
	s_mov_b32 s18, 0x623fde64
	s_mov_b32 s19, 0x3ec71dee
	s_mov_b32 s20, 0x7c89e6b0
	s_mov_b32 s21, 0x3efa0199
	s_mov_b32 s22, 0x14761f6e
	s_mov_b32 s23, 0x3f2a01a0
	s_mov_b32 s24, 0x1852b7b0
	s_mov_b32 s25, 0x3f56c16c
	v_mul_f64 v[1:2], v[1:2], s[6:7]
	s_mov_b32 s26, 0x11122322
	s_mov_b32 s27, 0x3f811111
	s_mov_b32 s6, 0x555502a1
	s_mov_b32 s7, 0x3fa55555
	s_mov_b32 s28, 0x55555511
	s_mov_b32 s29, 0x3fc55555
	s_mov_b32 s30, 11
	s_mov_b32 s31, 0x3fe00000
	v_cmp_nlt_f64_e32 vcc_lo, 0x40900000, v[3:4]
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_rndne_f64_e32 v[5:6], v[5:6]
	v_mul_f64 v[12:13], v[1:2], s[0:1]
	v_cmp_ngt_f64_e64 s0, 0xc090cc00, v[3:4]
	s_mov_b32 s1, 0
	s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_1) | instid1(VALU_DEP_4)
	v_fma_f64 v[7:8], v[5:6], s[2:3], v[3:4]
	v_cvt_i32_f64_e32 v18, v[5:6]
	v_rndne_f64_e32 v[12:13], v[12:13]
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_fma_f64 v[7:8], v[5:6], s[12:13], v[7:8]
	v_fma_f64 v[14:15], v[12:13], s[2:3], v[1:2]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_fma_f64 v[10:11], v[7:8], s[16:17], s[14:15]
	v_fma_f64 v[14:15], v[12:13], s[12:13], v[14:15]
	v_cvt_i32_f64_e32 v12, v[12:13]
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_fma_f64 v[10:11], v[7:8], v[10:11], s[18:19]
	v_fma_f64 v[16:17], v[14:15], s[16:17], s[14:15]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[10:11], v[7:8], v[10:11], s[20:21]
	v_fma_f64 v[10:11], v[7:8], v[10:11], s[22:23]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[10:11], v[7:8], v[10:11], s[24:25]
	v_fma_f64 v[10:11], v[7:8], v[10:11], s[26:27]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[10:11], v[7:8], v[10:11], s[6:7]
	v_fma_f64 v[10:11], v[7:8], v[10:11], s[28:29]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[10:11], v[7:8], v[10:11], s[30:31]
	v_fma_f64 v[10:11], v[7:8], v[10:11], 1.0
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_fma_f64 v[5:6], v[7:8], v[10:11], 1.0
	v_fma_f64 v[7:8], v[14:15], v[16:17], s[18:19]
	v_ldexp_f64 v[5:6], v[5:6], v18
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_fma_f64 v[7:8], v[14:15], v[7:8], s[20:21]
	v_cndmask_b32_e32 v6, 0x7ff00000, v6, vcc_lo
	s_and_b32 vcc_lo, s0, vcc_lo
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_fma_f64 v[3:4], v[14:15], v[7:8], s[22:23]
	v_cndmask_b32_e32 v5, 0, v5, vcc_lo
	s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_cndmask_b32_e64 v6, 0, v6, s0
	v_cmp_ngt_f64_e64 s0, 0xc090cc00, v[1:2]
	v_div_scale_f64 v[7:8], null, v[5:6], v[5:6], 1.0
	v_div_scale_f64 v[18:19], vcc_lo, 1.0, v[5:6], 1.0
	v_fma_f64 v[3:4], v[14:15], v[3:4], s[24:25]
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_rcp_f64_e32 v[10:11], v[7:8]
	v_fma_f64 v[3:4], v[14:15], v[3:4], s[26:27]
	s_waitcnt_depctr 0xfff
	v_fma_f64 v[16:17], -v[7:8], v[10:11], 1.0
	v_fma_f64 v[3:4], v[14:15], v[3:4], s[6:7]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_fma_f64 v[10:11], v[10:11], v[16:17], v[10:11]
	v_fma_f64 v[3:4], v[14:15], v[3:4], s[28:29]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_fma_f64 v[16:17], -v[7:8], v[10:11], 1.0
	v_fma_f64 v[3:4], v[14:15], v[3:4], s[30:31]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_fma_f64 v[10:11], v[10:11], v[16:17], v[10:11]
	v_fma_f64 v[3:4], v[14:15], v[3:4], 1.0
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_mul_f64 v[16:17], v[18:19], v[10:11]
	v_fma_f64 v[3:4], v[14:15], v[3:4], 1.0
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_fma_f64 v[7:8], -v[7:8], v[16:17], v[18:19]
	v_ldexp_f64 v[3:4], v[3:4], v12
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_div_fmas_f64 v[7:8], v[7:8], v[10:11], v[16:17]
	v_cmp_nlt_f64_e32 vcc_lo, 0x40900000, v[1:2]
	v_div_fixup_f64 v[1:2], v[7:8], v[5:6], 1.0
	s_delay_alu instid0(VALU_DEP_4) | instskip(SKIP_2) | instid1(VALU_DEP_2)
	v_cndmask_b32_e32 v4, 0x7ff00000, v4, vcc_lo
	s_and_b32 vcc_lo, s0, vcc_lo
	v_cndmask_b32_e32 v3, 0, v3, vcc_lo
	v_cndmask_b32_e64 v4, 0, v4, s0
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_3)
	v_div_scale_f64 v[10:11], null, v[3:4], v[3:4], 1.0
	v_add_f64 v[7:8], v[3:4], -v[1:2]
	v_add_f64 v[1:2], v[5:6], -v[1:2]
	v_rcp_f64_e32 v[14:15], v[10:11]
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_3) | instid1(VALU_DEP_1)
	v_div_scale_f64 v[5:6], null, v[1:2], v[1:2], v[7:8]
	s_waitcnt_depctr 0xfff
	v_fma_f64 v[18:19], -v[10:11], v[14:15], 1.0
	v_rcp_f64_e32 v[12:13], v[5:6]
	v_fma_f64 v[14:15], v[14:15], v[18:19], v[14:15]
	s_waitcnt_depctr 0xfff
	v_fma_f64 v[16:17], -v[5:6], v[12:13], 1.0
	v_fma_f64 v[18:19], -v[10:11], v[14:15], 1.0
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_fma_f64 v[12:13], v[12:13], v[16:17], v[12:13]
	v_fma_f64 v[14:15], v[14:15], v[18:19], v[14:15]
	v_div_scale_f64 v[18:19], s0, 1.0, v[3:4], 1.0
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_fma_f64 v[16:17], -v[5:6], v[12:13], 1.0
	v_mul_f64 v[22:23], v[18:19], v[14:15]
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_3)
	v_fma_f64 v[12:13], v[12:13], v[16:17], v[12:13]
	v_div_scale_f64 v[16:17], vcc_lo, v[7:8], v[1:2], v[7:8]
	v_fma_f64 v[10:11], -v[10:11], v[22:23], v[18:19]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_f64 v[20:21], v[16:17], v[12:13]
	v_fma_f64 v[5:6], -v[5:6], v[20:21], v[16:17]
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_4)
	v_div_fmas_f64 v[5:6], v[5:6], v[12:13], v[20:21]
	s_mov_b32 vcc_lo, s0
	s_mov_b32 s0, 0
	v_div_fmas_f64 v[10:11], v[10:11], v[14:15], v[22:23]
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_3)
	v_div_fixup_f64 v[1:2], v[5:6], v[1:2], v[7:8]
	v_lshlrev_b32_e32 v7, 4, v0
	v_div_fixup_f64 v[3:4], v[10:11], v[3:4], 1.0
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_sub_nc_u32_e32 v10, 0x800, v7
	v_add_f64 v[5:6], -v[1:2], 1.0
.LBB0_6:                                ; %.preheader
                                        ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_7 Depth 2
	scratch_load_b64 v[7:8], off, off offset:16
	s_mov_b32 s2, 0
.LBB0_7:                                ;   Parent Loop BB0_6 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_2) | instid1(SALU_CYCLE_1)
	v_add_nc_u32_e64 v11, s2, 16
	s_add_i32 s3, s2, 16
	s_add_i32 s2, s2, 8
	s_cmpk_lg_i32 s2, 0x80
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_3) | instid1(VALU_DEP_1)
	v_add_nc_u32_e32 v11, 8, v11
	scratch_load_b64 v[11:12], v11, off
	s_waitcnt vmcnt(0)
	v_mul_f64 v[13:14], v[1:2], v[11:12]
	v_fma_f64 v[7:8], v[5:6], v[7:8], v[13:14]
	s_delay_alu instid0(VALU_DEP_1)
	v_mul_f64 v[13:14], v[3:4], v[7:8]
	v_dual_mov_b32 v7, v11 :: v_dual_mov_b32 v8, v12
	scratch_store_b64 off, v[13:14], s3
	s_cbranch_scc1 .LBB0_7
; %bb.8:                                ;   in Loop: Header=BB0_6 Depth=1
	scratch_load_b64 v[7:8], off, off offset:16
	s_add_i32 s1, s1, 1
	s_delay_alu instid0(SALU_CYCLE_1)
	v_cmp_ge_i32_e32 vcc_lo, s1, v10
	s_or_b32 s0, vcc_lo, s0
	s_waitcnt vmcnt(0)
	ds_store_b64 v9, v[7:8]
	s_waitcnt lgkmcnt(0)
	s_waitcnt_vscnt null, 0x0
	s_barrier
	buffer_gl0_inv
	ds_load_b64 v[7:8], v9 offset:8
	s_waitcnt lgkmcnt(0)
	scratch_store_b64 off, v[7:8], off offset:144
	s_waitcnt_vscnt null, 0x0
	s_barrier
	buffer_gl0_inv
	s_and_not1_b32 exec_lo, exec_lo, s0
	s_cbranch_execnz .LBB0_6
.LBB0_9:                                ; %Flow88
	s_or_b32 exec_lo, exec_lo, s8
	s_delay_alu instid0(SALU_CYCLE_1)
	s_mov_b32 s0, exec_lo
	v_cmpx_eq_u32_e32 0, v0
	s_cbranch_execz .LBB0_11
; %bb.10:
	scratch_load_b64 v[0:1], off, off offset:16
	v_mov_b32_e32 v2, 0
	s_add_u32 s0, s4, s10
	s_addc_u32 s1, s5, s11
	s_waitcnt vmcnt(0)
	global_store_b64 v2, v[0:1], s[0:1]
.LBB0_11:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z13binomialGPUv5PdS_S_ddd
		.amdhsa_group_segment_fixed_size 1032
		.amdhsa_private_segment_fixed_size 160
		.amdhsa_kernarg_size 48
		.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 1
		.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 24
		.amdhsa_next_free_sgpr 40
		.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	_Z13binomialGPUv5PdS_S_ddd, .Lfunc_end0-_Z13binomialGPUv5PdS_S_ddd
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 2600
; NumSgprs: 42
; NumVgprs: 24
; ScratchSize: 160
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 1032 bytes/workgroup (compile time only)
; SGPRBlocks: 5
; VGPRBlocks: 2
; NumSGPRsForWavesPerEU: 42
; NumVGPRsForWavesPerEU: 24
; Occupancy: 16
; WaveLimiterHint : 1
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 1
; 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
      - .address_space:  global
        .offset:         16
        .size:           8
        .value_kind:     global_buffer
      - .offset:         24
        .size:           8
        .value_kind:     by_value
      - .offset:         32
        .size:           8
        .value_kind:     by_value
      - .offset:         40
        .size:           8
        .value_kind:     by_value
    .group_segment_fixed_size: 1032
    .kernarg_segment_align: 8
    .kernarg_segment_size: 48
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z13binomialGPUv5PdS_S_ddd
    .private_segment_fixed_size: 160
    .sgpr_count:     42
    .sgpr_spill_count: 0
    .symbol:         _Z13binomialGPUv5PdS_S_ddd.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     24
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
