#include "MuonSimu.cuh"

__global__ void
evt_calculate_add(int *evt_res_list,int *evt_res_back,int evtnum,int pmtnum)
{
    int id = blockIdx.x*blockDim.x+threadIdx.x;   
    // int evt_res_by_pmt = 0;
    if (id < evtnum) // The number of threads can't exceed the number of event
    {
        for(int i=0; i<pmtnum; i++) // i represent pmtid , id represent evtid
        {
            evt_res_back[id] += evt_res_list[id+i*evtnum];
           
        }
        printf("thread = %d,evt_res_back=%d\n",id,evt_res_back[id]);
        // evt_res_back[id] = evt_res_by_pmt;//return the result 

    }
}

__global__ void
step_calculate_every_pmt(double *r,double *pos_x,double *pos_y,double *pos_z,double *pmt_x,\
    double *pmt_y,double *pmt_z,double *intPart,double *fractionPart,double *start_time, int *evt_id,\
    int numElements,int evtnum,double *hittime_histo,double *npe,int *seed,double *result, \
    int *pmt_res_list,int *evt_res_list,int size)
{
    int id = blockIdx.x*blockDim.x+threadIdx.x;
    //numElements = pmt numbers
    if (id < numElements){
        curandState state;
        generateRandomInit(&state,seed[id]);
        // generateRandomInit(&state,seed);
        Res_Arr pmt_arr;
        init_res_arr(&pmt_arr,result,pmt_res_list,evt_res_list,id,size,evtnum);
        

        for(int i=0;i<size;i++)
        {
            // int index = i*numElements+id;
            calculate_by_step(r[i],pos_x[i],pos_y[i],pos_z[i],pmt_x[id],pmt_y[id],\
                pmt_z[id],intPart[i],fractionPart[i],start_time[i],evt_id[i],hittime_histo,\
                npe,&state,&pmt_arr,evt_res_list);
            // (int*)(evt_res_list+id*evtnum)
        }
        
    }
}

__device__ void
calculate_by_step(double r,double pos_x,double pos_y,double pos_z,double pmt_x,double pmt_y,\
    double pmt_z,double intPart,double fractionPart,double start_time,int evt_id,double *hittime_histo,\
    double *npe,curandState *state,Res_Arr *p_pmt_arr,int *evt_res_list)
{
    double theta = calculateAngle(pmt_x,pmt_y,pmt_z,pos_x,pos_y,pos_z);
    for(int j = 0;j<intPart; ++j){
        //r(m)
        generateHits(r,theta,1,start_time,evt_id,hittime_histo,npe,state,p_pmt_arr,evt_res_list);
    }
    generateHits(r,theta,fractionPart,start_time,evt_id,hittime_histo,npe,state,p_pmt_arr,evt_res_list);
}

__device__ double
calculateAngle(double x,double y,double z,double a,double b,double c)
{
    //  printf("x=%lf,y=%lf,z=%lf,a=%lf,b=%lf,c=%lf\n",x,y,z,a,b,c);
    double result = 0;
    if (a == 0 and b == 0 and c == 0){
        return result;
    }
    else{
        result = acos((a*x+b*y+c*z)/(norm3d(x,y,z)*norm3d(a,b,c)));
        //printf("result theta = %lf",result);
        return result;
    }
}

__device__ void 
generateHits(double r,double theta, double ratio,double start_time,int evt_id,double *hittime_histo,\
    double *npe,curandState *state,Res_Arr *p_r_arr,int *evt_res_list)
{
    
    int npe_histo_id = get_npe(r,theta,npe,state);
    if (npe_histo_id>0)
    {
        for (int hitj = 0; hitj < npe_histo_id; ++hitj) 
        {
            // skip the photon according to the energy deposit
            if (ratio<1 and generateRandom(state)>ratio)
            {
                continue;
            }
            double hittime_single = start_time;
            // (m_flag_time) 
            hittime_single += (double)get_hittime(r, theta, 0, hittime_histo, state);
            // printf("hittime = %lf\n",hittime_single);
            // generated hit
            // (m_flag_savehits) 
            append_res_arr(p_r_arr,hittime_single);
            add_evt_arr(p_r_arr,evt_id);
            // save_hits(pmtid, hittime_single,result);
        }
    }
}

__device__ int
get_hittime(double r, double theta, int mode, double *hittime_histo, curandState *state) {
    int binx = get_bin_x(r);
    int biny = get_bin_y(theta);
    
    return get_hittime_bin(binx, biny, mode, hittime_histo, state);
}

__device__ int 
get_hittime_bin(int binx, int biny, int mode, double *hittime_histo, curandState *state) {
    // hit time = tmean + tres
    int hittime_single = 0;
    if (mode == 0) {
        hittime_single = get_hittime_all(binx,biny,hittime_histo,state);
    }
    return hittime_single;
}

__device__ int 
get_hittime_all(int binx, int biny,double *hittime_histo, curandState *state) {
    // TH1F* h = get_hist(binx, biny);
    const int xbinnum = 200;
    const int ybinnum = 180;
    if (binx<1) { binx = 1; }
    else if (binx > xbinnum) { binx = xbinnum;}
    if (biny<1) { biny = 1; }
    else if (biny > ybinnum) { biny = ybinnum;}
    int idx = (binx-1)*ybinnum+(biny-1);
    int hittime_single = sampling(state,hittime_histo,3000,idx);
    return hittime_single;
}


__device__ int 
get_bin_x(double r) 
{
    int binx = 1;
    int xmode = 2;
    if (xmode == 2) //KR
    {
        binx = r_findBin(r);
    } 
    return binx;
}

__device__ int 
get_bin_y(double theta) {
    int biny = 1;
    int ymode = 4;
    if (ymode == 4) {
        biny = theta_findBin(theta);
    }
    return biny;
}

__device__ int 
r_findBin(double r)
{
    const int binnum = 200;
    const double begin = 0;
    const double end = 17.7;
    if(r==0){
        return 1;
    }
    else{
        return (int)ceil((r-begin)/(end-begin)*binnum); 
    }
}

__device__ int 
get_npe(double r,double theta,double *npe,curandState *state)
{
    int binx = r3_findBin(pow(r,3));
    int biny = theta_findBin(theta);
    // printf("[npe] r=%lf,theta=%lf,binx=%d,biny=%d\n",r,theta,binx,biny);
    return get_npe_num(binx,biny,npe,state);
}

__device__ int 
r3_findBin(double r3)
{
    const int binnum = 100;
    const double begin = 0;
    const double end = 5600;
    if(r3 == 0){
        return 1;
    }
    else{
        return (int)ceil((r3-begin)/(end-begin)*binnum);
    }
}


__device__ int 
theta_findBin(double theta)
{
    const int binnum = 180;
    const double begin = 0; 
    const double end = 180.01*CUDART_PI_F/180.0;
    if(theta == 0){
        
        return 1;
    }
    else{
        return (int)ceil((theta-begin)/(end-begin)*binnum);
    }
}

__device__ int 
get_npe_num(int binx,int biny,double *npe,curandState *state)
{
    int npe_from_single = 0;
    if (1 <= binx and binx <= 100 and 1 <= biny and biny <= 180) {
        npe_from_single = sampling(state,npe,33,(binx-1)*180+(biny-1));	
    } else if (binx==1 and (biny<1 or biny>180)) {
        biny = generateRandomInt(state,1,180);
        npe_from_single = sampling(state,npe,33,(binx-1)*180+(biny-1));	
    } else if (binx>1 and (biny<1 or biny>180)) {
        if (biny>180) { biny = 180; }
        else if (biny<1){ biny = 1; }
        npe_from_single = sampling(state,npe,33,(binx-1)*180+(biny-1));
    } else {
        static long warning = 0;
        ++warning;
        if (warning < 10) {
            printf("npe lost: %d/%d\n", binx,biny);
        } else if (warning == 10) {
            printf("too many npe lost complains.\n");
        }
    }
    return npe_from_single;
}

__device__ double
generateRandom(curandState *state)
{
    // int id = blockIdx.x*blockDim.x+threadIdx.x;   
    double result = abs(curand_uniform_double(state));
    return result;
}

__device__ int
generateRandomInt(curandState *state,int begin,int end)
{
    int result = begin+int(ceil(abs(curand_uniform_double(state))*(end-begin)));
    return result;
}

__device__ void
generateRandomInit(curandState *state,int seed)
{
    // printf("seed = %d\n",seed);
    int id = blockIdx.x*blockDim.x+threadIdx.x;   
    curand_init(seed, id, 0, state);
}

__device__ int 
sampling(curandState *state,double *histo,int max,int id)
{
    double prob; 
    prob = generateRandom(state);
    return binarySearch(histo,prob,max,id);
}

