// File: bolongz[P]Systematic-Alias-Sampling/test.cpp
// Function: main
int main(int argc, char *argv[]){

    
    int samplecount = 0;
    int bincount = 0;

    if(argc != 4){
        std::cout << "Usage: ./test bincount samplecount runtimes" << std::endl;
        exit(1);
    } 
    bincount = atoi(argv[1]); //bincount
    samplecount = atoi(argv[2]); //sampple count
    int times  = atoi(argv[3]) / samplecount; 
    
    
    struct timeval tvs, tvm; 
    std::vector<double> pmf;
    std::vector<double> values;
    
    double h = (8.0) / (bincount - 1); //[take value in [-4, 4]
    
    for(int i = 0; i < bincount; i++){
        double t = -4 + i * h;
        values.push_back(t);
        pmf.push_back(_normal_distribution(0.0, 1.0, t));
    }
    
    //  initial sas class 
    SystematicAliasSampling _sample(pmf, values);
    
    
    _sample.aliastable(); //generate table
    //std::vector<double> av = _sample.aliasvalue;;
    //std::sort(av.begin(), av.end());

    //for(int i = 0 ; i < av.size(); i++){
        //std::cout << av[i] << std::endl;
   //     std::cout << _normal_distribution(0.0, 1.0, av[i]) << std::endl;
    //} 
    std::vector<double> cdf(bincount);
    _sample.cummulative_distribution(cdf);
    
    double span0 =0.0;
    for(int j = 0; j < times ; j++){
        gettimeofday(&tvs, NULL);
        // binary search 
        std::vector<double> b_samples(samplecount);
        for(int i = 0; i < samplecount; i++){
            double x  = __random(gen);
            b_samples[i] = values[std::upper_bound(cdf.begin(), cdf.end(), x) - cdf.begin()];
            //std::cout << std::upper_bound(cdf.begin(), cdf.end(), x) - cdf.begin() << std::endl;
        
        }
        gettimeofday(&tvm, NULL);
        span0 += tvm.tv_sec-tvs.tv_sec + (tvm.tv_usec-tvs.tv_usec)/1000000.0;
    }
    //std::cout << "Binary Serach cost: " << span0 /times <<std::endl;
    
    // alias sampling method 
    std::uniform_real_distribution<double> ___random(0.0, bincount);
    
    double span =0.0;
    for(int j = 0; j < times; j++){
        gettimeofday(&tvs, NULL);
        std::vector<double> alias_samples(samplecount);
        for(int i = 0; i < samplecount; i++){
            double x  = ___random(gen);
            alias_samples[i]  = _sample.aliassample(int(x), x - int(x));
        }
        gettimeofday(&tvm, NULL);
        span += tvm.tv_sec-tvs.tv_sec + (tvm.tv_usec-tvs.tv_usec)/1000000.0;
    }
    //std::cout << "Alias method cost: " << span/times <<std::endl;
   

    // sas sampling 
    double span1 = 0.0;
    for(int j = 0; j < times; j++){
        gettimeofday(&tvs, NULL);
        std::vector<double> samples(samplecount); // store the results
        _sample.systematicaliassampling(samplecount, samples);
        gettimeofday(&tvm, NULL);
    
        span1 += tvm.tv_sec-tvs.tv_sec + (tvm.tv_usec-tvs.tv_usec)/1000000.0;
    }
    //std::cout << "SAS cost: " << span1 /times <<std::endl;
    
    //sas golden sampling 
    /*gettimeofday(&tvs, NULL);
    std::vector<double> samples2(samplecount);
    _sample.goldratioaliassampling(samplecount, samples2);
    
    gettimeofday(&tvm, NULL);
    double span4 = tvm.tv_sec-tvs.tv_sec + (tvm.tv_usec-tvs.tv_usec)/1000000.0;
    std::cout << "SAS-golden cost: " << span4 <<std::endl;
    */
    // normal_distribution in c++11 
    double span2 = 0.0;
    for(int j = 0; j < times; j++){
        gettimeofday(&tvs, NULL);
        std::vector<double> samples3(samplecount);
        __normal_distribution(samplecount, samples3);
        gettimeofday(&tvm, NULL);
        span2 += tvm.tv_sec-tvs.tv_sec + (tvm.tv_usec-tvs.tv_usec)/1000000.0;
    }
    //std::cout << "normal_distribution cost: " << span2/times <<std::endl;
    
    //discrete_distribution sampling in c++11 
    

    std::discrete_distribution<> _discrete_distribution(pmf.begin(), pmf.end());
    double span3 = 0.0;
    for(int j = 0; j < times; j++){
        gettimeofday(&tvs, NULL);
        std::vector<double> samples4(samplecount);;
        for(int i = 0 ; i < samplecount; i++){
            samples4[i] = _discrete_distribution(gen);
        }
        gettimeofday(&tvm, NULL);
        span3 += tvm.tv_sec-tvs.tv_sec + (tvm.tv_usec-tvs.tv_usec)/1000000.0;
    }
    //std::cout << "discrete_distribution cost: " << span3/times <<std::endl;
   
    std::cout << span0 /times <<" " << span/times << " " << span1/times << " " << span2/times <<" " << span3/times << std::endl;

   // std::vector<double> edf(bincount);
   
    //_sample.empirical_distribution(b_samples, edf);
    
   // for(int i = 0; i < bincount ; i++){
    //    std::cout << edf[i]<< std::endl;
        
   // }
   /* for(int j = 0 ; j < 1000; j ++){
        for(int i = 20; i < 2 * bincount; i++){
           // std::cout << "+++++++++++++"; 
           // double cvm = cramer_von_mises_alias(bincount, i);
            double cvm = cramer_von_mises_sas(bincount, i);
            //double cvm = cramer_von_mises_iid(bincount, i);
            std::cout << cvm <<" ";
        }
        std::cout << std::endl;
    }
    */
    return 0; 

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x3c0, %rsp            # imm = 0x3C0
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
movl $0x0, -0x18(%rbp)
cmpl $0x4, -0x8(%rbp)
je 0x2d79
movq 0xd284(%rip), %rdi      # 0xffd8
leaq 0x835d(%rip), %rsi      # 0xb0b8
callq 0x2110
movq %rax, %rdi
movq 0xd25e(%rip), %rsi      # 0xffc8
callq 0x2130
movl $0x1, %edi
callq 0x2150
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x21a0
movl %eax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x21a0
movl %eax, -0x14(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x21a0
cltd
idivl -0x14(%rbp)
movl %eax, -0x1c(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x3b90
leaq -0x70(%rbp), %rdi
callq 0x3b90
movl -0x18(%rbp), %eax
subl $0x1, %eax
cvtsi2sd %eax, %xmm1
movsd 0x827f(%rip), %xmm0     # 0xb050
divsd %xmm1, %xmm0
movsd %xmm0, -0x78(%rbp)
movl $0x0, -0x7c(%rbp)
movl -0x7c(%rbp), %eax
cmpl -0x18(%rbp), %eax
jge 0x2e77
cvtsi2sdl -0x7c(%rbp), %xmm0
movsd -0x78(%rbp), %xmm1
mulsd %xmm1, %xmm0
movsd 0x825d(%rip), %xmm1     # 0xb060
addsd %xmm1, %xmm0
movsd %xmm0, -0x88(%rbp)
leaq -0x70(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x3bb0
jmp 0x2e21
movsd -0x88(%rbp), %xmm2
xorps %xmm0, %xmm0
movsd 0x81d4(%rip), %xmm1     # 0xb008
callq 0x2430
movsd %xmm0, -0xa0(%rbp)
leaq -0x58(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x3c20
jmp 0x2e53
jmp 0x2e55
movl -0x7c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x7c(%rbp)
jmp 0x2de1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
jmp 0x3979
leaq -0x138(%rbp), %rdi
leaq -0x58(%rbp), %rsi
leaq -0x70(%rbp), %rdx
callq 0x3c50
jmp 0x2e8d
leaq -0x138(%rbp), %rdi
callq 0x3d80
jmp 0x2e9b
movslq -0x18(%rbp), %rax
movq %rax, -0x2d8(%rbp)
leaq -0x151(%rbp), %rdi
movq %rdi, -0x2d0(%rbp)
callq 0x43e0
movq -0x2d8(%rbp), %rsi
movq -0x2d0(%rbp), %rdx
leaq -0x150(%rbp), %rdi
callq 0x4400
jmp 0x2ed5
leaq -0x151(%rbp), %rdi
callq 0x4470
leaq -0x138(%rbp), %rdi
leaq -0x150(%rbp), %rsi
callq 0x4490
jmp 0x2ef6
xorps %xmm0, %xmm0
movsd %xmm0, -0x160(%rbp)
movl $0x0, -0x164(%rbp)
movl -0x164(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x3180
xorl %eax, %eax
movl %eax, %esi
leaq -0x30(%rbp), %rdi
callq 0x21b0
movslq -0x14(%rbp), %rax
movq %rax, -0x2e8(%rbp)
leaq -0x181(%rbp), %rdi
movq %rdi, -0x2e0(%rbp)
callq 0x43e0
movq -0x2e8(%rbp), %rsi
movq -0x2e0(%rbp), %rdx
leaq -0x180(%rbp), %rdi
callq 0x4400
jmp 0x2f61
leaq -0x181(%rbp), %rdi
callq 0x4470
movl $0x0, -0x188(%rbp)
movl -0x188(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x3119
leaq 0xf8cb(%rip), %rdi      # 0x12858
leaq 0xe53c(%rip), %rsi      # 0x114d0
callq 0x4560
movsd %xmm0, -0x2f0(%rbp)
jmp 0x2fa3
movsd -0x2f0(%rbp), %xmm0
movsd %xmm0, -0x190(%rbp)
leaq -0x150(%rbp), %rdi
movq %rdi, -0x300(%rbp)
callq 0x4620
movq -0x300(%rbp), %rdi
movq %rax, -0x1a0(%rbp)
callq 0x4650
movq %rax, -0x1a8(%rbp)
movq -0x1a0(%rbp), %rdi
movq -0x1a8(%rbp), %rsi
leaq -0x190(%rbp), %rdx
callq 0x45d0
movq %rax, -0x2f8(%rbp)
jmp 0x3003
movq -0x2f8(%rbp), %rax
movq %rax, -0x198(%rbp)
leaq -0x150(%rbp), %rdi
callq 0x4620
movq %rax, -0x1b0(%rbp)
leaq -0x198(%rbp), %rdi
leaq -0x1b0(%rbp), %rsi
callq 0x4590
movq %rax, %rsi
leaq -0x70(%rbp), %rdi
callq 0x3b70
movsd (%rax), %xmm0
movsd %xmm0, -0x308(%rbp)
movslq -0x188(%rbp), %rsi
leaq -0x180(%rbp), %rdi
callq 0x3b70
movsd -0x308(%rbp), %xmm0
movsd %xmm0, (%rax)
movl -0x188(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x188(%rbp)
jmp 0x2f77
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
jmp 0x396d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0x151(%rbp), %rdi
callq 0x4470
jmp 0x396d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
jmp 0x3961
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0x181(%rbp), %rdi
callq 0x4470
jmp 0x3961
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0x180(%rbp), %rdi
callq 0x4ad0
jmp 0x3961
leaq -0x40(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x21b0
movq -0x40(%rbp), %rax
subq -0x30(%rbp), %rax
cvtsi2sd %rax, %xmm0
movq -0x38(%rbp), %rax
subq -0x28(%rbp), %rax
cvtsi2sd %rax, %xmm1
movsd 0x7f10(%rip), %xmm2     # 0xb058
divsd %xmm2, %xmm1
addsd %xmm1, %xmm0
addsd -0x160(%rbp), %xmm0
movsd %xmm0, -0x160(%rbp)
leaq -0x180(%rbp), %rdi
callq 0x4ad0
movl -0x164(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x164(%rbp)
jmp 0x2f0b
cvtsi2sdl -0x18(%rbp), %xmm1
leaq -0x1c0(%rbp), %rdi
xorps %xmm0, %xmm0
callq 0x3ac0
jmp 0x3196
xorps %xmm0, %xmm0
movsd %xmm0, -0x1c8(%rbp)
movl $0x0, -0x1cc(%rbp)
movl -0x1cc(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x3364
xorl %eax, %eax
movl %eax, %esi
leaq -0x30(%rbp), %rdi
callq 0x21b0
movslq -0x14(%rbp), %rax
movq %rax, -0x318(%rbp)
leaq -0x1e9(%rbp), %rdi
movq %rdi, -0x310(%rbp)
callq 0x43e0
movq -0x318(%rbp), %rsi
movq -0x310(%rbp), %rdx
leaq -0x1e8(%rbp), %rdi
callq 0x4400
jmp 0x3201
leaq -0x1e9(%rbp), %rdi
callq 0x4470
movl $0x0, -0x1f0(%rbp)
movl -0x1f0(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x32fd
leaq 0xe2a3(%rip), %rsi      # 0x114d0
leaq -0x1c0(%rbp), %rdi
callq 0x4560
movsd %xmm0, -0x320(%rbp)
jmp 0x3243
movsd -0x320(%rbp), %xmm0
movsd %xmm0, -0x1f8(%rbp)
movsd -0x1f8(%rbp), %xmm0
cvttsd2si %xmm0, %esi
movaps %xmm0, %xmm1
cvttpd2dq %xmm1, %xmm1
cvtdq2pd %xmm1, %xmm1
subsd %xmm1, %xmm0
leaq -0x138(%rbp), %rdi
callq 0x4cd0
movsd %xmm0, -0x328(%rbp)
jmp 0x3284
movslq -0x1f0(%rbp), %rsi
leaq -0x1e8(%rbp), %rdi
callq 0x3b70
movsd -0x328(%rbp), %xmm0
movsd %xmm0, (%rax)
movl -0x1f0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1f0(%rbp)
jmp 0x3217
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0x1e9(%rbp), %rdi
callq 0x4470
jmp 0x3961
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0x1e8(%rbp), %rdi
callq 0x4ad0
jmp 0x3961
leaq -0x40(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x21b0
movq -0x40(%rbp), %rax
subq -0x30(%rbp), %rax
cvtsi2sd %rax, %xmm0
movq -0x38(%rbp), %rax
subq -0x28(%rbp), %rax
cvtsi2sd %rax, %xmm1
movsd 0x7d2c(%rip), %xmm2     # 0xb058
divsd %xmm2, %xmm1
addsd %xmm1, %xmm0
addsd -0x1c8(%rbp), %xmm0
movsd %xmm0, -0x1c8(%rbp)
leaq -0x1e8(%rbp), %rdi
callq 0x4ad0
movl -0x1cc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1cc(%rbp)
jmp 0x31ab
xorps %xmm0, %xmm0
movsd %xmm0, -0x200(%rbp)
movl $0x0, -0x204(%rbp)
movl -0x204(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x34a2
xorl %eax, %eax
movl %eax, %esi
leaq -0x30(%rbp), %rdi
callq 0x21b0
movslq -0x14(%rbp), %rax
movq %rax, -0x338(%rbp)
leaq -0x221(%rbp), %rdi
movq %rdi, -0x330(%rbp)
callq 0x43e0
movq -0x338(%rbp), %rsi
movq -0x330(%rbp), %rdx
leaq -0x220(%rbp), %rdi
callq 0x4400
jmp 0x33cf
leaq -0x221(%rbp), %rdi
callq 0x4470
movl -0x14(%rbp), %esi
leaq -0x138(%rbp), %rdi
leaq -0x220(%rbp), %rdx
xorl %ecx, %ecx
callq 0x4d60
jmp 0x33f5
leaq -0x40(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x21b0
movq -0x40(%rbp), %rax
subq -0x30(%rbp), %rax
cvtsi2sd %rax, %xmm0
movq -0x38(%rbp), %rax
subq -0x28(%rbp), %rax
cvtsi2sd %rax, %xmm1
movsd 0x7c34(%rip), %xmm2     # 0xb058
divsd %xmm2, %xmm1
addsd %xmm1, %xmm0
addsd -0x200(%rbp), %xmm0
movsd %xmm0, -0x200(%rbp)
leaq -0x220(%rbp), %rdi
callq 0x4ad0
movl -0x204(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x204(%rbp)
jmp 0x3379
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0x221(%rbp), %rdi
callq 0x4470
jmp 0x3961
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0x220(%rbp), %rdi
callq 0x4ad0
jmp 0x3961
xorps %xmm0, %xmm0
movsd %xmm0, -0x230(%rbp)
movl $0x0, -0x234(%rbp)
movl -0x234(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x35d7
xorl %eax, %eax
movl %eax, %esi
leaq -0x30(%rbp), %rdi
callq 0x21b0
movslq -0x14(%rbp), %rax
movq %rax, -0x348(%rbp)
leaq -0x251(%rbp), %rdi
movq %rdi, -0x340(%rbp)
callq 0x43e0
movq -0x348(%rbp), %rsi
movq -0x340(%rbp), %rdx
leaq -0x250(%rbp), %rdi
callq 0x4400
jmp 0x350d
leaq -0x251(%rbp), %rdi
callq 0x4470
movl -0x14(%rbp), %edi
leaq -0x250(%rbp), %rsi
callq 0x24b0
jmp 0x352a
leaq -0x40(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x21b0
movq -0x40(%rbp), %rax
subq -0x30(%rbp), %rax
cvtsi2sd %rax, %xmm0
movq -0x38(%rbp), %rax
subq -0x28(%rbp), %rax
cvtsi2sd %rax, %xmm1
movsd 0x7aff(%rip), %xmm2     # 0xb058
divsd %xmm2, %xmm1
addsd %xmm1, %xmm0
addsd -0x230(%rbp), %xmm0
movsd %xmm0, -0x230(%rbp)
leaq -0x250(%rbp), %rdi
callq 0x4ad0
movl -0x234(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x234(%rbp)
jmp 0x34b7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0x251(%rbp), %rdi
callq 0x4470
jmp 0x3961
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0x250(%rbp), %rdi
callq 0x4ad0
jmp 0x3961
leaq -0x58(%rbp), %rdi
movq %rdi, -0x350(%rbp)
callq 0x4620
movq -0x350(%rbp), %rdi
movq %rax, -0x290(%rbp)
callq 0x4650
movq %rax, -0x298(%rbp)
movq -0x290(%rbp), %rsi
movq -0x298(%rbp), %rdx
leaq -0x288(%rbp), %rdi
callq 0x4f50
jmp 0x361d
xorps %xmm0, %xmm0
movsd %xmm0, -0x2a0(%rbp)
movl $0x0, -0x2a4(%rbp)
movl -0x2a4(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x37b7
xorl %eax, %eax
movl %eax, %esi
leaq -0x30(%rbp), %rdi
callq 0x21b0
movslq -0x14(%rbp), %rax
movq %rax, -0x360(%rbp)
leaq -0x2c1(%rbp), %rdi
movq %rdi, -0x358(%rbp)
callq 0x43e0
movq -0x360(%rbp), %rsi
movq -0x358(%rbp), %rdx
leaq -0x2c0(%rbp), %rdi
callq 0x4400
jmp 0x3688
leaq -0x2c1(%rbp), %rdi
callq 0x4470
movl $0x0, -0x2c8(%rbp)
movl -0x2c8(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x3750
leaq 0xde1c(%rip), %rsi      # 0x114d0
leaq -0x288(%rbp), %rdi
callq 0x4f90
movl %eax, -0x364(%rbp)
jmp 0x36c8
movl -0x364(%rbp), %eax
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0x370(%rbp)
movslq -0x2c8(%rbp), %rsi
leaq -0x2c0(%rbp), %rdi
callq 0x3b70
movsd -0x370(%rbp), %xmm0
movsd %xmm0, (%rax)
movl -0x2c8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c8(%rbp)
jmp 0x369e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0x2c1(%rbp), %rdi
callq 0x4470
jmp 0x3955
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0x2c0(%rbp), %rdi
callq 0x4ad0
jmp 0x3955
leaq -0x40(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x21b0
movq -0x40(%rbp), %rax
subq -0x30(%rbp), %rax
cvtsi2sd %rax, %xmm0
movq -0x38(%rbp), %rax
subq -0x28(%rbp), %rax
cvtsi2sd %rax, %xmm1
movsd 0x78d9(%rip), %xmm2     # 0xb058
divsd %xmm2, %xmm1
addsd %xmm1, %xmm0
addsd -0x2a0(%rbp), %xmm0
movsd %xmm0, -0x2a0(%rbp)
leaq -0x2c0(%rbp), %rdi
callq 0x4ad0
movl -0x2a4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2a4(%rbp)
jmp 0x3632
movsd -0x160(%rbp), %xmm0
cvtsi2sdl -0x1c(%rbp), %xmm1
divsd %xmm1, %xmm0
movq 0xc809(%rip), %rdi      # 0xffd8
callq 0x2230
movq %rax, -0x378(%rbp)
jmp 0x37dd
movq -0x378(%rbp), %rdi
leaq 0x78f9(%rip), %rsi      # 0xb0e4
callq 0x2110
movq %rax, -0x380(%rbp)
jmp 0x37f9
movq -0x380(%rbp), %rdi
movsd -0x1c8(%rbp), %xmm0
cvtsi2sdl -0x1c(%rbp), %xmm1
divsd %xmm1, %xmm0
callq 0x2230
movq %rax, -0x388(%rbp)
jmp 0x381f
movq -0x388(%rbp), %rdi
leaq 0x78b7(%rip), %rsi      # 0xb0e4
callq 0x2110
movq %rax, -0x390(%rbp)
jmp 0x383b
movq -0x390(%rbp), %rdi
movsd -0x200(%rbp), %xmm0
cvtsi2sdl -0x1c(%rbp), %xmm1
divsd %xmm1, %xmm0
callq 0x2230
movq %rax, -0x398(%rbp)
jmp 0x3861
movq -0x398(%rbp), %rdi
leaq 0x7875(%rip), %rsi      # 0xb0e4
callq 0x2110
movq %rax, -0x3a0(%rbp)
jmp 0x387d
movq -0x3a0(%rbp), %rdi
movsd -0x230(%rbp), %xmm0
cvtsi2sdl -0x1c(%rbp), %xmm1
divsd %xmm1, %xmm0
callq 0x2230
movq %rax, -0x3a8(%rbp)
jmp 0x38a3
movq -0x3a8(%rbp), %rdi
leaq 0x7833(%rip), %rsi      # 0xb0e4
callq 0x2110
movq %rax, -0x3b0(%rbp)
jmp 0x38bf
movq -0x3b0(%rbp), %rdi
movsd -0x2a0(%rbp), %xmm0
cvtsi2sdl -0x1c(%rbp), %xmm1
divsd %xmm1, %xmm0
callq 0x2230
movq %rax, -0x3b8(%rbp)
jmp 0x38e5
movq -0x3b8(%rbp), %rdi
movq 0xc6d5(%rip), %rsi      # 0xffc8
callq 0x2130
jmp 0x38fa
movl $0x0, -0x4(%rbp)
leaq -0x288(%rbp), %rdi
callq 0x4fc0
leaq -0x150(%rbp), %rdi
callq 0x4ad0
leaq -0x138(%rbp), %rdi
callq 0x4b30
leaq -0x70(%rbp), %rdi
callq 0x4ad0
leaq -0x58(%rbp), %rdi
callq 0x4ad0
movl -0x4(%rbp), %eax
addq $0x3c0, %rsp            # imm = 0x3C0
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0x288(%rbp), %rdi
callq 0x4fc0
leaq -0x150(%rbp), %rdi
callq 0x4ad0
leaq -0x138(%rbp), %rdi
callq 0x4b30
leaq -0x70(%rbp), %rdi
callq 0x4ad0
leaq -0x58(%rbp), %rdi
callq 0x4ad0
movq -0x90(%rbp), %rdi
callq 0x2200
nopw (%rax,%rax)