// File: /workspace/github_cpp_makefile_star2_O1/MiWitt[P]HLAbaits/main.cpp
// Function: main
int main(int argc, char** argv) {

    try
    {
        // Achtung Anpassung auch weiter unten: if(argc==7) und ifstream inProbes(argv[6]);
        if(argc != 6 && argc != 7)
        {
            cout << "run like: " << basename(argv[0]) << " probe_length mis_matches tiling_step ref_seq_fasta scratch [existing_probes_fasta]" << endl;
            cout << "probe_length: define the length of the probes here probes (recommended 120)"  
                 << "mis_matches: for each new fasta sequence all existing probes are aligned to it using blat. Define the number of allowed mismatches here (recommended 5)"  
                 << "tiling_step: for nun overlapping probes set tiling step = probe_length. Set it to probe_length/2 for half overlapping (recommended 60)"  
                 << "ref_seq_fasta: Provide your collection of fasta sequences here. Set the path to a multiple fasta file "  
                 << "scratch: Set the path to a scratch directory where " << basename(argv[0]) << " has read write access "   
                 << "[existing_probes_fasta]: Provide a file of already existing probes here. Be aware of the important note below"  
                 << "All output goes to stdout, so redirect the output to your destination file. (e.g. > /foo/bar/my_baits.fa)" << endl;
            cout << "IMPORTANT: if you provide an existing probes (baits) file, provide it in following format. First line unique probe name, second line probe sequence, third line unique probe name, etc. NO BLANK LINES, NO REDUNDANT PROBE NAMES." << endl;
            exit(EXIT_FAILURE);
        }
        PROBE_SIZE = atoi(argv[1]);
        MISMATCH = atoi(argv[2]);
        TILING_STEP_SIZE = atoi(argv[3]);
        SCRATCH_DIR = string(argv[5])+"/";

        string scratch_template = SCRATCH_DIR+"template_seq.fasta";
        string scratch_baits = SCRATCH_DIR+"template_baits.fasta";
        string scratch_psl = SCRATCH_DIR+"output.psl";
        string ref_seq_fasta = argv[4];

        string strLine;
        string strLine2;

        map<string,string> new_baits;
        map<string,string> newer_baits;
        string ID = "5884b7a6-2879-4e85-841b-9284beb34974";
        vector<string>  sequences;

        if(argc==7)
        {
            ifstream inProbes(argv[6]);
            while(getline(inProbes,strLine) && getline(inProbes,strLine2))
            {
                new_baits[strLine]=strLine2;
            }
            inProbes.close();
        }
        
        
        CMultiFasta mfa(ref_seq_fasta.c_str());
        for(CMultiFasta::iterator iMfa = mfa.begin(); iMfa != mfa.end(); iMfa++)
        {
            strLine = iMfa->first;
            strLine2 = iMfa->second;
            
            vector<string> tok = Tokenize(strLine," ");
            if(tok[0] != ID)
            {
                string tiling_seq="";
                for(int i = 0; i < sequences.size(); i++)
                {
                    if(sequences[i].size() > MAX_EXON_SIZE)
                        sequences[i].erase(INCLUDE_INTRON_FLANKS,sequences[i].size()-(2*INCLUDE_INTRON_FLANKS));
                    tiling_seq+=sequences[i];
                }
                ofstream out(scratch_template.c_str());
                out << ID << endl;
                out << tiling_seq << endl;
                out.close();

                out.open(scratch_baits.c_str());
                for(map<string,string>::iterator iter = new_baits.begin();iter != new_baits.end();iter++)
                {
                    out << iter->first << endl << iter->second << endl;
                }
                out.close();

                sequences.clear();
                sequences.push_back(strLine2);

                ostringstream osr("");
                osr << "blat  -minScore=" << PROBE_SIZE-MISMATCH 
                    <<  " -repMatch=64000 -fine -fastMap " << scratch_template
                    << " " << scratch_baits << " " << scratch_psl;
                //cout << osr.str() << endl;
                cmd_exec(osr.str());
                // blat -minScore=77 -repMatch=64000 -fine -fastMap HLA_v3.12_block_wise.fasta std_referenz_baits.txt stdout

                vector<pair<int,int> > mapping_res = parseResults(scratch_psl);
                string matches(tiling_seq.size(),'0');
                for(int i = 0; i < mapping_res.size();i++)
                    for(int j = mapping_res[i].first; j < mapping_res[i].second;j++)
                        matches[j]='1';

                vector<pair<int,int> > unmapped = getUnmappedRegions(matches);

                for(int i = 0; i < unmapped.size();i++ )
                {
                    if(tiling_seq.size() < PROBE_SIZE)
                        continue;
                    map<string,string> add_baits = tile(ID,tiling_seq,unmapped[i].first,unmapped[i].second,TILING_STEP_SIZE);
                    new_baits.insert(add_baits.begin(),add_baits.end());
                    if(argc==6)
                        newer_baits.insert(add_baits.begin(),add_baits.end());
                }

                ID=tok[0];

                //for(int i = 0; i < unmapped.size();i++ )
                //    cout << ID << " " << unmapped[i].first << " - " << unmapped[i].second << endl;
                cerr << new_baits.size() << " baits after " << ID << endl;
            }
            else
                sequences.push_back(strLine2);
        }
        


        if(argc==6)
            for(map<string,string>::iterator iter = newer_baits.begin(); iter != newer_baits.end(); iter++)
                cout << iter->first << endl << iter->second << endl;
        else
            for(map<string,string>::iterator iter = new_baits.begin(); iter != new_baits.end(); iter++)
                cout << iter->first << endl << iter->second << endl;
    
        return (EXIT_SUCCESS);
    }
    catch(CMyException e)
    {
        cerr << "An error occured: " << e.what() << endl;
    }
    catch(exception e)
    {
        cerr << "An error occured: " << e.what() << endl;
    }
    catch(...)
    {
        cerr << "An undefined error occured ..." << endl;
    }
    return  EXIT_FAILURE;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x648, %rsp            # imm = 0x648
movq %rsi, %rbx
movq %rdi, 0x38(%rsp)
leal -0x8(%rdi), %eax
cmpl $-0x3, %eax
jbe 0x52c7
movq 0x8(%rbx), %rdi
callq 0x33a0
movl %eax, 0x6dd3(%rip)      # 0xb250
movq 0x10(%rbx), %rdi
callq 0x33a0
movl %eax, 0x6dc8(%rip)      # 0xb254
movq 0x18(%rbx), %rdi
callq 0x33a0
movl %eax, 0x6dbd(%rip)      # 0xb258
movq 0x28(%rbx), %rsi
leaq 0x4d0(%rsp), %rdi
leaq 0x290(%rsp), %rdx
callq 0x5a2e
leaq 0x3fd3(%rip), %rsi      # 0x848e
leaq 0x4d0(%rsp), %rdi
callq 0x3450
leaq 0x2d8(%rsp), %r13
movq %r13, -0x10(%r13)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x44f8
movq %rdx, 0x2c8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x2d8(%rsp)
jmp 0x4500
movups (%rcx), %xmm0
movups %xmm0, (%r13)
movq 0x8(%rax), %rdx
leaq 0x2c8(%rsp), %r14
movq %rdx, 0x8(%r14)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x6d72(%rip), %rdi      # 0xb298
movq %r14, %rsi
callq 0x32c0
movq (%r14), %rdi
cmpq %r13, %rdi
je 0x4546
movq 0x2d8(%rsp), %rsi
incq %rsi
callq 0x3240
leaq 0x4e0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4567
movq 0x4e0(%rsp), %rsi
incq %rsi
callq 0x3240
leaq 0xb0(%rsp), %rax
movq %rax, -0x10(%rax)
movq 0x6d1e(%rip), %rsi      # 0xb298
movq 0x6d1f(%rip), %rdx      # 0xb2a0
addq %rsi, %rdx
leaq 0xa0(%rsp), %rdi
callq 0x5c9a
leaq 0x3ef8(%rip), %rsi      # 0x8490
leaq 0xa0(%rsp), %rdi
callq 0x3450
leaq 0x90(%rsp), %rax
movq %rax, -0x10(%rax)
movq 0x6ce0(%rip), %rsi      # 0xb298
movq 0x6ce1(%rip), %rdx      # 0xb2a0
addq %rsi, %rdx
leaq 0x80(%rsp), %rdi
callq 0x5c9a
leaq 0x3ecd(%rip), %rsi      # 0x84a3
leaq 0x80(%rsp), %rdi
callq 0x3450
leaq 0x70(%rsp), %rax
movq %rax, -0x10(%rax)
movq 0x6ca5(%rip), %rsi      # 0xb298
movq 0x6ca6(%rip), %rdx      # 0xb2a0
addq %rsi, %rdx
leaq 0x60(%rsp), %rdi
callq 0x5c9a
leaq 0x3eaa(%rip), %rsi      # 0x84b8
leaq 0x60(%rsp), %rdi
callq 0x3450
movq 0x20(%rbx), %rsi
leaq 0x220(%rsp), %rdi
leaq 0x2c8(%rsp), %rdx
callq 0x5a2e
leaq 0x190(%rsp), %rcx
movq %rcx, -0x10(%rcx)
xorl %eax, %eax
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq 0x150(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq 0x1e0(%rsp), %rcx
movl %eax, (%rcx)
movq %rax, 0x8(%rcx)
movq %rcx, 0x10(%rcx)
movq %rcx, 0x18(%rcx)
movq %rax, 0x20(%rcx)
leaq 0x268(%rsp), %rcx
movl %eax, (%rcx)
movq %rax, 0x8(%rcx)
movq %rcx, 0x10(%rcx)
movq %rcx, 0x18(%rcx)
movq %rax, 0x20(%rcx)
leaq 0x28(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x3e28(%rip), %rsi      # 0x84c3
leaq 0x3e45(%rip), %rdx      # 0x84e7
leaq 0x18(%rsp), %rdi
callq 0x5d2a
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
cmpl $0x7, 0x38(%rsp)
jne 0x4797
movq 0x30(%rbx), %rsi
leaq 0x2c8(%rsp), %rbx
movq %rbx, %rdi
movl $0x8, %edx
callq 0x3430
leaq 0x180(%rsp), %r14
leaq 0x140(%rsp), %r15
leaq 0x1d8(%rsp), %r12
movq 0x2c8(%rsp), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3210
movsbl %al, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3440
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x477d
movq 0x2c8(%rsp), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3210
movsbl %al, %edx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x3440
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x477d
movq %r12, %rdi
movq %r14, %rsi
callq 0x5b4e
movq %rax, %rdi
movq %r15, %rsi
callq 0x3170
jmp 0x46f8
leaq 0x2c8(%rsp), %rdi
callq 0x3070
leaq 0x2c8(%rsp), %rdi
callq 0x3090
movq 0x220(%rsp), %rsi
leaq 0x2c8(%rsp), %rdi
leaq 0x4d0(%rsp), %rdx
callq 0x5a2e
leaq 0x290(%rsp), %rdi
leaq 0x2c8(%rsp), %rsi
callq 0x69f8
movq 0x2c8(%rsp), %rdi
cmpq %r13, %rdi
je 0x47e6
movq 0x2d8(%rsp), %rsi
incq %rsi
callq 0x3240
leaq 0x2a0(%rsp), %rax
movq 0x10(%rax), %r14
cmpq %rax, %r14
je 0x502f
movq 0x67b6(%rip), %rax      # 0xafb8
movq (%rax), %rcx
movq %rcx, 0x1c8(%rsp)
movq 0x18(%rax), %rax
movq %rax, 0x1c0(%rsp)
leaq 0x2c8(%rsp), %r13
leaq 0x40(%rsp), %r15
leaq 0xd8(%rsp), %rbp
leaq 0x20(%r14), %rsi
leaq 0x180(%rsp), %rdi
callq 0x3170
leaq 0x40(%r14), %rsi
leaq 0x140(%rsp), %rdi
callq 0x3170
leaq 0x2d8(%rsp), %rax
movq %rax, 0x2c8(%rsp)
movq %r13, %rdi
leaq 0x3cee(%rip), %rsi      # 0x8558
leaq 0x3ce8(%rip), %rdx      # 0x8559
callq 0x5d2a
leaq 0x208(%rsp), %rdi
leaq 0x180(%rsp), %rsi
movq %r13, %rdx
callq 0x360c
movq 0x2c8(%rsp), %rdi
leaq 0x2d8(%rsp), %rax
cmpq %rax, %rdi
je 0x48b3
movq 0x2d8(%rsp), %rsi
incq %rsi
callq 0x3240
movq 0x208(%rsp), %rax
movq 0x8(%rax), %rdx
cmpq 0x20(%rsp), %rdx
jne 0x48e4
testq %rdx, %rdx
je 0x4ff6
movq 0x18(%rsp), %rsi
movq (%rax), %rdi
callq 0x3250
testl %eax, %eax
je 0x4ff6
movq %r14, 0x1d0(%rsp)
leaq 0x50(%rsp), %rax
movq %rax, 0x40(%rsp)
movq %r15, %rdi
leaq 0x3726(%rip), %rdx      # 0x8026
movq %rdx, %rsi
callq 0x5d2a
movq (%rsp), %rdi
cmpq %rdi, 0x8(%rsp)
je 0x496b
xorl %ebx, %ebx
xorl %r14d, %r14d
movq 0x8(%rdi,%rbx), %rdx
cmpq $0x7a3ab, %rdx          # imm = 0x7A3AB
jb 0x493a
addq %rbx, %rdi
addq $-0x12c, %rdx           # imm = 0xFED4
movl $0x96, %esi
callq 0x3080
movq (%rsp), %rax
movq (%rax,%rbx), %rsi
movq 0x8(%rax,%rbx), %rdx
movq %r15, %rdi
callq 0x30e0
incq %r14
movq (%rsp), %rdi
movq 0x8(%rsp), %rax
subq %rdi, %rax
sarq $0x5, %rax
addq $0x20, %rbx
cmpq %r14, %rax
ja 0x4918
movq 0xa0(%rsp), %rsi
movq %r13, %rdi
movl $0x10, %edx
callq 0x3280
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rdx
movq %r13, %rdi
callq 0x3290
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x3210
movsbl %al, %esi
movq %r14, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3190
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
movq %r13, %rdi
callq 0x3290
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x3210
movsbl %al, %esi
movq %r14, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3190
movq %r13, %rdi
callq 0x3310
movq 0x80(%rsp), %rsi
movq %r13, %rdi
movl $0x10, %edx
callq 0x3050
movq 0x1f0(%rsp), %r14
leaq 0x1e0(%rsp), %rax
cmpq %rax, %r14
je 0x4ab2
movq 0x20(%r14), %rsi
movq 0x28(%r14), %rdx
movq %r13, %rdi
callq 0x3290
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3210
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3190
movq 0x40(%r14), %rsi
movq 0x48(%r14), %rdx
movq %rax, %rdi
callq 0x3290
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3210
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3190
movq %r14, %rdi
callq 0x31a0
movq %rax, %r14
jmp 0x4a1d
movq %r13, %rdi
callq 0x3310
movq (%rsp), %rbx
movq 0x8(%rsp), %r14
cmpq %rbx, %r14
je 0x4af8
leaq 0x10(%rbx), %r12
movq -0x10(%r12), %rdi
cmpq %rdi, %r12
je 0x4ae2
movq (%r12), %rsi
incq %rsi
callq 0x3240
leaq 0x20(%r12), %rax
addq $0x10, %r12
cmpq %r14, %r12
movq %rax, %r12
jne 0x4acc
movq %rbx, 0x8(%rsp)
movq %rsp, %rdi
leaq 0x140(%rsp), %rsi
callq 0x5bca
leaq 0xe8(%rsp), %rax
movq %rax, 0xd8(%rsp)
movq %rbp, %rdi
leaq 0x3504(%rip), %rdx      # 0x8026
movq %rdx, %rsi
callq 0x5d2a
leaq 0x4d0(%rsp), %rdi
movq %rbp, %rsi
movl $0x10, %edx
callq 0x32f0
movq 0x1d0(%rsp), %r14
movq 0xd8(%rsp), %rdi
leaq 0xe8(%rsp), %rax
cmpq %rax, %rdi
je 0x4b6c
movq 0xe8(%rsp), %rsi
incq %rsi
callq 0x3240
movl $0x10, %edx
leaq 0x4d0(%rsp), %rdi
leaq 0x3968(%rip), %rsi      # 0x84e8
callq 0x3290
movl 0x66c5(%rip), %esi      # 0xb250
subl 0x66c3(%rip), %esi      # 0xb254
leaq 0x4d0(%rsp), %rdi
callq 0x3400
movq %rax, %rbx
movl $0x20, %edx
movq %rax, %rdi
leaq 0x3949(%rip), %rsi      # 0x84f9
callq 0x3290
movq 0xa0(%rsp), %rsi
movq 0xa8(%rsp), %rdx
movq %rbx, %rdi
callq 0x3290
movq %rax, %rbx
movl $0x1, %edx
movq %rax, %rdi
leaq 0x3979(%rip), %rsi      # 0x8558
callq 0x3290
movq 0x80(%rsp), %rsi
movq 0x88(%rsp), %rdx
movq %rbx, %rdi
callq 0x3290
movq %rax, %rbx
movl $0x1, %edx
movq %rax, %rdi
leaq 0x394a(%rip), %rsi      # 0x8558
callq 0x3290
movq 0x60(%rsp), %rsi
movq 0x68(%rsp), %rdx
movq %rbx, %rdi
callq 0x3290
movq %rbp, %rdi
leaq 0x4d8(%rsp), %rsi
callq 0x33c0
leaq 0x240(%rsp), %rdi
movq %rbp, %rsi
callq 0x374a
movq 0x240(%rsp), %rdi
leaq 0x250(%rsp), %rax
cmpq %rax, %rdi
je 0x4c6a
movq 0x250(%rsp), %rsi
incq %rsi
callq 0x3240
movq 0xd8(%rsp), %rdi
leaq 0xe8(%rsp), %rax
cmpq %rax, %rdi
je 0x4c8f
movq 0xe8(%rsp), %rsi
incq %rsi
callq 0x3240
leaq 0xc0(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x38c4
movq 0x48(%rsp), %rsi
leaq 0x130(%rsp), %rax
movq %rax, 0x120(%rsp)
leaq 0x120(%rsp), %rdi
movl $0x30, %edx
callq 0x32a0
movq 0xc0(%rsp), %rcx
cmpq %rcx, 0xc8(%rsp)
je 0x4d2e
xorl %eax, %eax
movslq (%rcx,%rax,8), %rcx
movq 0xc0(%rsp), %rdx
cmpl 0x4(%rdx,%rax,8), %ecx
jge 0x4d0f
movq 0x120(%rsp), %rdx
movb $0x31, (%rdx,%rcx)
incq %rcx
movq 0xc0(%rsp), %rdx
movslq 0x4(%rdx,%rax,8), %rdx
cmpq %rdx, %rcx
jl 0x4cee
incq %rax
movq 0xc0(%rsp), %rcx
movq 0xc8(%rsp), %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
cmpq %rax, %rdx
ja 0x4cdc
leaq 0x108(%rsp), %rdi
leaq 0x120(%rsp), %rsi
callq 0x3ba7
movq 0x110(%rsp), %rax
cmpq 0x108(%rsp), %rax
je 0x4ea1
xorl %ebx, %ebx
movslq 0x64ee(%rip), %rax      # 0xb250
cmpq %rax, 0x48(%rsp)
jb 0x4e81
leaq 0x170(%rsp), %rax
movq %rax, 0x160(%rsp)
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rdx
addq %rsi, %rdx
leaq 0x160(%rsp), %rdi
callq 0x5c9a
leaq 0x1b0(%rsp), %rax
movq %rax, 0x1a0(%rsp)
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
addq %rsi, %rdx
leaq 0x1a0(%rsp), %r12
movq %r12, %rdi
callq 0x5c9a
movq 0x108(%rsp), %rax
movl (%rax,%rbx,8), %ecx
movl 0x4(%rax,%rbx,8), %r8d
movl 0x647d(%rip), %r9d      # 0xb258
movq %rbp, %rdi
leaq 0x160(%rsp), %rsi
movq %r12, %rdx
callq 0x3c79
movq 0x1a0(%rsp), %rdi
leaq 0x1b0(%rsp), %rax
cmpq %rax, %rdi
je 0x4e13
movq 0x1b0(%rsp), %rsi
incq %rsi
callq 0x3240
movq 0x160(%rsp), %rdi
leaq 0x170(%rsp), %rax
cmpq %rax, %rdi
je 0x4e38
movq 0x170(%rsp), %rsi
incq %rsi
callq 0x3240
movq 0xf0(%rsp), %rsi
leaq 0x1d8(%rsp), %rdi
leaq 0xe0(%rsp), %rdx
callq 0x64ee
cmpl $0x6, 0x38(%rsp)
jne 0x4e79
movq 0xf0(%rsp), %rsi
leaq 0x260(%rsp), %rdi
leaq 0xe0(%rsp), %rdx
callq 0x64ee
movq %rbp, %rdi
callq 0x5c08
incq %rbx
movq 0x110(%rsp), %rax
subq 0x108(%rsp), %rax
sarq $0x3, %rax
cmpq %rbx, %rax
ja 0x4d5b
movq 0x208(%rsp), %rsi
leaq 0x18(%rsp), %rdi
callq 0x3170
movq 0x200(%rsp), %rsi
movq 0x612e(%rip), %rdi      # 0xaff0
callq 0x3180
movq %rax, %rbx
movl $0xd, %edx
movq %rax, %rdi
leaq 0x3641(%rip), %rsi      # 0x851a
callq 0x3290
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rdx
movq %rbx, %rdi
callq 0x3290
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3210
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3190
movq 0x108(%rsp), %rdi
testq %rdi, %rdi
je 0x4f37
movq 0x118(%rsp), %rsi
subq %rdi, %rsi
callq 0x3240
movq 0x120(%rsp), %rdi
leaq 0x130(%rsp), %rax
cmpq %rax, %rdi
je 0x4f5c
movq 0x130(%rsp), %rsi
incq %rsi
callq 0x3240
movq 0xc0(%rsp), %rdi
testq %rdi, %rdi
je 0x4f79
movq 0xd0(%rsp), %rsi
subq %rdi, %rsi
callq 0x3240
leaq 0x4d0(%rsp), %rdi
movq 0x6038(%rip), %rsi      # 0xafc0
callq 0x3160
leaq 0x540(%rsp), %rdi
callq 0x30f0
movq 0x1c8(%rsp), %rax
movq %rax, 0x2c8(%rsp)
movq -0x18(%rax), %rax
movq 0x1c0(%rsp), %rcx
movq %rcx, 0x2c8(%rsp,%rax)
leaq 0x2d0(%rsp), %rdi
callq 0x31f0
leaq 0x3c0(%rsp), %rdi
callq 0x30f0
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x5006
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x3240
jmp 0x5006
movq %rsp, %rdi
leaq 0x140(%rsp), %rsi
callq 0x5bca
leaq 0x208(%rsp), %rdi
callq 0x5a6c
movq %r14, %rdi
callq 0x31a0
movq %rax, %r14
leaq 0x2a0(%rsp), %rax
cmpq %rax, %r14
jne 0x482e
cmpl $0x6, 0x38(%rsp)
jne 0x50e7
movq 0x278(%rsp), %rbx
leaq 0x268(%rsp), %r12
cmpq %r12, %rbx
je 0x5197
movq 0x5f76(%rip), %r14      # 0xafd0
movq 0x20(%rbx), %rsi
movq 0x28(%rbx), %rdx
movq %r14, %rdi
callq 0x3290
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x3210
movsbl %al, %esi
movq %r15, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3190
movq 0x40(%rbx), %rsi
movq 0x48(%rbx), %rdx
movq %rax, %rdi
callq 0x3290
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x3210
movsbl %al, %esi
movq %r15, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3190
movq %rbx, %rdi
callq 0x31a0
movq %rax, %rbx
cmpq %r12, %rax
jne 0x505a
jmp 0x5197
movq 0x1f0(%rsp), %rbx
leaq 0x1e0(%rsp), %rax
cmpq %rax, %rbx
je 0x5197
movq 0x5ec9(%rip), %r14      # 0xafd0
movq 0x20(%rbx), %rsi
movq 0x28(%rbx), %rdx
movq %r14, %rdi
callq 0x3290
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x3210
movsbl %al, %esi
movq %r15, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3190
movq 0x40(%rbx), %rsi
movq 0x48(%rbx), %rdx
movq %rax, %rdi
callq 0x3290
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x3210
movsbl %al, %esi
movq %r15, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3190
movq %rbx, %rdi
callq 0x31a0
movq %rax, %rbx
leaq 0x1e0(%rsp), %rax
cmpq %rax, %rbx
jne 0x5107
leaq 0x290(%rsp), %rdi
callq 0x706e
movq %rsp, %rdi
callq 0x5a6c
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x51c8
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x3240
leaq 0x260(%rsp), %rdi
callq 0x5c08
leaq 0x1d8(%rsp), %rdi
callq 0x5c08
movq 0x140(%rsp), %rdi
leaq 0x150(%rsp), %rax
cmpq %rax, %rdi
je 0x5207
movq 0x150(%rsp), %rsi
incq %rsi
callq 0x3240
movq 0x180(%rsp), %rdi
leaq 0x190(%rsp), %rax
cmpq %rax, %rdi
je 0x522c
movq 0x190(%rsp), %rsi
incq %rsi
callq 0x3240
leaq 0x230(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x524d
movq 0x230(%rsp), %rsi
incq %rsi
callq 0x3240
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x5269
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x3240
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x528e
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x3240
movq 0xa0(%rsp), %rdi
leaq 0xb0(%rsp), %rax
cmpq %rax, %rdi
je 0x52b3
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x3240
xorl %eax, %eax
addq $0x648, %rsp            # imm = 0x648
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x5d02(%rip), %rdi      # 0xafd0
leaq 0x2d82(%rip), %rsi      # 0x8057
movl $0xa, %edx
callq 0x3290
movq (%rbx), %rdi
callq 0x3330
movq 0x5ce2(%rip), %rdi      # 0xafd0
movq %rax, %rsi
callq 0x3220
movq %rax, %r14
leaq 0x2d62(%rip), %rsi      # 0x8062
movl $0x53, %edx
movq %rax, %rdi
callq 0x3290
movq %r14, %rdi
callq 0x3130
movq 0x5cb4(%rip), %rdi      # 0xafd0
leaq 0x2d93(%rip), %rsi      # 0x80b6
movl $0x4b, %edx
callq 0x3290
movq 0x5c9c(%rip), %rdi      # 0xafd0
leaq 0x2dc7(%rip), %rsi      # 0x8102
movl $0x97, %edx
callq 0x3290
movq 0x5c84(%rip), %rdi      # 0xafd0
leaq 0x2e47(%rip), %rsi      # 0x819a
movl $0x86, %edx
callq 0x3290
movq 0x5c6c(%rip), %rdi      # 0xafd0
leaq 0x2eb6(%rip), %rsi      # 0x8221
movl $0x66, %edx
callq 0x3290
movq 0x5c54(%rip), %rdi      # 0xafd0
leaq 0x2f05(%rip), %rsi      # 0x8288
movl $0x33, %edx
callq 0x3290
movq (%rbx), %rdi
callq 0x3330
movq 0x5c34(%rip), %rdi      # 0xafd0
movq %rax, %rsi
callq 0x3220
movq %rax, %rbx
leaq 0x2f0e(%rip), %rsi      # 0x82bc
movl $0x17, %edx
movq %rax, %rdi
callq 0x3290
leaq 0x2f12(%rip), %rsi      # 0x82d4
movl $0x6d, %edx
movq %rbx, %rdi
callq 0x3290
leaq 0x2f6c(%rip), %rsi      # 0x8342
movl $0x69, %edx
movq %rbx, %rdi
callq 0x3290
movq %rbx, %rdi
callq 0x3130
movq 0x5bde(%rip), %rdi      # 0xafd0
leaq 0x2fb3(%rip), %rsi      # 0x83ac
movl $0xe1, %edx
callq 0x3290
movq 0x5bc6(%rip), %rdi      # 0xafd0
callq 0x3130
movl $0x1, %edi
callq 0x32b0
jmp 0x5595
jmp 0x544c
movq %rdx, %rbx
movq %rax, %r14
movq 0x2c8(%rsp), %rdi
cmpq %r13, %rdi
je 0x5714
movq 0x2d8(%rsp), %rsi
incq %rsi
callq 0x3240
jmp 0x5714
movq %rdx, %rbx
movq %rax, %r14
jmp 0x5714
jmp 0x54b5
movq %rdx, %rbx
movq %rax, %r14
jmp 0x5738
jmp 0x5466
movq %rdx, %rbx
movq %rax, %r14
jmp 0x57bd
jmp 0x5473
movq %rdx, %rbx
movq %rax, %r14
jmp 0x57d9
jmp 0x5480
movq %rdx, %rbx
movq %rax, %r14
jmp 0x57fe
jmp 0x54b5
movq %rdx, %rbx
movq %rax, %r14
leaq 0x4e0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x5823
movq 0x4e0(%rsp), %rsi
jmp 0x581b
movq %rdx, %rbx
movq %rax, %r14
jmp 0x5823
jmp 0x5552
jmp 0x56cb
movq %rdx, %rbx
movq %rax, %r14
movq 0xd8(%rsp), %rdi
leaq 0xe8(%rsp), %rax
cmpq %rax, %rdi
je 0x56d1
movq 0xe8(%rsp), %rsi
incq %rsi
callq 0x3240
jmp 0x56d1
jmp 0x55bc
movq %rdx, %rbx
movq %rax, %r14
movq 0xd8(%rsp), %rdi
leaq 0xe8(%rsp), %rax
cmpq %rax, %rdi
je 0x56a0
movq 0xe8(%rsp), %rsi
incq %rsi
jmp 0x569b
jmp 0x55bc
movq %rdx, %rbx
movq %rax, %r14
jmp 0x5683
movq %rdx, %rbx
movq %rax, %r14
jmp 0x565e
jmp 0x56c3
movq %rdx, %rbx
movq %rax, %r14
jmp 0x56fa
jmp 0x55af
movq %rdx, %rbx
movq %rax, %r14
movq 0x2c8(%rsp), %rdi
leaq 0x2d8(%rsp), %rax
cmpq %rax, %rdi
je 0x5707
movq 0x2d8(%rsp), %rsi
incq %rsi
callq 0x3240
jmp 0x5707
jmp 0x55af
movq %rdx, %rbx
movq %rax, %r14
leaq 0x2c8(%rsp), %rdi
callq 0x3090
jmp 0x5714
jmp 0x55af
movq %rdx, %rbx
movq %rax, %r14
jmp 0x5707
jmp 0x5621
movq %rdx, %rbx
movq %rax, %r14
jmp 0x56a0
movq %rdx, %rbx
movq %rax, %r14
jmp 0x55fa
movq %rdx, %rbx
movq %rax, %r14
movq 0x1a0(%rsp), %rdi
leaq 0x1b0(%rsp), %rax
cmpq %rax, %rdi
je 0x55fa
movq 0x1b0(%rsp), %rsi
incq %rsi
callq 0x3240
movq 0x160(%rsp), %rdi
leaq 0x170(%rsp), %rax
cmpq %rax, %rdi
je 0x5641
movq 0x170(%rsp), %rsi
incq %rsi
callq 0x3240
jmp 0x5641
movq %rdx, %rbx
movq %rax, %r14
jmp 0x5641
jmp 0x56cb
movq %rdx, %rbx
movq %rax, %r14
leaq 0xd8(%rsp), %rdi
callq 0x5c08
movq 0x108(%rsp), %rdi
testq %rdi, %rdi
je 0x565e
movq 0x118(%rsp), %rsi
subq %rdi, %rsi
callq 0x3240
movq 0x120(%rsp), %rdi
leaq 0x130(%rsp), %rax
cmpq %rax, %rdi
je 0x5683
movq 0x130(%rsp), %rsi
incq %rsi
callq 0x3240
movq 0xc0(%rsp), %rdi
testq %rdi, %rdi
je 0x56a0
movq 0xd0(%rsp), %rsi
subq %rdi, %rsi
callq 0x3240
movq 0x5919(%rip), %rsi      # 0xafc0
leaq 0x4d0(%rsp), %rdi
callq 0x3160
leaq 0x540(%rsp), %rdi
callq 0x30f0
jmp 0x56d1
movq %rdx, %rbx
movq %rax, %r14
jmp 0x56de
movq %rdx, %rbx
movq %rax, %r14
leaq 0x2c8(%rsp), %rdi
callq 0x3340
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x56fa
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x3240
leaq 0x208(%rsp), %rdi
callq 0x5a6c
leaq 0x290(%rsp), %rdi
callq 0x706e
movq %rsp, %rdi
callq 0x5a6c
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x5738
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x3240
leaq 0x260(%rsp), %rdi
callq 0x5c08
leaq 0x1d8(%rsp), %rdi
callq 0x5c08
movq 0x140(%rsp), %rdi
leaq 0x150(%rsp), %rax
cmpq %rax, %rdi
je 0x5777
movq 0x150(%rsp), %rsi
incq %rsi
callq 0x3240
movq 0x180(%rsp), %rdi
leaq 0x190(%rsp), %rax
cmpq %rax, %rdi
je 0x579c
movq 0x190(%rsp), %rsi
incq %rsi
callq 0x3240
leaq 0x230(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x57bd
movq 0x230(%rsp), %rsi
incq %rsi
callq 0x3240
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x57d9
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x3240
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x57fe
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x3240
movq 0xa0(%rsp), %rdi
leaq 0xb0(%rsp), %rax
cmpq %rax, %rdi
je 0x5823
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x3240
cmpl $0x3, %ebx
jne 0x58f1
movq %r14, %rdi
callq 0x32d0
leaq 0x2c8(%rsp), %rdi
movq %rax, %rsi
callq 0x727e
movq %r14, %rdi
callq 0x3110
movq 0x579d(%rip), %rdi      # 0xaff0
leaq 0x2ced(%rip), %rsi      # 0x8547
movl $0x12, %edx
callq 0x3290
leaq 0x4d0(%rsp), %rbx
leaq 0x2c8(%rsp), %rsi
movq %rbx, %rdi
callq 0x752e
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq 0x5766(%rip), %rdi      # 0xaff0
callq 0x3290
movq %rax, %rdi
callq 0x3130
leaq 0x4e0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x58b8
movq 0x4e0(%rsp), %rsi
incq %rsi
callq 0x3240
leaq 0x54a1(%rip), %rax      # 0xad60
addq $0x10, %rax
leaq 0x2e0(%rsp), %rcx
movq %rax, -0x18(%rcx)
movq -0x10(%rcx), %rdi
cmpq %rcx, %rdi
je 0x5990
movq 0x2e0(%rsp), %rsi
incq %rsi
callq 0x3240
jmp 0x5990
cmpl $0x2, %ebx
jne 0x5964
movq %r14, %rdi
callq 0x32d0
movq 0x56c3(%rip), %rax      # 0xafc8
addq $0x10, %rax
movq %rax, 0x2c8(%rsp)
movq %r14, %rdi
callq 0x3110
movq 0x56d0(%rip), %rdi      # 0xaff0
leaq 0x2c20(%rip), %rsi      # 0x8547
movl $0x12, %edx
callq 0x3290
leaq 0x2c8(%rsp), %rdi
callq 0x3460
movq 0x56ab(%rip), %rdi      # 0xaff0
movq %rax, %rsi
callq 0x3220
movq %rax, %rdi
callq 0x3130
leaq 0x2c8(%rsp), %rdi
callq 0x3470
jmp 0x5990
movq %r14, %rdi
callq 0x3110
movq 0x567d(%rip), %rdi      # 0xaff0
leaq 0x2bae(%rip), %rsi      # 0x8528
movl $0x1e, %edx
callq 0x3290
movq 0x5665(%rip), %rdi      # 0xaff0
callq 0x3130
callq 0x33d0
movl $0x1, %eax
jmp 0x52b5
movq %rax, %rbx
callq 0x33d0
jmp 0x5a1e
movq %rax, %rbx
jmp 0x59e9
movq %rax, %rbx
leaq 0x2c8(%rsp), %rdi
callq 0x3470
callq 0x33d0
jmp 0x5a1e
movq %rax, %rbx
leaq 0x4e0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x59e9
movq 0x4e0(%rsp), %rsi
incq %rsi
callq 0x3240
leaq 0x5370(%rip), %rax      # 0xad60
addq $0x10, %rax
leaq 0x2e0(%rsp), %rcx
movq %rax, -0x18(%rcx)
movq -0x10(%rcx), %rdi
cmpq %rcx, %rdi
je 0x5a19
movq 0x2e0(%rsp), %rsi
incq %rsi
callq 0x3240
callq 0x33d0
movq %rbx, %rdi
callq 0x3410
movq %rax, %rdi
callq 0x5ac7