__device__ int
binarySearch(double *histo,double target,int max,int id)
{
    int start = 0;
    int end = max-1;
    int mid;
    while(start+1<end){
        mid = start+(end-start)/2;
        if (histo[id*max+mid]==target){
            end = mid;
        } 
        else if (histo[id*max+mid] < target){
            start = mid;
        }
        else if (histo[id*max+mid] > target){
            end = mid;
        }
    }
    if (target <= histo[id*max+start]){
        return start;
    }
    else if (histo[id*max+start] < target){
        return end;
    }
    
    return -1;
}

__device__ void
append_res_arr(Res_Arr *p, double val)//追加，可能成功，可能失败
{
    p->arr[p->index+p->pmt_list[p->id]] = val;
    p->pmt_list[p->id] += 1;
    if(p->pmt_list[p->id]>p->max){
        printf("error! out of memory for result!\n");
        assert(p->pmt_list[p->id]<=p->max);
    }

    return;

}

__device__ void 
add_evt_arr(Res_Arr *p,int evtid)
{
    p->evt_res[evtid+p->id*p->evt_num] +=1;
    return;
}

__device__ void
init_res_arr(Res_Arr *p,double *result,int *pmt_res_list,int *evt_res_list,int pmtid,int size,int evt_num){
    p->arr = result;//存储的内存空间
    p->evt_res = evt_res_list;//totalPE by event
    p->pmt_list = pmt_res_list;//存储每个pmt内存空间使用量
    p->index = pmtid*pmt_mem;//存储该pmt在数组中的起始存取点
    p->id = pmtid;
    p->max = pmt_mem;
    p->evt_num = evt_num;
    return;
}

inline void __cudaCheckError( const char *file, const int line )
{
#ifdef CUDA_ERROR_CHECK
    cudaError err = cudaGetLastError();
    if ( cudaSuccess != err )
    {
        fprintf( stderr, "cudaCheckError() failed at %s:%i : %s\n",
                 file, line, cudaGetErrorString( err ) );
        exit( -1 );
    }
    // Catch errors from CUDA kernel calls
    // More careful checking. However, this will affect performance.
    // Comment away if needed.
    // err = cudaDeviceSynchronize();
    // if( cudaSuccess != err )
    // {
    //     fprintf( stderr, "cudaCheckError() with sync failed at %s:%i : %s\n",
    //              file, line, cudaGetErrorString( err ) );
    //     exit( -1 );
    // }
#endif

    return;
}

float GPU_Sampling_wrapper(double *r,double *pos_x,double *pos_y,double *pos_z, \
    double *intPart, double *fractionPart,double *start_time,int *evt_id,int evtnum,double *pmt_x,double *pmt_y,\
    double *pmt_z,double *data_hit,double *data_npe,int *seed,int *size,double* h_result,int *h_evt_res_list)
{
    //debug
    // size_t psize = 0;
    // cudaDeviceGetLimit(&psize,cudaLimitPrintfFifoSize);
    
    //GPU计时，设置开始和结束事件
    cudaEvent_t start, stop;
    cudaEvent_t gpu_start,gpu_stop,data_start,data_stop;
    CHECK(cudaEventCreate(&start));
    CHECK(cudaEventCreate(&stop));
    CHECK(cudaEventCreate(&gpu_start));
    CHECK(cudaEventCreate(&gpu_stop));
    CHECK(cudaEventCreate(&data_start));
    CHECK(cudaEventCreate(&data_stop));
    CHECK(cudaEventRecord(start));
    CHECK(cudaEventRecord(data_start));
    //申请GPU内存
    double *d_r, *d_pos_x,*d_pos_y,*d_pos_z,*d_intPart,*d_fractionPart,*d_start_time;
    double *d_pmt_x,*d_pmt_y,*d_pmt_z,*d_data_hit,*d_data_npe;
    double *d_result;
    int *d_seed,*d_pmt_res_list,*d_evt_id,*d_evt_res_list,*d_evt_res_back;

    int *h_pmt_res_list = (int*)malloc(pmt_num*sizeof(int));
    CHECK(cudaMalloc((double**)&d_r,size[0]));
    CHECK(cudaMalloc((double**)&d_pos_x,size[0]));
    CHECK(cudaMalloc((double**)&d_pos_y,size[0]));
    CHECK(cudaMalloc((double**)&d_pos_z,size[0]));
    CHECK(cudaMalloc((double**)&d_intPart,size[0]));
    CHECK(cudaMalloc((double**)&d_fractionPart,size[0]));
    CHECK(cudaMalloc((double**)&d_start_time,size[0]));
    CHECK(cudaMalloc((int**)&d_evt_id,size[0]/2));
    CHECK(cudaMalloc((double**)&d_pmt_x,size[1]));
    CHECK(cudaMalloc((double**)&d_pmt_y,size[1]));
    CHECK(cudaMalloc((double**)&d_pmt_z,size[1]));
    CHECK(cudaMalloc((double**)&d_data_hit,size[2]));
    CHECK(cudaMalloc((double**)&d_data_npe,size[3]));
    CHECK(cudaMalloc((int**)&d_seed,size[4]));
    CHECK(cudaMalloc((double**)&d_result,pmt_num*pmt_mem*sizeof(double)));
    CHECK(cudaMalloc((int**)&d_pmt_res_list,pmt_num*sizeof(int)));
    CHECK(cudaMalloc((int**)&d_evt_res_list,evtnum*pmt_num*sizeof(int)));
    CHECK(cudaMalloc((int**)&d_evt_res_back,evtnum*sizeof(int)));

    //设置内存
    CHECK(cudaMemset(d_pmt_res_list,0,pmt_num*sizeof(int)));
    CHECK(cudaMemset(d_evt_res_list,0,evtnum*pmt_num*sizeof(int)));
    CHECK(cudaMemset(d_evt_res_back,0,evtnum*sizeof(int)));
    CHECK(cudaMemset(d_result,0,pmt_num*pmt_mem*sizeof(double)));
    //将CPU内存拷贝到GPU
    CHECK(cudaMemcpy(d_r, r, size[0], cudaMemcpyHostToDevice));
    CHECK(cudaMemcpy(d_pos_x, pos_x, size[0], cudaMemcpyHostToDevice));
    CHECK(cudaMemcpy(d_pos_y, pos_y, size[0], cudaMemcpyHostToDevice));
    CHECK(cudaMemcpy(d_pos_z, pos_z, size[0], cudaMemcpyHostToDevice));
    CHECK(cudaMemcpy(d_intPart, intPart, size[0], cudaMemcpyHostToDevice));
    CHECK(cudaMemcpy(d_fractionPart, fractionPart, size[0], cudaMemcpyHostToDevice));
    CHECK(cudaMemcpy(d_start_time, start_time, size[0], cudaMemcpyHostToDevice));
    CHECK(cudaMemcpy(d_pmt_x, pmt_x, size[1], cudaMemcpyHostToDevice));
    CHECK(cudaMemcpy(d_pmt_y, pmt_y, size[1], cudaMemcpyHostToDevice));
    CHECK(cudaMemcpy(d_pmt_z, pmt_z, size[1], cudaMemcpyHostToDevice));
    CHECK(cudaMemcpy(d_data_hit, data_hit, size[2], cudaMemcpyHostToDevice));
    CHECK(cudaMemcpy(d_data_npe, data_npe, size[3], cudaMemcpyHostToDevice));
    CHECK(cudaMemcpy(d_seed, seed, size[4], cudaMemcpyHostToDevice));
    CHECK(cudaMemcpy(d_evt_id, evt_id, size[0]/2, cudaMemcpyHostToDevice));

    CHECK(cudaEventRecord(data_stop));
    CHECK(cudaEventSynchronize(data_stop));
    // printf("[GPU]GPU数据拷贝完成\n");
    //设置使用编号为0的GPU
    CHECK(cudaSetDevice(0));
    // //设置线程数量
    int threadPerBlock= 256;
    int blocksPerGrid = 70;
    dim3 block(threadPerBlock);
    //设置块数量
    dim3 grid(blocksPerGrid);//blocksPerGrid
    //调用核函数
    printf("[GPU]核函数开始运行\n");
    CHECK(cudaEventRecord(gpu_start));
   
    step_calculate_every_pmt<<<grid, block>>>(d_r,d_pos_x,d_pos_y,d_pos_z,d_pmt_x,d_pmt_y,\
        d_pmt_z,d_intPart,d_fractionPart,d_start_time,d_evt_id,pmt_num,evtnum,d_data_hit,d_data_npe,d_seed,\
        d_result,d_pmt_res_list,d_evt_res_list,(int)(size[0]/sizeof(double)));
    CHECK(cudaDeviceSynchronize());
    dim3 grid_reduce(evtnum/threadPerBlock+1);
    evt_calculate_add<<<grid_reduce,block>>>(d_evt_res_list,d_evt_res_back,evtnum,pmt_num);
    CHECK(cudaDeviceSynchronize());
    CudaCheckError();
    CHECK(cudaEventRecord(gpu_stop));
    CHECK(cudaEventSynchronize(gpu_stop));
    
    printf("[GPU]核函数运行完成\n");
    // CHECK(cudaDeviceSynchronize());

    CHECK(cudaMemcpy(h_result, d_result, pmt_num*pmt_mem*sizeof(double), cudaMemcpyDeviceToHost));
    CHECK(cudaMemcpy(h_pmt_res_list, d_pmt_res_list, pmt_num*sizeof(int), cudaMemcpyDeviceToHost));
    CHECK(cudaMemcpy(h_evt_res_list, d_evt_res_back, evtnum*sizeof(int), cudaMemcpyDeviceToHost));
    

    //释放GPU内存
    CHECK(cudaFree(d_r));
    CHECK(cudaFree(d_pos_x));
    CHECK(cudaFree(d_pos_y));
    CHECK(cudaFree(d_pos_z));
    CHECK(cudaFree(d_intPart));
    CHECK(cudaFree(d_fractionPart));
    CHECK(cudaFree(d_start_time));
    CHECK(cudaFree(d_data_hit));
    CHECK(cudaFree(d_data_npe));
    CHECK(cudaFree(d_pmt_x));
    CHECK(cudaFree(d_pmt_y));
    CHECK(cudaFree(d_pmt_z));
    CHECK(cudaFree(d_seed));
    CHECK(cudaFree(d_result));
    CHECK(cudaFree(d_pmt_res_list));
    CHECK(cudaFree(d_evt_res_list));
    // printf("[GPU]GPU运行完成\n");

    CHECK(cudaEventRecord(stop));
    CHECK(cudaEventSynchronize(stop));
    float total_time,gputime,datatime;
    //计算用时，精度0.5us
    CHECK(cudaEventElapsedTime(&datatime, data_start, data_stop));
    CHECK(cudaEventElapsedTime(&gputime, gpu_start, gpu_stop));
    CHECK(cudaEventElapsedTime(&total_time, start, stop));
    CHECK(cudaEventDestroy(gpu_start));
    CHECK(cudaEventDestroy(gpu_stop));
    CHECK(cudaEventDestroy(data_start));
    CHECK(cudaEventDestroy(data_stop));
    CHECK(cudaEventDestroy(start));
    CHECK(cudaEventDestroy(stop));        
    printf("total use time %f ms\n", total_time);
    printf("gpu use time %f ms\n",gputime);
    printf("data use time %f ms\n",datatime);
    printf("data transport back use time %f ms\n",total_time - datatime - gputime);
    CHECK(cudaDeviceReset());        
    return total_time;
    // return 0.0;
}
	.file	"tmpxft_002503eb_00000000-6_MuonSimu.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2266:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2266:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z17calculate_by_stepddddddddddiPdS_P17curandStateXORWOWP7res_arrPi
	.type	_Z17calculate_by_stepddddddddddiPdS_P17curandStateXORWOWP7res_arrPi, @function
