// File: /workspace/github_cpp_makefile_star2_O2/schneebergerlab[P]DrLink/sample_molecule.cpp
// Function: sampling_molecule(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, double, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::map<int, double, std::less<int>, std::allocator<std::pair<int const, double>>>, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, unsigned long, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const, unsigned long>>>*, std::map<int, unsigned long, std::less<int>, std::allocator<std::pair<int const, unsigned long>>>*, std::map<int, unsigned long, std::less<int>, std::allocator<std::pair<int const, unsigned long>>>*, std::map<int, unsigned long, std::less<int>, std::allocator<std::pair<int const, unsigned long>>>*, std::map<int, unsigned long, std::less<int>, std::allocator<std::pair<int const, unsigned long>>>*, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, int, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const, int>>>*)
bool sampling_molecule(string molfile, 
                       double readratio,
                       string outprefix, 
                       map<int,           double>  msratio, 
                       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)
{
    // open for reading
    igzstream molfp;
    molfp.open(molfile.c_str());
    if(!molfp.good())
    {
        cout << "   Error: cannot file of raw molecule: " << molfile << endl;
        return false;
    }
    // open for writing
    // molecule info
    string ofilename = outprefix + "_min1000bp_sampled_molecule_table_trashme.txt.gz";
    ogzstream moutfp;
    moutfp.open(ofilename.c_str(), ios::out);
    if(!moutfp)
    {
        cout << "   Error: cannot open file " << ofilename << " for writing sampled molecules. " << endl;
        return false;
    }
    // read ids in selected molecules
    string oIDfilename = outprefix + "_min1000bp_sampled_molecule_readIDs_not_on.txt";    
    ofstream ridoutfp;
    ridoutfp.open(oIDfilename.c_str(), ios::out);
    if(!ridoutfp.is_open())
    {
        cout << "   Error: cannot open file " << oIDfilename << endl;
        return false;
    }
    //
    cout << "   Info: sampling molecules..."   << endl;
    // make sure this is out of the loop
    srand (time(NULL)); 
    while(molfp.good())
    {
        string line("");
        getline(molfp, line);
        if(line.size()==0 || line[0]=='#') continue;
        /* get info for current molecule - 11 columns:
                   0.chr#barcode 		1#AAACACCAGAACTCGG
                   1.first_aligned 		15095089
                   2.last_aligned 		15102519
                   3.molecule_len 		7580
                   4.molecule_cov 		0.04
                   5.read_num  		 	2
                   6.Uni_flag  		 	U
                   7.last_aligned_end  		15102668
                   8.all_reads_aligned_at  	15095089,15095230;15102519,15102668
                   9.R1R2  		 	1,2
                  10.read_id 		 	rid1,rid2 
                  11.read_cigar	                cig1,cig2
        */
        vector<string> lineinfo = split_string(line, '\t');
        if(lineinfo.size() < 12) continue; 
        
        // stage 1. sample reads first 
        vector<string> readPos = split_string(lineinfo[8],  ';');
        vector<string> readR12 = split_string(lineinfo[9],  ',');
        vector<string> readID  = split_string(lineinfo[10], ',');
        vector<string> readCIG = split_string(lineinfo[11], ',');
        
        unsigned long first_aligned    = 0;
        unsigned long last_aligned     = 0;
        unsigned long mole_len         = 0;
        unsigned long mole_covered_len = 0;        
        double        mole_base_cov    = 0;
        int           read_num         = 0;
        unsigned long last_aligned_end = 0;
        std::stringstream all_reads_aligned_at;
        std::stringstream R1R2;
        std::stringstream read_id;
        std::stringstream read_cigar;
        //
        all_reads_aligned_at.str("");   
        R1R2.str("");
        read_id.str("");
        read_cigar.str("");
        //
        vector<string>::iterator samread_itr;
        vector<string>::iterator samread_itr_end;
        samread_itr     = readPos.begin();
        samread_itr_end = readPos.end();    
        int iii = -1;
        while(samread_itr != samread_itr_end)
        {
            iii ++;
            // double myrand = ((double) rand() / (RAND_MAX)); 
            double myrand = rand()%1000000000*1.0 / 1000000000.0; 
            //if(myrand <= readratio || iii==0 || iii==readPos.size()-1) // try keeping length of molecules
            if(myrand <= readratio) // try keeping length of molecules
            {
                if(false && myrand <= readratio)
                {
                    cout << "   check: read " 
                         << *samread_itr 
                         << " selected, because myrand " 
                         << myrand 
                         << " < readratio " 
                         << readratio << endl; 
                } 
                if(false && iii==0)
                {
                    cout << "   check: read " 
                         << *samread_itr 
                         << " selected, because iii == 0 " 
                         << endl;                 
                }    
                if(false && iii==readPos.size()-1)
                {
                    cout << "   check: read " 
                         << *samread_itr 
                         << " selected, because iii ==  "  << iii << " == readPos.size()-1 == " << readPos.size()-1
                         << endl;                 
                } 
                vector<string> readspan = split_string(*samread_itr, ',');                      
                if(first_aligned == 0)
                {
                    first_aligned =  strtoul(readspan[0].c_str(), NULL, 0);
                }
                last_aligned      = strtoul(readspan[0].c_str(), NULL, 0);
                last_aligned_end  = strtoul(readspan[1].c_str(), NULL, 0);             
                mole_covered_len += (last_aligned_end - last_aligned);                   
                //
                read_num ++;
                //
                if(all_reads_aligned_at.str().size() > 0)
                all_reads_aligned_at << ";";
                all_reads_aligned_at << readPos[iii];
                //
                if(R1R2.str().size()>0)
                R1R2                 << ",";
                R1R2                 << readR12[iii];
                //
                if(read_id.str().size()>0)
                read_id              << ",";
                read_id              << readID[iii];
                //
                if(read_cigar.str().size()>0)
                read_cigar           << ",";
                read_cigar           << readCIG[iii];
            }
            else
            {
                if(false)
                cout << "   check: read " 
                     << *samread_itr 
                     << " not selected, because myrand " 
                     << myrand 
                     << " > readratio " 
                     << readratio << endl;
            }
            samread_itr ++;
        }
        mole_len      = last_aligned_end - first_aligned + 1;
        if(mole_len < 1000) continue;
        mole_base_cov = 1.0*mole_covered_len / mole_len;
        // stage 2. sample molecule 
        
        int    key    = (int)round((double)mole_len/1000);
        // double randra = ((double) rand() / (RAND_MAX)); 
        double randra = rand()%1000000000*1.0 / 1000000000.0;         
        if(randra <= msratio[key])
        {
            // collect this molecule
            moutfp << lineinfo[0]                << "\t"
                   << first_aligned              << "\t"
                   << last_aligned               << "\t"
                   << mole_len                   << "\t"
                   << setprecision(2)            << fixed 
                   << mole_base_cov              << "\t"
                   << read_num                   << "\t"
                   << lineinfo[6]                << "\t"
                   << last_aligned_end           << "\t"
                   << all_reads_aligned_at.str() << "\t"
                   << R1R2.str()                 << "\t"
                   << read_id.str()              << "\t"
                   << read_cigar.str()           << endl;
            // collect molecule cov
            std::stringstream mckey;
            mckey.str("");
            mckey << setprecision(2) << fixed << mole_base_cov;            
            map<string, unsigned long>::iterator mcitr = (*molecule_cov).find(mckey.str());
            if(mcitr == (*molecule_cov).end())
            {
                (*molecule_cov).insert(std::pair<string, unsigned long>(mckey.str(), 1));
            }
            else
            {
                (*mcitr).second += 1;
            }
            // collect molecule len
            map<int, unsigned long>::iterator mlitr = (*molecule_len).find(key);
            if(mlitr == (*molecule_len).end())
            {
                (*molecule_len).insert(std::pair<int, unsigned long>(key, 1));
                (*molecule_len_sum).insert(std::pair<int, unsigned long>(key,  mole_len));
            }
            else
            {
                (*mlitr).second += 1;
                (*molecule_len_sum)[key] += mole_len;
            }
            // collect molecule read number
            map<int,    unsigned long>::iterator readitr;
            readitr     = (*molecule_read_num).find(read_num);
            if(readitr == (*molecule_read_num).end())
            {
                (*molecule_read_num).insert(std::pair<int, unsigned long>(read_num, 1));
                (*molecule_read_num_sum).insert(std::pair<int, unsigned long>(read_num, mole_covered_len));
            }
            else
            {
                (*molecule_read_num)[read_num] += 1;
                (*molecule_read_num_sum)[read_num] += mole_covered_len;
            }
            // molecules per barcode
            vector<string> chrbc = split_string(lineinfo[0], '#'); // get [0]:chr, [1]:barcode/partition
            map<string, int>::iterator bcitr;
            bcitr = (*barcode_molecule_cnt).find(chrbc[1]);
            if(bcitr == (*barcode_molecule_cnt).end())
            {
                (*barcode_molecule_cnt).insert(std::pair<string, int>(chrbc[1], 1));
            }
            else
            {
                (*barcode_molecule_cnt)[chrbc[1]] +=1;
            }     
            // read ids
            if(false)
            {
                vector<string> readids = split_string(read_id.str(), ',');
                map<string, int> checkreads;
                vector<string>::iterator iditr;
                vector<string>::iterator iditr_end;
                iditr     = readids.begin();
                iditr_end = readids.end();
                while(iditr != iditr_end)
                {
                    string this_id = *iditr;
                    if(checkreads.find(this_id) == checkreads.end() )
                    {
                        checkreads.insert(std::pair<string, int>(this_id, 1) );
                        ridoutfp << this_id << endl;
                    }
                    iditr ++;
                }
                checkreads.clear();
            }
        }
    }
    molfp.close();  
    moutfp.close();    
    ridoutfp.close();  
    return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10c8, %rsp           # imm = 0x10C8
movq %r9, 0xa8(%rsp)
movq %r8, 0x68(%rsp)
movq %rcx, %rbp
movq %rdx, %r12
movq %rsi, %rbx
movsd %xmm0, 0xe8(%rsp)
movq %rdi, %r14
leaq 0x990(%rsp), %r15
movq %r15, %rdi
callq 0x94d2
movq (%r14), %rsi
pushq $0x8
popq %rdx
movq %r15, %r13
movq %r15, %rdi
callq 0x27e38
movq 0x990(%rsp), %rax
movq -0x18(%rax), %rax
cmpl $0x0, 0x9b0(%rsp,%rax)
je 0x1bbf4
movq 0x213fa(%rip), %rdi     # 0x3cfc8
leaq 0x11807(%rip), %rsi     # 0x2d3dc
callq 0x4330
movq %rax, %rdi
movq %r14, %rsi
callq 0x42e0
movq %rax, %rdi
callq 0x41c0
xorl %ebx, %ebx
jmp 0x1c8e5
leaq 0x11809(%rip), %rdx     # 0x2d404
leaq 0x190(%rsp), %rdi
movq %rbx, %rsi
callq 0x95e2
leaq 0xe30(%rsp), %rdi
callq 0x5c58
movq %r13, %r14
movq 0x190(%rsp), %rsi
leaq 0xe30(%rsp), %rdi
pushq $0x10
popq %rdx
movq %rdi, 0xa0(%rsp)
callq 0x27e38
movq 0xe30(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0xe50(%rsp,%rax)
je 0x1bc92
movq 0x21370(%rip), %rdi     # 0x3cfc8
leaq 0xdef7(%rip), %rsi      # 0x29b56
callq 0x4330
leaq 0x190(%rsp), %rsi
movq %rax, %rdi
callq 0x42e0
leaq 0x117ba(%rip), %rsi     # 0x2d435
movq %rax, %rdi
callq 0x4330
movq %rax, %rdi
callq 0x41c0
xorl %ebx, %ebx
jmp 0x1c8cb
leaq 0x117bd(%rip), %rdx     # 0x2d456
leaq 0x170(%rsp), %rdi
movq %rbx, %rsi
callq 0x95e2
leaq 0xc30(%rsp), %rdi
callq 0x4570
movq 0x170(%rsp), %rsi
leaq 0xc30(%rsp), %rdi
pushq $0x10
popq %rdx
callq 0x4050
leaq 0xca0(%rsp), %rdi
callq 0x40c0
movl %eax, %ebx
testb %al, %al
je 0x1c85d
movq 0x212dc(%rip), %rdi     # 0x3cfc8
leaq 0x11792(%rip), %rsi     # 0x2d485
callq 0x4330
movq %rax, %rdi
callq 0x41c0
movq 0x1110(%rsp), %r15
movq 0x1100(%rsp), %r13
xorl %edi, %edi
callq 0x4300
movl %eax, %edi
callq 0x4320
movl $0x188, %eax            # imm = 0x188
addq %rax, %r14
addq %rax, 0xa0(%rsp)
leaq 0x8(%rbp), %rax
movq %rax, 0xc8(%rsp)
movq 0x68(%rsp), %rax
addq $0x8, %rax
movq %rax, 0xc0(%rsp)
leaq 0x8(%r13), %rax
movq %rax, 0xb8(%rsp)
leaq 0x8(%r15), %rax
movq %rax, 0xb0(%rsp)
leaq 0x11db0(%rip), %r13     # 0x2db1a
leaq 0x370(%rsp), %rdx
movq %rbp, 0xe0(%rsp)
movq %r12, 0xd0(%rsp)
movl %ebx, 0x74(%rsp)
movq %r14, 0xd8(%rsp)
movq 0x990(%rsp), %rax
movq -0x18(%rax), %rax
cmpl $0x0, 0x9b0(%rsp,%rax)
jne 0x1c88a
leaq 0x108(%rsp), %r15
movq %r15, %rdi
movq %r13, %rsi
callq 0x4d3e
movq %r14, %rdi
movq %r15, %rsi
callq 0x4090
cmpq $0x0, 0x110(%rsp)
je 0x1c843
movq 0x108(%rsp), %rax
cmpb $0x23, (%rax)
je 0x1c843
movb $0x9, 0x370(%rsp)
leaq 0x78(%rsp), %rdi
leaq 0x108(%rsp), %rsi
leaq 0x370(%rsp), %rdx
callq 0x26120
movq 0x78(%rsp), %rsi
movq 0x80(%rsp), %rax
subq %rsi, %rax
cmpq $0x180, %rax            # imm = 0x180
jb 0x1c839
addq $0x100, %rsi            # imm = 0x100
movb $0x3b, 0x370(%rsp)
leaq 0xf0(%rsp), %rdi
leaq 0x370(%rsp), %r15
movq %r15, %rdx
callq 0x26120
movq 0x78(%rsp), %rsi
movl $0x120, %eax            # imm = 0x120
addq %rax, %rsi
movb $0x2c, 0x370(%rsp)
leaq 0x158(%rsp), %rdi
movq %r15, %rdx
callq 0x26120
movq 0x78(%rsp), %rsi
movl $0x140, %eax            # imm = 0x140
addq %rax, %rsi
movb $0x2c, 0x370(%rsp)
leaq 0x140(%rsp), %rdi
movq %r15, %rdx
callq 0x26120
movq 0x78(%rsp), %rsi
movl $0x160, %eax            # imm = 0x160
addq %rax, %rsi
movb $0x2c, 0x370(%rsp)
leaq 0x128(%rsp), %rdi
movq %r15, %rdx
callq 0x26120
andl $0x0, 0x8(%rsp)
movq %r15, %rdi
callq 0x4250
leaq 0x808(%rsp), %rdi
callq 0x4250
leaq 0x680(%rsp), %rdi
callq 0x4250
leaq 0x4f8(%rsp), %rdi
callq 0x4250
leaq 0x1c8(%rsp), %r15
movq %r15, %rdi
movq %r13, %rsi
leaq 0x10(%rsp), %rdx
callq 0x4d3e
leaq 0x388(%rsp), %rdi
movq %r15, %rsi
callq 0x4490
movq %r15, %rdi
callq 0x4638
movq %r15, %rdi
movq %r13, %rsi
leaq 0x10(%rsp), %rdx
callq 0x4d3e
leaq 0x820(%rsp), %rdi
movq %r15, %rsi
callq 0x4490
movq %r15, %rdi
callq 0x4638
movq %r15, %rdi
movq %r13, %rsi
leaq 0x10(%rsp), %rdx
callq 0x4d3e
leaq 0x698(%rsp), %rdi
movq %r15, %rsi
callq 0x4490
movq %r15, %rdi
callq 0x4638
movq %r15, %rdi
movq %r13, %rsi
leaq 0x10(%rsp), %rdx
callq 0x4d3e
leaq 0x510(%rsp), %rdi
movq %r15, %rsi
callq 0x4490
movq %r15, %rdi
callq 0x4638
movq 0xf0(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0xf8(%rsp), %r13
xorl %ebp, %ebp
movq $0x0, 0x38(%rsp)
xorl %r12d, %r12d
xorl %ebx, %ebx
movq $0x0, 0x90(%rsp)
movq 0x40(%rsp), %rax
leaq (%rax,%rbp), %r14
cmpq %r13, %r14
je 0x1c1fa
callq 0x40f0
cltd
movl $0x3b9aca00, %ecx       # imm = 0x3B9ACA00
idivl %ecx
cvtsi2sd %edx, %xmm0
divsd 0x10fc6(%rip), %xmm0    # 0x2cfb8
movsd 0xe8(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jb 0x1c1f1
movb $0x2c, 0x1c8(%rsp)
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
leaq 0x1c8(%rsp), %rdx
callq 0x26120
cmpq $0x0, 0x90(%rsp)
jne 0x1c046
movq 0x10(%rsp), %rax
movq (%rax), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x4130
movq %rax, 0x90(%rsp)
movq 0x10(%rsp), %rax
movq (%rax), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x4130
movq %rax, %rbx
movq 0x10(%rsp), %rax
movq 0x20(%rax), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x4130
movq %rax, %r12
incl 0x8(%rsp)
leaq 0x1c8(%rsp), %r15
movq %r15, %rdi
leaq 0x388(%rsp), %rsi
callq 0x44e0
movq 0x1d0(%rsp), %r14
movq %r15, %rdi
callq 0x4638
testq %r14, %r14
je 0x1c0b4
leaq 0x380(%rsp), %rdi
leaq 0xf30b(%rip), %rsi      # 0x2b3ba
callq 0x4330
movq 0xf0(%rsp), %rsi
addq %rbp, %rsi
leaq 0x380(%rsp), %rdi
callq 0x42e0
leaq 0x1c8(%rsp), %r15
movq %r15, %rdi
leaq 0x820(%rsp), %rsi
callq 0x44e0
movq 0x1d0(%rsp), %r14
movq %r15, %rdi
callq 0x4638
testq %r14, %r14
je 0x1c10d
leaq 0x818(%rsp), %rdi
leaq 0xdd98(%rip), %rsi      # 0x29ea0
callq 0x4330
movq 0x158(%rsp), %rsi
addq %rbp, %rsi
leaq 0x818(%rsp), %rdi
callq 0x42e0
leaq 0x1c8(%rsp), %r15
movq %r15, %rdi
leaq 0x698(%rsp), %rsi
callq 0x44e0
movq 0x1d0(%rsp), %r14
movq %r15, %rdi
callq 0x4638
testq %r14, %r14
je 0x1c166
leaq 0x690(%rsp), %rdi
leaq 0xdd3f(%rip), %rsi      # 0x29ea0
callq 0x4330
movq 0x140(%rsp), %rsi
addq %rbp, %rsi
leaq 0x690(%rsp), %rdi
callq 0x42e0
leaq 0x1c8(%rsp), %r15
movq %r15, %rdi
leaq 0x510(%rsp), %rsi
callq 0x44e0
movq 0x1d0(%rsp), %r14
movq %r15, %rdi
callq 0x4638
testq %r14, %r14
je 0x1c1bf
leaq 0x508(%rsp), %rdi
leaq 0xdce6(%rip), %rsi      # 0x29ea0
callq 0x4330
movq 0x128(%rsp), %rsi
addq %rbp, %rsi
leaq 0x508(%rsp), %rdi
callq 0x42e0
movq 0x38(%rsp), %rax
subq %rbx, %rax
addq %r12, %rax
movq %rax, 0x38(%rsp)
leaq 0x10(%rsp), %rdi
callq 0x5d02
addq $0x20, %rbp
jmp 0x1bfc7
movq %r12, %rax
subq 0x90(%rsp), %rax
incq %rax
cmpq $0x3e8, %rax            # imm = 0x3E8
movq 0xe0(%rsp), %rbp
leaq 0x118fd(%rip), %r13     # 0x2db1a
jb 0x1c7c5
movq %rax, 0x40(%rsp)
movq %rax, %xmm0
punpckldq 0xde8b(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0xde93(%rip), %xmm0     # 0x2a0d0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movapd %xmm1, 0x1b0(%rsp)
movapd %xmm1, %xmm0
divsd 0xd672(%rip), %xmm0     # 0x298d0
callq 0x4180
cvttsd2si %xmm0, %eax
movl %eax, 0xc(%rsp)
callq 0x40f0
movl %eax, %r14d
movq 0xd0(%rsp), %rdi
leaq 0xc(%rsp), %rsi
callq 0x1d5ee
movq %rax, %rcx
movl %r14d, %eax
cltd
movl $0x3b9aca00, %esi       # imm = 0x3B9ACA00
idivl %esi
cvtsi2sd %edx, %xmm0
divsd 0x10d19(%rip), %xmm0    # 0x2cfb8
movsd (%rcx), %xmm1
ucomisd %xmm0, %xmm1
jb 0x1c7c5
movq 0x78(%rsp), %rsi
movq 0xa0(%rsp), %rdi
callq 0x42e0
movq %rax, %rdi
leaq 0x11850(%rip), %rsi     # 0x2db19
callq 0x4330
movq %rax, %rdi
movq 0x90(%rsp), %rsi
callq 0x4230
movq %rax, %rdi
leaq 0x11831(%rip), %rsi     # 0x2db19
callq 0x4330
movq %rax, %rdi
movq %rbx, %rsi
callq 0x4230
movq %rax, %rdi
leaq 0x11817(%rip), %rsi     # 0x2db19
callq 0x4330
movq %rax, %rdi
movq 0x40(%rsp), %rsi
callq 0x4230
movq %rax, %rdi
leaq 0x117fb(%rip), %rsi     # 0x2db19
callq 0x4330
movsd 0x38(%rsp), %xmm1
unpcklps 0xdd90(%rip), %xmm1     # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0xdd98(%rip), %xmm1     # 0x2a0d0
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
divsd 0x1b0(%rsp), %xmm0
movq (%rax), %rcx
movq -0x18(%rcx), %rdx
movq $0x2, 0x8(%rax,%rdx)
movq -0x18(%rcx), %rcx
movl 0x18(%rax,%rcx), %edx
movl $0xfffffefb, %esi       # imm = 0xFFFFFEFB
andl %esi, %edx
orl $0x4, %edx
movl %edx, 0x18(%rax,%rcx)
movq %rax, %rdi
movapd %xmm0, 0x90(%rsp)
callq 0x4510
movq %rax, %rdi
leaq 0x1178b(%rip), %rsi     # 0x2db19
callq 0x4330
movl 0x8(%rsp), %esi
movq %rax, %rdi
callq 0x4580
movq %rax, %rdi
leaq 0x11770(%rip), %rsi     # 0x2db19
callq 0x4330
movq 0x78(%rsp), %rsi
movl $0xc0, %ecx
addq %rcx, %rsi
movq %rax, %rdi
callq 0x42e0
movq %rax, %rdi
leaq 0x1174c(%rip), %rsi     # 0x2db19
callq 0x4330
movq %rax, %rdi
movq %r12, %rsi
callq 0x4230
movq %rax, %rdi
leaq 0x11732(%rip), %rsi     # 0x2db19
callq 0x4330
movq %rax, %rbx
leaq 0x1c8(%rsp), %r14
movq %r14, %rdi
leaq 0x388(%rsp), %rsi
callq 0x44e0
movq %rbx, %rdi
movq %r14, %rsi
callq 0x42e0
leaq 0x1e0(%rsp), %r14
movq %rax, %rdi
leaq 0x116f5(%rip), %rsi     # 0x2db19
callq 0x4330
movq %rax, %rbx
leaq 0x10(%rsp), %r15
movq %r15, %rdi
leaq 0x820(%rsp), %rsi
callq 0x44e0
movq %rbx, %rdi
movq %r15, %rsi
callq 0x42e0
movq %rax, %rdi
leaq 0x116c3(%rip), %rsi     # 0x2db19
callq 0x4330
movq %rax, %rbx
leaq 0x48(%rsp), %r15
movq %r15, %rdi
leaq 0x698(%rsp), %rsi
callq 0x44e0
movq %rbx, %rdi
movq %r15, %rsi
callq 0x42e0
movq %rax, %rdi
leaq 0x11691(%rip), %rsi     # 0x2db19
callq 0x4330
movq %rax, %rbx
leaq 0x350(%rsp), %r15
movq %r15, %rdi
leaq 0x510(%rsp), %rsi
callq 0x44e0
movq %rbx, %rdi
movq %r15, %rsi
callq 0x42e0
movq %rax, %rdi
callq 0x41c0
movq %r15, %rdi
callq 0x4638
leaq 0x48(%rsp), %r12
movq %r12, %rdi
callq 0x4638
leaq 0x10(%rsp), %r15
movq %r15, %rdi
callq 0x4638
leaq 0x1c8(%rsp), %rbx
movq %rbx, %rdi
callq 0x4638
movq %rbx, %rdi
callq 0x4250
movq %r15, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x4d3e
movq %r14, %rdi
movq %r15, %rsi
callq 0x4490
movq %r15, %rdi
callq 0x4638
movq 0x1d8(%rsp), %rax
movq -0x18(%rax), %rcx
movq $0x2, 0x1e0(%rsp,%rcx)
movq -0x18(%rax), %rax
movl 0x1f0(%rsp,%rax), %ecx
movl $0xfffffefb, %edx       # imm = 0xFFFFFEFB
andl %edx, %ecx
orl $0x4, %ecx
movl %ecx, 0x1f0(%rsp,%rax)
leaq 0x1d8(%rsp), %rdi
movapd 0x90(%rsp), %xmm0
callq 0x4510
movq %r15, %rdi
movq %r14, %rsi
callq 0x44e0
movq %rbp, %rdi
movq %r15, %rsi
callq 0xa47a
movq %rax, %rbx
movq %r15, %rdi
callq 0x4638
cmpq 0xc8(%rsp), %rbx
je 0x1c5a6
incq 0x40(%rbx)
movq 0x1100(%rsp), %rbx
leaq 0x10(%rsp), %r14
leaq 0x48(%rsp), %r15
jmp 0x1c635
leaq 0x48(%rsp), %rdi
movq %r14, %rsi
callq 0x44e0
leaq 0x20(%rsp), %rdx
movq %rdx, 0x10(%rsp)
movq 0x48(%rsp), %rax
leaq 0x58(%rsp), %rcx
cmpq %rcx, %rax
movq 0x1100(%rsp), %rbx
je 0x1c5e5
movq %rax, 0x10(%rsp)
movq 0x58(%rsp), %rax
movq %rax, 0x20(%rsp)
jmp 0x1c5ed
movupd (%rcx), %xmm0
movupd %xmm0, (%rdx)
movq 0x50(%rsp), %rax
movq %rcx, 0x48(%rsp)
andq $0x0, 0x50(%rsp)
movq %rax, 0x18(%rsp)
movb $0x0, 0x58(%rsp)
movq $0x1, 0x30(%rsp)
movq %rbp, %rdi
leaq 0x10(%rsp), %r14
movq %r14, %rsi
callq 0xa4f0
movq %r14, %rdi
callq 0x4638
leaq 0x48(%rsp), %r15
movq %r15, %rdi
callq 0x4638
movq 0x68(%rsp), %rdi
leaq 0xc(%rsp), %rsi
callq 0xa69a
cmpq 0xc0(%rsp), %rax
je 0x1c66e
incq 0x28(%rax)
movq 0xa8(%rsp), %rdi
leaq 0xc(%rsp), %rsi
callq 0x973e
movq 0x40(%rsp), %rcx
addq %rcx, (%rax)
jmp 0x1c6ae
movl 0xc(%rsp), %eax
movl %eax, 0x10(%rsp)
movq $0x1, 0x18(%rsp)
movq 0x68(%rsp), %rdi
movq %r14, %rsi
callq 0xa6ec
movl 0xc(%rsp), %eax
movl %eax, 0x10(%rsp)
movq 0x40(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0xa8(%rsp), %rdi
movq %r14, %rsi
callq 0xa6ec
movq %rbx, %rdi
leaq 0x8(%rsp), %rsi
callq 0xa69a
cmpq 0xb8(%rsp), %rax
je 0x1c6f2
movq %rbx, %rdi
leaq 0x8(%rsp), %rbx
movq %rbx, %rsi
callq 0x973e
incq (%rax)
movq 0x1108(%rsp), %rdi
movq %rbx, %rsi
callq 0x973e
movq 0x38(%rsp), %rcx
addq %rcx, (%rax)
jmp 0x1c730
movl 0x8(%rsp), %eax
movl %eax, 0x10(%rsp)
movq $0x1, 0x18(%rsp)
movq %rbx, %rdi
movq %r14, %rsi
callq 0xa6ec
movl 0x8(%rsp), %eax
movl %eax, 0x10(%rsp)
movq 0x38(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x1108(%rsp), %rdi
movq %r14, %rsi
callq 0xa6ec
movq 0x78(%rsp), %rsi
movb $0x23, 0x10(%rsp)
movq %r15, %rdi
movq %r14, %rdx
callq 0x26120
movq 0x48(%rsp), %rsi
addq $0x20, %rsi
movq 0x1110(%rsp), %rdi
callq 0xa992
cmpq 0xb0(%rsp), %rax
je 0x1c77f
movq 0x48(%rsp), %rsi
addq $0x20, %rsi
movq 0x1110(%rsp), %rdi
callq 0x978c
incl (%rax)
jmp 0x1c7b0
movq 0x48(%rsp), %rsi
addq $0x20, %rsi
movq %r14, %rdi
callq 0x4400
movl $0x1, 0x30(%rsp)
movq 0x1110(%rsp), %rdi
movq %r14, %rsi
callq 0xaa08
movq %r14, %rdi
callq 0x4638
movq %r15, %rdi
callq 0x5d02
leaq 0x1c8(%rsp), %rdi
callq 0x4280
leaq 0x4f8(%rsp), %rdi
callq 0x4280
leaq 0x680(%rsp), %rdi
callq 0x4280
leaq 0x808(%rsp), %rdi
callq 0x4280
leaq 0x370(%rsp), %rdi
callq 0x4280
leaq 0x128(%rsp), %rdi
callq 0x5d02
leaq 0x140(%rsp), %rdi
callq 0x5d02
leaq 0x158(%rsp), %rdi
callq 0x5d02
leaq 0xf0(%rsp), %rdi
callq 0x5d02
movl 0x74(%rsp), %ebx
movq 0xd8(%rsp), %r14
leaq 0x78(%rsp), %rdi
callq 0x5d02
leaq 0x108(%rsp), %rdi
callq 0x4638
leaq 0x370(%rsp), %rdx
jmp 0x1bd8e
movq 0x20764(%rip), %rdi     # 0x3cfc8
leaq 0xd2eb(%rip), %rsi      # 0x29b56
callq 0x4330
leaq 0x170(%rsp), %rsi
movq %rax, %rdi
callq 0x42e0
movq %rax, %rdi
callq 0x41c0
jmp 0x1c8b1
leaq 0x990(%rsp), %rdi
callq 0x280e0
leaq 0xe30(%rsp), %rdi
callq 0x280e0
leaq 0xc30(%rsp), %rdi
callq 0x4430
leaq 0xc30(%rsp), %rdi
callq 0x4480
leaq 0x170(%rsp), %rdi
callq 0x4638
leaq 0xe30(%rsp), %rdi
callq 0x5d24
leaq 0x190(%rsp), %rdi
callq 0x4638
leaq 0x990(%rsp), %rdi
callq 0x96aa
movl %ebx, %eax
addq $0x10c8, %rsp           # imm = 0x10C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x4638
jmp 0x1c93a
jmp 0x1c937
jmp 0x1c973
jmp 0x1c973
jmp 0x1c973
jmp 0x1c973
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x4638
leaq 0x48(%rsp), %rdi
jmp 0x1c956
jmp 0x1c973
jmp 0x1c937
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x5d02
jmp 0x1c976
jmp 0x1c973
jmp 0x1c973
jmp 0x1c94e
jmp 0x1c973
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x4638
jmp 0x1c976
jmp 0x1ca5a
jmp 0x1c9b6
jmp 0x1c9e2
jmp 0x1c973
jmp 0x1c973
jmp 0x1c9a7
jmp 0x1ca5a
jmp 0x1c973
movq %rax, %rbx
leaq 0x1c8(%rsp), %rdi
callq 0x4280
jmp 0x1ca6e
movq %rax, %rbx
jmp 0x1cafa
jmp 0x1ca32
movq %rax, %rbx
leaq 0x350(%rsp), %rdi
callq 0x4638
jmp 0x1c9aa
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x4638
jmp 0x1c9b9
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x4638
jmp 0x1c9e5
jmp 0x1c9e2
movq %rax, %rbx
jmp 0x1caaf
jmp 0x1c9e2
jmp 0x1c9e2
jmp 0x1c9e2
jmp 0x1ca5a
movq %rax, %rbx
jmp 0x1ca95
movq %rax, %rbx
leaq 0x1c8(%rsp), %rdi
callq 0x4638
jmp 0x1ca6e
movq %rax, %rbx
jmp 0x1cac9
movq %rax, %rbx
jmp 0x1ca88
movq %rax, %rbx
jmp 0x1ca7b
movq %rax, %rbx
jmp 0x1cad6
jmp 0x1ca5a
jmp 0x1ca5a
jmp 0x1ca5a
movq %rax, %rbx
jmp 0x1cabc
movq %rax, %rbx
jmp 0x1caa2
movq %rax, %rbx
jmp 0x1cb14
jmp 0x1ca4c
jmp 0x1ca44
jmp 0x1ca3c
movq %rax, %rbx
jmp 0x1cb07
jmp 0x1ca5a
movq %rax, %rbx
jmp 0x1caed
movq %rax, %rbx
jmp 0x1cae0
movq %rax, %rbx
jmp 0x1cb21
jmp 0x1ca61
jmp 0x1ca61
jmp 0x1ca61
movq %rax, %rbx
jmp 0x1ca6e
jmp 0x1ca61
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x5d02
leaq 0x4f8(%rsp), %rdi
callq 0x4280
leaq 0x680(%rsp), %rdi
callq 0x4280
leaq 0x808(%rsp), %rdi
callq 0x4280
leaq 0x370(%rsp), %rdi
callq 0x4280
leaq 0x128(%rsp), %rdi
callq 0x5d02
leaq 0x140(%rsp), %rdi
callq 0x5d02
leaq 0x158(%rsp), %rdi
callq 0x5d02
leaq 0xf0(%rsp), %rdi
callq 0x5d02
leaq 0x78(%rsp), %rdi
callq 0x5d02
leaq 0x108(%rsp), %rdi
callq 0x4638
leaq 0xc30(%rsp), %rdi
callq 0x4480
leaq 0x170(%rsp), %rdi
callq 0x4638
leaq 0xe30(%rsp), %rdi
callq 0x5d24
leaq 0x190(%rsp), %rdi
callq 0x4638
leaq 0x990(%rsp), %rdi
callq 0x96aa
movq %rbx, %rdi
callq 0x45a0