// File: /workspace/github_cpp_makefile_star2_O2/schneebergerlab[P]DrLink/sample_molecule.cpp
// Function: sample_molecule(int, char**)
bool sample_molecule(int argc, char* argv[])
{
    std::stringstream usage;
    usage.str("");
    if(argc < 8)
    {
        usage << endl;
        usage << "   Given sets of molecule size distributions and molecule info, "                         
              << endl;
        usage << "   this function samples molecules according to intersection of molecule sizes"           
              << endl;        
        const char *buildString = __DATE__", " __TIME__;
        usage << "   (compiled on " << buildString << ")"                                                   
              << endl << endl;
        usage << "   Usage: DrLink resample msize1.txt,msize2.txt[,...] mole1.gz,mole2.gz[,...] read1,read2[,...] labels outprefix srand-sleep-int" 
              << endl << endl;
        usage << "\twhere "                                                         << endl;
        usage << "\tmsize*.txt:   molecule size distribution of pools"              << endl;
        usage << "\tmole*.gz  :   molecule meta info corresponding to molecule size of pools from DrLink molecule"  
              << endl;
        usage << "\tread*     :   mean molecule read coverage in raw data"          << endl;
        usage << "\tlabels    :   sample-specific label of output files"            << endl;
        usage << "\toutprefix :   general label of output files"                    << endl;
        cout  << usage.str() << endl;
        return false;
    }
    double startT   = clock(); 
    int srandsleep  = atoi(argv[7]); 
    cout << "   Info: sleeping " << srandsleep << " seconds to get various srand seeds. " << endl;
    sleep(srandsleep);
    string lenfiles = (string)argv[2];
    vector<string> lenfileinfo = split_string(lenfiles, ',');
    if(lenfileinfo.size()<2)
    {
        cout << "   Error: only one file given. No need to sample!" << endl;
        return false;
    }
    string molfiles = (string)argv[3];
    vector<string> molfileinfo = split_string(molfiles, ',');
    if(molfileinfo.size()<2)
    {
        cout << "   Error: only one file given. No need to sample!" << endl;
        return false;
    }    
    if(lenfileinfo.size() != molfileinfo.size())
    {
        cout << "   Error: molecule-size file-number does not matach molecule-meta-info file-number. " << endl;
        return false;
    }
    //
    vector<string> labels = split_string((string)argv[5], ',');
    string out_prefix     = string(argv[6]);       
    // 1. read number of molecule-size distributions in pools
    map<int, unsigned long> mNum_intersec;
    map<int, map<int, unsigned long> > mNum_individ;
    vector<string>::iterator lfitr;
    vector<string>::iterator lfitr_end;
    lfitr     = lenfileinfo.begin();
    lfitr_end = lenfileinfo.end();
    int i = -1;
    while(lfitr != lfitr_end)
    {
        string msfile = *lfitr;
        map<int, unsigned long> mNum;
        if(!(read_msize_dist(msfile, &mNum, &mNum_intersec)))
        {
            cout << "   Error: failed in reading molecule size distribution. " << endl;
            return false;
        }
        i ++;
        //
        mNum_individ.insert(std::pair<int, map<int, unsigned long> >(i, mNum) );
        //
        lfitr ++;
    }
    // 2. get sampling ratio with respecitve to a specific molecule size for each pool
    map<int, map<int, double> > mNum_individ_sratio;
    lfitr     = lenfileinfo.begin();
    lfitr_end = lenfileinfo.end();
    i = -1;
    while(lfitr != lfitr_end)
    {
        map<int, double> msratio;
        //
        i ++;
        map<int, unsigned long> mNum = mNum_individ[i];
        map<int, unsigned long>::iterator lenitr;
        map<int, unsigned long>::iterator lenitr_end;
        lenitr     = mNum.begin();
        lenitr_end = mNum.end();
        while(lenitr != lenitr_end)
        {
            int key           = (*lenitr).first;
            unsigned long num = (*lenitr).second;
            assert( mNum_intersec.find(key) != mNum_intersec.end() );
            if(num == 0) num  = 1;
            double sratio     = mNum_intersec[key]*1.0/num;
            sratio = sratio*0.96;
            
            // scaling - 2018-09-25: to get C substantially sampled while keeping around 6 million molecules
            if(labels[i].compare("B") == 0) 
            {
                sratio = sratio*(6000000.0/7016664.0);
            }else
            if(labels[i].compare("C") == 0)
            {
                sratio = sratio*(6000000.0/6949772.0);
            }else
            if(labels[i].compare("D") == 0) 
            {
                sratio = sratio*(6000000.0/7273738.0);
            }else
            if(labels[i].compare("E") == 0) 
            {
                sratio = sratio*(6000000.0/7101105.0);
            }else
            if(labels[i].compare("P") == 0) 
            {
                sratio = sratio*(6000000.0/6682080.0); // 6882080
            }else ;
            //
               
            msratio.insert(std::pair<int, double>(key, sratio)); // to make D sampled
            lenitr ++;
        }
        //
        mNum_individ_sratio.insert(std::pair<int, map<int, double> >(i, msratio));      
        //
        lfitr ++; 
    }
    // check
    if(true)
    {
        lfitr     = lenfileinfo.begin();
        lfitr_end = lenfileinfo.end();
        i = -1;   
        while(lfitr != lfitr_end)     
        {
            i ++;
            map<int, unsigned long> mNum = mNum_individ[i];
            map<int, double>     msratio = mNum_individ_sratio[i];
            cout << "   Check: file " << lenfileinfo[i] << endl << endl;
            if(labels[i].compare("D") == 0) 
            {
                cout << "   Info: all length ratio decreased by 0.04 to get D a random molecule number. " << endl;
            }
            map<int, double>::iterator sritr;
            map<int, double>::iterator sritr_end;
            sritr     = msratio.begin();
            sritr_end = msratio.end();
            while(sritr != sritr_end)
            {
                int key = (*sritr).first;
                cout << "      " 
                     << (*sritr).first 
                     << "\t" << (*sritr).second 
                     << " from " 
                     << mNum_intersec[key] 
                     << "/" 
                     << mNum[key] 
                     << endl;
                sritr ++;
            }
            lfitr ++;
        }
    }
    // 3. get sampling ratio with respecitve to a specific molecule base coverage for each pool
    
    // 4. sample molecules
    // read ratio
    vector<string> readratiostr = split_string((string)argv[4], ',');
    vector<double> readratio; // ratio of reads to keep
    double minmrc = 1;
    vector<string>::iterator rritr;
    vector<string>::iterator rritr_end;
    rritr     = readratiostr.begin();
    rritr_end = readratiostr.end();
    while(rritr != rritr_end)
    {
        double rr = atof((*rritr).c_str());
        readratio.push_back(rr);
        if(minmrc > rr) minmrc = rr;
        rritr ++;
    }
    vector<double>::iterator rr2itr     = readratio.begin();
    vector<double>::iterator rr2itr_end = readratio.end();
    while(rr2itr != rr2itr_end)
    {
        (*rr2itr) = 1.0 - ((*rr2itr) - minmrc)/(*rr2itr);
        rr2itr ++;
    }
    // molecule
    vector<string>::iterator mfitr;
    vector<string>::iterator mfitr_end;
    mfitr     = molfileinfo.begin();
    mfitr_end = molfileinfo.end();
    i = -1;
    while(mfitr != mfitr_end)
    {
        i ++;
        double this_readratio       = readratio[i];
            // special - caution!
            if(labels[i].compare("B") == 0) 
            {
                this_readratio = this_readratio*0.95*0.83643;
            }else
            if(labels[i].compare("C") == 0)
            {
                this_readratio = this_readratio*1.00*0.788091;
            }else
            if(labels[i].compare("D") == 0) 
            {
                this_readratio = this_readratio*0.92*44.0/49.0;
            }else
            if(labels[i].compare("E") == 0) 
            {
                this_readratio = this_readratio*1.00;
            }else
            if(labels[i].compare("P") == 0) 
            {
                this_readratio = this_readratio*0.92*44.0/49.0;
            }else ;
        string molfile              = molfileinfo[i];
        string ilabel               = labels[i];
        map<int,    double> msratio = mNum_individ_sratio[i];    
        //    
        map<string, unsigned long> molecule_cov;
        map<int,    unsigned long> molecule_len;
        map<int,    unsigned long> molecule_len_sum;                 
        map<int,    unsigned long> molecule_read_num;
        map<int,    unsigned long> molecule_read_num_sum;
        map<string,           int> barcode_molecule_cnt;
        if(molfile.compare("skip") != 0)
        {
            if(!sampling_molecule(molfile, 
                                this_readratio,
                                out_prefix + "_" + ilabel, 
                                msratio, 
                                &molecule_cov,
                                &molecule_len,
                                &molecule_len_sum,                      
                                &molecule_read_num,
                                &molecule_read_num_sum,
                                &barcode_molecule_cnt))
            {
                return false;
            }  
            if(!write_sampled_molecule_stat(molecule_cov, 
                                            molecule_len, 
                                            molecule_len_sum, 
                                            molecule_read_num,
                                            molecule_read_num_sum,
                                            barcode_molecule_cnt,
                                            out_prefix + "_" + ilabel))
            {
                return false;
            }
        }
        mfitr ++;  
    }  
        
    double finishT= clock();
    cout << "   Time consumed: " << (finishT-startT)/1000000 << " seconds" << endl << endl;    
    return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x6c8, %rsp            # imm = 0x6C8
movq %rsi, %r14
movl %edi, %ebp
leaq 0x540(%rsp), %rdi
callq 0x4250
leaq 0x136c0(%rip), %rsi     # 0x2db1a
leaq 0x30(%rsp), %rdi
leaq 0x270(%rsp), %rdx
callq 0x4d3e
leaq 0x558(%rsp), %rbx
leaq 0x30(%rsp), %rsi
movq %rbx, %rdi
callq 0x4490
leaq 0x30(%rsp), %rdi
callq 0x4638
cmpl $0x7, %ebp
jg 0x1a5ef
leaq 0x550(%rsp), %r14
movq %r14, %rdi
callq 0x41c0
leaq 0x12b15(%rip), %rsi     # 0x2cfc0
movq %r14, %rdi
callq 0x4330
movq %rax, %rdi
callq 0x41c0
leaq 0x12b3f(%rip), %rsi     # 0x2d001
movq %r14, %rdi
callq 0x4330
movq %rax, %rdi
callq 0x41c0
leaq 0x127ea(%rip), %rsi     # 0x2ccc3
movq %r14, %rdi
callq 0x4330
leaq 0x12b68(%rip), %rsi     # 0x2d050
movq %rax, %rdi
callq 0x4330
leaq 0x12e41(%rip), %rsi     # 0x2d338
movq %rax, %rdi
callq 0x4330
movq %rax, %rdi
callq 0x41c0
movq %rax, %rdi
callq 0x41c0
leaq 0x12b50(%rip), %rsi     # 0x2d066
movq %r14, %rdi
callq 0x4330
movq %rax, %rdi
callq 0x41c0
movq %rax, %rdi
callq 0x41c0
leaq 0x127f0(%rip), %rsi     # 0x2cd25
movq %r14, %rdi
callq 0x4330
movq %rax, %rdi
callq 0x41c0
leaq 0x12b9b(%rip), %rsi     # 0x2d0e7
movq %r14, %rdi
callq 0x4330
movq %rax, %rdi
callq 0x41c0
leaq 0x12bb7(%rip), %rsi     # 0x2d11a
movq %r14, %rdi
callq 0x4330
movq %rax, %rdi
callq 0x41c0
leaq 0x12bff(%rip), %rsi     # 0x2d179
movq %r14, %rdi
callq 0x4330
movq %rax, %rdi
callq 0x41c0
leaq 0x12c1f(%rip), %rsi     # 0x2d1b0
movq %r14, %rdi
callq 0x4330
movq %rax, %rdi
callq 0x41c0
leaq 0x12c3d(%rip), %rsi     # 0x2d1e5
movq %r14, %rdi
callq 0x4330
movq %rax, %rdi
callq 0x41c0
leaq 0x30(%rsp), %rdi
movq %rbx, %rsi
callq 0x44e0
movq 0x229fc(%rip), %rdi     # 0x3cfc8
leaq 0x30(%rsp), %rsi
callq 0x42e0
movq %rax, %rdi
callq 0x41c0
leaq 0x30(%rsp), %rdi
callq 0x4638
xorl %ebx, %ebx
jmp 0x1b555
callq 0x4220
movq %rax, %rbx
movq 0x38(%r14), %rdi
callq 0x44c0
movl %eax, %ebp
movq 0x229bf(%rip), %rdi     # 0x3cfc8
leaq 0x12c02(%rip), %rsi     # 0x2d212
callq 0x4330
movq %rax, %rdi
movl %ebp, %esi
callq 0x4580
leaq 0x12bff(%rip), %rsi     # 0x2d225
movq %rax, %rdi
callq 0x4330
movq %rax, %rdi
callq 0x41c0
movl %ebp, %edi
callq 0x4290
movq 0x10(%r14), %rsi
leaq 0x370(%rsp), %rdi
leaq 0x30(%rsp), %rdx
callq 0x4d3e
leaq 0x30(%rsp), %rdx
movb $0x2c, (%rdx)
leaq 0x80(%rsp), %rdi
leaq 0x370(%rsp), %rsi
callq 0x26120
movq 0x88(%rsp), %rax
subq 0x80(%rsp), %rax
cmpq $0x20, %rax
ja 0x1a6a8
movq 0x2293b(%rip), %rdi     # 0x3cfc8
leaq 0x12bb7(%rip), %rsi     # 0x2d24b
callq 0x4330
movq %rax, %rdi
callq 0x41c0
xorl %ebx, %ebx
jmp 0x1b53b
movq 0x18(%r14), %rsi
leaq 0x350(%rsp), %rdi
leaq 0x30(%rsp), %rdx
callq 0x4d3e
leaq 0x30(%rsp), %rdx
movb $0x2c, (%rdx)
leaq 0x108(%rsp), %rdi
leaq 0x350(%rsp), %rsi
callq 0x26120
movq 0x110(%rsp), %rax
subq 0x108(%rsp), %rax
cmpq $0x21, %rax
jae 0x1a6fd
leaq 0x12b53(%rip), %rsi     # 0x2d24b
jmp 0x1a8d6
movq 0x88(%rsp), %rcx
subq 0x80(%rsp), %rcx
cmpq %rax, %rcx
jne 0x1a8cf
movq 0x28(%r14), %rsi
leaq 0x30(%rsp), %rdi
leaq 0x270(%rsp), %rdx
callq 0x4d3e
leaq 0x300(%rsp), %rdx
movb $0x2c, (%rdx)
leaq 0x68(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x26120
leaq 0x30(%rsp), %rdi
callq 0x4638
movq %r14, 0xc8(%rsp)
movq 0x30(%r14), %rsi
leaq 0x2e0(%rsp), %rdi
leaq 0x30(%rsp), %rdx
callq 0x4d3e
cvtsi2sd %rbx, %xmm0
movsd %xmm0, 0x1a0(%rsp)
leaq 0x278(%rsp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
leaq 0x308(%rsp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
orl $-0x1, 0xc(%rsp)
movq 0x80(%rsp), %rbx
movq 0x88(%rsp), %rbp
leaq 0x98(%rsp), %r15
leaq 0x4c0(%rsp), %r12
leaq 0x120(%rsp), %r13
cmpq %rbp, %rbx
je 0x1a8f1
movq %r15, %rdi
movq %rbx, %rsi
callq 0x4400
andl $0x0, 0x128(%rsp)
andq $0x0, 0x130(%rsp)
leaq 0x128(%rsp), %rax
movq %rax, 0x138(%rsp)
movq %rax, 0x140(%rsp)
andq $0x0, 0x148(%rsp)
movq %r12, %rdi
movq %r15, %rsi
callq 0x4400
movq %r12, %rdi
movq %r13, %rsi
leaq 0x270(%rsp), %rdx
callq 0x1b8d3
movl %eax, %r14d
movq %r12, %rdi
callq 0x4638
testb %r14b, %r14b
je 0x1a894
movl 0xc(%rsp), %eax
incl %eax
movl %eax, 0xc(%rsp)
movl %eax, 0x30(%rsp)
leaq 0x38(%rsp), %rdi
movq %r13, %rsi
callq 0x9b48
leaq 0x300(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x1d996
leaq 0x38(%rsp), %rdi
callq 0xa018
addq $0x20, %rbx
jmp 0x1a8af
movq 0x2272d(%rip), %rdi     # 0x3cfc8
leaq 0x12a30(%rip), %rsi     # 0x2d2d2
callq 0x4330
movq %rax, %rdi
callq 0x41c0
movq %r13, %rdi
callq 0xa018
movq %r15, %rdi
callq 0x4638
testb %r14b, %r14b
jne 0x1a7e3
xorl %ebx, %ebx
jmp 0x1b4f0
leaq 0x129a7(%rip), %rsi     # 0x2d27d
movq 0x226eb(%rip), %rdi     # 0x3cfc8
callq 0x4330
movq %rax, %rdi
callq 0x41c0
xorl %ebx, %ebx
jmp 0x1b521
leaq 0x120(%rsp), %rax
andl $0x0, 0x8(%rax)
andq $0x0, 0x10(%rax)
leaq 0x128(%rsp), %rcx
movq %rcx, 0x18(%rax)
movq %rcx, 0x20(%rax)
andq $0x0, 0x28(%rax)
leaq 0xc(%rsp), %rax
orl $-0x1, (%rax)
movq 0x80(%rsp), %r13
movq 0x88(%rsp), %rax
movq %rax, 0xd0(%rsp)
leaq 0x98(%rsp), %rbp
leaq 0x30(%rsp), %r12
leaq 0x270(%rsp), %rbx
leaq 0x150(%rsp), %r14
cmpq 0xd0(%rsp), %r13
je 0x1abd7
movq %r13, 0x28(%rsp)
andl $0x0, 0xa0(%rsp)
andq $0x0, 0xa8(%rsp)
leaq 0xa0(%rsp), %rax
movq %rax, 0xb0(%rsp)
movq %rax, 0xb8(%rsp)
andq $0x0, 0xc0(%rsp)
incl 0xc(%rsp)
leaq 0x300(%rsp), %rdi
leaq 0xc(%rsp), %rsi
callq 0x1d530
leaq 0xd8(%rsp), %rdi
movq %rax, %rsi
callq 0x9b48
movq 0xf0(%rsp), %r13
leaq 0xe0(%rsp), %rax
cmpq %rax, %r13
je 0x1ab84
movl 0x20(%r13), %eax
movl %eax, 0x150(%rsp)
movq 0x28(%r13), %r15
movq %rbx, %rdi
movq %r14, %rsi
callq 0xa69a
leaq 0x278(%rsp), %rcx
cmpq %rcx, %rax
je 0x1b576
movq %rbx, %rdi
movq %r14, %rsi
callq 0x973e
cmpq $0x1, %r15
adcq $0x0, %r15
movsd (%rax), %xmm0
movsd 0xf69e(%rip), %xmm1     # 0x2a0c0
unpcklps %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0xf6a3(%rip), %xmm2     # 0x2a0d0
subpd %xmm2, %xmm0
movapd %xmm0, %xmm3
unpckhpd %xmm0, %xmm3            # xmm3 = xmm3[1],xmm0[1]
addsd %xmm0, %xmm3
movq %r15, %xmm0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
subpd %xmm2, %xmm0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
divsd %xmm1, %xmm3
mulsd 0x124ee(%rip), %xmm3    # 0x2cf50
movapd %xmm3, 0x10(%rsp)
movslq 0xc(%rsp), %rdi
shlq $0x5, %rdi
addq 0x68(%rsp), %rdi
leaq 0x128f4(%rip), %rsi     # 0x2d371
callq 0x4110
testl %eax, %eax
je 0x1ab0a
movslq 0xc(%rsp), %rdi
shlq $0x5, %rdi
addq 0x68(%rsp), %rdi
leaq 0x10127(%rip), %rsi     # 0x2abc6
callq 0x4110
testl %eax, %eax
je 0x1ab1a
movslq 0xc(%rsp), %rdi
shlq $0x5, %rdi
addq 0x68(%rsp), %rdi
leaq 0x128b6(%rip), %rsi     # 0x2d373
callq 0x4110
testl %eax, %eax
je 0x1ab2a
movslq 0xc(%rsp), %rdi
shlq $0x5, %rdi
addq 0x68(%rsp), %rdi
leaq 0x1289a(%rip), %rsi     # 0x2d375
callq 0x4110
testl %eax, %eax
je 0x1ab3a
movslq 0xc(%rsp), %rdi
shlq $0x5, %rdi
addq 0x68(%rsp), %rdi
leaq 0x12d0a(%rip), %rsi     # 0x2d803
callq 0x4110
testl %eax, %eax
je 0x1ab4a
movapd 0x10(%rsp), %xmm0
jmp 0x1ab58
movapd 0x10(%rsp), %xmm0
mulsd 0x12460(%rip), %xmm0    # 0x2cf78
jmp 0x1ab58
movapd 0x10(%rsp), %xmm0
mulsd 0x12448(%rip), %xmm0    # 0x2cf70
jmp 0x1ab58
movapd 0x10(%rsp), %xmm0
mulsd 0x12430(%rip), %xmm0    # 0x2cf68
jmp 0x1ab58
movapd 0x10(%rsp), %xmm0
mulsd 0x12418(%rip), %xmm0    # 0x2cf60
jmp 0x1ab58
movapd 0x10(%rsp), %xmm0
mulsd 0x12400(%rip), %xmm0    # 0x2cf58
movl 0x150(%rsp), %eax
movl %eax, 0x30(%rsp)
movsd %xmm0, 0x38(%rsp)
movq %rbp, %rdi
movq %r12, %rsi
callq 0x1dd2c
movq %r13, %rdi
callq 0x4240
movq %rax, %r13
jmp 0x1a9c7
movl 0xc(%rsp), %eax
movl %eax, 0x30(%rsp)
leaq 0x38(%rsp), %r15
movq %r15, %rdi
movq %rbp, %rsi
callq 0x1d6f8
leaq 0x120(%rsp), %rdi
movq %r12, %rsi
callq 0x1de6e
movq 0x28(%rsp), %r13
movq %r15, %rdi
callq 0x1d6a0
addq $0x20, %r13
leaq 0xd8(%rsp), %rdi
callq 0xa018
movq %rbp, %rdi
callq 0x1d6a0
jmp 0x1a954
leaq 0xc(%rsp), %r14
orl $-0x1, (%r14)
movq 0x80(%rsp), %rax
movq 0x88(%rsp), %rcx
movq %rcx, 0x28(%rsp)
leaq 0x30(%rsp), %r12
movq 0x223c7(%rip), %r15     # 0x3cfc8
leaq 0xd8(%rsp), %r13
leaq 0x1315a(%rip), %rbx     # 0x2dd6a
cmpq 0x28(%rsp), %rax
je 0x1adbc
movq %rax, 0x10(%rsp)
incl 0xc(%rsp)
leaq 0x300(%rsp), %rdi
movq %r14, %rsi
callq 0x1d530
movq %r12, %rdi
movq %rax, %rsi
callq 0x9b48
leaq 0x120(%rsp), %rdi
movq %r14, %rsi
callq 0x1d57e
leaq 0x98(%rsp), %rdi
movq %rax, %rsi
callq 0x1d6f8
movq %r15, %rdi
leaq 0x1270e(%rip), %rsi     # 0x2d377
callq 0x4330
movslq 0xc(%rsp), %rsi
shlq $0x5, %rsi
addq 0x80(%rsp), %rsi
movq %rax, %rdi
callq 0x42e0
movq %rax, %rdi
callq 0x41c0
movq %rax, %rdi
callq 0x41c0
movslq 0xc(%rsp), %rdi
shlq $0x5, %rdi
addq 0x68(%rsp), %rdi
leaq 0x126c7(%rip), %rsi     # 0x2d373
callq 0x4110
testl %eax, %eax
jne 0x1accc
movq %r15, %rdi
leaq 0x126c8(%rip), %rsi     # 0x2d387
callq 0x4330
movq %rax, %rdi
callq 0x41c0
movq 0xb0(%rsp), %r14
leaq 0xa0(%rsp), %rax
cmpq %rax, %r14
je 0x1ad91
movl 0x20(%r14), %eax
movl %eax, 0xd8(%rsp)
movq %r15, %rdi
leaq 0x1066d(%rip), %rsi     # 0x2b367
callq 0x4330
movl 0x20(%r14), %esi
movq %rax, %rdi
callq 0x4580
movq %rax, %rdi
leaq 0x12e04(%rip), %rsi     # 0x2db19
callq 0x4330
movsd 0x28(%r14), %xmm0
movq %rax, %rdi
callq 0x4510
movq %rax, %rdi
leaq 0x128ac(%rip), %rsi     # 0x2d5de
callq 0x4330
movq %rax, %rbp
leaq 0x270(%rsp), %rdi
movq %r13, %rsi
callq 0x973e
movq (%rax), %rsi
movq %rbp, %rdi
callq 0x4230
movq %rax, %rdi
movq %rbx, %rsi
callq 0x4330
movq %rax, %rbp
movq %r12, %rdi
movq %r13, %rsi
callq 0x973e
movq (%rax), %rsi
movq %rbp, %rdi
callq 0x4230
movq %rax, %rdi
callq 0x41c0
movq %r14, %rdi
callq 0x4240
movq %rax, %r14
jmp 0x1acd4
movq 0x10(%rsp), %r14
addq $0x20, %r14
leaq 0x98(%rsp), %rdi
callq 0x1d6a0
movq %r12, %rdi
callq 0xa018
movq %r14, %rax
leaq 0xc(%rsp), %r14
jmp 0x1ac10
movq 0xc8(%rsp), %rax
movq 0x20(%rax), %rsi
leaq 0x30(%rsp), %rdi
leaq 0x98(%rsp), %rdx
callq 0x4d3e
leaq 0xd8(%rsp), %rdx
movb $0x2c, (%rdx)
leaq 0x238(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x26120
leaq 0x30(%rsp), %rbx
movq %rbx, %rdi
callq 0x4638
xorpd %xmm0, %xmm0
leaq 0x180(%rsp), %r14
andq $0x0, 0x10(%r14)
movapd %xmm0, (%r14)
movq 0x238(%rsp), %r15
movq 0x240(%rsp), %r12
movsd 0x1214e(%rip), %xmm3    # 0x2cf80
cmpq %r12, %r15
je 0x1ae6c
movsd %xmm3, 0x10(%rsp)
movq (%r15), %rdi
callq 0x43d0
movsd %xmm0, 0x30(%rsp)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x1d5cc
movsd 0x30(%rsp), %xmm0
minsd 0x10(%rsp), %xmm0
addq $0x20, %r15
movapd %xmm0, %xmm3
jmp 0x1ae32
movq 0x180(%rsp), %rax
movq 0x188(%rsp), %rcx
movsd 0x120fc(%rip), %xmm0    # 0x2cf80
cmpq %rcx, %rax
je 0x1aeab
movsd (%rax), %xmm1
movapd %xmm1, %xmm2
subsd %xmm3, %xmm2
divsd %xmm1, %xmm2
movapd %xmm0, %xmm1
subsd %xmm2, %xmm1
movsd %xmm1, (%rax)
addq $0x8, %rax
jmp 0x1ae84
movq 0x108(%rsp), %rax
movq %rax, 0x28(%rsp)
leaq 0xc(%rsp), %rax
orl $-0x1, (%rax)
movq 0x110(%rsp), %rax
movq %rax, 0xd0(%rsp)
leaq 0x4e0(%rsp), %rbx
movq 0x28(%rsp), %rax
cmpq 0xd0(%rsp), %rax
sete %al
movl %eax, 0xc8(%rsp)
je 0x1b46a
movslq 0xc(%rsp), %rax
leaq 0x1(%rax), %rdi
movl %edi, 0xc(%rsp)
movq 0x180(%rsp), %rcx
movsd 0x8(%rcx,%rax,8), %xmm0
movsd %xmm0, 0x10(%rsp)
shlq $0x5, %rdi
addq 0x68(%rsp), %rdi
leaq 0x1244b(%rip), %rsi     # 0x2d371
callq 0x4110
testl %eax, %eax
je 0x1afcf
movslq 0xc(%rsp), %rdi
shlq $0x5, %rdi
addq 0x68(%rsp), %rdi
leaq 0xfc7e(%rip), %rsi      # 0x2abc6
callq 0x4110
testl %eax, %eax
je 0x1afe7
movslq 0xc(%rsp), %rdi
shlq $0x5, %rdi
addq 0x68(%rsp), %rdi
leaq 0x12409(%rip), %rsi     # 0x2d373
callq 0x4110
testl %eax, %eax
je 0x1afaf
movslq 0xc(%rsp), %rdi
shlq $0x5, %rdi
addq 0x68(%rsp), %rdi
leaq 0x123ed(%rip), %rsi     # 0x2d375
callq 0x4110
testl %eax, %eax
je 0x1affb
movslq 0xc(%rsp), %rdi
shlq $0x5, %rdi
addq 0x68(%rsp), %rdi
leaq 0x1285d(%rip), %rsi     # 0x2d803
callq 0x4110
testl %eax, %eax
jne 0x1affb
movsd 0x10(%rsp), %xmm0
mulsd 0x11fcb(%rip), %xmm0    # 0x2cf88
mulsd 0x11fcb(%rip), %xmm0    # 0x2cf90
divsd 0x11fcb(%rip), %xmm0    # 0x2cf98
jmp 0x1aff5
movsd 0x10(%rsp), %xmm0
mulsd 0x11fcb(%rip), %xmm0    # 0x2cfa8
mulsd 0x11fcb(%rip), %xmm0    # 0x2cfb0
jmp 0x1aff5
movsd 0x10(%rsp), %xmm0
mulsd 0x11fab(%rip), %xmm0    # 0x2cfa0
movsd %xmm0, 0x10(%rsp)
movslq 0xc(%rsp), %rsi
shlq $0x5, %rsi
addq 0x108(%rsp), %rsi
leaq 0x2c0(%rsp), %rdi
callq 0x4400
movslq 0xc(%rsp), %rsi
shlq $0x5, %rsi
addq 0x68(%rsp), %rsi
leaq 0x2a0(%rsp), %rdi
callq 0x4400
leaq 0x120(%rsp), %rdi
leaq 0xc(%rsp), %rsi
callq 0x1d57e
leaq 0x30(%rsp), %rdi
movq %rax, %rsi
callq 0x1d6f8
andl $0x0, 0xa0(%rsp)
andq $0x0, 0xa8(%rsp)
leaq 0xa0(%rsp), %rax
movq %rax, 0xb0(%rsp)
movq %rax, 0xb8(%rsp)
andq $0x0, 0xc0(%rsp)
andl $0x0, 0xe0(%rsp)
andq $0x0, 0xe8(%rsp)
leaq 0xe0(%rsp), %rax
movq %rax, 0xf0(%rsp)
movq %rax, 0xf8(%rsp)
andq $0x0, 0x100(%rsp)
andl $0x0, 0x158(%rsp)
andq $0x0, 0x160(%rsp)
leaq 0x158(%rsp), %rax
movq %rax, 0x168(%rsp)
movq %rax, 0x170(%rsp)
andq $0x0, 0x178(%rsp)
andl $0x0, 0x210(%rsp)
andq $0x0, 0x218(%rsp)
leaq 0x210(%rsp), %rax
movq %rax, 0x220(%rsp)
movq %rax, 0x228(%rsp)
andq $0x0, 0x230(%rsp)
andl $0x0, 0x1e0(%rsp)
andq $0x0, 0x1e8(%rsp)
leaq 0x1e0(%rsp), %rax
movq %rax, 0x1f0(%rsp)
movq %rax, 0x1f8(%rsp)
andq $0x0, 0x200(%rsp)
andl $0x0, 0x1b0(%rsp)
andq $0x0, 0x1b8(%rsp)
leaq 0x1b0(%rsp), %rax
movq %rax, 0x1c0(%rsp)
movq %rax, 0x1c8(%rsp)
andq $0x0, 0x1d0(%rsp)
leaq 0x2c0(%rsp), %rdi
leaq 0x12249(%rip), %rsi     # 0x2d3d7
callq 0x4110
testl %eax, %eax
je 0x1b3df
leaq 0x390(%rsp), %rdi
leaq 0x2c0(%rsp), %rsi
callq 0x4400
leaq 0x250(%rsp), %r14
movq %r14, %rdi
leaq 0x2e0(%rsp), %rsi
leaq 0xf8ed(%rip), %rdx      # 0x2aab7
callq 0x95e2
leaq 0x4a0(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
leaq 0x2a0(%rsp), %rdx
callq 0x961a
leaq 0x510(%rsp), %rbp
movq %rbp, %rdi
leaq 0x30(%rsp), %rsi
callq 0x1d6f8
subq $0x8, %rsp
leaq 0x398(%rsp), %r13
movq %r13, %rdi
movsd 0x18(%rsp), %xmm0
movq %r15, %rsi
movq %rbp, %rdx
leaq 0xa0(%rsp), %rcx
leaq 0xe0(%rsp), %r8
leaq 0x158(%rsp), %r9
leaq 0x1b0(%rsp), %rax
pushq %rax
leaq 0x1e8(%rsp), %rax
pushq %rax
leaq 0x220(%rsp), %rax
pushq %rax
callq 0x1bb5d
addq $0x20, %rsp
movl %eax, %r14d
movq %rbp, %rdi
callq 0x1d6a0
movq %r15, %rdi
callq 0x4638
leaq 0x250(%rsp), %rdi
callq 0x4638
movq %r13, %rdi
callq 0x4638
testb %r14b, %r14b
je 0x1b3ea
movq %rbx, %rdi
leaq 0x98(%rsp), %rsi
callq 0x9888
leaq 0x3b0(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
callq 0x9b48
leaq 0x470(%rsp), %rdi
leaq 0x150(%rsp), %rsi
callq 0x9b48
leaq 0x440(%rsp), %rdi
leaq 0x208(%rsp), %rsi
callq 0x9b48
leaq 0x410(%rsp), %rdi
leaq 0x1d8(%rsp), %rsi
callq 0x9b48
leaq 0x3e0(%rsp), %rdi
leaq 0x1a8(%rsp), %rsi
callq 0x9d62
leaq 0x250(%rsp), %r14
movq %r14, %rdi
leaq 0x2e0(%rsp), %rsi
leaq 0xf79d(%rip), %rdx      # 0x2aab7
callq 0x95e2
leaq 0x330(%rsp), %rdi
movq %r14, %rsi
leaq 0x2a0(%rsp), %rdx
callq 0x961a
subq $0x8, %rsp
movq %rbx, %rdi
leaq 0x3b8(%rsp), %rsi
leaq 0x478(%rsp), %r12
movq %r12, %rdx
movq %rbx, %r15
leaq 0x448(%rsp), %rbx
movq %rbx, %rcx
leaq 0x418(%rsp), %rbp
movq %rbp, %r8
leaq 0x3e8(%rsp), %r13
movq %r13, %r9
leaq 0x338(%rsp), %rax
pushq %rax
callq 0x1cb36
popq %rcx
popq %rdx
movl %eax, %r14d
leaq 0x330(%rsp), %rdi
callq 0x4638
leaq 0x250(%rsp), %rdi
callq 0x4638
movq %r13, %rdi
callq 0xa004
movq %rbp, %rdi
callq 0xa018
movq %rbx, %rdi
callq 0xa018
movq %r12, %rdi
callq 0xa018
leaq 0x3b0(%rsp), %rdi
callq 0xa018
movq %r15, %rdi
callq 0xa02c
testb %r14b, %r14b
movq %r15, %rbx
je 0x1b3ea
addq $0x20, 0x28(%rsp)
movb $0x1, %r14b
jmp 0x1b3ed
xorl %r14d, %r14d
leaq 0x1a8(%rsp), %rdi
callq 0xa004
leaq 0x1d8(%rsp), %rdi
callq 0xa018
leaq 0x208(%rsp), %rdi
callq 0xa018
leaq 0x150(%rsp), %rdi
callq 0xa018
leaq 0xd8(%rsp), %rdi
callq 0xa018
leaq 0x98(%rsp), %rdi
callq 0xa02c
leaq 0x30(%rsp), %rdi
callq 0x1d6a0
leaq 0x2a0(%rsp), %rdi
callq 0x4638
leaq 0x2c0(%rsp), %rdi
callq 0x4638
testb %r14b, %r14b
jne 0x1aed8
jmp 0x1b4c2
callq 0x4220
movq %rax, %r14
movq 0x21b4f(%rip), %rdi     # 0x3cfc8
leaq 0xdec5(%rip), %rsi      # 0x29345
callq 0x4330
cvtsi2sd %r14, %xmm0
subsd 0x1a0(%rsp), %xmm0
divsd 0xdb6d(%rip), %xmm0     # 0x29008
movq %rax, %rdi
callq 0x4510
leaq 0xdeae(%rip), %rsi      # 0x29358
movq %rax, %rdi
callq 0x4330
movq %rax, %rdi
callq 0x41c0
movq %rax, %rdi
callq 0x41c0
leaq 0x180(%rsp), %rdi
callq 0x1e1ae
leaq 0x238(%rsp), %rdi
callq 0x5d02
leaq 0x120(%rsp), %rdi
callq 0x1d8ce
movl 0xc8(%rsp), %ebx
leaq 0x300(%rsp), %rdi
callq 0x1d932
leaq 0x270(%rsp), %rdi
callq 0xa018
leaq 0x2e0(%rsp), %rdi
callq 0x4638
leaq 0x68(%rsp), %rdi
callq 0x5d02
leaq 0x108(%rsp), %rdi
callq 0x5d02
leaq 0x350(%rsp), %rdi
callq 0x4638
leaq 0x80(%rsp), %rdi
callq 0x5d02
leaq 0x370(%rsp), %rdi
callq 0x4638
leaq 0x540(%rsp), %rdi
callq 0x4280
movl %ebx, %eax
addq $0x6c8, %rsp            # imm = 0x6C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x11d8e(%rip), %rdi     # 0x2d30b
leaq 0x11db6(%rip), %rsi     # 0x2d33a
leaq 0x11dc3(%rip), %rcx     # 0x2d34e
movl $0xa1, %edx
callq 0x4210
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x4638
jmp 0x1b84c
jmp 0x1b7d8
movq %rax, %rbx
jmp 0x1b880
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x4638
jmp 0x1b88a
jmp 0x1b6b5
jmp 0x1b752
movq %rax, %rbx
leaq 0x330(%rsp), %rdi
callq 0x4638
jmp 0x1b5e5
movq %rax, %rbx
leaq 0x250(%rsp), %rdi
callq 0x4638
jmp 0x1b5f7
movq %rax, %rbx
leaq 0x3e0(%rsp), %rdi
callq 0xa004
jmp 0x1b609
movq %rax, %rbx
leaq 0x410(%rsp), %rdi
callq 0xa018
jmp 0x1b61b
movq %rax, %rbx
leaq 0x440(%rsp), %rdi
callq 0xa018
leaq 0x470(%rsp), %rdi
callq 0xa018
leaq 0x3b0(%rsp), %rdi
callq 0xa018
leaq 0x4e0(%rsp), %rdi
callq 0xa02c
jmp 0x1b6c0
movq %rax, %rbx
jmp 0x1b628
movq %rax, %rbx
jmp 0x1b635
movq %rax, %rbx
jmp 0x1b642
movq %rax, %rbx
jmp 0x1b897
jmp 0x1b73d
movq %rax, %rbx
jmp 0x1b699
movq %rax, %rbx
jmp 0x1b6a6
movq %rax, %rbx
leaq 0x510(%rsp), %rdi
callq 0x1d6a0
jmp 0x1b68c
movq %rax, %rbx
leaq 0x4a0(%rsp), %rdi
callq 0x4638
leaq 0x250(%rsp), %rdi
callq 0x4638
leaq 0x390(%rsp), %rdi
callq 0x4638
jmp 0x1b6c0
movq %rax, %rbx
jmp 0x1b88a
movq %rax, %rbx
leaq 0x1a8(%rsp), %rdi
callq 0xa004
leaq 0x1d8(%rsp), %rdi
callq 0xa018
leaq 0x208(%rsp), %rdi
callq 0xa018
leaq 0x150(%rsp), %rdi
callq 0xa018
leaq 0xd8(%rsp), %rdi
callq 0xa018
leaq 0x98(%rsp), %rdi
callq 0xa02c
leaq 0x30(%rsp), %rdi
callq 0x1d6a0
jmp 0x1b789
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0xa018
jmp 0x1b7e5
jmp 0x1b7e2
jmp 0x1b752
movq %rax, %rbx
jmp 0x1b796
jmp 0x1b807
movq %rax, %rbx
jmp 0x1b8a4
movq %rax, %rbx
jmp 0x1b8b1
jmp 0x1b807
movq %rax, %rbx
jmp 0x1b7a3
jmp 0x1b813
movq %rax, %rbx
movq %r15, %rdi
callq 0x1d6a0
jmp 0x1b816
movq %rax, %rbx
leaq 0x4c0(%rsp), %rdi
callq 0x4638
jmp 0x1b7e5
movq %rax, %rbx
jmp 0x1b859
movq %rax, %rbx
leaq 0x2a0(%rsp), %rdi
callq 0x4638
leaq 0x2c0(%rsp), %rdi
callq 0x4638
leaq 0x180(%rsp), %rdi
callq 0x1e1ae
leaq 0x238(%rsp), %rdi
callq 0x5d02
jmp 0x1b84c
jmp 0x1b7c4
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
jmp 0x1b8b9
jmp 0x1b807
movq %rax, %rbx
jmp 0x1b842
movq %rax, %rbx
jmp 0x1b84c
movq %rax, %rbx
jmp 0x1b823
movq %rax, %rbx
leaq 0x120(%rsp), %rdi
callq 0xa018
leaq 0x98(%rsp), %rdi
callq 0x4638
jmp 0x1b859
jmp 0x1b807
jmp 0x1b807
jmp 0x1b832
movq %rax, %rbx
jmp 0x1b8be
jmp 0x1b813
jmp 0x1b813
movq %rax, %rbx
leaq 0xd8(%rsp), %rdi
callq 0xa018
leaq 0x98(%rsp), %rdi
callq 0x1d6a0
jmp 0x1b84c
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0x1d6a0
leaq 0x30(%rsp), %rdi
callq 0xa018
leaq 0x120(%rsp), %rdi
callq 0x1d8ce
leaq 0x300(%rsp), %rdi
callq 0x1d932
leaq 0x270(%rsp), %rdi
callq 0xa018
leaq 0x2e0(%rsp), %rdi
callq 0x4638
leaq 0x68(%rsp), %rdi
callq 0x5d02
leaq 0x108(%rsp), %rdi
callq 0x5d02
leaq 0x350(%rsp), %rdi
callq 0x4638
leaq 0x80(%rsp), %rdi
callq 0x5d02
leaq 0x370(%rsp), %rdi
callq 0x4638
leaq 0x540(%rsp), %rdi
callq 0x4280
movq %rbx, %rdi
callq 0x45a0