_Z17calculate_by_stepddddddddddiPdS_P17curandStateXORWOWP7res_arrPi:
.LFB2241:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE2241:
	.size	_Z17calculate_by_stepddddddddddiPdS_P17curandStateXORWOWP7res_arrPi, .-_Z17calculate_by_stepddddddddddiPdS_P17curandStateXORWOWP7res_arrPi
	.globl	_Z14calculateAngledddddd
	.type	_Z14calculateAngledddddd, @function
_Z14calculateAngledddddd:
.LFB2242:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE2242:
	.size	_Z14calculateAngledddddd, .-_Z14calculateAngledddddd
	.globl	_Z12generateHitsddddiPdS_P17curandStateXORWOWP7res_arrPi
	.type	_Z12generateHitsddddiPdS_P17curandStateXORWOWP7res_arrPi, @function
_Z12generateHitsddddiPdS_P17curandStateXORWOWP7res_arrPi:
.LFB2243:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE2243:
	.size	_Z12generateHitsddddiPdS_P17curandStateXORWOWP7res_arrPi, .-_Z12generateHitsddddiPdS_P17curandStateXORWOWP7res_arrPi
	.globl	_Z11get_hittimeddiPdP17curandStateXORWOW
	.type	_Z11get_hittimeddiPdP17curandStateXORWOW, @function
_Z11get_hittimeddiPdP17curandStateXORWOW:
.LFB2244:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE2244:
	.size	_Z11get_hittimeddiPdP17curandStateXORWOW, .-_Z11get_hittimeddiPdP17curandStateXORWOW
	.globl	_Z15get_hittime_biniiiPdP17curandStateXORWOW
	.type	_Z15get_hittime_biniiiPdP17curandStateXORWOW, @function
_Z15get_hittime_biniiiPdP17curandStateXORWOW:
.LFB2245:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE2245:
	.size	_Z15get_hittime_biniiiPdP17curandStateXORWOW, .-_Z15get_hittime_biniiiPdP17curandStateXORWOW
	.globl	_Z15get_hittime_alliiPdP17curandStateXORWOW
	.type	_Z15get_hittime_alliiPdP17curandStateXORWOW, @function
_Z15get_hittime_alliiPdP17curandStateXORWOW:
.LFB2246:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE2246:
	.size	_Z15get_hittime_alliiPdP17curandStateXORWOW, .-_Z15get_hittime_alliiPdP17curandStateXORWOW
	.globl	_Z9get_bin_xd
	.type	_Z9get_bin_xd, @function
_Z9get_bin_xd:
.LFB2247:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE2247:
	.size	_Z9get_bin_xd, .-_Z9get_bin_xd
	.globl	_Z9get_bin_yd
	.type	_Z9get_bin_yd, @function
_Z9get_bin_yd:
.LFB2412:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	pushq	%rax
	.cfi_def_cfa_offset 16
	call	_Z9get_bin_xd
	.cfi_endproc
.LFE2412:
	.size	_Z9get_bin_yd, .-_Z9get_bin_yd
	.globl	_Z9r_findBind
	.type	_Z9r_findBind, @function
_Z9r_findBind:
.LFB2414:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	pushq	%rax
	.cfi_def_cfa_offset 16
	call	_Z9get_bin_xd
	.cfi_endproc
.LFE2414:
	.size	_Z9r_findBind, .-_Z9r_findBind
	.globl	_Z7get_npeddPdP17curandStateXORWOW
	.type	_Z7get_npeddPdP17curandStateXORWOW, @function
_Z7get_npeddPdP17curandStateXORWOW:
.LFB2250:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE2250:
	.size	_Z7get_npeddPdP17curandStateXORWOW, .-_Z7get_npeddPdP17curandStateXORWOW
	.globl	_Z10r3_findBind
	.type	_Z10r3_findBind, @function
_Z10r3_findBind:
.LFB2416:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	pushq	%rax
	.cfi_def_cfa_offset 16
	call	_Z9get_bin_xd
	.cfi_endproc
.LFE2416:
	.size	_Z10r3_findBind, .-_Z10r3_findBind
	.globl	_Z13theta_findBind
	.type	_Z13theta_findBind, @function
_Z13theta_findBind:
.LFB2418:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	pushq	%rax
	.cfi_def_cfa_offset 16
	call	_Z9get_bin_xd
	.cfi_endproc
.LFE2418:
	.size	_Z13theta_findBind, .-_Z13theta_findBind
	.globl	_Z11get_npe_numiiPdP17curandStateXORWOW
	.type	_Z11get_npe_numiiPdP17curandStateXORWOW, @function
_Z11get_npe_numiiPdP17curandStateXORWOW:
.LFB2422:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE2422:
	.size	_Z11get_npe_numiiPdP17curandStateXORWOW, .-_Z11get_npe_numiiPdP17curandStateXORWOW
	.globl	_Z14generateRandomP17curandStateXORWOW
	.type	_Z14generateRandomP17curandStateXORWOW, @function
_Z14generateRandomP17curandStateXORWOW:
.LFB2254:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE2254:
	.size	_Z14generateRandomP17curandStateXORWOW, .-_Z14generateRandomP17curandStateXORWOW
	.globl	_Z17generateRandomIntP17curandStateXORWOWii
	.type	_Z17generateRandomIntP17curandStateXORWOWii, @function
