// File: /workspace/github_cpp_makefile_star2_O2/schneebergerlab[P]DrLink/detect_recombsite.cpp
// Function: read_chr_var(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, 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, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>>, std::multimap<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, iMARKER, 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, iMARKER>>>*)
bool read_chr_var(string vcffilename, map<string, string> knownMarker, multimap<string, iMARKER>* moleculeSet)
{
    // this function collects variants specific to chr from subfile_chr_x_longranger_variants.vcf.gz
    igzstream  fp;
    fp.open(vcffilename.c_str());
    if(!fp.good())
    {
        cout << "   Error: cannot open vcf file " 
             << vcffilename 
             << ". " 
             << endl;
        return false;
    }
    //
    unsigned long snpnum        = 0;
    unsigned long delnum        = 0;
    unsigned long insnum        = 0;
    unsigned long lineNum       = 0;
    unsigned long mkrNumChr     = 0;
    unsigned long snpnum_all    = 0;
    unsigned long delnum_all    = 0;
    unsigned long insnum_all    = 0;
    unsigned long mkrNumChr_all = 0;    
    cout << "   Info: only markers with coverage in [" 
         << minVarCov << "x, " << maxVarCov << "x] will be recorded (snps/1-bp indels considered). " 
         << endl;
    while(fp.good())
    {
        string line("");
        getline(fp, line);
        if(line.size()==0 || line[0]=='#' || line[0]=='*') continue;
               
        lineNum ++;
        if(lineNum%100000 == 0) cout << "   Info: " 
                                     << lineNum     << "th var of " 
                                     << vcffilename << "..." 
                                     << endl;
        vector<string> lineinfo = split_string(line, '\t');
        if(lineinfo.size() < 10)
        {
            cout << "   Warning: skip line due to insufficient cell info: " << line << endl; 
            continue;
        }
        //
        if(lineinfo[4].find(",")!=std::string::npos)
        {
            continue; // multiple alternative allele; skip!
        }
        //
        if(lineinfo[6].compare("PASS") != 0)
        {
            // caution: USED: low-quality variation calls - 2018-06-07
            // check: https://support.10xgenomics.com/genome-exome/software/pipelines/latest/output/vcf
            // continue;
        }
        // get barcodes related to marker; especially check het-barcodes before any filtering
        vector<string> varBarcodes;   
        vector<string> refBarcodes;         
        if(!get_var_ref_barcode(lineinfo[8], 
                                lineinfo[9], 
                                &varBarcodes, 
                                &refBarcodes, 
                                lineinfo[0], 
                                lineinfo[1], 
                                &HeteroBarcode))
        {
            cout << "   Warning: unexpected barcode info at " << line << endl;
            continue;
        }
        // key= chr#pos#ref#alt: snp: 1#1000#G#A, del: 1#1000#G#-, ins: 1#1000#-#G
        string key;
        string itype("snp");
        std::stringstream dss;
        dss.str("");        
        if(lineinfo[3].size()==2 && lineinfo[4].size()==1) // 1-bp del
        {
            unsigned long dpos = strtoul(lineinfo[1].c_str(), NULL, 0);
            dpos ++;
            dss << dpos;
            key   = lineinfo[0] + "#" + dss.str() + "#" + lineinfo[3].substr(1,1) + "#" + "-";
            itype = "del";
        }
        else
        if(lineinfo[3].size()==1 && lineinfo[4].size()==2) // 1-bp ins
        {
            dss << lineinfo[1];
            key   = lineinfo[0] + "#" + dss.str() + "#" + "-" + "#" + lineinfo[4].substr(1,1);
            itype = "ins";            
        }
        else
        if(lineinfo[3].size()==1 && lineinfo[4].size()==1) // snp
        {
            dss << lineinfo[1];
            key   = lineinfo[0] + "#" + dss.str() + "#" + lineinfo[3] + "#" + lineinfo[4];
        }
        else
        {
            // skip >=2bp non SNP variations/multiple alleles; // new 2018-06-16
            continue;
        }        
        //
        // all markers checked
        if(itype.compare("del")==0) delnum_all ++;
        else
        if(itype.compare("ins")==0) insnum_all ++;
        else
        if(itype.compare("snp")==0) snpnum_all ++;
        else ;
        mkrNumChr_all ++;        
        //
        bool isGiven = true;
        if(knownMarker.find(key) == knownMarker.end()) 
        {
            isGiven = false; // not in marker list; skip!
            continue;
        }        
        // check raw coverage on marker site - caution - only well-covered snps used as markers.
        size_t posDPsta = lineinfo[7].find("DP=");
        size_t posDPend = lineinfo[7].find(";", posDPsta);
        string posCov   = lineinfo[7].substr(posDPsta+3, posDPend - posDPsta - 3);
        
        // testing on allele coverage: 2018-04-11: sample A: avg 323+-323/4
        int allele_depth = strtoul(posCov.c_str(), NULL, 0);
        if(allele_depth<minVarCov || allele_depth>maxVarCov)
        {
            /*
            cout << "   Check: low-cov marker " << posCov << "x at " 
                 << lineinfo[0] << "\t" 
                 << lineinfo[1] << "\t" 
                 << lineinfo[3] << "\t"
                 << lineinfo[4] << endl;
            */
            continue;
        }
        // check observed allele frequency of markers: from AB <= SRF;SRR;SAF;SAR or RO/AO
        // SRF=55;SRR=62;SAF=43;SAR=53 ==> AB=(43+53)÷(43+53+55+62)
        double maf = 0; // allele frequency
        /*
        if(lineinfo[7].find("AB=") != std::string::npos)
        {
            size_t posABsta = lineinfo[7].find("AB=");
            size_t posABend = lineinfo[7].find(";", posABsta+1); 
            if(posABend == std::string::npos)
            {
                posABend = lineinfo[7].size()+1;
            }
            string ABstr    = lineinfo[7].substr(posABsta+3, posABend - posABsta - 3);
            maf             = atof(ABstr.c_str());           
        }
        else
        if(lineinfo[7].find("SRF=")!=std::string::npos &&
           lineinfo[7].find("SRR=")!=std::string::npos &&
           lineinfo[7].find("SAF=")!=std::string::npos &&
           lineinfo[7].find("SAR=")!=std::string::npos)
        {
            size_t posSRFsta = lineinfo[7].find("SRF=");
            size_t posSRFend = lineinfo[7].find(";", posSRFsta+1);
            if(posSRFend == std::string::npos)
            {
                posSRFend = lineinfo[7].size()+1;
            }
            string SRFCov    = lineinfo[7].substr(posSRFsta+4, posSRFend - posSRFsta - 4);
            double SRFcnt    = atof(SRFCov.c_str());
            //
            size_t posSRRsta = lineinfo[7].find("SRR=");
            size_t posSRRend = lineinfo[7].find(";", posSRRsta+1);
            if(posSRRend == std::string::npos)
            {
                posSRRend = lineinfo[7].size()+1;
            }
            string SRRCov    = lineinfo[7].substr(posSRRsta+4, posSRRend - posSRRsta - 4);  
            double SRRcnt    = atof(SRRCov.c_str());
            //
            size_t posSAFsta = lineinfo[7].find("SAF=");
            size_t posSAFend = lineinfo[7].find(";", posSAFsta+1);
            if(posSAFend == std::string::npos)
            {
                posSAFend = lineinfo[7].size()+1;
            }
            string SAFCov    = lineinfo[7].substr(posSAFsta+4, posSAFend - posSAFsta - 4);
            double SAFcnt    = atof(SAFCov.c_str());
            //
            size_t posSARsta = lineinfo[7].find("SAR=");
            size_t posSARend = lineinfo[7].find(";", posSARsta+1);
            if(posSARend == std::string::npos)
            {
                posSARend = lineinfo[7].size()+1;
            }
            string SARCov    = lineinfo[7].substr(posSARsta+4, posSARend - posSARsta - 4);
            double SARcnt    = atof(SARCov.c_str());
            maf              = (SAFcnt+SARcnt)/(SRFcnt+SRRcnt+SAFcnt+SARcnt);
            maf              = round(maf*1000000)/1000000;
        }
        else
        */ // the above is not used, as sometimes AB is 0 from longranger, but there are observed reads! why 20180629?
        if(lineinfo[7].find("RO=")!=std::string::npos && 
           lineinfo[7].find("AO=")!=std::string::npos)
        {
            size_t posROsta = lineinfo[7].find("RO=");
            size_t posROend = lineinfo[7].find(";", posROsta+1);
            if(posROend == std::string::npos)
            {
                posROend = lineinfo[7].size()+1;
            }
            string ROCov    = lineinfo[7].substr(posROsta+3, posROend - posROsta - 3);        
            size_t posAOsta = lineinfo[7].find("AO=");
            size_t posAOend = lineinfo[7].find(";", posAOsta+1);
            if(posAOend == std::string::npos)
            {
                posAOend = lineinfo[7].size()+1;
            }
            string AOCov    = lineinfo[7].substr(posAOsta+3, posAOend - posAOsta - 3);
            maf             = atof( AOCov.c_str() )/( atof( AOCov.c_str() ) + atof( ROCov.c_str() ) );
            maf             = round(maf*1000000)/1000000;
        }
        if(maf<minVarAF || maf>maxVarAF) // TODO: control with maximum as well! - 2018-03-12
        {
            /*
             cout << "   Check: skipped AF at " 
                  << lineinfo[0] << "\t" 
                  << lineinfo[1] << "\twith RO,AO:"
                  << ROCov       << ","             << AOCov << endl;     
            */
            continue; // caution: only vcf-variations with af>=0.2 used as markers.
        }
        // insert molecule info:
        // cluster barcodes in vcf into molecules
        vector<string>::iterator bcitr;
        vector<string>::iterator bcitr_end;
        // alternative from donor parent
        bcitr     = varBarcodes.begin();
        bcitr_end = varBarcodes.end();            
        while(bcitr != bcitr_end)
        {
            iMARKER tmpmkr;
            //tmpmkr.pos  = strtoul(lineinfo[1].c_str(), NULL, 0);
            tmpmkr.pos    = strtoul(dss.str().c_str(), NULL, 0);
            if(isGiven == true)
            {
                tmpmkr.from   = knownMarker[key];
            }
            else
            {
                tmpmkr.from   = "2";
            }
            tmpmkr.af     = maf;
            tmpmkr.cov    = posCov;
            tmpmkr.isGiven= isGiven;
            string bckey  = lineinfo[0] + "#" + *bcitr; // molecule id at chr: chr#bc
            (*moleculeSet).insert(std::pair<string, iMARKER>(bckey, tmpmkr));
            bcitr++;
        }
        // reference from another
        bcitr     = refBarcodes.begin();
        bcitr_end = refBarcodes.end();
        while(bcitr != bcitr_end)
        {
            iMARKER tmpmkr;
            //tmpmkr.pos  = strtoul(lineinfo[1].c_str(), NULL, 0);
            tmpmkr.pos    = strtoul(dss.str().c_str(), NULL, 0);
            if(isGiven == true && knownMarker[key].compare("1") == 0)
            {
                tmpmkr.from = "2";
            }
            else
            {
                tmpmkr.from = "1";
            }
            tmpmkr.af     = maf;
            tmpmkr.cov    = posCov;
            tmpmkr.isGiven= isGiven;                
            string bckey  = lineinfo[0] + "#" + *bcitr; // molecule id at chr: chr#bc
            (*moleculeSet).insert(std::pair<string, iMARKER>(bckey, tmpmkr));
            bcitr++;
        }
        // number of informative markers of different types intersecting given list
        if(isGiven == true)
        {
            if(itype.compare("del")==0) delnum ++;
            else
            if(itype.compare("ins")==0) insnum ++;
            else
            if(itype.compare("snp")==0) snpnum ++;
            else ;            
            mkrNumChr ++;
        }
    }
    cout << "   Info: number of collected markers    (excluding unknown) with cov>="  << minVarCov << "x: "  
         <<               mkrNumChr                           << endl;
    cout << "         "<< delnum        << " 1-bp deletions"  << endl;
    cout << "         "<< insnum        << " 1-bp insertions" << endl;
    cout << "         "<< snpnum        << "      snps"       << endl;
    cout << "   Info: number of checked   variations (including unknown) with cov>="  << minVarCov << "x: " 
         <<               mkrNumChr_all                       << endl;
    cout << "         "<< delnum_all    << " 1-bp deletions"  << endl;
    cout << "         "<< insnum_all    << " 1-bp insertions" << endl;
    cout << "         "<< snpnum_all    << "      snps"       << endl;    
    // close files
    fp.close();
    return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x7a8, %rsp            # imm = 0x7A8
movq %rdx, 0x138(%rsp)
movq %rsi, %r12
movq %rdi, %r14
leaq 0x508(%rsp), %rbx
movq %rbx, %rdi
callq 0x94d2
movq (%r14), %rsi
pushq $0x8
popq %rdx
movq %rbx, %rdi
callq 0x27e38
movq 0x508(%rsp), %rax
movq -0x18(%rax), %rax
movl 0x528(%rsp,%rax), %eax
movl %eax, 0x5c(%rsp)
testl %eax, %eax
je 0x126de
movq 0x2a91d(%rip), %rdi     # 0x3cfc8
leaq 0x1979d(%rip), %rsi     # 0x2be4f
callq 0x4330
movq %rax, %rdi
movq %r14, %rsi
callq 0x42e0
leaq 0x19804(%rip), %rsi     # 0x2becd
movq %rax, %rdi
callq 0x4330
movq %rax, %rdi
callq 0x41c0
jmp 0x137e1
movq 0x2a8e3(%rip), %rdi     # 0x3cfc8
leaq 0x19783(%rip), %rsi     # 0x2be6f
callq 0x4330
movl 0x2ac39(%rip), %esi     # 0x3d330
movq %rax, %rdi
callq 0x4580
leaq 0x19792(%rip), %rsi     # 0x2be98
movq %rax, %rdi
callq 0x4330
movl 0x2ac20(%rip), %esi     # 0x3d334
movq %rax, %rdi
callq 0x4580
leaq 0x19779(%rip), %rsi     # 0x2be9c
movq %rax, %rdi
callq 0x4330
movq %rax, %rdi
callq 0x41c0
movq %r14, 0x240(%rsp)
movq %r12, 0x28(%rsp)
leaq 0x8(%r12), %rax
movq %rax, 0x238(%rsp)
leaq 0x218(%rsp), %r14
leaq 0x360(%rsp), %r15
leaq 0x320(%rsp), %r13
movq $0x0, 0x130(%rsp)
movq $0x0, 0x118(%rsp)
movq $0x0, 0x120(%rsp)
movq $0x0, 0x128(%rsp)
movq $0x0, 0x110(%rsp)
movq $0x0, 0x30(%rsp)
movq $0x0, 0xf8(%rsp)
movq $0x0, 0x100(%rsp)
movq $0x0, 0x108(%rsp)
movq 0x508(%rsp), %rax
movq -0x18(%rax), %rax
cmpl $0x0, 0x528(%rsp,%rax)
jne 0x135e8
leaq 0x180(%rsp), %rbx
movq %rbx, %rdi
leaq 0x1b320(%rip), %rsi     # 0x2db1a
leaq 0x380(%rsp), %rdx
callq 0x4d3e
leaq 0x690(%rsp), %rdi
movq %rbx, %rsi
callq 0x4090
cmpq $0x0, 0x188(%rsp)
je 0x135d6
movq 0x180(%rsp), %rax
movzbl (%rax), %eax
cmpl $0x23, %eax
leaq 0x180(%rsp), %rdi
je 0x135de
cmpl $0x2a, %eax
je 0x135de
movq 0x30(%rsp), %rax
incq %rax
movq %rax, 0x30(%rsp)
xorl %edx, %edx
movl $0x186a0, %ecx          # imm = 0x186A0
divq %rcx
testq %rdx, %rdx
jne 0x128bd
movq 0x2a75a(%rip), %rdi     # 0x3cfc8
leaq 0x17631(%rip), %rsi     # 0x29ea6
callq 0x4330
movq %rax, %rdi
movq 0x30(%rsp), %rsi
callq 0x4230
movq %rax, %rdi
leaq 0x1963f(%rip), %rsi     # 0x2bed0
callq 0x4330
movq %rax, %rdi
movq 0x240(%rsp), %rsi
callq 0x42e0
movq %rax, %rdi
leaq 0x16b73(%rip), %rsi     # 0x29423
callq 0x4330
movq %rax, %rdi
callq 0x41c0
movb $0x9, 0x380(%rsp)
leaq 0x8(%rsp), %rdi
leaq 0x180(%rsp), %rsi
leaq 0x380(%rsp), %rdx
callq 0x26120
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rax
subq %rdi, %rax
cmpq $0x13f, %rax            # imm = 0x13F
ja 0x12924
movq 0x2a6cd(%rip), %rdi     # 0x3cfc8
leaq 0x195d9(%rip), %rsi     # 0x2bedb
callq 0x4330
movq %rax, %rdi
leaq 0x180(%rsp), %rsi
callq 0x42e0
movq %rax, %rdi
callq 0x41c0
jmp 0x135cc
subq $-0x80, %rdi
leaq 0x17571(%rip), %rsi     # 0x29ea0
xorl %edx, %edx
callq 0x4600
cmpq $-0x1, %rax
jne 0x135cc
movq 0x8(%rsp), %rdi
movl $0xc0, %eax
addq %rax, %rdi
leaq 0x195bd(%rip), %rsi     # 0x2bf11
callq 0x4110
andq $0x0, 0x1d0(%rsp)
andq $0x0, 0x1b0(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x1c0(%rsp)
movapd %xmm0, 0x1a0(%rsp)
movq 0x8(%rsp), %rsi
movl $0x100, %eax            # imm = 0x100
addq %rax, %rsi
movq %r14, %rdi
callq 0x4400
movq 0x8(%rsp), %rsi
movl $0x120, %eax            # imm = 0x120
addq %rax, %rsi
movq %r15, %rdi
callq 0x4400
movq %r13, %r12
movq 0x8(%rsp), %rsi
leaq 0x300(%rsp), %rdi
callq 0x4400
movq 0x8(%rsp), %rsi
addq $0x20, %rsi
leaq 0x340(%rsp), %r13
movq %r13, %rdi
callq 0x4400
leaq 0x2a998(%rip), %rax     # 0x3d378
movq %rax, (%rsp)
movq %r14, %rdi
movq %r15, %rsi
leaq 0x1c0(%rsp), %rdx
leaq 0x1a0(%rsp), %rcx
leaq 0x300(%rsp), %rbp
movq %rbp, %r8
movq %r13, %r9
callq 0x14e6e
movl %eax, %ebx
movq %r13, %rdi
callq 0x4638
movq %rbp, %rdi
callq 0x4638
movq %r15, %rbp
movq %r15, %rdi
callq 0x4638
movq %r14, %rdi
callq 0x4638
testb %bl, %bl
je 0x12c4f
leaq 0x170(%rsp), %rax
movq %rax, 0x160(%rsp)
andq $0x0, 0x168(%rsp)
movb $0x0, 0x170(%rsp)
movq %r12, %r13
movq %r12, %rdi
leaq 0x194d6(%rip), %rsi     # 0x2bf3e
leaq 0x380(%rsp), %rbx
movq %rbx, %rdx
callq 0x4d3e
movq %rbx, %rdi
callq 0x4250
leaq 0x218(%rsp), %r14
movq %rbp, %r15
leaq 0x268(%rsp), %rbx
movq %rbx, %rdi
leaq 0x1b07d(%rip), %rsi     # 0x2db1a
leaq 0x80(%rsp), %rdx
callq 0x4d3e
leaq 0x398(%rsp), %rdi
movq %rbx, %rsi
callq 0x4490
movq %rbx, %rdi
callq 0x4638
movq 0x8(%rsp), %rsi
movq 0x68(%rsi), %rax
cmpq $0x1, %rax
je 0x12c8d
cmpq $0x2, %rax
jne 0x13590
cmpq $0x1, 0x88(%rsi)
jne 0x13590
movq 0x20(%rsi), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x4130
leaq 0x1(%rax), %rsi
leaq 0x390(%rsp), %rdi
callq 0x4230
leaq 0x268(%rsp), %rbx
leaq 0x80(%rsp), %r14
movq 0x8(%rsp), %rsi
leaq 0x140(%rsp), %rdi
leaq 0x1b4b3(%rip), %rdx     # 0x2dfe2
callq 0x95e2
leaq 0x1d8(%rsp), %r12
movq %r12, %rdi
leaq 0x398(%rsp), %rsi
callq 0x44e0
leaq 0x1f8(%rsp), %rbp
movq %rbp, %rdi
leaq 0x140(%rsp), %rsi
movq %r12, %rdx
callq 0x957b
leaq 0x38(%rsp), %rdi
movq %rbp, %rsi
leaq 0x1b46c(%rip), %rdx     # 0x2dfe2
callq 0x5c38
movq 0x8(%rsp), %rsi
addq $0x60, %rsi
leaq 0x248(%rsp), %rbp
movq %rbp, %rdi
pushq $0x1
popq %rcx
movq %rcx, %rdx
callq 0x4360
leaq 0x60(%rsp), %r12
movq %r12, %rdi
leaq 0x38(%rsp), %rsi
movq %rbp, %rdx
callq 0x957b
movq %r14, %rdi
movq %r12, %rsi
leaq 0x1b426(%rip), %rdx     # 0x2dfe2
callq 0x5c38
movq %rbx, %rdi
movq %r14, %rsi
leaq 0x169e0(%rip), %rdx     # 0x295ae
callq 0x5c38
leaq 0x160(%rsp), %rdi
movq %rbx, %rsi
callq 0x43c0
movq %rbx, %rdi
callq 0x4638
movq %r14, %rdi
callq 0x4638
leaq 0x60(%rsp), %rdi
callq 0x4638
leaq 0x248(%rsp), %rdi
callq 0x4638
leaq 0x38(%rsp), %rdi
callq 0x4638
leaq 0x1f8(%rsp), %rdi
callq 0x4638
leaq 0x1d8(%rsp), %rdi
callq 0x4638
leaq 0x140(%rsp), %rdi
callq 0x4638
movq %r13, %rdi
leaq 0x192fd(%rip), %rsi     # 0x2bf42
callq 0x45e0
jmp 0x12f17
movq 0x2a372(%rip), %rdi     # 0x3cfc8
leaq 0x192b9(%rip), %rsi     # 0x2bf16
callq 0x4330
leaq 0x218(%rsp), %r14
movq %rbp, %r15
movq %r12, %r13
movq %rax, %rdi
leaq 0x180(%rsp), %rsi
callq 0x42e0
movq %rax, %rdi
callq 0x41c0
jmp 0x135b2
movq 0x88(%rsi), %rax
cmpq $0x1, %rax
je 0x12df9
cmpq $0x2, %rax
jne 0x13590
addq $0x20, %rsi
leaq 0x390(%rsp), %rdi
callq 0x42e0
leaq 0x268(%rsp), %rbx
leaq 0x80(%rsp), %r14
movq 0x8(%rsp), %rsi
leaq 0x140(%rsp), %rdi
leaq 0x1b305(%rip), %rdx     # 0x2dfe2
callq 0x95e2
leaq 0x1d8(%rsp), %r12
movq %r12, %rdi
leaq 0x398(%rsp), %rsi
callq 0x44e0
leaq 0x1f8(%rsp), %rbp
movq %rbp, %rdi
leaq 0x140(%rsp), %rsi
movq %r12, %rdx
callq 0x957b
leaq 0x38(%rsp), %r12
movq %r12, %rdi
movq %rbp, %rsi
leaq 0x1b2bb(%rip), %rdx     # 0x2dfe2
callq 0x5c38
leaq 0x60(%rsp), %rbp
movq %rbp, %rdi
movq %r12, %rsi
leaq 0x16870(%rip), %rdx     # 0x295ae
callq 0x5c38
movq %r14, %rdi
movq %rbp, %rsi
leaq 0x1b292(%rip), %rdx     # 0x2dfe2
callq 0x5c38
movq 0x8(%rsp), %rsi
subq $-0x80, %rsi
leaq 0x248(%rsp), %r12
movq %r12, %rdi
pushq $0x1
popq %rcx
movq %rcx, %rdx
callq 0x4360
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x957b
leaq 0x160(%rsp), %rdi
movq %rbx, %rsi
callq 0x43c0
movq %rbx, %rdi
callq 0x4638
movq %r12, %rdi
callq 0x4638
movq %r14, %rdi
callq 0x4638
leaq 0x60(%rsp), %rdi
callq 0x4638
leaq 0x38(%rsp), %rdi
callq 0x4638
leaq 0x1f8(%rsp), %rdi
callq 0x4638
leaq 0x1d8(%rsp), %rdi
callq 0x4638
leaq 0x140(%rsp), %rdi
callq 0x4638
movq %r13, %rdi
leaq 0x19157(%rip), %rsi     # 0x2bf46
callq 0x45e0
jmp 0x12f17
addq $0x20, %rsi
leaq 0x390(%rsp), %rdi
callq 0x42e0
leaq 0x268(%rsp), %rbx
leaq 0x80(%rsp), %r14
movq 0x8(%rsp), %rsi
leaq 0x140(%rsp), %rdi
leaq 0x1b1b4(%rip), %rdx     # 0x2dfe2
callq 0x95e2
leaq 0x1d8(%rsp), %r12
movq %r12, %rdi
leaq 0x398(%rsp), %rsi
callq 0x44e0
leaq 0x1f8(%rsp), %rbp
movq %rbp, %rdi
leaq 0x140(%rsp), %rsi
movq %r12, %rdx
callq 0x957b
leaq 0x38(%rsp), %r12
movq %r12, %rdi
movq %rbp, %rsi
leaq 0x1b16a(%rip), %rdx     # 0x2dfe2
callq 0x5c38
movq 0x8(%rsp), %rdx
addq $0x60, %rdx
leaq 0x60(%rsp), %rbp
movq %rbp, %rdi
movq %r12, %rsi
callq 0x961a
movq %r14, %rdi
movq %rbp, %rsi
leaq 0x1b13f(%rip), %rdx     # 0x2dfe2
callq 0x5c38
movq 0x8(%rsp), %rdx
subq $-0x80, %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x961a
leaq 0x160(%rsp), %rdi
movq %rbx, %rsi
callq 0x43c0
movq %rbx, %rdi
callq 0x4638
movq %r14, %rdi
callq 0x4638
leaq 0x60(%rsp), %rdi
callq 0x4638
leaq 0x38(%rsp), %rdi
callq 0x4638
leaq 0x1f8(%rsp), %rdi
callq 0x4638
leaq 0x1d8(%rsp), %rdi
callq 0x4638
leaq 0x140(%rsp), %rdi
callq 0x4638
movq %r13, %rdi
leaq 0x19021(%rip), %rsi     # 0x2bf42
callq 0x4110
testl %eax, %eax
je 0x12f5f
movq %r13, %rdi
leaq 0x19012(%rip), %rsi     # 0x2bf46
callq 0x4110
testl %eax, %eax
movl $0xe0, %ebx
je 0x12f6e
movq %r13, %rdi
leaq 0x18ff2(%rip), %rsi     # 0x2bf3e
callq 0x4110
cmpl $0x1, %eax
adcq $0x0, 0x128(%rsp)
jmp 0x12f76
incq 0x120(%rsp)
movl $0xe0, %ebx
jmp 0x12f76
incq 0x118(%rsp)
movq 0x28(%rsp), %rdi
leaq 0x160(%rsp), %rsi
callq 0xb44c
incq 0x130(%rsp)
cmpq 0x238(%rsp), %rax
je 0x1336c
movq 0x8(%rsp), %rdi
addq %rbx, %rdi
leaq 0x18f9d(%rip), %rsi     # 0x2bf4a
xorl %edx, %edx
callq 0x4600
movl $0xe0, %ebx
movq %rax, %r14
movq 0x8(%rsp), %rdi
addq %rbx, %rdi
leaq 0x183ef(%rip), %rsi     # 0x2b3ba
movq %rax, %rdx
callq 0x4600
movq 0x8(%rsp), %rsi
addq %rbx, %rsi
subq %r14, %rax
addq $0x3, %r14
leaq -0x3(%rax), %rcx
leaq 0x60(%rsp), %rdi
movq %r14, %rdx
callq 0x4360
movq 0x60(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x4130
cmpl %eax, 0x2a329(%rip)     # 0x3d330
leaq 0x218(%rsp), %r14
jg 0x13586
cmpl %eax, 0x2a319(%rip)     # 0x3d334
jl 0x13586
movq 0x8(%rsp), %rdi
movl $0xe0, %ebx
addq %rbx, %rdi
leaq 0x18f19(%rip), %rsi     # 0x2bf4e
xorl %edx, %edx
callq 0x4600
xorpd %xmm1, %xmm1
cmpq $-0x1, %rax
je 0x131c5
movq 0x8(%rsp), %rdi
addq %rbx, %rdi
leaq 0x18ef9(%rip), %rsi     # 0x2bf52
xorl %edx, %edx
callq 0x4600
xorpd %xmm1, %xmm1
cmpq $-0x1, %rax
je 0x131c5
movq 0x8(%rsp), %rdi
movl $0xe0, %ebx
addq %rbx, %rdi
leaq 0x18ecc(%rip), %rsi     # 0x2bf4e
xorl %edx, %edx
callq 0x4600
movq %rax, %r14
movq 0x8(%rsp), %rdi
addq %rbx, %rdi
leaq 0x1(%rax), %rdx
leaq 0x1831b(%rip), %rsi     # 0x2b3ba
callq 0x4600
movq 0x8(%rsp), %rsi
cmpq $-0x1, %rax
jne 0x130b9
movq 0xe8(%rsi), %rax
incq %rax
addq $0xe0, %rsi
subq %r14, %rax
addq $0x3, %r14
addq $-0x3, %rax
leaq 0x268(%rsp), %rdi
movq %r14, %rdx
movq %rax, %rcx
callq 0x4360
movq 0x8(%rsp), %rdi
movl $0xe0, %ebx
addq %rbx, %rdi
leaq 0x18e60(%rip), %rsi     # 0x2bf52
xorl %edx, %edx
callq 0x4600
movq %rax, %r14
movq 0x8(%rsp), %rdi
addq %rbx, %rdi
leaq 0x1(%rax), %rdx
leaq 0x182ab(%rip), %rsi     # 0x2b3ba
callq 0x4600
movq 0x8(%rsp), %rsi
cmpq $-0x1, %rax
jne 0x13129
movq 0xe8(%rsi), %rax
incq %rax
addq $0xe0, %rsi
subq %r14, %rax
addq $0x3, %r14
addq $-0x3, %rax
leaq 0x80(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rdx
movq %rax, %rcx
callq 0x4360
movq 0x80(%rsp), %rdi
callq 0x43d0
movsd %xmm0, 0x20(%rsp)
movq 0x268(%rsp), %rdi
callq 0x43d0
movsd 0x20(%rsp), %xmm1
addsd %xmm1, %xmm0
divsd %xmm0, %xmm1
movsd 0x15e81(%rip), %xmm0    # 0x29008
mulsd %xmm0, %xmm1
movapd %xmm1, %xmm0
callq 0x4180
divsd 0x15e6c(%rip), %xmm0    # 0x29008
movsd %xmm0, 0x20(%rsp)
movq %rbx, %rdi
callq 0x4638
leaq 0x268(%rsp), %rdi
callq 0x4638
movsd 0x20(%rsp), %xmm1
leaq 0x218(%rsp), %r14
movsd 0x2a16b(%rip), %xmm0    # 0x3d338
ucomisd %xmm1, %xmm0
ja 0x13586
ucomisd 0x2a161(%rip), %xmm1    # 0x3d340
ja 0x13586
movq 0x1c0(%rsp), %r14
movq 0x1c8(%rsp), %rbp
movsd %xmm1, 0x20(%rsp)
cmpq %rbp, %r14
je 0x13379
leaq 0x90(%rsp), %rax
movq %rax, 0x80(%rsp)
andq $0x0, 0x88(%rsp)
xorl %ecx, %ecx
movb %cl, 0x90(%rsp)
leaq 0xb8(%rsp), %rax
movq %rax, 0xa8(%rsp)
andq $0x0, 0xb0(%rsp)
movb %cl, 0xb8(%rsp)
leaq 0xe0(%rsp), %rax
movq %rax, 0xd0(%rsp)
andq $0x0, 0xd8(%rsp)
movb %cl, 0xe0(%rsp)
leaq 0x268(%rsp), %rbx
movq %rbx, %rdi
leaq 0x398(%rsp), %rsi
callq 0x44e0
movq 0x268(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x4130
movq %rax, 0xa0(%rsp)
movq %rbx, %rdi
callq 0x4638
movq 0x28(%rsp), %rdi
leaq 0x160(%rsp), %rsi
callq 0x15660
leaq 0xa8(%rsp), %rdi
movq %rax, %rsi
callq 0x41e0
movsd 0x20(%rsp), %xmm0
movsd %xmm0, 0xc8(%rsp)
leaq 0xd0(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x41e0
movb $0x1, 0xf0(%rsp)
movq 0x8(%rsp), %rsi
leaq 0x268(%rsp), %rbx
movq %rbx, %rdi
leaq 0x1ace1(%rip), %rdx     # 0x2dfe2
callq 0x95e2
leaq 0x38(%rsp), %r12
movq %r12, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x961a
movq %rbx, %rdi
callq 0x4638
movq %rbx, %rdi
movq %r12, %rsi
leaq 0x80(%rsp), %rdx
callq 0x158f8
movq 0x138(%rsp), %rdi
movq %rbx, %rsi
callq 0x1823a
movq %rbx, %rdi
callq 0x1592e
addq $0x20, %r14
leaq 0x38(%rsp), %rdi
callq 0x4638
leaq 0x80(%rsp), %rdi
callq 0x157b6
jmp 0x131fb
leaq 0x218(%rsp), %r14
jmp 0x13590
movq 0x1a0(%rsp), %r14
movq 0x1a8(%rsp), %rbp
cmpq %rbp, %r14
je 0x13519
leaq 0x90(%rsp), %rax
movq %rax, 0x80(%rsp)
andq $0x0, 0x88(%rsp)
xorl %ecx, %ecx
movb %cl, 0x90(%rsp)
leaq 0xb8(%rsp), %rax
movq %rax, 0xa8(%rsp)
andq $0x0, 0xb0(%rsp)
movb %cl, 0xb8(%rsp)
leaq 0xe0(%rsp), %rax
movq %rax, 0xd0(%rsp)
andq $0x0, 0xd8(%rsp)
movb %cl, 0xe0(%rsp)
leaq 0x268(%rsp), %rbx
movq %rbx, %rdi
leaq 0x398(%rsp), %rsi
callq 0x44e0
movq 0x268(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x4130
movq %rax, 0xa0(%rsp)
movq %rbx, %rdi
callq 0x4638
movq 0x28(%rsp), %rdi
leaq 0x160(%rsp), %rsi
callq 0x15660
movq %rax, %rdi
leaq 0x161f8(%rip), %rbx     # 0x29641
movq %rbx, %rsi
callq 0x4110
testl %eax, %eax
leaq 0x1aab3(%rip), %rax     # 0x2df0d
cmoveq %rax, %rbx
leaq 0xa8(%rsp), %rdi
movq %rbx, %rsi
callq 0x45e0
movsd 0x20(%rsp), %xmm0
movsd %xmm0, 0xc8(%rsp)
leaq 0xd0(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x41e0
movb $0x1, 0xf0(%rsp)
movq 0x8(%rsp), %rsi
leaq 0x268(%rsp), %rbx
movq %rbx, %rdi
leaq 0x1ab34(%rip), %rdx     # 0x2dfe2
callq 0x95e2
leaq 0x38(%rsp), %r12
movq %r12, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x961a
movq %rbx, %rdi
callq 0x4638
movq %rbx, %rdi
movq %r12, %rsi
leaq 0x80(%rsp), %rdx
callq 0x158f8
movq 0x138(%rsp), %rdi
movq %rbx, %rsi
callq 0x1823a
movq %rbx, %rdi
callq 0x1592e
addq $0x20, %r14
leaq 0x38(%rsp), %rdi
callq 0x4638
leaq 0x80(%rsp), %rdi
callq 0x157b6
jmp 0x13389
movq %r13, %rdi
leaq 0x18a1f(%rip), %rsi     # 0x2bf42
callq 0x4110
testl %eax, %eax
je 0x13564
movq %r13, %rdi
leaq 0x18a10(%rip), %rsi     # 0x2bf46
callq 0x4110
testl %eax, %eax
leaq 0x218(%rsp), %r14
je 0x13576
movq %r13, %rdi
leaq 0x189ed(%rip), %rsi     # 0x2bf3e
callq 0x4110
cmpl $0x1, %eax
adcq $0x0, 0x108(%rsp)
jmp 0x1357e
incq 0x100(%rsp)
leaq 0x218(%rsp), %r14
jmp 0x1357e
incq 0xf8(%rsp)
incq 0x110(%rsp)
leaq 0x60(%rsp), %rdi
callq 0x4638
leaq 0x380(%rsp), %rdi
callq 0x4280
movq %r13, %rdi
callq 0x4638
leaq 0x160(%rsp), %rdi
callq 0x4638
leaq 0x1a0(%rsp), %rdi
callq 0x5d02
leaq 0x1c0(%rsp), %rdi
callq 0x5d02
leaq 0x8(%rsp), %rdi
callq 0x5d02
leaq 0x180(%rsp), %rdi
callq 0x4638
jmp 0x127ce
movq 0x299d9(%rip), %rdi     # 0x3cfc8
leaq 0x18960(%rip), %rsi     # 0x2bf56
callq 0x4330
movl 0x29d2f(%rip), %esi     # 0x3d330
movq %rax, %rdi
callq 0x4580
leaq 0x1898d(%rip), %rsi     # 0x2bf9d
movq %rax, %rdi
callq 0x4330
movq %rax, %rdi
movq 0x110(%rsp), %rsi
callq 0x4230
movq %rax, %rdi
callq 0x41c0
movq 0x29991(%rip), %rdi     # 0x3cfc8
leaq 0x17d26(%rip), %rsi     # 0x2b364
callq 0x4330
movq %rax, %rdi
movq 0x100(%rsp), %rsi
callq 0x4230
leaq 0x18947(%rip), %rsi     # 0x2bfa1
movq %rax, %rdi
callq 0x4330
movq %rax, %rdi
callq 0x41c0
movq 0x29957(%rip), %rdi     # 0x3cfc8
leaq 0x17cec(%rip), %rsi     # 0x2b364
callq 0x4330
movq %rax, %rdi
movq 0xf8(%rsp), %rsi
callq 0x4230
leaq 0x1891d(%rip), %rsi     # 0x2bfb1
movq %rax, %rdi
callq 0x4330
movq %rax, %rdi
callq 0x41c0
movq 0x2991d(%rip), %rdi     # 0x3cfc8
leaq 0x17cb2(%rip), %rsi     # 0x2b364
callq 0x4330
movq %rax, %rdi
movq 0x108(%rsp), %rsi
callq 0x4230
leaq 0x188f4(%rip), %rsi     # 0x2bfc2
movq %rax, %rdi
callq 0x4330
movq %rax, %rdi
callq 0x41c0
movq 0x298e3(%rip), %rdi     # 0x3cfc8
leaq 0x188e1(%rip), %rsi     # 0x2bfcd
callq 0x4330
movl 0x29c39(%rip), %esi     # 0x3d330
movq %rax, %rdi
callq 0x4580
leaq 0x18897(%rip), %rsi     # 0x2bf9d
movq %rax, %rdi
callq 0x4330
movq %rax, %rdi
movq 0x130(%rsp), %rsi
callq 0x4230
movq %rax, %rdi
callq 0x41c0
movq 0x2989b(%rip), %rdi     # 0x3cfc8
leaq 0x17c30(%rip), %rsi     # 0x2b364
callq 0x4330
movq %rax, %rdi
movq 0x120(%rsp), %rsi
callq 0x4230
leaq 0x18851(%rip), %rsi     # 0x2bfa1
movq %rax, %rdi
callq 0x4330
movq %rax, %rdi
callq 0x41c0
movq 0x29861(%rip), %rdi     # 0x3cfc8
leaq 0x17bf6(%rip), %rsi     # 0x2b364
callq 0x4330
movq %rax, %rdi
movq 0x118(%rsp), %rsi
callq 0x4230
leaq 0x18827(%rip), %rsi     # 0x2bfb1
movq %rax, %rdi
callq 0x4330
movq %rax, %rdi
callq 0x41c0
movq 0x29827(%rip), %rdi     # 0x3cfc8
leaq 0x17bbc(%rip), %rsi     # 0x2b364
callq 0x4330
movq %rax, %rdi
movq 0x128(%rsp), %rsi
callq 0x4230
leaq 0x187fe(%rip), %rsi     # 0x2bfc2
movq %rax, %rdi
callq 0x4330
movq %rax, %rdi
callq 0x41c0
leaq 0x508(%rsp), %rdi
callq 0x280e0
cmpl $0x0, 0x5c(%rsp)
sete %bl
leaq 0x508(%rsp), %rdi
callq 0x96aa
movl %ebx, %eax
addq $0x7a8, %rsp            # imm = 0x7A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x139bd
movq %rax, %rbx
leaq 0x268(%rsp), %rdi
callq 0x4638
jmp 0x139bd
jmp 0x1388f
jmp 0x138ec
jmp 0x1388f
jmp 0x138f9
movq %rax, %rbx
leaq 0x248(%rsp), %rdi
callq 0x4638
jmp 0x13863
jmp 0x13883
jmp 0x13860
jmp 0x138ec
jmp 0x13883
jmp 0x13879
jmp 0x1385b
jmp 0x138f9
movq %rax, %rbx
jmp 0x13870
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x4638
leaq 0x60(%rsp), %rdi
jmp 0x138b6
jmp 0x13879
movq %rax, %rbx
jmp 0x138bb
movq %rax, %rbx
jmp 0x138a4
movq %rax, %rbx
jmp 0x138d2
movq %rax, %rbx
jmp 0x138ae
jmp 0x138f9
movq %rax, %rbx
jmp 0x138c5
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x4638
leaq 0x60(%rsp), %rdi
callq 0x4638
leaq 0x248(%rsp), %rdi
callq 0x4638
leaq 0x38(%rsp), %rdi
callq 0x4638
leaq 0x1f8(%rsp), %rdi
callq 0x4638
leaq 0x1d8(%rsp), %rdi
callq 0x4638
leaq 0x140(%rsp), %rdi
jmp 0x139c2
movq %rax, %rbx
jmp 0x138df
jmp 0x138f9
jmp 0x138f9
jmp 0x138f9
jmp 0x138f9
movq %rax, %rbx
jmp 0x139c7
movq %rax, %rbx
leaq 0x268(%rsp), %rdi
jmp 0x139c2
movq %rax, %rbx
jmp 0x139d4
movq %rax, %rbx
jmp 0x139e1
jmp 0x139ad
jmp 0x139ad
jmp 0x13954
jmp 0x13931
jmp 0x13947
movq %rax, %rbx
leaq 0x268(%rsp), %rdi
callq 0x1592e
jmp 0x13957
jmp 0x139ad
jmp 0x139ad
movq %rax, %rbx
leaq 0x268(%rsp), %rdi
jmp 0x1395c
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x4638
jmp 0x139b0
movq %rax, %rbx
jmp 0x1399c
movq %rax, %rbx
jmp 0x13982
movq %rax, %rbx
jmp 0x1398f
movq %rax, %rbx
leaq 0x340(%rsp), %rdi
callq 0x4638
leaq 0x300(%rsp), %rdi
callq 0x4638
leaq 0x360(%rsp), %rdi
callq 0x4638
leaq 0x218(%rsp), %rdi
jmp 0x139e9
movq %rax, %rbx
jmp 0x139ee
jmp 0x139ad
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x157b6
leaq 0x60(%rsp), %rdi
callq 0x4638
leaq 0x380(%rsp), %rdi
callq 0x4280
leaq 0x320(%rsp), %rdi
callq 0x4638
leaq 0x160(%rsp), %rdi
callq 0x4638
leaq 0x1a0(%rsp), %rdi
callq 0x5d02
leaq 0x1c0(%rsp), %rdi
callq 0x5d02
jmp 0x13a11
jmp 0x13a24
jmp 0x13a1f
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x5d02
jmp 0x13a27
jmp 0x13a1f
movq %rax, %rbx
jmp 0x13a34
movq %rax, %rbx
leaq 0x180(%rsp), %rdi
callq 0x4638
leaq 0x508(%rsp), %rdi
callq 0x96aa
movq %rbx, %rdi
callq 0x45a0