// File: /workspace/github_cpp_makefile_star2_O2/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 0x4e57
movq 0x3819b(%rip), %rdi     # 0x3cfc8
leaq 0x2455c(%rip), %rsi     # 0x29390
callq 0x4330
leaq 0x24567(%rip), %rsi     # 0x293a7
movq %rax, %rdi
callq 0x4330
movq %rax, %rdi
callq 0x41c0
xorl %ebp, %ebp
jmp 0x5afe
movq %rsi, %rbx
callq 0x4220
movq %rax, %r14
movq 0x3815f(%rip), %rdi     # 0x3cfc8
leaq 0x24585(%rip), %rsi     # 0x293f5
callq 0x4330
movq %rax, %rdi
callq 0x41c0
movq 0x18(%rbx), %rsi
leaq 0x1e0(%rsp), %rdi
leaq 0x180(%rsp), %rdx
callq 0x4d3e
leaq 0x2458a(%rip), %rdx     # 0x29427
leaq 0x1c0(%rsp), %rdi
leaq 0x1e0(%rsp), %rsi
callq 0x5c38
leaq 0x1e0(%rsp), %rdi
callq 0x4638
leaq 0x1e0(%rsp), %rdi
callq 0x5c58
movq 0x1c0(%rsp), %rsi
leaq 0x1e0(%rsp), %rdi
pushq $0x10
popq %rdx
callq 0x27e38
movq 0x1e0(%rsp), %rax
movq -0x18(%rax), %rax
cmpl $0x0, 0x200(%rsp,%rax)
je 0x4f34
movq 0x380ef(%rip), %rdi     # 0x3cff0
leaq 0x24533(%rip), %rsi     # 0x2943b
callq 0x4330
leaq 0x1c0(%rsp), %rsi
movq %rax, %rdi
callq 0x42e0
movb $0x1, %bpl
leaq 0x2452a(%rip), %rsi     # 0x29451
movq %rax, %rdi
callq 0x4330
jmp 0x5ae4
leaq 0x368(%rsp), %rdi
leaq 0x24519(%rip), %rsi     # 0x2945c
callq 0x4330
movq %rax, %rdi
callq 0x41c0
leaq 0x28bc3(%rip), %rsi     # 0x2db1a
leaq 0x180(%rsp), %rdi
leaq 0x160(%rsp), %rdx
callq 0x4d3e
leaq 0x28ba7(%rip), %rsi     # 0x2db1a
leaq 0x160(%rsp), %rdi
leaq 0x140(%rsp), %rdx
callq 0x4d3e
leaq 0x28b8b(%rip), %rsi     # 0x2db1a
leaq 0x140(%rsp), %rdi
leaq 0x120(%rsp), %rdx
callq 0x4d3e
leaq 0x28b6f(%rip), %rsi     # 0x2db1a
leaq 0x120(%rsp), %rdi
leaq 0xe0(%rsp), %rdx
callq 0x4d3e
movq %r14, 0xd8(%rsp)
leaq 0x28b4b(%rip), %rsi     # 0x2db1a
leaq 0xe0(%rsp), %rdi
leaq 0x98(%rsp), %rdx
callq 0x4d3e
leaq 0xa8(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq $0x0, 0x8(%rsp)
movq 0x37fd0(%rip), %r13     # 0x3cfd8
leaq 0x98(%rsp), %r12
leaq 0x24494(%rip), %r15     # 0x294ab
leaq 0x24492(%rip), %rbx     # 0x294b0
leaq 0x2448d(%rip), %r14     # 0x294b2
movq $0x0, 0x58(%rsp)
movq $0x0, 0x68(%rsp)
movq $0x0, 0x70(%rsp)
movq $0x0, 0x50(%rsp)
movq $0x0, 0x60(%rsp)
movq $0x0, 0x28(%rsp)
xorl %ebp, %ebp
movq %r13, %rdi
movq %r12, %rsi
callq 0x4090
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x589d
movq %r12, %rdi
movq %r15, %rsi
callq 0x4110
testl %eax, %eax
je 0x589d
movq %r12, %rdi
movq %rbx, %rsi
callq 0x4110
testl %eax, %eax
je 0x589d
movq %r12, %rdi
movq %r14, %rsi
callq 0x4110
testl %eax, %eax
je 0x589d
cmpq $0x0, 0xa0(%rsp)
je 0x505d
movq 0x98(%rsp), %rax
cmpb $0x23, (%rax)
je 0x505d
movq 0x8(%rsp), %rax
incq %rax
movq %rax, 0x8(%rsp)
xorl %edx, %edx
movl $0x989680, %ecx         # imm = 0x989680
divq %rcx
testq %rdx, %rdx
jne 0x511e
movq 0x37eda(%rip), %rdi     # 0x3cfc8
leaq 0x243c2(%rip), %rsi     # 0x294b7
callq 0x4330
movq %rax, %rdi
movq 0x8(%rsp), %rsi
callq 0x4230
movq %rax, %rdi
leaq 0x243b0(%rip), %rsi     # 0x294c1
callq 0x4330
movq %rax, %rdi
callq 0x41c0
movb $0x9, 0x30(%rsp)
leaq 0x10(%rsp), %rdi
movq %r12, %rsi
leaq 0x30(%rsp), %rdx
callq 0x26120
movq 0x10(%rsp), %rdi
movl $0xa0, %eax
addq %rax, %rdi
leaq 0x24384(%rip), %rsi     # 0x294cd
callq 0x4110
testl %eax, %eax
je 0x51dd
movq 0x10(%rsp), %rdi
movl $0xc0, %eax
addq %rax, %rdi
leaq 0x26916(%rip), %rsi     # 0x2ba80
callq 0x4110
testl %eax, %eax
je 0x5243
cmpq $0x0, 0xe8(%rsp)
jne 0x51d3
leaq 0xe0(%rsp), %rdi
movq %r12, %rsi
callq 0x41e0
movq 0x37e2f(%rip), %rdi     # 0x3cfc8
leaq 0x243d0(%rip), %rsi     # 0x29570
callq 0x4330
movq %rax, %rdi
movq %r12, %rsi
callq 0x42e0
movq %rax, %rdi
callq 0x41c0
movq 0x37e09(%rip), %rdi     # 0x3cfc8
leaq 0x2435a(%rip), %rsi     # 0x29520
callq 0x4330
movq %rax, %rdi
callq 0x41c0
incq 0x28(%rsp)
jmp 0x588e
cmpq $0x0, 0x168(%rsp)
jne 0x5239
leaq 0x160(%rsp), %rdi
movq %r12, %rsi
callq 0x41e0
movq 0x37dc9(%rip), %rdi     # 0x3cfc8
leaq 0x242c9(%rip), %rsi     # 0x294cf
callq 0x4330
movq %rax, %rdi
movq %r12, %rsi
callq 0x42e0
movq %rax, %rdi
callq 0x41c0
movq 0x37da3(%rip), %rdi     # 0x3cfc8
leaq 0x242f4(%rip), %rsi     # 0x29520
callq 0x4330
movq %rax, %rdi
callq 0x41c0
incq 0x70(%rsp)
jmp 0x588e
leaq 0x40(%rsp), %rax
movq %rax, 0x30(%rsp)
andq $0x0, 0x38(%rsp)
movb $0x0, 0x40(%rsp)
movq 0x10(%rsp), %rdi
movl $0x100, %eax            # imm = 0x100
addq %rax, %rdi
leaq 0x24342(%rip), %rsi     # 0x295ae
xorl %edx, %edx
callq 0x4600
cmpq $-0x1, %rax
je 0x5298
movq 0x10(%rsp), %rsi
movl $0x100, %eax            # imm = 0x100
addq %rax, %rsi
leaq 0x78(%rsp), %rdi
pushq $0x1
popq %rdx
pushq $-0x1
popq %rcx
callq 0x4360
jmp 0x52b4
movq 0x10(%rsp), %rsi
movl $0x100, %eax            # imm = 0x100
addq %rax, %rsi
leaq 0x78(%rsp), %rdi
xorl %edx, %edx
pushq $-0x1
popq %rcx
callq 0x4360
leaq 0x30(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0x43c0
leaq 0x78(%rsp), %rdi
callq 0x4638
movq 0x30(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x4130
decq %rax
movq %rax, (%rsp)
cmpq $0x7d0, %rax            # imm = 0x7D0
jb 0x534b
cmpq $0x0, 0xe8(%rsp)
jne 0x5346
leaq 0xe0(%rsp), %rdi
movq %r12, %rsi
callq 0x41e0
movq 0x37cbc(%rip), %rdi     # 0x3cfc8
leaq 0x2425d(%rip), %rsi     # 0x29570
callq 0x4330
movq %rax, %rdi
movq %r12, %rsi
callq 0x42e0
movq %rax, %rdi
callq 0x41c0
movq 0x37c96(%rip), %rdi     # 0x3cfc8
leaq 0x241e7(%rip), %rsi     # 0x29520
callq 0x4330
movq %rax, %rdi
callq 0x41c0
incq 0x28(%rsp)
leaq 0x30(%rsp), %rdi
callq 0x4638
cmpq $0x7d0, (%rsp)          # imm = 0x7D0
jae 0x588e
movq %r12, %rdi
leaq 0x24243(%rip), %rsi     # 0x295b0
xorl %edx, %edx
callq 0x4600
cmpq $-0x1, %rax
je 0x5548
incq %rax
movq %r12, %rdi
leaq 0x2878e(%rip), %rsi     # 0x2db19
movq %rax, (%rsp)
movq %rax, %rdx
callq 0x4600
cmpq $-0x1, %rax
jne 0x53a5
movq 0xa0(%rsp), %rax
movq (%rsp), %rdx
subq %rdx, %rax
leaq 0x30(%rsp), %rdi
movq %r12, %rsi
movq %rax, %rcx
callq 0x4360
movq %r12, %rdi
leaq 0x24232(%rip), %rsi     # 0x295f8
xorl %edx, %edx
callq 0x4600
movq %rax, (%rsp)
cmpq $-0x1, %rax
jne 0x5438
cmpq $0x0, 0x148(%rsp)
jne 0x5433
leaq 0x140(%rsp), %rdi
movq %r12, %rsi
callq 0x41e0
movq 0x37bcf(%rip), %rdi     # 0x3cfc8
leaq 0x241fd(%rip), %rsi     # 0x295fd
callq 0x4330
movq %rax, %rdi
movq %r12, %rsi
callq 0x42e0
movq %rax, %rdi
callq 0x41c0
movq 0x37ba9(%rip), %rdi     # 0x3cfc8
leaq 0x240fa(%rip), %rsi     # 0x29520
callq 0x4330
movq %rax, %rdi
callq 0x41c0
incq 0x50(%rsp)
leaq 0x78(%rsp), %rdi
leaq 0x241fc(%rip), %rsi     # 0x29640
leaq 0xb8(%rsp), %rdx
callq 0x4d3e
movq (%rsp), %rax
cmpq $-0x1, %rax
je 0x54bd
leaq 0x1(%rax), %rdx
movq %r12, %rdi
leaq 0x286b0(%rip), %rsi     # 0x2db19
callq 0x4600
cmpq $-0x1, %rax
jne 0x547c
movq 0xa0(%rsp), %rax
movq (%rsp), %rdx
subq %rdx, %rax
addq $0x6, %rdx
addq $-0x6, %rax
leaq 0xb8(%rsp), %rdi
movq %r12, %rsi
movq %rax, %rcx
callq 0x4360
leaq 0x78(%rsp), %rdi
leaq 0xb8(%rsp), %rsi
callq 0x43c0
leaq 0xb8(%rsp), %rdi
callq 0x4638
movq 0x10(%rsp), %rax
movq 0x20(%rax), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x4410
movq %rax, (%rsp)
cmpl $0x100, %eax            # imm = 0x100
jl 0x55ae
incq 0x60(%rsp)
cmpq $0x0, 0x128(%rsp)
jne 0x587a
leaq 0x120(%rsp), %rdi
movq %r12, %rsi
callq 0x41e0
movq 0x37abf(%rip), %rdi     # 0x3cfc8
leaq 0x24133(%rip), %rsi     # 0x29643
callq 0x4330
movq %rax, %rdi
movq %r12, %rsi
callq 0x42e0
movq %rax, %rdi
callq 0x41c0
movq 0x37a99(%rip), %rdi     # 0x3cfc8
leaq 0x23fea(%rip), %rsi     # 0x29520
callq 0x4330
movq %rax, %rdi
callq 0x41c0
jmp 0x587a
cmpq $0x0, 0x188(%rsp)
jne 0x55a4
leaq 0x180(%rsp), %rdi
movq %r12, %rsi
callq 0x41e0
movq 0x37a5e(%rip), %rdi     # 0x3cfc8
leaq 0x24044(%rip), %rsi     # 0x295b5
callq 0x4330
movq %rax, %rdi
movq %r12, %rsi
callq 0x42e0
movq %rax, %rdi
callq 0x41c0
movq 0x37a38(%rip), %rdi     # 0x3cfc8
leaq 0x23f89(%rip), %rsi     # 0x29520
callq 0x4330
movq %rax, %rdi
callq 0x41c0
incq 0x68(%rsp)
jmp 0x588e
leaq 0xb8(%rsp), %rdi
leaq 0x240ed(%rip), %rsi     # 0x296aa
leaq 0x100(%rsp), %rdx
callq 0x4d3e
movq (%rsp), %rax
andb $-0x40, %al
negb %al
leaq 0x240d6(%rip), %rsi     # 0x296af
jo 0x55f0
movq (%rsp), %rax
andl $0xc0, %eax
cmpl $0x40, %eax
jne 0x5602
leaq 0x240bc(%rip), %rsi     # 0x296ac
leaq 0xb8(%rsp), %rdi
callq 0x45e0
jmp 0x5698
leaq 0xb8(%rsp), %rdi
leaq 0x240a1(%rip), %rsi     # 0x296b2
callq 0x45e0
movq 0x379ab(%rip), %rdi     # 0x3cfc8
leaq 0x24091(%rip), %rsi     # 0x296b5
callq 0x4330
movq %rax, %rdi
movq (%rsp), %rsi
callq 0x4580
movq %rax, %rdi
callq 0x41c0
movq 0x37984(%rip), %rdi     # 0x3cfc8
leaq 0x24076(%rip), %rsi     # 0x296c1
callq 0x4330
movq (%rsp), %rcx
movl %ecx, %esi
andl $0x40, %esi
movq %rax, %rdi
callq 0x4580
movq %rax, %rdi
callq 0x41c0
movq 0x37958(%rip), %rdi     # 0x3cfc8
leaq 0x24066(%rip), %rsi     # 0x296dd
callq 0x4330
movq (%rsp), %rcx
movl %ecx, %esi
andl $0x80, %esi
movq %rax, %rdi
callq 0x4580
movq %rax, %rdi
callq 0x41c0
leaq 0x100(%rsp), %rdi
leaq 0x24052(%rip), %rsi     # 0x296f9
leaq 0x1a0(%rsp), %rdx
callq 0x4d3e
testb $0x10, (%rsp)
je 0x56ce
leaq 0x100(%rsp), %rdi
leaq 0x24031(%rip), %rsi     # 0x296fa
callq 0x45e0
movq 0x10(%rsp), %rsi
addq $0x40, %rsi
leaq 0x368(%rsp), %rdi
callq 0x42e0
movq %rax, %rdi
leaq 0x2842b(%rip), %rsi     # 0x2db19
callq 0x4330
movq 0x10(%rsp), %rsi
addq $0x60, %rsi
movq %rax, %rdi
callq 0x42e0
movq %rax, %rdi
leaq 0x2840b(%rip), %rsi     # 0x2db19
callq 0x4330
movq 0x10(%rsp), %rsi
movl $0xa0, %ecx
addq %rcx, %rsi
movq %rax, %rdi
callq 0x42e0
movq %rax, %rdi
leaq 0x283e7(%rip), %rsi     # 0x2db19
callq 0x4330
movq %rax, (%rsp)
movq 0x38(%rsp), %rcx
addq $-0x7, %rcx
leaq 0x1a0(%rsp), %rdi
leaq 0x30(%rsp), %rsi
pushq $0x5
popq %rdx
callq 0x4360
movq (%rsp), %rdi
leaq 0x1a0(%rsp), %rsi
callq 0x42e0
movq %rax, %rdi
leaq 0x283a5(%rip), %rsi     # 0x2db19
callq 0x4330
movq %rax, %rdi
leaq 0x78(%rsp), %rsi
callq 0x42e0
movq %rax, %rdi
leaq 0x28389(%rip), %rsi     # 0x2db19
callq 0x4330
movq %rax, %rdi
leaq 0xb8(%rsp), %rsi
callq 0x42e0
movq %rax, %rdi
leaq 0x23e4c(%rip), %rsi     # 0x295fb
callq 0x4330
movq 0x10(%rsp), %rsi
addq $0x20, %rsi
movq %rax, %rdi
callq 0x42e0
movq %rax, %rdi
leaq 0x2834a(%rip), %rsi     # 0x2db19
callq 0x4330
movq %rax, %rdi
leaq 0x100(%rsp), %rsi
callq 0x42e0
movq %rax, %rdi
leaq 0x2832b(%rip), %rsi     # 0x2db19
callq 0x4330
movq 0x10(%rsp), %rsi
movq %rax, %rdi
callq 0x42e0
movq %rax, %rdi
leaq 0x2830f(%rip), %rsi     # 0x2db19
callq 0x4330
movq 0x10(%rsp), %rsi
movl $0xe0, %ecx
addq %rcx, %rsi
movq %rax, %rdi
callq 0x42e0
movq %rax, %rdi
callq 0x41c0
leaq 0x1a0(%rsp), %rdi
callq 0x4638
incq 0x58(%rsp)
movzbl %bpl, %ebp
testb $0x1, %bpl
pushq $0x1
popq %rax
cmovel %eax, %ebp
andq $0x0, 0xa0(%rsp)
movq 0x98(%rsp), %rax
movb $0x0, (%rax)
leaq 0x100(%rsp), %rdi
callq 0x4638
leaq 0xb8(%rsp), %rdi
callq 0x4638
leaq 0x78(%rsp), %rdi
callq 0x4638
leaq 0x30(%rsp), %rdi
callq 0x4638
leaq 0x10(%rsp), %rdi
callq 0x5d02
jmp 0x505d
leaq 0x1e0(%rsp), %rdi
callq 0x280e0
movq 0x28(%rsp), %rbx
movq 0x60(%rsp), %r14
movq 0x50(%rsp), %r15
movq 0x70(%rsp), %r12
movq 0x68(%rsp), %r13
testq %r13, %r13
je 0x58fd
movq 0x376f9(%rip), %rdi     # 0x3cfc8
leaq 0x23e27(%rip), %rsi     # 0x296fd
callq 0x4330
movq %rax, %rdi
movq %r13, %rsi
callq 0x4230
leaq 0x23e27(%rip), %rsi     # 0x29714
movq %rax, %rdi
callq 0x4330
movq %rax, %rdi
callq 0x41c0
testq %r12, %r12
je 0x5937
movq 0x376bf(%rip), %rdi     # 0x3cfc8
leaq 0x23ded(%rip), %rsi     # 0x296fd
callq 0x4330
movq %rax, %rdi
movq %r12, %rsi
callq 0x4230
leaq 0x23e14(%rip), %rsi     # 0x2973b
movq %rax, %rdi
callq 0x4330
movq %rax, %rdi
callq 0x41c0
testq %r15, %r15
je 0x5971
movq 0x37685(%rip), %rdi     # 0x3cfc8
leaq 0x23db3(%rip), %rsi     # 0x296fd
callq 0x4330
movq %rax, %rdi
movq %r15, %rsi
callq 0x4230
leaq 0x23e0c(%rip), %rsi     # 0x2976d
movq %rax, %rdi
callq 0x4330
movq %rax, %rdi
callq 0x41c0
testq %r14, %r14
je 0x59ba
movq 0x3764b(%rip), %rdi     # 0x3cfc8
leaq 0x23d79(%rip), %rsi     # 0x296fd
callq 0x4330
movq %rax, %rdi
movq %r14, %rsi
callq 0x4230
leaq 0x23df9(%rip), %rsi     # 0x29794
movq %rax, %rdi
callq 0x4330
leaq 0x23e1e(%rip), %rsi     # 0x297c8
movq %rax, %rdi
callq 0x4330
movq %rax, %rdi
callq 0x41c0
testq %rbx, %rbx
je 0x59f4
movq 0x37602(%rip), %rdi     # 0x3cfc8
leaq 0x23d30(%rip), %rsi     # 0x296fd
callq 0x4330
movq %rax, %rdi
movq %rbx, %rsi
callq 0x4230
leaq 0x23e06(%rip), %rsi     # 0x297ea
movq %rax, %rdi
callq 0x4330
movq %rax, %rdi
callq 0x41c0
movq 0x375cd(%rip), %rdi     # 0x3cfc8
leaq 0x23e37(%rip), %rsi     # 0x29839
callq 0x4330
movq %rax, %rdi
movq 0x8(%rsp), %rsi
callq 0x4230
leaq 0x23e31(%rip), %rsi     # 0x2984c
movq %rax, %rdi
callq 0x4330
movq %rax, %rdi
movq 0x58(%rsp), %rsi
callq 0x4230
leaq 0x23e31(%rip), %rsi     # 0x29868
movq %rax, %rdi
callq 0x4330
movq %rax, %rdi
callq 0x41c0
movq 0x3757a(%rip), %rdi     # 0x3cfc8
leaq 0x23e31(%rip), %rsi     # 0x29886
callq 0x4330
movq %rax, %rbx
callq 0x4220
subq 0xd8(%rsp), %rax
cvtsi2ss %rax, %xmm0
divss 0x23915(%rip), %xmm0    # 0x2938c
movq %rbx, %rdi
callq 0x4270
leaq 0x23e31(%rip), %rsi     # 0x298b7
movq %rax, %rdi
callq 0x4330
movq %rax, %rdi
callq 0x41c0
leaq 0x98(%rsp), %rdi
callq 0x4638
leaq 0xe0(%rsp), %rdi
callq 0x4638
leaq 0x120(%rsp), %rdi
callq 0x4638
leaq 0x140(%rsp), %rdi
callq 0x4638
leaq 0x160(%rsp), %rdi
callq 0x4638
leaq 0x180(%rsp), %rdi
callq 0x4638
leaq 0x1e0(%rsp), %rdi
callq 0x5d24
leaq 0x1c0(%rsp), %rdi
callq 0x4638
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 0x5b34
jmp 0x5b2d
jmp 0x5b24
jmp 0x5b24
jmp 0x5b39
jmp 0x5b39
jmp 0x5b82
movq %rax, %rbx
jmp 0x5b68
jmp 0x5b39
jmp 0x5b82
movq %rax, %rbx
jmp 0x5b5b
jmp 0x5b39
movq %rax, %rbx
jmp 0x5b4e
movq %rax, %rbx
jmp 0x5b72
movq %rax, %rbx
leaq 0x1a0(%rsp), %rdi
callq 0x4638
leaq 0x100(%rsp), %rdi
callq 0x4638
leaq 0xb8(%rsp), %rdi
callq 0x4638
leaq 0x78(%rsp), %rdi
callq 0x4638
leaq 0x30(%rsp), %rdi
callq 0x4638
jmp 0x5b85
jmp 0x5bc5
jmp 0x5bc5
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x5d02
jmp 0x5bc8
movq %rax, %rbx
jmp 0x5be2
movq %rax, %rbx
jmp 0x5bef
movq %rax, %rbx
jmp 0x5bfc
movq %rax, %rbx
jmp 0x5c09
jmp 0x5bc0
movq %rax, %rbx
jmp 0x5c23
movq %rax, %rbx
leaq 0x1e0(%rsp), %rdi
jmp 0x5c2b
movq %rax, %rbx
jmp 0x5c30
jmp 0x5bc5
movq %rax, %rbx
jmp 0x5c16
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0x4638
leaq 0xe0(%rsp), %rdi
callq 0x4638
leaq 0x120(%rsp), %rdi
callq 0x4638
leaq 0x140(%rsp), %rdi
callq 0x4638
leaq 0x160(%rsp), %rdi
callq 0x4638
leaq 0x180(%rsp), %rdi
callq 0x4638
leaq 0x1e0(%rsp), %rdi
callq 0x5d24
leaq 0x1c0(%rsp), %rdi
callq 0x4638
movq %rbx, %rdi
callq 0x45a0