_Z17generateRandomIntP17curandStateXORWOWii:
.LFB2255:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE2255:
	.size	_Z17generateRandomIntP17curandStateXORWOWii, .-_Z17generateRandomIntP17curandStateXORWOWii
	.globl	_Z18generateRandomInitP17curandStateXORWOWi
	.type	_Z18generateRandomInitP17curandStateXORWOWi, @function
_Z18generateRandomInitP17curandStateXORWOWi:
.LFB2256:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE2256:
	.size	_Z18generateRandomInitP17curandStateXORWOWi, .-_Z18generateRandomInitP17curandStateXORWOWi
	.globl	_Z8samplingP17curandStateXORWOWPdii
	.type	_Z8samplingP17curandStateXORWOWPdii, @function
_Z8samplingP17curandStateXORWOWPdii:
.LFB2257:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE2257:
	.size	_Z8samplingP17curandStateXORWOWPdii, .-_Z8samplingP17curandStateXORWOWPdii
	.globl	_Z12binarySearchPddii
	.type	_Z12binarySearchPddii, @function
_Z12binarySearchPddii:
.LFB2258:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE2258:
	.size	_Z12binarySearchPddii, .-_Z12binarySearchPddii
	.globl	_Z14append_res_arrP7res_arrd
	.type	_Z14append_res_arrP7res_arrd, @function
_Z14append_res_arrP7res_arrd:
.LFB2259:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE2259:
	.size	_Z14append_res_arrP7res_arrd, .-_Z14append_res_arrP7res_arrd
	.globl	_Z11add_evt_arrP7res_arri
	.type	_Z11add_evt_arrP7res_arri, @function
_Z11add_evt_arrP7res_arri:
.LFB2420:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	pushq	%rax
	.cfi_def_cfa_offset 16
	call	_Z18generateRandomInitP17curandStateXORWOWi
	.cfi_endproc
.LFE2420:
	.size	_Z11add_evt_arrP7res_arri, .-_Z11add_evt_arrP7res_arri
	.globl	_Z12init_res_arrP7res_arrPdPiS2_iii
	.type	_Z12init_res_arrP7res_arrPdPiS2_iii, @function
_Z12init_res_arrP7res_arrPdPiS2_iii:
.LFB2261:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE2261:
	.size	_Z12init_res_arrP7res_arrPdPiS2_iii, .-_Z12init_res_arrP7res_arrPdPiS2_iii
	.globl	_Z41__device_stub__Z17evt_calculate_addPiS_iiPiS_ii
	.type	_Z41__device_stub__Z17evt_calculate_addPiS_iiPiS_ii, @function
