// File: 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
movq %rsp, %rbp
subq $0xc90, %rsp            # imm = 0xC90
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpl $0x6, -0x8(%rbp)
je 0x4d93
cmpl $0x7, -0x8(%rbp)
je 0x4d93
movq 0xd40c(%rip), %rdi      # 0x11fd0
leaq 0x748c(%rip), %rsi      # 0xc057
callq 0x32b0
movq %rax, -0xa30(%rbp)
jmp 0x4bd9
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x3490
movq -0xa30(%rbp), %rdi
movq %rax, %rsi
callq 0x32b0
movq %rax, -0xa38(%rbp)
jmp 0x4bfd
movq -0xa38(%rbp), %rdi
leaq 0x7457(%rip), %rsi      # 0xc062
callq 0x32b0
movq %rax, -0xa40(%rbp)
jmp 0x4c19
movq -0xa40(%rbp), %rdi
movq 0xd381(%rip), %rsi      # 0x11fa8
callq 0x3310
jmp 0x4c2e
movq 0xd39b(%rip), %rdi      # 0x11fd0
leaq 0x747a(%rip), %rsi      # 0xc0b6
callq 0x32b0
movq %rax, -0xa48(%rbp)
jmp 0x4c4a
movq -0xa48(%rbp), %rdi
leaq 0x74aa(%rip), %rsi      # 0xc102
callq 0x32b0
movq %rax, -0xa50(%rbp)
jmp 0x4c66
movq -0xa50(%rbp), %rdi
leaq 0x7526(%rip), %rsi      # 0xc19a
callq 0x32b0
movq %rax, -0xa58(%rbp)
jmp 0x4c82
movq -0xa58(%rbp), %rdi
leaq 0x7591(%rip), %rsi      # 0xc221
callq 0x32b0
movq %rax, -0xa60(%rbp)
jmp 0x4c9e
movq -0xa60(%rbp), %rdi
leaq 0x75dc(%rip), %rsi      # 0xc288
callq 0x32b0
movq %rax, -0xa68(%rbp)
jmp 0x4cba
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x3490
movq -0xa68(%rbp), %rdi
movq %rax, %rsi
callq 0x32b0
movq %rax, -0xa70(%rbp)
jmp 0x4cde
movq -0xa70(%rbp), %rdi
leaq 0x75d0(%rip), %rsi      # 0xc2bc
callq 0x32b0
movq %rax, -0xa78(%rbp)
jmp 0x4cfa
movq -0xa78(%rbp), %rdi
leaq 0x75cc(%rip), %rsi      # 0xc2d4
callq 0x32b0
movq %rax, -0xa80(%rbp)
jmp 0x4d16
movq -0xa80(%rbp), %rdi
leaq 0x761e(%rip), %rsi      # 0xc342
callq 0x32b0
movq %rax, -0xa88(%rbp)
jmp 0x4d32
movq -0xa88(%rbp), %rdi
movq 0xd268(%rip), %rsi      # 0x11fa8
callq 0x3310
jmp 0x4d47
movq 0xd282(%rip), %rdi      # 0x11fd0
leaq 0x7657(%rip), %rsi      # 0xc3ac
callq 0x32b0
movq %rax, -0xa90(%rbp)
jmp 0x4d63
movq -0xa90(%rbp), %rdi
movq 0xd237(%rip), %rsi      # 0x11fa8
callq 0x3310
jmp 0x4d78
movl $0x1, %edi
callq 0x33b0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
jmp 0x606c
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x34e0
movl %eax, 0xd552(%rip)      # 0x122f8
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x34e0
movl %eax, 0xd543(%rip)      # 0x122fc
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x34e0
movl %eax, 0xd534(%rip)      # 0x12300
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0xaa0(%rbp)
leaq -0x61(%rbp), %rdi
movq %rdi, -0xa98(%rbp)
callq 0x3540
movq -0xaa0(%rbp), %rsi
movq -0xa98(%rbp), %rdx
leaq -0x60(%rbp), %rdi
callq 0x62c0
jmp 0x4e04
leaq 0x7683(%rip), %rdx      # 0xc48e
leaq -0x40(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x6770
jmp 0x4e1a
leaq 0xd51f(%rip), %rdi      # 0x12340
movq %rdi, -0xaa8(%rbp)
leaq -0x40(%rbp), %rsi
movq %rsi, -0xab0(%rbp)
callq 0x33c0
movq -0xab0(%rbp), %rdi
callq 0x35d8
leaq -0x60(%rbp), %rdi
callq 0x35d8
leaq -0x61(%rbp), %rdi
callq 0x3330
movq -0xaa8(%rbp), %rsi
leaq 0x762c(%rip), %rdx      # 0xc490
leaq -0x88(%rbp), %rdi
callq 0x67c0
jmp 0x4e72
leaq 0xd4c7(%rip), %rsi      # 0x12340
leaq 0x7623(%rip), %rdx      # 0xc4a3
leaq -0xa8(%rbp), %rdi
callq 0x67c0
jmp 0x4e8e
leaq 0xd4ab(%rip), %rsi      # 0x12340
leaq 0x761c(%rip), %rdx      # 0xc4b8
leaq -0xc8(%rbp), %rdi
callq 0x67c0
jmp 0x4eaa
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0xac0(%rbp)
leaq -0xe9(%rbp), %rdi
movq %rdi, -0xab8(%rbp)
callq 0x3540
movq -0xac0(%rbp), %rsi
movq -0xab8(%rbp), %rdx
leaq -0xe8(%rbp), %rdi
callq 0x62c0
jmp 0x4ee8
leaq -0xe9(%rbp), %rdi
callq 0x3330
leaq -0x110(%rbp), %rdi
callq 0x3440
leaq -0x130(%rbp), %rdi
callq 0x3440
leaq -0x160(%rbp), %rdi
callq 0x6560
leaq -0x190(%rbp), %rdi
callq 0x6560
leaq -0x1b1(%rbp), %rdi
movq %rdi, -0xac8(%rbp)
callq 0x3540
movq -0xac8(%rbp), %rdx
leaq 0x757e(%rip), %rsi      # 0xc4c3
leaq -0x1b0(%rbp), %rdi
callq 0x62c0
jmp 0x4f53
leaq -0x1b1(%rbp), %rdi
callq 0x3330
leaq -0x1d0(%rbp), %rdi
callq 0x6370
cmpl $0x7, -0x8(%rbp)
jne 0x5143
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rsi
leaq -0x3d8(%rbp), %rdi
movl $0x8, %edx
callq 0x3560
jmp 0x4f90
jmp 0x4f92
leaq -0x3d8(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0x3080
movq %rax, -0xad0(%rbp)
jmp 0x4fae
movq -0xad0(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x33f0
movb %al, -0xad1(%rbp)
jmp 0x4fcc
movb -0xad1(%rbp), %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0xad2(%rbp)
jne 0x4fe1
jmp 0x5029
leaq -0x3d8(%rbp), %rdi
leaq -0x130(%rbp), %rsi
callq 0x3080
movq %rax, -0xae0(%rbp)
jmp 0x4ffd
movq -0xae0(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x33f0
movb %al, -0xae1(%rbp)
jmp 0x501b
movb -0xae1(%rbp), %al
movb %al, -0xad2(%rbp)
jmp 0x5029
movb -0xad2(%rbp), %al
testb $0x1, %al
jne 0x5038
jmp 0x5129
leaq -0x160(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0x6840
movq %rax, -0xaf0(%rbp)
jmp 0x5054
movq -0xaf0(%rbp), %rdi
leaq -0x130(%rbp), %rsi
callq 0x3040
jmp 0x5069
jmp 0x4f92
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
jmp 0x5091
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x35d8
leaq -0x61(%rbp), %rdi
callq 0x3330
jmp 0x606c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
jmp 0x6060
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
jmp 0x6054
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
leaq -0xe9(%rbp), %rdi
callq 0x3330
jmp 0x6048
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
leaq -0x1b1(%rbp), %rdi
callq 0x3330
jmp 0x600c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
jmp 0x5ff4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
leaq -0x3d8(%rbp), %rdi
callq 0x30d0
jmp 0x5ff4
leaq -0x3d8(%rbp), %rdi
callq 0x3090
jmp 0x5137
leaq -0x3d8(%rbp), %rdi
callq 0x30d0
leaq -0xe8(%rbp), %rdi
callq 0x3150
movq %rax, -0xb00(%rbp)
leaq -0x431(%rbp), %rdi
movq %rdi, -0xaf8(%rbp)
callq 0x3540
movq -0xb00(%rbp), %rsi
movq -0xaf8(%rbp), %rdx
leaq -0x430(%rbp), %rdi
callq 0x62c0
jmp 0x5185
leaq -0x410(%rbp), %rdi
leaq -0x430(%rbp), %rsi
callq 0xa720
jmp 0x519a
leaq -0x430(%rbp), %rdi
callq 0x35d8
leaq -0x431(%rbp), %rdi
callq 0x3330
leaq -0x410(%rbp), %rdi
callq 0x6920
movq %rax, -0xb08(%rbp)
jmp 0x51c7
movq -0xb08(%rbp), %rax
movq %rax, -0x440(%rbp)
leaq -0x410(%rbp), %rdi
callq 0x6980
movq %rax, -0xb10(%rbp)
jmp 0x51ea
movq -0xb10(%rbp), %rax
movq %rax, -0x448(%rbp)
leaq -0x440(%rbp), %rdi
leaq -0x448(%rbp), %rsi
callq 0x6950
testb $0x1, %al
jne 0x5214
jmp 0x5d91
leaq -0x440(%rbp), %rdi
callq 0x69b0
movq %rax, %rsi
leaq -0x110(%rbp), %rdi
callq 0x3040
jmp 0x5231
leaq -0x440(%rbp), %rdi
callq 0x69b0
movq %rax, %rsi
addq $0x20, %rsi
leaq -0x130(%rbp), %rdi
callq 0x3040
jmp 0x5252
leaq -0x481(%rbp), %rdi
movq %rdi, -0xb18(%rbp)
callq 0x3540
movq -0xb18(%rbp), %rdx
leaq 0x72e5(%rip), %rsi      # 0xc558
leaq -0x480(%rbp), %rdi
callq 0x62c0
jmp 0x5281
leaq -0x460(%rbp), %rdi
leaq -0x110(%rbp), %rsi
leaq -0x480(%rbp), %rdx
callq 0x3790
jmp 0x529d
leaq -0x480(%rbp), %rdi
callq 0x35d8
leaq -0x481(%rbp), %rdi
callq 0x3330
leaq -0x460(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x6440
movq %rax, %rdi
leaq -0x1b0(%rbp), %rsi
callq 0x69d0
testb $0x1, %al
jne 0x52dd
jmp 0x5d35
leaq -0x4a9(%rbp), %rdi
movq %rdi, -0xb20(%rbp)
callq 0x3540
movq -0xb20(%rbp), %rdx
leaq 0x6d28(%rip), %rsi      # 0xc026
leaq -0x4a8(%rbp), %rdi
callq 0x62c0
jmp 0x530c
leaq -0x4a9(%rbp), %rdi
callq 0x3330
movl $0x0, -0x4b0(%rbp)
movslq -0x4b0(%rbp), %rax
movq %rax, -0xb28(%rbp)
leaq -0x1d0(%rbp), %rdi
callq 0x6a00
movq %rax, %rcx
movq -0xb28(%rbp), %rax
cmpq %rcx, %rax
jae 0x54bb
movslq -0x4b0(%rbp), %rsi
leaq -0x1d0(%rbp), %rdi
callq 0x6440
movq %rax, %rdi
callq 0x3210
cmpq $0x7a3aa, %rax          # imm = 0x7A3AA
jbe 0x5481
movslq -0x4b0(%rbp), %rsi
leaq -0x1d0(%rbp), %rdi
movq %rdi, -0xb38(%rbp)
callq 0x6440
movq -0xb38(%rbp), %rdi
movq %rax, -0xb30(%rbp)
movslq -0x4b0(%rbp), %rsi
callq 0x6440
movq %rax, %rdi
callq 0x3210
movq -0xb30(%rbp), %rdi
movq %rax, %rdx
addq $-0x12c, %rdx           # imm = 0xFED4
movl $0x96, %esi
callq 0x30a0
jmp 0x53cf
jmp 0x5481
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
jmp 0x53fa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
leaq -0x430(%rbp), %rdi
callq 0x35d8
leaq -0x431(%rbp), %rdi
callq 0x3330
jmp 0x5ff4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
jmp 0x5fe8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
jmp 0x5442
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
leaq -0x480(%rbp), %rdi
callq 0x35d8
leaq -0x481(%rbp), %rdi
callq 0x3330
jmp 0x5fe8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
leaq -0x4a9(%rbp), %rdi
callq 0x3330
jmp 0x5d80
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
jmp 0x5d27
movslq -0x4b0(%rbp), %rsi
leaq -0x1d0(%rbp), %rdi
callq 0x6440
movq %rax, %rsi
leaq -0x4a8(%rbp), %rdi
callq 0x3400
jmp 0x54a5
jmp 0x54a7
movl -0x4b0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4b0(%rbp)
jmp 0x5322
leaq -0x88(%rbp), %rdi
callq 0x3150
movq %rax, %rsi
leaq -0x6b0(%rbp), %rdi
movl $0x10, %edx
callq 0x3340
jmp 0x54dd
leaq -0x6b0(%rbp), %rdi
leaq -0x1b0(%rbp), %rsi
callq 0x3290
movq %rax, -0xb40(%rbp)
jmp 0x54f9
movq -0xb40(%rbp), %rdi
movq 0xcaa1(%rip), %rsi      # 0x11fa8
callq 0x3310
jmp 0x550e
leaq -0x6b0(%rbp), %rdi
leaq -0x4a8(%rbp), %rsi
callq 0x3290
movq %rax, -0xb48(%rbp)
jmp 0x552a
movq -0xb48(%rbp), %rdi
movq 0xca70(%rip), %rsi      # 0x11fa8
callq 0x3310
jmp 0x553f
leaq -0x6b0(%rbp), %rdi
callq 0x3470
jmp 0x554d
leaq -0xa8(%rbp), %rdi
callq 0x3150
movq %rax, %rsi
leaq -0x6b0(%rbp), %rdi
movl $0x10, %edx
callq 0x3050
jmp 0x556f
leaq -0x160(%rbp), %rdi
callq 0x66f0
movq %rax, -0x6b8(%rbp)
leaq -0x160(%rbp), %rdi
callq 0x6720
movq %rax, -0x6c0(%rbp)
leaq -0x6b8(%rbp), %rdi
leaq -0x6c0(%rbp), %rsi
callq 0x6950
testb $0x1, %al
jne 0x55b1
jmp 0x565b
leaq -0x6b8(%rbp), %rdi
callq 0x69b0
movq %rax, %rsi
leaq -0x6b0(%rbp), %rdi
callq 0x3290
movq %rax, -0xb50(%rbp)
jmp 0x55d5
movq -0xb50(%rbp), %rdi
movq 0xc9c5(%rip), %rsi      # 0x11fa8
callq 0x3310
movq %rax, -0xb58(%rbp)
jmp 0x55f1
leaq -0x6b8(%rbp), %rdi
callq 0x69b0
movq -0xb58(%rbp), %rdi
movq %rax, %rsi
addq $0x20, %rsi
callq 0x3290
movq %rax, -0xb60(%rbp)
jmp 0x5619
movq -0xb60(%rbp), %rdi
movq 0xc981(%rip), %rsi      # 0x11fa8
callq 0x3310
jmp 0x562e
jmp 0x5630
leaq -0x6b8(%rbp), %rdi
xorl %esi, %esi
callq 0x6a20
movq %rax, -0x6c8(%rbp)
jmp 0x5582
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
jmp 0x5d1b
leaq -0x6b0(%rbp), %rdi
callq 0x3470
jmp 0x5669
leaq -0x1d0(%rbp), %rdi
movq %rdi, -0xb68(%rbp)
callq 0x6a60
movq -0xb68(%rbp), %rdi
leaq -0x130(%rbp), %rsi
callq 0x6a80
jmp 0x5691
leaq -0x861(%rbp), %rdi
movq %rdi, -0xb70(%rbp)
callq 0x3540
movq -0xb70(%rbp), %rdx
leaq 0x6974(%rip), %rsi      # 0xc026
leaq -0x860(%rbp), %rdi
callq 0x62c0
jmp 0x56c0
leaq -0x840(%rbp), %rdi
leaq -0x860(%rbp), %rsi
movl $0x10, %edx
callq 0x3450
jmp 0x56da
leaq -0x860(%rbp), %rdi
callq 0x35d8
leaq -0x861(%rbp), %rdi
callq 0x3330
leaq 0x6def(%rip), %rsi      # 0xc4e8
leaq -0x840(%rbp), %rdi
callq 0x32b0
movq %rax, -0xb78(%rbp)
jmp 0x570e
movq -0xb78(%rbp), %rdi
movl 0xcbdd(%rip), %esi      # 0x122f8
movl 0xcbdb(%rip), %eax      # 0x122fc
subl %eax, %esi
callq 0x3520
movq %rax, -0xb80(%rbp)
jmp 0x5731
movq -0xb80(%rbp), %rdi
leaq 0x6dba(%rip), %rsi      # 0xc4f9
callq 0x32b0
movq %rax, -0xb88(%rbp)
jmp 0x574d
movq -0xb88(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x3290
movq %rax, -0xb90(%rbp)
jmp 0x5769
movq -0xb90(%rbp), %rdi
leaq 0x6de1(%rip), %rsi      # 0xc558
callq 0x32b0
movq %rax, -0xb98(%rbp)
jmp 0x5785
movq -0xb98(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x3290
movq %rax, -0xba0(%rbp)
jmp 0x57a1
movq -0xba0(%rbp), %rdi
leaq 0x6da9(%rip), %rsi      # 0xc558
callq 0x32b0
movq %rax, -0xba8(%rbp)
jmp 0x57bd
movq -0xba8(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x3290
jmp 0x57d2
leaq -0x8a8(%rbp), %rdi
leaq -0x840(%rbp), %rsi
callq 0x32e0
jmp 0x57e7
leaq -0x888(%rbp), %rdi
leaq -0x8a8(%rbp), %rsi
callq 0x3920
jmp 0x57fc
leaq -0x888(%rbp), %rdi
callq 0x35d8
leaq -0x8a8(%rbp), %rdi
callq 0x35d8
leaq -0x8c0(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x3b00
jmp 0x5829
leaq -0x4a8(%rbp), %rdi
callq 0x3210
movq %rax, -0xbb8(%rbp)
leaq -0x8e1(%rbp), %rdi
movq %rdi, -0xbb0(%rbp)
callq 0x3540
movq -0xbb8(%rbp), %rsi
movq -0xbb0(%rbp), %rcx
leaq -0x8e0(%rbp), %rdi
movl $0x30, %edx
callq 0x6af0
jmp 0x5870
leaq -0x8e1(%rbp), %rdi
callq 0x3330
movl $0x0, -0x8e8(%rbp)
movslq -0x8e8(%rbp), %rax
movq %rax, -0xbc0(%rbp)
leaq -0x8c0(%rbp), %rdi
callq 0x6b60
movq %rax, %rcx
movq -0xbc0(%rbp), %rax
cmpq %rcx, %rax
jae 0x59df
movslq -0x8e8(%rbp), %rsi
leaq -0x8c0(%rbp), %rdi
callq 0x6b80
movl (%rax), %eax
movl %eax, -0x8ec(%rbp)
movl -0x8ec(%rbp), %eax
movl %eax, -0xbc4(%rbp)
movslq -0x8e8(%rbp), %rsi
leaq -0x8c0(%rbp), %rdi
callq 0x6b80
movq %rax, %rcx
movl -0xbc4(%rbp), %eax
cmpl 0x4(%rcx), %eax
jge 0x59c9
movslq -0x8ec(%rbp), %rsi
leaq -0x8e0(%rbp), %rdi
callq 0x35c0
movq %rax, -0xbd0(%rbp)
jmp 0x591b
movq -0xbd0(%rbp), %rax
movb $0x31, (%rax)
movl -0x8ec(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8ec(%rbp)
jmp 0x58ce
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
jmp 0x595c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
leaq -0x860(%rbp), %rdi
callq 0x35d8
leaq -0x861(%rbp), %rdi
callq 0x3330
jmp 0x5d1b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
jmp 0x5d0f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
leaq -0x8a8(%rbp), %rdi
callq 0x35d8
jmp 0x5d0f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
leaq -0x8e1(%rbp), %rdi
callq 0x3330
jmp 0x5d03
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
jmp 0x5cf7
jmp 0x59cb
movl -0x8e8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8e8(%rbp)
jmp 0x5886
leaq -0x908(%rbp), %rdi
leaq -0x8e0(%rbp), %rsi
callq 0x3f50
jmp 0x59f4
movl $0x0, -0x90c(%rbp)
movslq -0x90c(%rbp), %rax
movq %rax, -0xbd8(%rbp)
leaq -0x908(%rbp), %rdi
callq 0x6b60
movq %rax, %rcx
movq -0xbd8(%rbp), %rax
cmpq %rcx, %rax
jae 0x5c0f
leaq -0x4a8(%rbp), %rdi
callq 0x3210
movslq 0xc8ba(%rip), %rcx      # 0x122f8
cmpq %rcx, %rax
jae 0x5a48
jmp 0x5bfb
leaq -0x960(%rbp), %rdi
leaq -0x1b0(%rbp), %rsi
callq 0x3160
jmp 0x5a5d
leaq -0x980(%rbp), %rdi
leaq -0x4a8(%rbp), %rsi
callq 0x3160
jmp 0x5a72
movslq -0x90c(%rbp), %rsi
leaq -0x908(%rbp), %rdi
movq %rdi, -0xbe8(%rbp)
callq 0x6b80
movq -0xbe8(%rbp), %rdi
movl (%rax), %eax
movl %eax, -0xbdc(%rbp)
movslq -0x90c(%rbp), %rsi
callq 0x6b80
movl -0xbdc(%rbp), %ecx
movl 0x4(%rax), %r8d
movl 0xc848(%rip), %r9d      # 0x12300
leaq -0x940(%rbp), %rdi
leaq -0x960(%rbp), %rsi
leaq -0x980(%rbp), %rdx
callq 0x40a0
jmp 0x5ad4
leaq -0x980(%rbp), %rdi
callq 0x35d8
leaq -0x960(%rbp), %rdi
callq 0x35d8
leaq -0x940(%rbp), %rdi
movq %rdi, -0xbf0(%rbp)
callq 0x66f0
movq -0xbf0(%rbp), %rdi
movq %rax, -0x988(%rbp)
callq 0x6720
movq %rax, -0x990(%rbp)
movq -0x988(%rbp), %rsi
movq -0x990(%rbp), %rdx
leaq -0x160(%rbp), %rdi
callq 0x66b0
jmp 0x5b35
cmpl $0x6, -0x8(%rbp)
jne 0x5bef
leaq -0x940(%rbp), %rdi
movq %rdi, -0xbf8(%rbp)
callq 0x66f0
movq -0xbf8(%rbp), %rdi
movq %rax, -0x998(%rbp)
callq 0x6720
movq %rax, -0x9a0(%rbp)
movq -0x998(%rbp), %rsi
movq -0x9a0(%rbp), %rdx
leaq -0x190(%rbp), %rdi
callq 0x66b0
jmp 0x5b88
jmp 0x5bef
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
jmp 0x5ceb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
jmp 0x5bc1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
leaq -0x980(%rbp), %rdi
callq 0x35d8
leaq -0x960(%rbp), %rdi
callq 0x35d8
jmp 0x5ceb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
leaq -0x940(%rbp), %rdi
callq 0x6750
jmp 0x5ceb
leaq -0x940(%rbp), %rdi
callq 0x6750
movl -0x90c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x90c(%rbp)
jmp 0x59fe
xorl %eax, %eax
movl %eax, %esi
leaq -0x460(%rbp), %rdi
callq 0x6440
movq %rax, %rsi
leaq -0x1b0(%rbp), %rdi
callq 0x3040
jmp 0x5c30
leaq -0x160(%rbp), %rdi
callq 0x6ba0
movq %rax, %rsi
movq 0xc3aa(%rip), %rdi      # 0x11ff0
callq 0x30b0
movq %rax, -0xc00(%rbp)
jmp 0x5c54
movq -0xc00(%rbp), %rdi
leaq 0x68b8(%rip), %rsi      # 0xc51a
callq 0x32b0
movq %rax, -0xc08(%rbp)
jmp 0x5c70
movq -0xc08(%rbp), %rdi
leaq -0x1b0(%rbp), %rsi
callq 0x3290
movq %rax, -0xc10(%rbp)
jmp 0x5c8c
movq -0xc10(%rbp), %rdi
movq 0xc30e(%rip), %rsi      # 0x11fa8
callq 0x3310
jmp 0x5ca1
leaq -0x908(%rbp), %rdi
callq 0x64c0
leaq -0x8e0(%rbp), %rdi
callq 0x35d8
leaq -0x8c0(%rbp), %rdi
callq 0x64c0
leaq -0x840(%rbp), %rdi
callq 0x30c0
leaq -0x6b0(%rbp), %rdi
callq 0x34a0
leaq -0x4a8(%rbp), %rdi
callq 0x35d8
jmp 0x5d5a
leaq -0x908(%rbp), %rdi
callq 0x64c0
leaq -0x8e0(%rbp), %rdi
callq 0x35d8
leaq -0x8c0(%rbp), %rdi
callq 0x64c0
leaq -0x840(%rbp), %rdi
callq 0x30c0
leaq -0x6b0(%rbp), %rdi
callq 0x34a0
leaq -0x4a8(%rbp), %rdi
callq 0x35d8
jmp 0x5d80
leaq -0x1d0(%rbp), %rdi
leaq -0x130(%rbp), %rsi
callq 0x6a80
jmp 0x5d4a
jmp 0x5d5a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
jmp 0x5d80
leaq -0x460(%rbp), %rdi
callq 0x63c0
leaq -0x440(%rbp), %rdi
xorl %esi, %esi
callq 0x6a20
movq %rax, -0x9a8(%rbp)
jmp 0x51d5
leaq -0x460(%rbp), %rdi
callq 0x63c0
jmp 0x5fe8
cmpl $0x6, -0x8(%rbp)
jne 0x5e7b
leaq -0x190(%rbp), %rdi
callq 0x66f0
movq %rax, -0x9b0(%rbp)
leaq -0x190(%rbp), %rdi
callq 0x6720
movq %rax, -0x9b8(%rbp)
leaq -0x9b0(%rbp), %rdi
leaq -0x9b8(%rbp), %rsi
callq 0x6950
testb $0x1, %al
jne 0x5ddd
jmp 0x5e76
leaq -0x9b0(%rbp), %rdi
callq 0x69b0
movq %rax, %rsi
movq 0xc1dd(%rip), %rdi      # 0x11fd0
callq 0x3290
movq %rax, -0xc18(%rbp)
jmp 0x5e01
movq -0xc18(%rbp), %rdi
movq 0xc199(%rip), %rsi      # 0x11fa8
callq 0x3310
movq %rax, -0xc20(%rbp)
jmp 0x5e1d
leaq -0x9b0(%rbp), %rdi
callq 0x69b0
movq -0xc20(%rbp), %rdi
movq %rax, %rsi
addq $0x20, %rsi
callq 0x3290
movq %rax, -0xc28(%rbp)
jmp 0x5e45
movq -0xc28(%rbp), %rdi
movq 0xc155(%rip), %rsi      # 0x11fa8
callq 0x3310
jmp 0x5e5a
jmp 0x5e5c
leaq -0x9b0(%rbp), %rdi
xorl %esi, %esi
callq 0x6a20
movq %rax, -0x9c0(%rbp)
jmp 0x5dae
jmp 0x5f58
leaq -0x160(%rbp), %rdi
callq 0x66f0
movq %rax, -0x9c8(%rbp)
leaq -0x160(%rbp), %rdi
callq 0x6720
movq %rax, -0x9d0(%rbp)
leaq -0x9c8(%rbp), %rdi
leaq -0x9d0(%rbp), %rsi
callq 0x6950
testb $0x1, %al
jne 0x5ebd
jmp 0x5f56
leaq -0x9c8(%rbp), %rdi
callq 0x69b0
movq %rax, %rsi
movq 0xc0fd(%rip), %rdi      # 0x11fd0
callq 0x3290
movq %rax, -0xc30(%rbp)
jmp 0x5ee1
movq -0xc30(%rbp), %rdi
movq 0xc0b9(%rip), %rsi      # 0x11fa8
callq 0x3310
movq %rax, -0xc38(%rbp)
jmp 0x5efd
leaq -0x9c8(%rbp), %rdi
callq 0x69b0
movq -0xc38(%rbp), %rdi
movq %rax, %rsi
addq $0x20, %rsi
callq 0x3290
movq %rax, -0xc40(%rbp)
jmp 0x5f25
movq -0xc40(%rbp), %rdi
movq 0xc075(%rip), %rsi      # 0x11fa8
callq 0x3310
jmp 0x5f3a
jmp 0x5f3c
leaq -0x9c8(%rbp), %rdi
xorl %esi, %esi
callq 0x6a20
movq %rax, -0x9d8(%rbp)
jmp 0x5e8e
jmp 0x5f58
movl $0x0, -0x4(%rbp)
leaq -0x410(%rbp), %rdi
callq 0xafb0
leaq -0x1d0(%rbp), %rdi
callq 0x63c0
leaq -0x1b0(%rbp), %rdi
callq 0x35d8
leaq -0x190(%rbp), %rdi
callq 0x6750
leaq -0x160(%rbp), %rdi
callq 0x6750
leaq -0x130(%rbp), %rdi
callq 0x35d8
leaq -0x110(%rbp), %rdi
callq 0x35d8
leaq -0xe8(%rbp), %rdi
callq 0x35d8
leaq -0xc8(%rbp), %rdi
callq 0x35d8
leaq -0xa8(%rbp), %rdi
callq 0x35d8
leaq -0x88(%rbp), %rdi
callq 0x35d8
jmp 0x629b
leaq -0x410(%rbp), %rdi
callq 0xafb0
leaq -0x1d0(%rbp), %rdi
callq 0x63c0
leaq -0x1b0(%rbp), %rdi
callq 0x35d8
leaq -0x190(%rbp), %rdi
callq 0x6750
leaq -0x160(%rbp), %rdi
callq 0x6750
leaq -0x130(%rbp), %rdi
callq 0x35d8
leaq -0x110(%rbp), %rdi
callq 0x35d8
leaq -0xe8(%rbp), %rdi
callq 0x35d8
leaq -0xc8(%rbp), %rdi
callq 0x35d8
leaq -0xa8(%rbp), %rdi
callq 0x35d8
leaq -0x88(%rbp), %rdi
callq 0x35d8
movl -0x1c(%rbp), %eax
movl %eax, -0xc44(%rbp)
movl $0x3, %ecx
cmpl %ecx, %eax
jne 0x613d
movq -0x18(%rbp), %rdi
movq %rdi, -0xc58(%rbp)
callq 0x33e0
movq %rax, %rsi
leaq -0xa08(%rbp), %rdi
callq 0xb340
movq -0xc58(%rbp), %rdi
callq 0x3140
movq 0xbf3c(%rip), %rdi      # 0x11ff0
leaq 0x648c(%rip), %rsi      # 0xc547
callq 0x32b0
movq %rax, -0xc50(%rbp)
jmp 0x60c9
leaq -0xa28(%rbp), %rdi
movq %rdi, -0xc68(%rbp)
leaq -0xa08(%rbp), %rsi
callq 0xb540
movq -0xc50(%rbp), %rdi
movq -0xc68(%rbp), %rsi
callq 0x3290
movq %rax, -0xc60(%rbp)
jmp 0x60ff
movq -0xc60(%rbp), %rdi
movq 0xbe9b(%rip), %rsi      # 0x11fa8
callq 0x3310
jmp 0x6114
leaq -0xa28(%rbp), %rdi
callq 0x35d8
leaq -0xa08(%rbp), %rdi
callq 0x6be0
callq 0x3500
movl $0x1, -0x4(%rbp)
jmp 0x629b
movl -0xc44(%rbp), %eax
movl $0x2, %ecx
cmpl %ecx, %eax
jne 0x61e6
movq -0x18(%rbp), %rdi
movq %rdi, -0xc78(%rbp)
callq 0x33e0
movq %rax, %rsi
leaq -0x9e0(%rbp), %rdi
callq 0x6bc0
movq -0xc78(%rbp), %rdi
callq 0x3140
movq 0xbe6e(%rip), %rdi      # 0x11ff0
leaq 0x63be(%rip), %rsi      # 0xc547
callq 0x32b0
movq %rax, -0xc70(%rbp)
jmp 0x6197
leaq -0x9e0(%rbp), %rdi
callq 0x3590
movq -0xc70(%rbp), %rdi
movq %rax, %rsi
callq 0x32b0
movq %rax, -0xc80(%rbp)
jmp 0x61bb
movq -0xc80(%rbp), %rdi
movq 0xbddf(%rip), %rsi      # 0x11fa8
callq 0x3310
jmp 0x61d0
leaq -0x9e0(%rbp), %rdi
callq 0x35a0
callq 0x3500
jmp 0x6131
movq -0x18(%rbp), %rdi
callq 0x3140
movq 0xbdfa(%rip), %rdi      # 0x11ff0
leaq 0x632b(%rip), %rsi      # 0xc528
callq 0x32b0
movq %rax, -0xc88(%rbp)
jmp 0x620b
movq -0xc88(%rbp), %rdi
movq 0xbd8f(%rip), %rsi      # 0x11fa8
callq 0x3310
jmp 0x6220
callq 0x3500
jmp 0x6131
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
callq 0x3500
jmp 0x623d
jmp 0x62a7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
leaq -0x9e0(%rbp), %rdi
callq 0x35a0
callq 0x3500
jmp 0x625e
jmp 0x62a7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
jmp 0x6286
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
leaq -0xa28(%rbp), %rdi
callq 0x35d8
leaq -0xa08(%rbp), %rdi
callq 0x6be0
callq 0x3500
jmp 0x6299
jmp 0x62a7
movl -0x4(%rbp), %eax
addq $0xc90, %rsp            # imm = 0xC90
popq %rbp
retq
movq -0x18(%rbp), %rdi
callq 0x3530
movq %rax, %rdi
callq 0x6520
nopl (%rax,%rax)