// File: /workspace/github_cpp_makefile_star2_O1/schneebergerlab[P]DrLink/convert_bam.cpp
// Function: convertBam(int, char**)
bool convertBam(int argc, char* argv[])
{
    if(argc < 4)
    {
        cout << "\n   DrLink preprocess\t"
             << "Usage: samtools view longranger_wgs.bam | DrLink preprocess - out_prefix_str " << endl;  
        return false;
    }
    clock_t tbeg;
    tbeg = clock();
    bool verbose = true; // to add future option    
    //
    cout << "   Info: converting streaming bam info started..." << endl;
    // prepare output gzipped file
    string ofilename = (string)argv[3] + "_bamInfo_trashme.gz";
    ogzstream  ofp;
    ofp.open(ofilename.c_str());
    if ( ! ofp.good()) {
        std::cerr << "ERROR: Opening file `" << ofilename << "' failed.\n";
	return 1;
    }
    ofp << "#chr\tpos\tbamCIGAR\tbarcode\tlrMI\tread-order:bamFLAG\treversed-align\tread-id\tpnext" << endl;
    // pnext: where its pair is aligned: must be the same-chr-position - only concordant alignments kept.
    //
    unsigned long numraw  = 0;
    unsigned long numcov  = 0;
    unsigned long numNoBX = 0;
    unsigned long numNoCG = 0; // no cigar string    
    unsigned long numNoMI = 0;
    unsigned long numNoMA = 0; // number of reads showing multiple alignment: only one kept.    
    unsigned long numDiscordant = 0; // read pairs aligned not in the same chr-region.
    string exampleNoBX("");
    string exampleNoCG("");    
    string exampleNoMI("");
    string exampleNoMA("");
    string exampleDiscordant("");
    bool out = false;
    std::string line;
    while (std::getline(std::cin, line)) 
    {
        if(line.compare("quit")==0 || line.compare("q")==0 || line.compare("exit")==0) break;
        if(line.size()==0 || line[0]=='#') continue;
        numraw ++;
        if(numraw%10000000 == 0)
        {
            cout << "   info: " << numraw << "th aligm..." << endl;
        }
        //
        vector<string> lineinfo = split_string(line, '\t');
        
        // cigar string
        if(lineinfo[5].compare("*") == 0) 
        {
            if(exampleNoCG.size()==0)
            {
                exampleNoCG = line;
                cout << "   Warning: there are alignments without explicit CIGAR string, skipped., e.g.: " 
                     << line 
                     << endl;
                cout << "   Info: you will get a total number of such alignments in the end of program. " 
                     << endl;
            }
            numNoCG ++;
            continue;
        }
        // discordant read pairs
        if(lineinfo[6].compare("=") != 0)
        {
            // case 1: not on the same chr
            if(exampleDiscordant.size()==0)
            {
                exampleDiscordant = line;
                cout << "   Warning: there are discordant alignments, skipped., e.g.: " 
                     << line 
                     << endl;
                cout << "   Info: you will get a total number of such alignments in the end of program. " 
                     << endl;
            }  
            numDiscordant ++;
            continue;                      
        }
        else
        {
            // case 2: on the same read, but unexpected template length 
            string tmplen;
            if(lineinfo[8].find("-") != std::string::npos)
            {
                tmplen = lineinfo[8].substr(1);
            }
            else
            {
                tmplen = lineinfo[8].substr(0);
            }
            unsigned long templateLen = strtoul(tmplen.c_str(), NULL, 0);
            if(templateLen==0 || templateLen>2000) // caution: fragment size
            {
                if(exampleDiscordant.size()==0)
                {
                    exampleDiscordant = line;
                    cout << "   Warning: there are discordant alignments, skipped., e.g.: " 
                         << line 
                         << endl;
                    cout << "   Info: you will get a total number of such alignments in the end of program. " 
                         << endl;
                }
                numDiscordant ++;
                continue;    
            }
        }
        //
        /* BX: Chromium barcode sequence that is error-corrected and confirmed against 
           a list of known-good barcode sequences. Use this for analysis, e.g., '\tBX:Z:TTTGTGTGTATGACTC-1' */        
        size_t pos1  = line.find("\tBX:");
        if(pos1 == std::string::npos) 
        {
            if(exampleNoBX.size()==0)
            {
                exampleNoBX = line;
                cout << "   Warning: there are alignments without BX info, skipped., e.g.: " 
                     << line 
                     << endl;
                cout << "   Info: you will get a total number of such alignments in the end of program. " 
                     << endl;                
            }
            numNoBX ++;
            continue;
        }
        pos1 += 1; // from 'BX:Z:...'
        size_t pos2  = line.find("\t", pos1);
        if(pos2 == std::string::npos)
        {
            pos2 = line.size();
        }        
        string rawbx = line.substr(pos1, pos2-pos1);
        //
        /* MI: Global molecule identifier for molecule that generated this read,
           e.g.,  '\tMI:i:29' */
        size_t pos3  = line.find("\tMI:");
        bool foundmi = true;
        if(pos3 == std::string::npos)
        {
            if(exampleNoMI.size()==0)
            {
                exampleNoMI = line;
                cout << "   Warning: there are alignments without MI info, but kept, e.g.: " 
                     << line 
                     << endl;
                cout << "   Info: you will get a total number of such alignments in the end of program. " 
                     << endl;                
            }
            numNoMI ++;
            foundmi = false;
        }
        pos3 += 1; // from 'MI:i:...'
        size_t pos4;
        string rawmi("-1");
        if(foundmi)
        {
            pos4 = line.find("\t", pos3);
            if(pos4 == std::string::npos)
            {
                pos4 = line.size();
            }
            rawmi = line.substr(pos3+5, pos4-pos3-5); // without "MI:i:"
        }
        //
        // check if it is read 1 or read 2
        int hexflag = strtol(lineinfo[1].c_str(), NULL, 0);
        if(hexflag > 255) 
        {
            numNoMA ++;
            if(exampleNoMA.size()==0)
            {
                exampleNoMA = line;
                cout << "   Warning: there are alignments being secondary/supplementary or not passing filters, skipped, e.g.: " 
                     << line 
                     << endl;
                cout << "   Info: you will get a total number of such alignments in the end of program. " 
                     << endl;                
            }
            continue;
        }

        string readflag = "U";
        
        if((hexflag & 0x40) == 0x40 && (hexflag & 0x80) == 0)
        {
            readflag = "R1";
        }
        else
        if((hexflag & 0x40) == 0    && (hexflag & 0x80) == 0x80)
        {
            readflag = "R2";
        }
        else
        {
            readflag = "U0";
            cout << "   hexflag=" << hexflag << endl;
            cout << "   hexflag & 0x40 == 0x40= " << (hexflag & 0x40) << endl;
            cout << "   hexflag & 0x80 == 0   = " << (hexflag & 0x80) << endl;            
        }
        string reversed = "nrc";
        if((hexflag & 0x10) == 0x10) reversed = "rc";
        // chr	pos	CIGAR	barcode	MI	read-ordering:R1/R2	reversed	read-id	pnext
        // caution!!! code below also works for reversed-cases of alignment!
        // in bam/sam, it is always pos + CIGAR"M" ==> spanning of a read!!!
        ofp << lineinfo[2]                     << "\t" 
            << lineinfo[3]                     << "\t" 
            << lineinfo[5]                     << "\t" 
            << rawbx.substr(5, rawbx.size()-7) << "\t"
            << rawmi                           << "\t"
            << readflag  << ":" << lineinfo[1] << "\t" 
            << reversed                        << "\t"
            << lineinfo[0]                     << "\t"
            << lineinfo[7]                     << endl; // with read id and pnext
        //
        numcov ++;            
        if(!out) out = true;
        line.clear();
    }    
    //
    ofp.close();

    if(numNoBX > 0)
    {
        cout << "   Warning: there are "<< numNoBX 
             << " alignments without BX info, skipped. "              
             << endl;
    }
    if(numNoCG > 0)
    {
        cout << "   Warning: there are "<< numNoCG 
             << " alignments without explicit CIAGR info, skipped."   
             << endl;     
    }    
    if(numNoMI > 0)
    {
        cout << "   Warning: there are "<< numNoMI 
             << " alignments without MI info, but kept."              
             << endl;     
    }
    if(numNoMA > 0)
    {
        cout << "   Warning: there are "<< numNoMA 
             << " alignments being secondary/supplementary alignment"
             << " or not passing filters, skipped." 
             << endl;     
    }  
    if(numDiscordant > 0)
    {
        cout << "   Warning: there are "<< numDiscordant 
             << " alignments being discordant (pairs not on same chr or distance>2kb), skipped." 
             << endl;         
    }  
    cout << "   Info: in total " 
         << numraw  
         << " alignment lines, of which " 
         << numcov               
         << " with barcode info converted." 
         <<  endl;
    cout << "   Info: time on converting streaming bam info: " 
         << (float)(clock()-tbeg)/CLOCKS_PER_SEC 
         << " seconds.\n" 
         << endl;
    if(!out) return false;
    else return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x478, %rsp            # imm = 0x478
cmpl $0x3, %edi
jg 0x5487
movq 0x46b97(%rip), %rbx     # 0x4bfc8
leaq 0x34f58(%rip), %rsi     # 0x3a390
movl $0x16, %edx
movq %rbx, %rdi
callq 0x43a0
leaq 0x34f5b(%rip), %rsi     # 0x3a3a7
movl $0x4d, %edx
movq %rbx, %rdi
callq 0x43a0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4310
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x4220
xorl %ebp, %ebp
jmp 0x6732
movq %rsi, %rbx
callq 0x4200
movq %rax, %r14
movq 0x46b2f(%rip), %r13     # 0x4bfc8
leaq 0x34f55(%rip), %rsi     # 0x3a3f5
movl $0x31, %edx
movq %r13, %rdi
callq 0x43a0
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x4310
movsbl %al, %esi
movq %r13, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x4220
movq 0x18(%rbx), %rsi
leaq 0x1e0(%rsp), %rdi
leaq 0x130(%rsp), %rdx
callq 0x5346
leaq 0x34f32(%rip), %rsi     # 0x3a427
leaq 0x1e0(%rsp), %rdi
callq 0x45e0
leaq 0xb8(%rsp), %rbx
movq %rbx, -0x10(%rbx)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x5532
movq %rdx, 0xa8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0xb8(%rsp)
jmp 0x5538
movups (%rcx), %xmm0
movups %xmm0, (%rbx)
movq 0x8(%rax), %rdx
movq %rdx, 0xb0(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x1f0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x5574
movq 0x1f0(%rsp), %rsi
incq %rsi
callq 0x4340
leaq 0x1e0(%rsp), %rdi
callq 0x69c4
movq 0xa8(%rsp), %rsi
leaq 0x1e0(%rsp), %rdi
movl $0x10, %edx
callq 0x39386
movq 0x1e0(%rsp), %rax
movq -0x18(%rax), %rax
cmpl $0x0, 0x200(%rsp,%rax)
je 0x5601
movq 0x46a38(%rip), %rdi     # 0x4bff0
leaq 0x34e7c(%rip), %rsi     # 0x3a43b
movl $0x15, %edx
callq 0x43a0
movq 0xa8(%rsp), %rsi
movq 0xb0(%rsp), %rdx
movq 0x46a10(%rip), %rdi     # 0x4bff0
callq 0x43a0
movb $0x1, %bpl
leaq 0x34e62(%rip), %rsi     # 0x3a451
movl $0xa, %edx
movq %rax, %rdi
callq 0x43a0
jmp 0x66f4
leaq 0x368(%rsp), %rbx
leaq 0x34e4c(%rip), %rsi     # 0x3a45c
movl $0x4e, %edx
movq %rbx, %rdi
callq 0x43a0
movq 0x368(%rsp), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4310
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x4220
leaq 0x140(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x394c6(%rip), %rdx     # 0x3eb22
leaq 0x130(%rsp), %rdi
movq %rdx, %rsi
callq 0x5384
leaq 0x1a0(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x394a3(%rip), %rdx     # 0x3eb22
leaq 0x190(%rsp), %rdi
movq %rdx, %rsi
callq 0x5384
leaq 0x180(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x39480(%rip), %rdx     # 0x3eb22
leaq 0x170(%rsp), %rdi
movq %rdx, %rsi
callq 0x5384
leaq 0x160(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x3945d(%rip), %rdx     # 0x3eb22
leaq 0x150(%rsp), %rdi
movq %rdx, %rsi
callq 0x5384
movq %r14, 0x1d8(%rsp)
leaq 0x120(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x39432(%rip), %rdx     # 0x3eb22
leaq 0x110(%rsp), %rdi
movq %rdx, %rsi
callq 0x5384
leaq 0x10(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq $0x0, 0x40(%rsp)
movq 0x468b4(%rip), %r12     # 0x4bfd8
movq %rsp, %r14
leaq 0x34d7d(%rip), %rbx     # 0x3a4ab
movq $0x0, 0xd0(%rsp)
movq $0x0, 0xe0(%rsp)
movq $0x0, 0xe8(%rsp)
movq $0x0, 0xc8(%rsp)
movq $0x0, 0xd8(%rsp)
movq $0x0, 0xa0(%rsp)
xorl %ebp, %ebp
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x4310
movsbl %al, %edx
movq %r12, %rdi
movq %r14, %rsi
callq 0x45c0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x62af
movq %r14, %rdi
movq %rbx, %rsi
callq 0x4100
testl %eax, %eax
je 0x62af
movq %r14, %rdi
leaq 0x34ce6(%rip), %rsi     # 0x3a4b0
callq 0x4100
testl %eax, %eax
je 0x62af
movq %r14, %rdi
leaq 0x34cd1(%rip), %rsi     # 0x3a4b2
callq 0x4100
testl %eax, %eax
je 0x62af
cmpq $0x0, 0x8(%rsp)
je 0x5778
movq (%rsp), %rax
cmpb $0x23, (%rax)
je 0x5778
movq 0x40(%rsp), %rcx
incq %rcx
movq %rcx, %rax
movq %rcx, 0x40(%rsp)
movabsq $-0x1afcdb885172b95b, %rcx # imm = 0xE5032477AE8D46A5
imulq %rcx, %rax
rorq $0x7, %rax
movabsq $0x1ad7f29abca, %rcx    # imm = 0x1AD7F29ABCA
cmpq %rcx, %rax
ja 0x5893
movl $0x9, %edx
movq %r13, %rdi
leaq 0x34c74(%rip), %rsi     # 0x3a4b7
callq 0x43a0
movq %r13, %rdi
movq 0x40(%rsp), %rsi
callq 0x4210
movq %rax, %r15
movl $0xb, %edx
movq %rax, %rdi
leaq 0x34c5a(%rip), %rsi     # 0x3a4c1
callq 0x43a0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x4310
movsbl %al, %esi
movq %r15, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x4220
movb $0x9, 0x20(%rsp)
leaq 0x68(%rsp), %rdi
movq %r14, %rsi
leaq 0x20(%rsp), %rdx
callq 0x36b7c
movq 0x68(%rsp), %rdi
movl $0xa0, %eax
addq %rax, %rdi
leaq 0x34c0f(%rip), %rsi     # 0x3a4cd
callq 0x4100
testl %eax, %eax
je 0x59a3
movq 0x68(%rsp), %rdi
movl $0xc0, %eax
addq %rax, %rdi
leaq 0x371c1(%rip), %rsi     # 0x3caa0
callq 0x4100
testl %eax, %eax
je 0x5a5a
cmpq $0x0, 0x118(%rsp)
jne 0x5996
leaq 0x110(%rsp), %rdi
movq %r14, %rsi
callq 0x41c0
movl $0x3d, %edx
movq %r13, %rdi
leaq 0x34c56(%rip), %rsi     # 0x3a570
callq 0x43a0
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq %r13, %rdi
callq 0x43a0
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x4310
movsbl %al, %esi
movq %r15, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x4220
movl $0x4f, %edx
movq %r13, %rdi
leaq 0x34bb7(%rip), %rsi     # 0x3a520
callq 0x43a0
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x4310
movsbl %al, %esi
movq %r13, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x4220
incq 0xa0(%rsp)
jmp 0x62a0
cmpq $0x0, 0x198(%rsp)
jne 0x5a4d
leaq 0x190(%rsp), %rdi
movq %r14, %rsi
callq 0x41c0
movl $0x50, %edx
movq %r13, %rdi
leaq 0x34afe(%rip), %rsi     # 0x3a4cf
callq 0x43a0
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq %r13, %rdi
callq 0x43a0
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x4310
movsbl %al, %esi
movq %r15, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x4220
movl $0x4f, %edx
movq %r13, %rdi
leaq 0x34b00(%rip), %rsi     # 0x3a520
callq 0x43a0
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x4310
movsbl %al, %esi
movq %r13, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x4220
incq 0xe8(%rsp)
jmp 0x62a0
leaq 0x30(%rsp), %rax
movq %rax, 0x20(%rsp)
movq $0x0, 0x28(%rsp)
movb $0x0, 0x30(%rsp)
movq 0x68(%rsp), %rdi
movl $0x100, %r15d           # imm = 0x100
addq %r15, %rdi
movl $0x1, %ecx
leaq 0x34b22(%rip), %rsi     # 0x3a5ae
xorl %edx, %edx
callq 0x4590
cmpq $-0x1, %rax
je 0x5abc
movq 0x68(%rsp), %rsi
addq %r15, %rsi
movl $0x1, %edx
leaq 0x48(%rsp), %r15
movq %r15, %rdi
movq $-0x1, %rcx
callq 0x4360
jmp 0x5ada
movq 0x68(%rsp), %rsi
addq %r15, %rsi
leaq 0x48(%rsp), %r15
movq %r15, %rdi
xorl %edx, %edx
movq $-0x1, %rcx
callq 0x4360
leaq 0x20(%rsp), %rdi
movq %r15, %rsi
callq 0x43e0
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x5b03
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x4340
movq 0x20(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x4130
decq %rax
movq %rax, 0x1d0(%rsp)
cmpq $0x7d0, %rax            # imm = 0x7D0
jb 0x5bda
cmpq $0x0, 0x118(%rsp)
jne 0x5bd2
leaq 0x110(%rsp), %rdi
movq %r14, %rsi
callq 0x41c0
movl $0x3d, %edx
movq %r13, %rdi
leaq 0x34a1a(%rip), %rsi     # 0x3a570
callq 0x43a0
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq %r13, %rdi
callq 0x43a0
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x4310
movsbl %al, %esi
movq %r15, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x4220
movl $0x4f, %edx
movq %r13, %rdi
leaq 0x3497b(%rip), %rsi     # 0x3a520
callq 0x43a0
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x4310
movsbl %al, %esi
movq %r13, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x4220
incq 0xa0(%rsp)
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x5bf6
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x4340
cmpq $0x7d0, 0x1d0(%rsp) # imm = 0x7D0
jae 0x62a0
movl $0x4, %ecx
movq %r14, %rdi
leaq 0x34999(%rip), %rsi     # 0x3a5b0
xorl %edx, %edx
callq 0x4590
cmpq $-0x1, %rax
je 0x5e29
movq %rax, %r15
incq %r15
movl $0x1, %ecx
movq %r14, %rdi
leaq 0x38ee4(%rip), %rsi     # 0x3eb21
movq %r15, %rdx
callq 0x4590
cmpq $-0x1, %rax
jne 0x5c50
movq 0x8(%rsp), %rax
subq %r15, %rax
leaq 0x20(%rsp), %rdi
movq %r14, %rsi
movq %r15, %rdx
movq %rax, %rcx
callq 0x4360
movl $0x4, %ecx
movq %r14, %rdi
leaq 0x34983(%rip), %rsi     # 0x3a5f8
xorl %edx, %edx
callq 0x4590
movq %rax, %r15
cmpq $-0x1, %rax
jne 0x5cf1
cmpq $0x0, 0x178(%rsp)
jne 0x5ce9
leaq 0x170(%rsp), %rdi
movq %r14, %rsi
callq 0x41c0
movl $0x42, %edx
movq %r13, %rdi
leaq 0x3494e(%rip), %rsi     # 0x3a5fd
callq 0x43a0
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq %r13, %rdi
callq 0x43a0
movq %rax, %rdi
callq 0x41a0
movl $0x4f, %edx
movq %r13, %rdi
leaq 0x34844(%rip), %rsi     # 0x3a520
callq 0x43a0
movq %r13, %rdi
callq 0x41a0
incq 0xc8(%rsp)
leaq 0x58(%rsp), %rax
movq %rax, 0x48(%rsp)
leaq 0x48(%rsp), %rdi
leaq 0x34939(%rip), %rsi     # 0x3a640
leaq 0x34934(%rip), %rdx     # 0x3a642
callq 0x5384
cmpq $-0x1, %r15
je 0x5d92
leaq 0x1(%r15), %rdx
movl $0x1, %ecx
movq %r14, %rdi
leaq 0x38df5(%rip), %rsi     # 0x3eb21
callq 0x4590
cmpq $-0x1, %rax
jne 0x5d3c
movq 0x8(%rsp), %rax
subq %r15, %rax
addq $0x6, %r15
addq $-0x6, %rax
movq %r15, %rdx
leaq 0x80(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
movq %rax, %rcx
callq 0x4360
leaq 0x48(%rsp), %rdi
movq %r15, %rsi
callq 0x43e0
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x5d92
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x4340
movq 0x68(%rsp), %rax
movq 0x20(%rax), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x4420
movq %rax, %r15
cmpl $0x100, %r15d           # imm = 0x100
jl 0x5e9a
incq 0xd8(%rsp)
cmpq $0x0, 0x158(%rsp)
jne 0x6268
leaq 0x150(%rsp), %rdi
movq %r14, %rsi
callq 0x41c0
movl $0x66, %edx
movq %r13, %rdi
leaq 0x34859(%rip), %rsi     # 0x3a643
callq 0x43a0
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq %r13, %rdi
callq 0x43a0
movq %rax, %rdi
callq 0x41a0
movl $0x4f, %edx
movq %r13, %rdi
leaq 0x34709(%rip), %rsi     # 0x3a520
callq 0x43a0
movq %r13, %rdi
callq 0x41a0
jmp 0x6268
cmpq $0x0, 0x138(%rsp)
jne 0x5e8d
leaq 0x130(%rsp), %rdi
movq %r14, %rsi
callq 0x41c0
movl $0x42, %edx
movq %r13, %rdi
leaq 0x34762(%rip), %rsi     # 0x3a5b5
callq 0x43a0
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq %r13, %rdi
callq 0x43a0
movq %rax, %rdi
callq 0x41a0
movl $0x4f, %edx
movq %r13, %rdi
leaq 0x346a0(%rip), %rsi     # 0x3a520
callq 0x43a0
movq %r13, %rdi
callq 0x41a0
incq 0xe0(%rsp)
jmp 0x62a0
leaq 0x90(%rsp), %rax
movq %rax, 0x80(%rsp)
leaq 0x80(%rsp), %rdi
leaq 0x347f1(%rip), %rsi     # 0x3a6aa
leaq 0x347eb(%rip), %rdx     # 0x3a6ab
callq 0x5384
movl %r15d, %eax
andl $0xc0, %eax
leaq 0x347d8(%rip), %rsi     # 0x3a6ac
cmpl $0x40, %eax
je 0x5ee7
leaq 0x347cf(%rip), %rsi     # 0x3a6af
cmpl $0x80, %eax
jne 0x5ef9
leaq 0x80(%rsp), %rdi
callq 0x4410
jmp 0x5f8b
leaq 0x80(%rsp), %rdi
leaq 0x347aa(%rip), %rsi     # 0x3a6b2
callq 0x4410
movl $0xb, %edx
movq %r13, %rdi
leaq 0x34799(%rip), %rsi     # 0x3a6b5
callq 0x43a0
movq %r13, %rdi
movl %r15d, %esi
callq 0x4580
movq %rax, %rdi
callq 0x41a0
movl $0x1b, %edx
movq %r13, %rdi
leaq 0x3477e(%rip), %rsi     # 0x3a6c1
callq 0x43a0
movl %r15d, %esi
andl $0x40, %esi
movq %r13, %rdi
callq 0x4580
movq %rax, %rdi
callq 0x41a0
movl $0x1b, %edx
movq %r13, %rdi
leaq 0x34770(%rip), %rsi     # 0x3a6dd
callq 0x43a0
movl %r15d, %esi
andl $0x80, %esi
movq %r13, %rdi
callq 0x4580
movq %rax, %rdi
callq 0x41a0
leaq 0x100(%rsp), %rax
movq %rax, 0xf0(%rsp)
leaq 0xf0(%rsp), %rdi
leaq 0x3474f(%rip), %rsi     # 0x3a6f9
leaq 0x3474b(%rip), %rdx     # 0x3a6fc
callq 0x5384
testb $0x10, %r15b
je 0x5fd0
leaq 0xf0(%rsp), %rdi
leaq 0x3472f(%rip), %rsi     # 0x3a6fa
callq 0x4410
movq 0x68(%rsp), %rax
movq 0x40(%rax), %rsi
movq 0x48(%rax), %rdx
leaq 0x368(%rsp), %rdi
callq 0x43a0
movq %rax, %r15
movl $0x1, %edx
movq %rax, %rdi
leaq 0x38b25(%rip), %rsi     # 0x3eb21
callq 0x43a0
movq 0x68(%rsp), %rax
movq 0x60(%rax), %rsi
movq 0x68(%rax), %rdx
movq %r15, %rdi
callq 0x43a0
movq %rax, %r15
movl $0x1, %edx
movq %rax, %rdi
leaq 0x38af9(%rip), %rsi     # 0x3eb21
callq 0x43a0
movq 0x68(%rsp), %rax
movq 0xa0(%rax), %rsi
movq 0xa8(%rax), %rdx
movq %r15, %rdi
callq 0x43a0
movq %rax, %r15
movl $0x1, %edx
movq %rax, %rdi
leaq 0x38ac7(%rip), %rsi     # 0x3eb21
callq 0x43a0
movq 0x28(%rsp), %rcx
addq $-0x7, %rcx
movl $0x5, %edx
leaq 0x1b0(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x4360
movq 0x1b0(%rsp), %rsi
movq 0x1b8(%rsp), %rdx
movq %r15, %rdi
callq 0x43a0
movq %rax, %r15
movl $0x1, %edx
movq %rax, %rdi
leaq 0x38a78(%rip), %rsi     # 0x3eb21
callq 0x43a0
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %rdx
movq %r15, %rdi
callq 0x43a0
movq %rax, %r15
movl $0x1, %edx
movq %rax, %rdi
leaq 0x38a4f(%rip), %rsi     # 0x3eb21
callq 0x43a0
movq 0x80(%rsp), %rsi
movq 0x88(%rsp), %rdx
movq %r15, %rdi
callq 0x43a0
movq %rax, %r15
movl $0x1, %edx
movq %rax, %rdi
leaq 0x344fa(%rip), %rsi     # 0x3a5fb
callq 0x43a0
movq 0x68(%rsp), %rax
movq 0x20(%rax), %rsi
movq 0x28(%rax), %rdx
movq %r15, %rdi
callq 0x43a0
movq %rax, %r15
movl $0x1, %edx
movq %rax, %rdi
leaq 0x389f4(%rip), %rsi     # 0x3eb21
callq 0x43a0
movq 0xf0(%rsp), %rsi
movq 0xf8(%rsp), %rdx
movq %r15, %rdi
callq 0x43a0
movq %rax, %r15
movl $0x1, %edx
movq %rax, %rdi
leaq 0x389c5(%rip), %rsi     # 0x3eb21
callq 0x43a0
movq 0x68(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
movq %r15, %rdi
callq 0x43a0
movq %rax, %r15
movl $0x1, %edx
movq %rax, %rdi
leaq 0x3899a(%rip), %rsi     # 0x3eb21
callq 0x43a0
movq 0x68(%rsp), %rax
movq 0xe0(%rax), %rsi
movq 0xe8(%rax), %rdx
movq %r15, %rdi
callq 0x43a0
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x4310
movsbl %al, %esi
movq %r15, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x4220
movq 0x1b0(%rsp), %rdi
leaq 0x1c0(%rsp), %rax
cmpq %rax, %rdi
je 0x61f6
movq 0x1c0(%rsp), %rsi
incq %rsi
callq 0x4340
movzbl %bpl, %ebp
testb $0x1, %bpl
movl $0x1, %eax
cmovel %eax, %ebp
movq $0x0, 0x8(%rsp)
movq (%rsp), %rax
movb $0x0, (%rax)
movq 0xf0(%rsp), %rdi
leaq 0x100(%rsp), %rax
cmpq %rax, %rdi
je 0x623b
movq 0x100(%rsp), %rsi
incq %rsi
callq 0x4340
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x6260
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x4340
incq 0xd0(%rsp)
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x6284
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x4340
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x62a0
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x4340
leaq 0x68(%rsp), %rdi
callq 0x6aa2
jmp 0x5778
leaq 0x1e0(%rsp), %rdi
callq 0x3962e
movq 0xa0(%rsp), %r14
movq 0xd8(%rsp), %r15
movq 0xc8(%rsp), %r12
movq 0xe8(%rsp), %r13
movq 0xe0(%rsp), %rbx
testq %rbx, %rbx
je 0x634e
movq 0x45cd8(%rip), %rdi     # 0x4bfc8
leaq 0x34406(%rip), %rsi     # 0x3a6fd
movl $0x16, %edx
callq 0x43a0
movq 0x45cc0(%rip), %rdi     # 0x4bfc8
movq %rbx, %rsi
callq 0x4210
movq %rax, %rbx
leaq 0x343fa(%rip), %rsi     # 0x3a714
movl $0x26, %edx
movq %rax, %rdi
callq 0x43a0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4310
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x4220
testq %r13, %r13
je 0x63b8
movq 0x45c6e(%rip), %rdi     # 0x4bfc8
leaq 0x3439c(%rip), %rsi     # 0x3a6fd
movl $0x16, %edx
callq 0x43a0
movq 0x45c56(%rip), %rdi     # 0x4bfc8
movq %r13, %rsi
callq 0x4210
movq %rax, %rbx
leaq 0x343b7(%rip), %rsi     # 0x3a73b
movl $0x31, %edx
movq %rax, %rdi
callq 0x43a0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4310
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x4220
testq %r12, %r12
je 0x6422
movq 0x45c04(%rip), %rdi     # 0x4bfc8
leaq 0x34332(%rip), %rsi     # 0x3a6fd
movl $0x16, %edx
callq 0x43a0
movq 0x45bec(%rip), %rdi     # 0x4bfc8
movq %r12, %rsi
callq 0x4210
movq %rax, %rbx
leaq 0x3437f(%rip), %rsi     # 0x3a76d
movl $0x26, %edx
movq %rax, %rdi
callq 0x43a0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4310
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x4220
testq %r15, %r15
je 0x64a0
movq 0x45b9a(%rip), %rdi     # 0x4bfc8
leaq 0x342c8(%rip), %rsi     # 0x3a6fd
movl $0x16, %edx
callq 0x43a0
movq 0x45b82(%rip), %rdi     # 0x4bfc8
movq %r15, %rsi
callq 0x4210
movq %rax, %rbx
leaq 0x3433c(%rip), %rsi     # 0x3a794
movl $0x33, %edx
movq %rax, %rdi
callq 0x43a0
leaq 0x3435c(%rip), %rsi     # 0x3a7c8
movl $0x21, %edx
movq %rbx, %rdi
callq 0x43a0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4310
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x4220
testq %r14, %r14
je 0x650a
movq 0x45b1c(%rip), %rdi     # 0x4bfc8
leaq 0x3424a(%rip), %rsi     # 0x3a6fd
movl $0x16, %edx
callq 0x43a0
movq 0x45b04(%rip), %rdi     # 0x4bfc8
movq %r14, %rsi
callq 0x4210
movq %rax, %rbx
leaq 0x34314(%rip), %rsi     # 0x3a7ea
movl $0x4e, %edx
movq %rax, %rdi
callq 0x43a0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4310
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x4220
movq 0x45ab7(%rip), %rdi     # 0x4bfc8
leaq 0x34321(%rip), %rsi     # 0x3a839
movl $0x12, %edx
callq 0x43a0
movq 0x45a9f(%rip), %rdi     # 0x4bfc8
movq 0x40(%rsp), %rsi
callq 0x4210
movq %rax, %rbx
leaq 0x3430f(%rip), %rsi     # 0x3a84c
movl $0x1b, %edx
movq %rax, %rdi
callq 0x43a0
movq %rbx, %rdi
movq 0xd0(%rsp), %rsi
callq 0x4210
movq %rax, %rbx
leaq 0x34304(%rip), %rsi     # 0x3a868
movl $0x1d, %edx
movq %rax, %rdi
callq 0x43a0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4310
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x4220
movq 0x45a29(%rip), %rdi     # 0x4bfc8
leaq 0x342e0(%rip), %rsi     # 0x3a886
movl $0x30, %edx
callq 0x43a0
callq 0x4200
subq 0x1d8(%rsp), %rax
cvtsi2ss %rax, %xmm0
divss 0x33dc2(%rip), %xmm0    # 0x3a38c
cvtss2sd %xmm0, %xmm0
movq 0x459f3(%rip), %rdi     # 0x4bfc8
callq 0x4510
movq %rax, %rbx
leaq 0x342d3(%rip), %rsi     # 0x3a8b7
movl $0xa, %edx
movq %rax, %rdi
callq 0x43a0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4310
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x4220
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
leaq 0xb8(%rsp), %rbx
leaq 0x140(%rsp), %r14
je 0x6643
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x4340
movq 0x110(%rsp), %rdi
leaq 0x120(%rsp), %rax
cmpq %rax, %rdi
je 0x6668
movq 0x120(%rsp), %rsi
incq %rsi
callq 0x4340
movq 0x150(%rsp), %rdi
leaq 0x160(%rsp), %rax
cmpq %rax, %rdi
je 0x668d
movq 0x160(%rsp), %rsi
incq %rsi
callq 0x4340
movq 0x170(%rsp), %rdi
leaq 0x180(%rsp), %rax
cmpq %rax, %rdi
je 0x66b2
movq 0x180(%rsp), %rsi
incq %rsi
callq 0x4340
movq 0x190(%rsp), %rdi
leaq 0x1a0(%rsp), %rax
cmpq %rax, %rdi
je 0x66d7
movq 0x1a0(%rsp), %rsi
incq %rsi
callq 0x4340
movq 0x130(%rsp), %rdi
cmpq %r14, %rdi
je 0x66f4
movq 0x140(%rsp), %rsi
incq %rsi
callq 0x4340
leaq 0x45325(%rip), %rsi     # 0x4ba20
leaq 0x1e0(%rsp), %rdi
callq 0x39330
leaq 0x370(%rsp), %rdi
callq 0x4140
movq 0xa8(%rsp), %rdi
cmpq %rbx, %rdi
je 0x6732
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x4340
andb $0x1, %bpl
movl %ebp, %eax
addq $0x478, %rsp            # imm = 0x478
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x6771
jmp 0x676a
jmp 0x675b
jmp 0x675b
jmp 0x6776
jmp 0x6776
jmp 0x682e
movq %rax, %rbx
jmp 0x67f0
jmp 0x6776
jmp 0x682e
movq %rax, %rbx
jmp 0x67cb
jmp 0x6776
movq %rax, %rbx
jmp 0x67a6
movq %rax, %rbx
jmp 0x680c
movq %rax, %rbx
movq 0x1b0(%rsp), %rdi
leaq 0x1c0(%rsp), %rax
cmpq %rax, %rdi
je 0x67a6
movq 0x1c0(%rsp), %rsi
incq %rsi
callq 0x4340
movq 0xf0(%rsp), %rdi
leaq 0x100(%rsp), %rax
cmpq %rax, %rdi
je 0x67cb
movq 0x100(%rsp), %rsi
incq %rsi
callq 0x4340
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x67f0
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x4340
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x680c
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x4340
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x6831
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x4340
jmp 0x6831
jmp 0x689e
jmp 0x689e
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x6aa2
jmp 0x68a1
movq %rax, %rbx
jmp 0x68e1
movq %rax, %rbx
jmp 0x6906
movq %rax, %rbx
jmp 0x692b
movq %rax, %rbx
jmp 0x6950
jmp 0x6894
movq %rax, %rbx
jmp 0x6996
movq %rax, %rbx
leaq 0x1f0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x69bb
movq 0x1f0(%rsp), %rsi
jmp 0x69b3
movq %rax, %rbx
jmp 0x69bb
movq %rax, %rbx
jmp 0x6975
jmp 0x689e
movq %rax, %rbx
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x68bc
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x4340
movq 0x110(%rsp), %rdi
leaq 0x120(%rsp), %rax
cmpq %rax, %rdi
je 0x68e1
movq 0x120(%rsp), %rsi
incq %rsi
callq 0x4340
movq 0x150(%rsp), %rdi
leaq 0x160(%rsp), %rax
cmpq %rax, %rdi
je 0x6906
movq 0x160(%rsp), %rsi
incq %rsi
callq 0x4340
movq 0x170(%rsp), %rdi
leaq 0x180(%rsp), %rax
cmpq %rax, %rdi
je 0x692b
movq 0x180(%rsp), %rsi
incq %rsi
callq 0x4340
movq 0x190(%rsp), %rdi
leaq 0x1a0(%rsp), %rax
cmpq %rax, %rdi
je 0x6950
movq 0x1a0(%rsp), %rsi
incq %rsi
callq 0x4340
movq 0x130(%rsp), %rdi
leaq 0x140(%rsp), %rax
cmpq %rax, %rdi
je 0x6975
movq 0x140(%rsp), %rsi
incq %rsi
callq 0x4340
leaq 0x450a4(%rip), %rsi     # 0x4ba20
leaq 0x1e0(%rsp), %rdi
callq 0x39330
leaq 0x370(%rsp), %rdi
callq 0x4140
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0x69bb
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x4340
movq %rbx, %rdi
callq 0x45a0
nop