_Z41__device_stub__Z17evt_calculate_addPiS_iiPiS_ii:
.LFB2288:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdi, 24(%rsp)
	leaq	56(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	68(%rsp), %rsi
	movl	%edx, 12(%rsp)
	leaq	40(%rsp), %rdx
	movl	%ecx, 8(%rsp)
	leaq	48(%rsp), %rcx
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 64(%rsp)
	movq	%rax, 104(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 128(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 56(%rsp)
	movq	%rax, 68(%rsp)
	movl	$1, 76(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L44
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z17evt_calculate_addPiS_ii(%rip), %rdi
	pushq	48(%rsp)
	.cfi_def_cfa_offset 176
	movq	84(%rsp), %rcx
	movl	92(%rsp), %r8d
	movq	72(%rsp), %rsi
	movl	80(%rsp), %edx
	leaq	120(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 168
	popq	%rdx
	.cfi_def_cfa_offset 160
.L44:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L46
	call	__stack_chk_fail@PLT
.L46:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2288:
	.size	_Z41__device_stub__Z17evt_calculate_addPiS_iiPiS_ii, .-_Z41__device_stub__Z17evt_calculate_addPiS_iiPiS_ii
	.globl	_Z17evt_calculate_addPiS_ii
	.type	_Z17evt_calculate_addPiS_ii, @function
_Z17evt_calculate_addPiS_ii:
.LFB2289:
	.cfi_startproc
	endbr64
	jmp	_Z41__device_stub__Z17evt_calculate_addPiS_iiPiS_ii
	.cfi_endproc
.LFE2289:
	.size	_Z17evt_calculate_addPiS_ii, .-_Z17evt_calculate_addPiS_ii
	.globl	_Z82__device_stub__Z24step_calculate_every_pmtPdS_S_S_S_S_S_S_S_S_PiiiS_S_S0_S_S0_S0_iPdS_S_S_S_S_S_S_S_S_PiiiS_S_S0_S_S0_S0_i
	.type	_Z82__device_stub__Z24step_calculate_every_pmtPdS_S_S_S_S_S_S_S_S_PiiiS_S_S0_S_S0_S0_iPdS_S_S_S_S_S_S_S_S_PiiiS_S_S0_S_S0_S0_i, @function
_Z82__device_stub__Z24step_calculate_every_pmtPdS_S_S_S_S_S_S_S_S_PiiiS_S_S0_S_S0_S0_iPdS_S_S_S_S_S_S_S_S_PiiiS_S_S0_S_S0_S0_i:
.LFB2290:
	.cfi_startproc
	endbr64
	subq	$392, %rsp
	.cfi_def_cfa_offset 400
	movq	400(%rsp), %rax
	movq	%rdi, 136(%rsp)
	leaq	168(%rsp), %rdi
	movq	%rsi, 128(%rsp)
	leaq	180(%rsp), %rsi
	movq	%rax, 88(%rsp)
	movq	408(%rsp), %rax
	movq	%rdx, 120(%rsp)
	leaq	152(%rsp), %rdx
	movq	%rax, 80(%rsp)
	movq	416(%rsp), %rax
	movq	%rcx, 112(%rsp)
	leaq	160(%rsp), %rcx
	movq	%rax, 72(%rsp)
	movq	424(%rsp), %rax
	movq	%r8, 104(%rsp)
	movq	%rax, 64(%rsp)
	movq	432(%rsp), %rax
	movq	%r9, 96(%rsp)
	movq	%rax, 56(%rsp)
	movq	456(%rsp), %rax
	movq	%rax, 48(%rsp)
	movq	464(%rsp), %rax
	movq	%rax, 40(%rsp)
	movq	472(%rsp), %rax
	movq	%rax, 32(%rsp)
	movq	480(%rsp), %rax
	movq	%rax, 24(%rsp)
	movq	488(%rsp), %rax
	movq	%rax, 16(%rsp)
	movq	496(%rsp), %rax
	movq	%rax, 8(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 376(%rsp)
	xorl	%eax, %eax
	leaq	136(%rsp), %rax
	movq	%rax, 216(%rsp)
	leaq	128(%rsp), %rax
	movq	%rax, 224(%rsp)
	leaq	120(%rsp), %rax
	movq	%rax, 232(%rsp)
	leaq	112(%rsp), %rax
	movq	%rax, 240(%rsp)
	leaq	104(%rsp), %rax
	movq	%rax, 248(%rsp)
	leaq	96(%rsp), %rax
	movq	%rax, 256(%rsp)
	leaq	88(%rsp), %rax
	movq	%rax, 264(%rsp)
	leaq	80(%rsp), %rax
	movq	%rax, 272(%rsp)
	leaq	72(%rsp), %rax
	movq	%rax, 280(%rsp)
	leaq	64(%rsp), %rax
	movq	%rax, 288(%rsp)
	leaq	56(%rsp), %rax
	movq	%rax, 296(%rsp)
	leaq	440(%rsp), %rax
	movq	%rax, 304(%rsp)
	leaq	448(%rsp), %rax
	movq	%rax, 312(%rsp)
	leaq	48(%rsp), %rax
	movq	%rax, 320(%rsp)
	leaq	40(%rsp), %rax
	movq	%rax, 328(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 336(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 344(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 352(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 360(%rsp)
	leaq	504(%rsp), %rax
	movq	%rax, 368(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 168(%rsp)
	movl	$1, 176(%rsp)
	movq	%rax, 180(%rsp)
	movl	$1, 188(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L50
	pushq	160(%rsp)
	.cfi_def_cfa_offset 408
	leaq	_Z24step_calculate_every_pmtPdS_S_S_S_S_S_S_S_S_PiiiS_S_S0_S_S0_S0_i(%rip), %rdi
	pushq	160(%rsp)
	.cfi_def_cfa_offset 416
	movq	196(%rsp), %rcx
	movl	204(%rsp), %r8d
	movq	184(%rsp), %rsi
	movl	192(%rsp), %edx
	leaq	232(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 408
	popq	%rdx
	.cfi_def_cfa_offset 400
.L50:
	movq	376(%rsp), %rax
	subq	%fs:40, %rax
	je	.L52
	call	__stack_chk_fail@PLT
.L52:
	addq	$392, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2290:
	.size	_Z82__device_stub__Z24step_calculate_every_pmtPdS_S_S_S_S_S_S_S_S_PiiiS_S_S0_S_S0_S0_iPdS_S_S_S_S_S_S_S_S_PiiiS_S_S0_S_S0_S0_i, .-_Z82__device_stub__Z24step_calculate_every_pmtPdS_S_S_S_S_S_S_S_S_PiiiS_S_S0_S_S0_S0_iPdS_S_S_S_S_S_S_S_S_PiiiS_S_S0_S_S0_S0_i
	.globl	_Z24step_calculate_every_pmtPdS_S_S_S_S_S_S_S_S_PiiiS_S_S0_S_S0_S0_i
	.type	_Z24step_calculate_every_pmtPdS_S_S_S_S_S_S_S_S_PiiiS_S_S0_S_S0_S0_i, @function
_Z24step_calculate_every_pmtPdS_S_S_S_S_S_S_S_S_PiiiS_S_S0_S_S0_S0_i:
.LFB2291:
	.cfi_startproc
	endbr64
	jmp	_Z82__device_stub__Z24step_calculate_every_pmtPdS_S_S_S_S_S_S_S_S_PiiiS_S_S0_S_S0_S0_iPdS_S_S_S_S_S_S_S_S_PiiiS_S_S0_S_S0_S0_i
	.cfi_endproc
.LFE2291:
	.size	_Z24step_calculate_every_pmtPdS_S_S_S_S_S_S_S_S_PiiiS_S_S0_S_S0_S0_i, .-_Z24step_calculate_every_pmtPdS_S_S_S_S_S_S_S_S_PiiiS_S_S0_S_S0_S0_i
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"/home/ubuntu/Datasets/stackv2/train-structured/advancc/gpulearn/master/MuonSimu.cu"
.LC1:
	.string	"Error:%s:%d, "
.LC2:
	.string	"code:%d, reason: %s\n"
.LC3:
	.string	"[GPU]\346\240\270\345\207\275\346\225\260\345\274\200\345\247\213\350\277\220\350\241\214\n"
.LC4:
	.string	"cudaCheckError() failed at %s:%i : %s\n"
.LC5:
	.string	"[GPU]\346\240\270\345\207\275\346\225\260\350\277\220\350\241\214\345\256\214\346\210\220\n"
.LC6:
	.string	"total use time %f ms\n"
.LC7:
	.string	"gpu use time %f ms\n"
.LC8:
	.string	"data use time %f ms\n"
.LC9:
	.string	"data transport back use time %f ms\n"
	.text
	.globl	GPU_Sampling_wrapper
	.type	GPU_Sampling_wrapper, @function
GPU_Sampling_wrapper:
.LFB2263:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movq	%rdi, %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movq	%rsi, %r14
	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	$392, %rsp
	.cfi_def_cfa_offset 448
	movq	448(%rsp), %rax
	movq	%rdx, 16(%rsp)
	leaq	144(%rsp), %rdi
	movq	%rcx, 24(%rsp)
	movq	%rax, 48(%rsp)
	movq	456(%rsp), %rax
	movq	%r8, 32(%rsp)
	movq	%rax, 56(%rsp)
	movq	472(%rsp), %rax
	movq	%r9, 40(%rsp)
	movq	%rax, 64(%rsp)
	movq	480(%rsp), %rax
	movq	%rax, 72(%rsp)
	movq	488(%rsp), %rax
	movq	%rax, 80(%rsp)
	movq	496(%rsp), %rax
	movq	%rax, 88(%rsp)
	movq	504(%rsp), %rax
	movq	%rax, 96(%rsp)
	movq	512(%rsp), %rax
	movq	520(%rsp), %rbx
	movq	%rax, 104(%rsp)
	movq	528(%rsp), %rax
	movq	%rax, 112(%rsp)
	movq	536(%rsp), %rax
	movq	%rax, 120(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 376(%rsp)
	xorl	%eax, %eax
	call	cudaEventCreate@PLT
	testl	%eax, %eax
	je	.L56
	movl	%eax, %ebp
	movl	$366, %ecx
	jmp	.L144
.L56:
	leaq	152(%rsp), %rdi
	call	cudaEventCreate@PLT
	movl	%eax, %ebp
	testl	%eax, %eax
	je	.L57
	movl	$367, %ecx
.L144:
	leaq	.LC0(%rip), %rdx
	leaq	.LC1(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	%ebp, %edi
	call	cudaGetErrorString@PLT
	movl	%ebp, %edx
	movq	%rax, %rcx
.L145:
	movl	$2, %edi
	leaq	.LC2(%rip), %rsi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$1, %edi
.L146:
	call	exit@PLT
.L57:
	leaq	160(%rsp), %rdi
	call	cudaEventCreate@PLT
	movl	$368, %ecx
	movl	%eax, %ebp
	testl	%eax, %eax
	jne	.L144
	leaq	168(%rsp), %rdi
	call	cudaEventCreate@PLT
	movl	$369, %ecx
	movl	%eax, %ebp
	testl	%eax, %eax
	jne	.L144
	leaq	176(%rsp), %rdi
	call	cudaEventCreate@PLT
	movl	$370, %ecx
	movl	%eax, %ebp
	testl	%eax, %eax
	jne	.L144
	leaq	184(%rsp), %rdi
	call	cudaEventCreate@PLT
	movl	$371, %ecx
	movl	%eax, %ebp
	testl	%eax, %eax
	jne	.L144
	movq	144(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movl	$372, %ecx
	movl	%eax, %ebp
	testl	%eax, %eax
	jne	.L144
	movq	176(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movl	$373, %ecx
	movl	%eax, %ebp
	testl	%eax, %eax
	jne	.L144
	movl	$70984, %edi
	call	malloc@PLT
	movslq	(%rbx), %rsi
	leaq	192(%rsp), %rdi
	movq	%rax, 8(%rsp)
	call	cudaMalloc@PLT
	movl	$381, %ecx
	movl	%eax, %ebp
	testl	%eax, %eax
	jne	.L144
	movslq	(%rbx), %rsi
	leaq	200(%rsp), %rdi
	call	cudaMalloc@PLT
	movl	$382, %ecx
	movl	%eax, %ebp
	testl	%eax, %eax
	jne	.L144
	movslq	(%rbx), %rsi
	leaq	208(%rsp), %rdi
	call	cudaMalloc@PLT
	movl	$383, %ecx
	movl	%eax, %ebp
	testl	%eax, %eax
	jne	.L144
	movslq	(%rbx), %rsi
	leaq	216(%rsp), %rdi
	call	cudaMalloc@PLT
	movl	$384, %ecx
	movl	%eax, %ebp
	testl	%eax, %eax
	jne	.L144
	movslq	(%rbx), %rsi
	leaq	224(%rsp), %rdi
	call	cudaMalloc@PLT
	movl	$385, %ecx
	movl	%eax, %ebp
	testl	%eax, %eax
	jne	.L144
	movslq	(%rbx), %rsi
	leaq	232(%rsp), %rdi
	call	cudaMalloc@PLT
	movl	$386, %ecx
	movl	%eax, %ebp
	testl	%eax, %eax
	jne	.L144
	movslq	(%rbx), %rsi
	leaq	240(%rsp), %rdi
	call	cudaMalloc@PLT
	movl	$387, %ecx
	movl	%eax, %ebp
	testl	%eax, %eax
	jne	.L144
	movl	(%rbx), %eax
	movl	$2, %ecx
	leaq	312(%rsp), %rdi
	cltd
	idivl	%ecx
	movslq	%eax, %rsi
	call	cudaMalloc@PLT
	movl	$388, %ecx
	movl	%eax, %ebp
	testl	%eax, %eax
	jne	.L144
	movslq	4(%rbx), %rsi
	leaq	248(%rsp), %rdi
	call	cudaMalloc@PLT
	movl	$389, %ecx
	movl	%eax, %ebp
	testl	%eax, %eax
	jne	.L144
	movslq	4(%rbx), %rsi
	leaq	256(%rsp), %rdi
	call	cudaMalloc@PLT
	movl	$390, %ecx
	movl	%eax, %ebp
	testl	%eax, %eax
	jne	.L144
	movslq	4(%rbx), %rsi
	leaq	264(%rsp), %rdi
	call	cudaMalloc@PLT
	movl	$391, %ecx
	movl	%eax, %ebp
	testl	%eax, %eax
	jne	.L144
	movslq	8(%rbx), %rsi
	leaq	272(%rsp), %rdi
	call	cudaMalloc@PLT
	movl	$392, %ecx
	movl	%eax, %ebp
	testl	%eax, %eax
	jne	.L144
	movslq	12(%rbx), %rsi
	leaq	280(%rsp), %rdi
	call	cudaMalloc@PLT
	movl	$393, %ecx
	movl	%eax, %ebp
	testl	%eax, %eax
	jne	.L144
	movslq	16(%rbx), %rsi
	leaq	296(%rsp), %rdi
	call	cudaMalloc@PLT
	movl	$394, %ecx
	movl	%eax, %ebp
	testl	%eax, %eax
	jne	.L144
	leaq	288(%rsp), %rdi
	movl	$283936000, %esi
	call	cudaMalloc@PLT
	movl	$395, %ecx
	movl	%eax, %ebp
	testl	%eax, %eax
	jne	.L144
	leaq	304(%rsp), %rdi
	movl	$70984, %esi
	call	cudaMalloc@PLT
	movl	$396, %ecx
	movl	%eax, %ebp
	testl	%eax, %eax
	jne	.L144
	imull	$17746, 464(%rsp), %ebp
	leaq	320(%rsp), %rdi
	movslq	%ebp, %rbp
	salq	$2, %rbp
	movq	%rbp, %rsi
	call	cudaMalloc@PLT
	movl	%eax, %r12d
	testl	%eax, %eax
	je	.L80
	movl	$397, %ecx
	leaq	.LC0(%rip), %rdx
	leaq	.LC1(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	movl	%r12d, %edi
	call	cudaGetErrorString@PLT
	movl	%r12d, %edx
	movq	%rax, %rcx
	jmp	.L145
.L80:
	movslq	464(%rsp), %r12
	leaq	328(%rsp), %rdi
	salq	$2, %r12
	movq	%r12, %rsi
	call	cudaMalloc@PLT
	movl	$398, %ecx
	movl	%eax, %r13d
	testl	%eax, %eax
	jne	.L148
	movq	304(%rsp), %rdi
	movl	$70984, %edx
	xorl	%esi, %esi
	call	cudaMemset@PLT
	movl	%eax, %r13d
	testl	%eax, %eax
	je	.L82
	movl	$401, %ecx
.L148:
	leaq	.LC0(%rip), %rdx
	leaq	.LC1(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	%r13d, %edi
	call	cudaGetErrorString@PLT
	movl	%r13d, %edx
	movq	%rax, %rcx
	jmp	.L145
.L82:
	movq	320(%rsp), %rdi
	movq	%rbp, %rdx
	xorl	%esi, %esi
	call	cudaMemset@PLT
	movl	$402, %ecx
	movl	%eax, %ebp
	testl	%eax, %eax
	jne	.L144
	movq	328(%rsp), %rdi
	movq	%r12, %rdx
	xorl	%esi, %esi
	call	cudaMemset@PLT
	movl	$403, %ecx
	movl	%eax, %ebp
	testl	%eax, %eax
	jne	.L144
	movq	288(%rsp), %rdi
	movl	$283936000, %edx
	xorl	%esi, %esi
	call	cudaMemset@PLT
	movl	$404, %ecx
	movl	%eax, %ebp
	testl	%eax, %eax
	jne	.L144
	movslq	(%rbx), %rdx
	movq	192(%rsp), %rdi
	movl	$1, %ecx
	movq	%r15, %rsi
	call	cudaMemcpy@PLT
	movl	$406, %ecx
	movl	%eax, %ebp
	testl	%eax, %eax
	jne	.L144
	movslq	(%rbx), %rdx
	movq	200(%rsp), %rdi
	movl	$1, %ecx
	movq	%r14, %rsi
	call	cudaMemcpy@PLT
	movl	$407, %ecx
	movl	%eax, %ebp
	testl	%eax, %eax
	jne	.L144
	movslq	(%rbx), %rdx
	movq	16(%rsp), %rsi
	movl	$1, %ecx
	movq	208(%rsp), %rdi
	call	cudaMemcpy@PLT
	movl	$408, %ecx
	movl	%eax, %ebp
	testl	%eax, %eax
	jne	.L144
	movslq	(%rbx), %rdx
	movq	24(%rsp), %rsi
	movl	$1, %ecx
	movq	216(%rsp), %rdi
	call	cudaMemcpy@PLT
	movl	$409, %ecx
	movl	%eax, %ebp
	testl	%eax, %eax
	jne	.L144
	movslq	(%rbx), %rdx
	movq	32(%rsp), %rsi
	movl	$1, %ecx
	movq	224(%rsp), %rdi
	call	cudaMemcpy@PLT
	movl	$410, %ecx
	movl	%eax, %ebp
	testl	%eax, %eax
	jne	.L144
	movslq	(%rbx), %rdx
	movq	40(%rsp), %rsi
	movl	$1, %ecx
	movq	232(%rsp), %rdi
	call	cudaMemcpy@PLT
	movl	$411, %ecx
	movl	%eax, %ebp
	testl	%eax, %eax
	jne	.L144
	movslq	(%rbx), %rdx
	movq	48(%rsp), %rsi
	movl	$1, %ecx
	movq	240(%rsp), %rdi
	call	cudaMemcpy@PLT
	movl	$412, %ecx
	movl	%eax, %ebp
	testl	%eax, %eax
	jne	.L144
	movslq	4(%rbx), %rdx
	movq	64(%rsp), %rsi
	movl	$1, %ecx
	movq	248(%rsp), %rdi
	call	cudaMemcpy@PLT
	movl	$413, %ecx
	movl	%eax, %ebp
	testl	%eax, %eax
	jne	.L144
	movslq	4(%rbx), %rdx
	movq	72(%rsp), %rsi
	movl	$1, %ecx
	movq	256(%rsp), %rdi
	call	cudaMemcpy@PLT
	movl	$414, %ecx
	movl	%eax, %ebp
	testl	%eax, %eax
	jne	.L144
	movslq	4(%rbx), %rdx
	movq	80(%rsp), %rsi
	movl	$1, %ecx
	movq	264(%rsp), %rdi
	call	cudaMemcpy@PLT
	movl	$415, %ecx
	movl	%eax, %ebp
	testl	%eax, %eax
	jne	.L144
	movslq	8(%rbx), %rdx
	movq	88(%rsp), %rsi
	movl	$1, %ecx
	movq	272(%rsp), %rdi
	call	cudaMemcpy@PLT
	movl	$416, %ecx
	movl	%eax, %ebp
	testl	%eax, %eax
	jne	.L144
	movslq	12(%rbx), %rdx
	movq	96(%rsp), %rsi
	movl	$1, %ecx
	movq	280(%rsp), %rdi
	call	cudaMemcpy@PLT
	movl	$417, %ecx
	movl	%eax, %ebp
	testl	%eax, %eax
	jne	.L144
	movslq	16(%rbx), %rdx
	movq	104(%rsp), %rsi
	movl	$1, %ecx
	movq	296(%rsp), %rdi
	call	cudaMemcpy@PLT
	movl	$418, %ecx
	movl	%eax, %ebp
	testl	%eax, %eax
	jne	.L144
	movl	(%rbx), %eax
	movl	$2, %ecx
	movq	56(%rsp), %rsi
	movq	312(%rsp), %rdi
	cltd
	idivl	%ecx
	movl	$1, %ecx
	movslq	%eax, %rdx
	call	cudaMemcpy@PLT
	movl	$419, %ecx
	movl	%eax, %ebp
	testl	%eax, %eax
	jne	.L144
	movq	184(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movl	$421, %ecx
	movl	%eax, %ebp
	testl	%eax, %eax
	jne	.L144
	movq	184(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movl	$422, %ecx
	movl	%eax, %ebp
	testl	%eax, %eax
	jne	.L144
	xorl	%edi, %edi
	call	cudaSetDevice@PLT
	movl	$425, %ecx
	movl	%eax, %ebp
	testl	%eax, %eax
	jne	.L144
	movl	$16777217, %eax
	movl	$2, %edi
	leaq	.LC3(%rip), %rsi
	movl	$1, 348(%rsp)
	movl	$1, 360(%rsp)
	salq	$8, %rax
	movq	%rax, 340(%rsp)
	subq	$186, %rax
	movq	%rax, 352(%rsp)
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	160(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movl	$434, %ecx
	movl	%eax, %ebp
	testl	%eax, %eax
	jne	.L144
	movl	348(%rsp), %ecx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movq	340(%rsp), %rdx
	movq	352(%rsp), %rdi
	movl	360(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L104
	movslq	(%rbx), %rax
	shrq	$3, %rax
	pushq	%rax
	.cfi_def_cfa_offset 456
	pushq	328(%rsp)
	.cfi_def_cfa_offset 464
	pushq	320(%rsp)
	.cfi_def_cfa_offset 472
	pushq	312(%rsp)
	.cfi_def_cfa_offset 480
	pushq	328(%rsp)
	.cfi_def_cfa_offset 488
	pushq	320(%rsp)
	.cfi_def_cfa_offset 496
	pushq	320(%rsp)
	.cfi_def_cfa_offset 504
	movl	520(%rsp), %eax
	pushq	%rax
	.cfi_def_cfa_offset 512
	pushq	$17746
	.cfi_def_cfa_offset 520
	pushq	384(%rsp)
	.cfi_def_cfa_offset 528
	pushq	320(%rsp)
	.cfi_def_cfa_offset 536
	pushq	320(%rsp)
	.cfi_def_cfa_offset 544
	pushq	320(%rsp)
	.cfi_def_cfa_offset 552
	pushq	368(%rsp)
	.cfi_def_cfa_offset 560
	movq	368(%rsp), %r9
	movq	360(%rsp), %r8
	movq	328(%rsp), %rcx
	movq	320(%rsp), %rdx
	movq	312(%rsp), %rsi
	movq	304(%rsp), %rdi
	call	_Z82__device_stub__Z24step_calculate_every_pmtPdS_S_S_S_S_S_S_S_S_PiiiS_S_S0_S_S0_S0_iPdS_S_S_S_S_S_S_S_S_PiiiS_S_S0_S_S0_S0_i
	addq	$112, %rsp
	.cfi_def_cfa_offset 448
.L104:
	call	cudaDeviceSynchronize@PLT
	movl	$439, %ecx
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	.L147
	movl	464(%rsp), %eax
	movl	$256, %ecx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	cltd
	idivl	%ecx
	movl	348(%rsp), %ecx
	movq	340(%rsp), %rdx
	incl	%eax
	movl	%eax, 364(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 368(%rsp)
	movq	364(%rsp), %rdi
	movl	372(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L106
	movl	464(%rsp), %edx
	movq	328(%rsp), %rsi
	movl	$17746, %ecx
	movq	320(%rsp), %rdi
	call	_Z41__device_stub__Z17evt_calculate_addPiS_iiPiS_ii
.L106:
	call	cudaDeviceSynchronize@PLT
	movl	$442, %ecx
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	.L147
	call	cudaGetLastError@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L108
	call	cudaGetErrorString@PLT
	movl	$443, %r8d
	movq	stderr(%rip), %rdi
	leaq	.LC0(%rip), %rcx
	movq	%rax, %r9
	leaq	.LC4(%rip), %rdx
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	orl	$-1, %edi
	jmp	.L146
.L108:
	movq	168(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movl	$444, %ecx
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	.L147
	movq	168(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movl	$445, %ecx
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	.L147
	leaq	.LC5(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	112(%rsp), %rdi
	movl	$2, %ecx
	movq	288(%rsp), %rsi
	movl	$283936000, %edx
	call	cudaMemcpy@PLT
	movl	$450, %ecx
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	.L147
	movq	8(%rsp), %rdi
	movl	$2, %ecx
	movl	$70984, %edx
	movq	304(%rsp), %rsi
	call	cudaMemcpy@PLT
	movl	$451, %ecx
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	.L147
	movq	328(%rsp), %rsi
	movq	120(%rsp), %rdi
	movl	$2, %ecx
	movq	%r12, %rdx
	call	cudaMemcpy@PLT
	movl	$452, %ecx
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	.L147
	movq	192(%rsp), %rdi
	call	cudaFree@PLT
	movl	$456, %ecx
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	.L147
	movq	200(%rsp), %rdi
	call	cudaFree@PLT
	movl	$457, %ecx
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	.L147
	movq	208(%rsp), %rdi
	call	cudaFree@PLT
	movl	$458, %ecx
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	.L147
	movq	216(%rsp), %rdi
	call	cudaFree@PLT
	movl	$459, %ecx
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	.L147
	movq	224(%rsp), %rdi
	call	cudaFree@PLT
	movl	$460, %ecx
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	.L147
	movq	232(%rsp), %rdi
	call	cudaFree@PLT
	movl	$461, %ecx
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	.L147
	movq	240(%rsp), %rdi
	call	cudaFree@PLT
	movl	$462, %ecx
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	.L147
	movq	272(%rsp), %rdi
	call	cudaFree@PLT
	movl	$463, %ecx
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	.L147
	movq	280(%rsp), %rdi
	call	cudaFree@PLT
	movl	$464, %ecx
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	.L147
	movq	248(%rsp), %rdi
	call	cudaFree@PLT
	movl	$465, %ecx
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	.L147
	movq	256(%rsp), %rdi
	call	cudaFree@PLT
	movl	$466, %ecx
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	.L147
	movq	264(%rsp), %rdi
	call	cudaFree@PLT
	movl	$467, %ecx
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	.L147
	movq	296(%rsp), %rdi
	call	cudaFree@PLT
	movl	$468, %ecx
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	.L147
	movq	288(%rsp), %rdi
	call	cudaFree@PLT
	movl	$469, %ecx
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	.L147
	movq	304(%rsp), %rdi
	call	cudaFree@PLT
	movl	$470, %ecx
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	.L147
	movq	320(%rsp), %rdi
	call	cudaFree@PLT
	movl	$471, %ecx
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	.L147
	movq	152(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movl	$474, %ecx
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	.L147
	movq	152(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movl	$475, %ecx
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	.L147
	movq	184(%rsp), %rdx
	movq	176(%rsp), %rsi
	leaq	140(%rsp), %rdi
	call	cudaEventElapsedTime@PLT
	movl	$478, %ecx
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	.L147
	movq	168(%rsp), %rdx
	movq	160(%rsp), %rsi
	leaq	136(%rsp), %rdi
	call	cudaEventElapsedTime@PLT
	movl	$479, %ecx
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	.L147
	movq	152(%rsp), %rdx
	movq	144(%rsp), %rsi
	leaq	132(%rsp), %rdi
	call	cudaEventElapsedTime@PLT
	movl	$480, %ecx
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	.L147
	movq	160(%rsp), %rdi
	call	cudaEventDestroy@PLT
	movl	$481, %ecx
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	.L147
	movq	168(%rsp), %rdi
	call	cudaEventDestroy@PLT
	movl	$482, %ecx
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	.L147
	movq	176(%rsp), %rdi
	call	cudaEventDestroy@PLT
	movl	$483, %ecx
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	.L147
	movq	184(%rsp), %rdi
	call	cudaEventDestroy@PLT
	movl	$484, %ecx
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	.L147
	movq	144(%rsp), %rdi
	call	cudaEventDestroy@PLT
	movl	$485, %ecx
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	.L147
	movq	152(%rsp), %rdi
	call	cudaEventDestroy@PLT
	movl	$486, %ecx
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	.L147
	leaq	.LC6(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	cvtss2sd	132(%rsp), %xmm0
	call	__printf_chk@PLT
	leaq	.LC7(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	cvtss2sd	136(%rsp), %xmm0
	call	__printf_chk@PLT
	movb	$1, %al
	leaq	.LC8(%rip), %rsi
	cvtss2sd	140(%rsp), %xmm0
	movl	$2, %edi
	call	__printf_chk@PLT
	leaq	.LC9(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	movss	132(%rsp), %xmm0
	subss	140(%rsp), %xmm0
	subss	136(%rsp), %xmm0
	cvtss2sd	%xmm0, %xmm0
	call	__printf_chk@PLT
	call	cudaDeviceReset@PLT
	movl	%eax, %ebx
	testl	%eax, %eax
	je	.L141
	movl	$491, %ecx
.L147:
	leaq	.LC0(%rip), %rdx
	leaq	.LC1(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	%ebx, %edi
	call	cudaGetErrorString@PLT
	movl	%ebx, %edx
	movq	%rax, %rcx
	jmp	.L145
.L141:
	movss	132(%rsp), %xmm0
	movq	376(%rsp), %rax
	subq	%fs:40, %rax
	je	.L142
	call	__stack_chk_fail@PLT
.L142:
	addq	$392, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2263:
	.size	GPU_Sampling_wrapper, .-GPU_Sampling_wrapper
	.section	.rodata.str1.1
.LC10:
	.string	"_Z24step_calculate_every_pmtPdS_S_S_S_S_S_S_S_S_PiiiS_S_S0_S_S0_S0_i"
.LC11:
	.string	"_Z17evt_calculate_addPiS_ii"
.LC12:
	.string	"precalc_xorwow_matrix"
.LC13:
	.string	"precalc_xorwow_offset_matrix"
.LC14:
	.string	"mrg32k3aM1"
.LC15:
	.string	"mrg32k3aM2"
.LC16:
	.string	"mrg32k3aM1SubSeq"
.LC17:
	.string	"mrg32k3aM2SubSeq"
.LC18:
	.string	"mrg32k3aM1Seq"
.LC19:
	.string	"mrg32k3aM2Seq"
.LC20:
	.string	"__cr_lgamma_table"
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2293:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	pushq	$0
	.cfi_def_cfa_offset 24
	xorl	%r9d, %r9d
	orl	$-1, %r8d
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC10(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z24step_calculate_every_pmtPdS_S_S_S_S_S_S_S_S_PiiiS_S_S0_S_S0_S0_i(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r9d, %r9d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC11(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z17evt_calculate_addPiS_ii(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 40
	pushq	$0
	.cfi_def_cfa_offset 48
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC12(%rip), %rdx
	movl	$102400, %r9d
	leaq	_ZL21precalc_xorwow_matrix(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	call	__cudaRegisterVar@PLT
	popq	%rax
	.cfi_def_cfa_offset 24
	popq	%rdx
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC13(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movq	%rdx, %rcx
	movl	$102400, %r9d
	leaq	_ZL28precalc_xorwow_offset_matrix(%rip), %rsi
	call	__cudaRegisterVar@PLT
	popq	%rcx
	.cfi_def_cfa_offset 24
	popq	%rsi
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC14(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movq	%rdx, %rcx
	movl	$2304, %r9d
	leaq	_ZL10mrg32k3aM1(%rip), %rsi
	call	__cudaRegisterVar@PLT
	popq	%rdi
	.cfi_def_cfa_offset 24
	popq	%r8
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC15(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movq	%rdx, %rcx
	movl	$2304, %r9d
	leaq	_ZL10mrg32k3aM2(%rip), %rsi
	call	__cudaRegisterVar@PLT
	popq	%r9
	.cfi_def_cfa_offset 24
	popq	%r10
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC16(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movq	%rdx, %rcx
	movl	$2016, %r9d
	leaq	_ZL16mrg32k3aM1SubSeq(%rip), %rsi
	call	__cudaRegisterVar@PLT
	popq	%r11
	.cfi_def_cfa_offset 24
	popq	%rax
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC17(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movq	%rdx, %rcx
	movl	$2016, %r9d
	leaq	_ZL16mrg32k3aM2SubSeq(%rip), %rsi
	call	__cudaRegisterVar@PLT
	popq	%rax
	.cfi_def_cfa_offset 24
	popq	%rdx
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC18(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movq	%rdx, %rcx
	movl	$2304, %r9d
	leaq	_ZL13mrg32k3aM1Seq(%rip), %rsi
	call	__cudaRegisterVar@PLT
	popq	%rcx
	.cfi_def_cfa_offset 24
	popq	%rsi
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC19(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movq	%rdx, %rcx
	movl	$2304, %r9d
	leaq	_ZL13mrg32k3aM2Seq(%rip), %rsi
	call	__cudaRegisterVar@PLT
	popq	%rdi
	.cfi_def_cfa_offset 24
	popq	%r8
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$1
	.cfi_def_cfa_offset 32
	leaq	.LC20(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movl	$72, %r9d
	movq	%rdx, %rcx
	leaq	_ZL17__cr_lgamma_table(%rip), %rsi
	call	__cudaRegisterVar@PLT
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	popq	%r9
	.cfi_def_cfa_offset 24
	popq	%r10
	.cfi_def_cfa_offset 16
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE2293:
	.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
	.local	_ZL17__cr_lgamma_table
	.comm	_ZL17__cr_lgamma_table,72,32
	.local	_ZL13mrg32k3aM2Seq
	.comm	_ZL13mrg32k3aM2Seq,2304,32
	.local	_ZL13mrg32k3aM1Seq
	.comm	_ZL13mrg32k3aM1Seq,2304,32
	.local	_ZL16mrg32k3aM2SubSeq
	.comm	_ZL16mrg32k3aM2SubSeq,2016,32
	.local	_ZL16mrg32k3aM1SubSeq
	.comm	_ZL16mrg32k3aM1SubSeq,2016,32
	.local	_ZL10mrg32k3aM2
	.comm	_ZL10mrg32k3aM2,2304,32
	.local	_ZL10mrg32k3aM1
	.comm	_ZL10mrg32k3aM1,2304,32
	.local	_ZL28precalc_xorwow_offset_matrix
	.comm	_ZL28precalc_xorwow_offset_matrix,102400,32
	.local	_ZL21precalc_xorwow_matrix
	.comm	_ZL21precalc_xorwow_matrix,102400,32
	.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:

#ifndef MUONSIMU_H
#define MUONSIMU_H
#include <hip/hip_runtime.h>
#include <hip/hip_runtime_api.h>
#include <hiprand/hiprand.h>
#include <hiprand/hiprand_kernel.h>
#include <stdio.h>
#include <hip/hip_math_constants.h>
#include <assert.h>

typedef struct res_arr
{
    double *arr;
    int *pmt_list;
    int index;
    int id;
    int max;
    //evt 
    int *evt_res;
    int evt_num;

} Res_Arr;

__device__ double generateRandom(hiprandState *state);
__device__ void generateRandomInit(hiprandState *state,int seed);
__device__ int sampling(hiprandState *state,double *histo,int max,int id);
__device__ int binarySearch(double *histo,double target,int max,int id);
__device__ double calculateAngle(double x,double y,double z,double a,double b,double c);
__device__ void generateHits(double r,double theta, double ratio,double start_time,int evt_id,\
    double *hittime_histo,double *npe,hiprandState *state,Res_Arr *p_r_arr,int *evt_res_list);
__device__ int get_hittime(double r, double theta, int mode, double *hittime_histo, hiprandState *state);
__device__ int get_hittime_bin(int binx, int biny, int mode, double *hittime_histo, hiprandState *state);
__device__ int get_hittime_all(int binx, int biny,double *hittime_histo, hiprandState *state);
__device__ int get_bin_x(double r);
__device__ int get_bin_y(double theta);
__device__ int r_findBin(double r);
__device__ int get_npe(double r,double theta,double *npe,hiprandState *state);
__device__ int r3_findBin(double r3);
__device__ int theta_findBin(double theta);
__device__ int get_npe_num(int binx,int biny,double *npe,hiprandState *state);
__device__ int generateRandomInt(hiprandState *state,int begin,int end);

__device__ void calculate_by_step(double r,double pos_x,double pos_y,double pos_z,\
    double pmt_x,double pmt_y,double pmt_z,double intPart,double fractionPart,\
    double start_time,int evt_id,double *hittime_histo,double *npe,hiprandState *state,\
    Res_Arr *p_pmt_arr,int *evt_res_list);
__global__ void step_calculate_every_pmt(double *r,double *pos_x,double *pos_y,\
    double *pos_z,double *pmt_x,double *pmt_y,double *pmt_z,double *intPart,\
    double *fractionPart,double *start_time, int *evt_id,int numElements,int evtnum,\
    double *hittime_histo,double *npe,int *seed,double *result,int *pmt_res_list,\
    int *evt_res_list,int size);
__global__ void evt_calculate_add(int *evt_res_list,int *evt_res_back,int evtnum,int pmtnum);

__device__ void append_res_arr(Res_Arr *p, double val);
__device__ void add_evt_arr(Res_Arr *p, int evtid);
__device__ void init_res_arr(Res_Arr *p,double *result,int *pmt_res_list,int *evt_res_list,int pmtid,int size,int evt_num);

#define CHECK(call) \
{\
    const hipError_t error = call;\
    if (error != hipSuccess)\
    {\
        printf("Error:%s:%d, ", __FILE__, __LINE__);\
        printf("code:%d, reason: %s\n", error, hipGetErrorString(error));\
        exit(1);\
    }\
}

#define pmt_num 17746
#define pmt_mem 2000
#define HIP_PI_F 3.141592654f
#define CUDA_ERROR_CHECK
#define CudaCheckError()    __cudaCheckError( __FILE__, __LINE__ )

extern "C" float GPU_Sampling_wrapper(double *r,double *pos_x,double *pos_y,double *pos_z, \
    double *intPart, double *fractionPart,double *start_time,int *evt_id,int evtnum,double *pmt_x,double *pmt_y,\
    double *pmt_z,double *data_hit,double *data_npe,int *seed,int *size,double* h_result,int *h_evt_res_list);

#endif
	.text
	.file	"MuonSimu.hip"
	.type	__hip_cuid_,@object             # @__hip_cuid_
	.bss
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               # 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_

	.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_
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.amdgpu_metadata
---
amdhsa.kernels:  []
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
