// File: /workspace/github_cpp_makefile_star2_O2/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 $0x638, %rsp            # imm = 0x638
movq %rsi, %rbx
movl %edi, %r13d
leal -0x8(%r13), %eax
cmpl $-0x3, %eax
jbe 0x4937
movq 0x8(%rbx), %rdi
callq 0x3390
movl %eax, 0x7199(%rip)      # 0xb248
movq 0x10(%rbx), %rdi
callq 0x3390
movl %eax, 0x718e(%rip)      # 0xb24c
movq 0x18(%rbx), %rdi
callq 0x3390
movl %eax, 0x7183(%rip)      # 0xb250
movq 0x28(%rbx), %rsi
leaq 0x4a0(%rsp), %rdi
leaq 0x220(%rsp), %rdx
callq 0x4e06
leaq 0x33a1(%rip), %rdx      # 0x748e
leaq 0x298(%rsp), %rdi
leaq 0x4a0(%rsp), %rsi
callq 0x4ed4
leaq 0x7187(%rip), %r14      # 0xb290
leaq 0x298(%rsp), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x32b0
movq %r15, %rdi
callq 0x3478
leaq 0x4a0(%rsp), %rdi
callq 0x3478
leaq 0x3358(%rip), %rdx      # 0x7490
leaq 0x190(%rsp), %rdi
movq %r14, %rsi
callq 0x4ef3
leaq 0x7141(%rip), %rsi      # 0xb290
leaq 0x334d(%rip), %rdx      # 0x74a3
leaq 0x170(%rsp), %rdi
callq 0x4ef3
leaq 0x7126(%rip), %rsi      # 0xb290
leaq 0x3347(%rip), %rdx      # 0x74b8
leaq 0x150(%rsp), %rdi
callq 0x4ef3
movq 0x20(%rbx), %rsi
leaq 0x200(%rsp), %rdi
leaq 0x298(%rsp), %rdx
callq 0x4e06
leaq 0x140(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
xorl %ecx, %ecx
movb %cl, (%rax)
leaq 0xd8(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb %cl, (%rax)
leaq 0x108(%rsp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
leaq 0x1d8(%rsp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
leaq 0x32c3(%rip), %rsi      # 0x74c3
leaq 0x78(%rsp), %rdi
leaq 0x298(%rsp), %rdx
callq 0x4e06
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
andq $0x0, 0x10(%rsp)
cmpl $0x7, %r13d
jne 0x42c1
movq 0x30(%rbx), %rsi
leaq 0x298(%rsp), %rdi
pushq $0x8
popq %rdx
callq 0x3410
leaq 0x298(%rsp), %rbx
leaq 0x130(%rsp), %r14
leaq 0xc8(%rsp), %r15
leaq 0x100(%rsp), %r12
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3060
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x42a7
movq %rbx, %rdi
movq %r15, %rsi
callq 0x3060
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x42a7
movq %r12, %rdi
movq %r14, %rsi
callq 0x4f2c
movq %rax, %rdi
movq %r15, %rsi
callq 0x3170
jmp 0x425d
leaq 0x298(%rsp), %rdi
callq 0x3070
leaq 0x298(%rsp), %rdi
callq 0x30a0
movq 0x200(%rsp), %rsi
leaq 0x298(%rsp), %rdi
leaq 0x4a0(%rsp), %rdx
callq 0x4e06
leaq 0x220(%rsp), %rdi
leaq 0x298(%rsp), %rsi
callq 0x5d16
leaq 0x298(%rsp), %r14
movq %r14, %rdi
callq 0x3478
leaq 0x230(%rsp), %r12
movq 0x10(%r12), %rax
leaq 0x1b0(%rsp), %r15
leaq 0x278(%rsp), %rbx
cmpq %r12, %rax
je 0x47f0
leaq 0x20(%rax), %rsi
leaq 0x130(%rsp), %rdi
movq %rax, %rbp
callq 0x3170
leaq 0x40(%rbp), %rsi
leaq 0xc8(%rsp), %rdi
callq 0x3170
movq %rbp, 0x20(%rsp)
movq %r14, %rdi
leaq 0x31fb(%rip), %rsi      # 0x7558
leaq 0x4a0(%rsp), %rdx
callq 0x4e06
leaq 0xe8(%rsp), %rdi
leaq 0x130(%rsp), %rsi
movq %r14, %rdx
callq 0x35dc
movq %r14, %rdi
callq 0x3478
movq 0xe8(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0x4f92
testb %al, %al
je 0x4413
movq %r14, %rdx
movq %r13, %r14
movq %r15, %rdi
leaq 0x2c76(%rip), %rsi      # 0x7026
movq %rdx, %rbp
callq 0x4e06
xorl %r12d, %r12d
xorl %r13d, %r13d
movq (%rsp), %rax
movq 0x8(%rsp), %rcx
subq %rax, %rcx
sarq $0x5, %rcx
cmpq %r13, %rcx
jbe 0x4428
movq 0x8(%rax,%r12), %rdx
cmpq $0x7a3ab, %rdx          # imm = 0x7A3AB
jb 0x43fc
addq %r12, %rax
addq $-0x12c, %rdx           # imm = 0xFED4
movl $0x96, %esi
movq %rax, %rdi
callq 0x3080
movq (%rsp), %rax
addq %r12, %rax
movq %r15, %rdi
movq %rax, %rsi
callq 0x3440
incq %r13
addq $0x20, %r12
jmp 0x43be
movq %rsp, %rdi
leaq 0xc8(%rsp), %rsi
callq 0x4fa4
jmp 0x47d4
movq 0x190(%rsp), %rsi
movq %rbp, %rdi
pushq $0x10
popq %rdx
callq 0x3270
movq %rbp, %rdi
leaq 0x78(%rsp), %rsi
callq 0x3200
movq %r14, %r13
movq %rbp, %r14
movq %rax, %rdi
callq 0x3130
movq %r14, %rdi
movq %r15, %rsi
callq 0x3200
movq %rax, %rdi
callq 0x3130
movq %r14, %rdi
callq 0x3320
movq 0x170(%rsp), %rsi
movq %r14, %rdi
pushq $0x10
popq %rdx
callq 0x3040
movq 0x118(%rsp), %r12
leaq 0x108(%rsp), %rax
cmpq %rax, %r12
je 0x44d0
leaq 0x20(%r12), %rsi
movq %r14, %rdi
callq 0x3200
movq %rax, %rdi
callq 0x3130
leaq 0x40(%r12), %rsi
movq %rax, %rdi
callq 0x3200
movq %rax, %rdi
callq 0x3130
movq %r12, %rdi
callq 0x3190
movq %rax, %r12
jmp 0x448c
movq %r14, %rdi
callq 0x3320
movq %rsp, %r12
movq %r12, %rdi
callq 0x4f9c
movq %r12, %rdi
leaq 0xc8(%rsp), %rsi
callq 0x4fa4
leaq 0x98(%rsp), %rbp
movq %rbp, %rdi
leaq 0x2b21(%rip), %rsi      # 0x7026
leaq 0x40(%rsp), %rdx
callq 0x4e06
leaq 0x4a0(%rsp), %r12
movq %r12, %rdi
movq %rbp, %rsi
pushq $0x10
popq %rdx
callq 0x3300
movq %rbp, %rdi
callq 0x3478
movq %r12, %rdi
leaq 0x2fb1(%rip), %rsi      # 0x74e8
callq 0x3220
movl 0x6d06(%rip), %esi      # 0xb248
subl 0x6d04(%rip), %esi      # 0xb24c
movq %rax, %rdi
callq 0x33e0
movq %rax, %rdi
leaq 0x2f9f(%rip), %rsi      # 0x74f9
callq 0x3220
movq %rax, %rdi
leaq 0x190(%rsp), %rsi
callq 0x3200
movq %rax, %rdi
leaq 0x2fdf(%rip), %rsi      # 0x7558
callq 0x3220
movq %rax, %rdi
leaq 0x170(%rsp), %rsi
callq 0x3200
movq %rax, %rdi
leaq 0x2fc0(%rip), %rsi      # 0x7558
callq 0x3220
movq %rax, %rdi
leaq 0x150(%rsp), %rsi
callq 0x3200
leaq 0x98(%rsp), %r12
movq %r12, %rdi
leaq 0x4a8(%rsp), %rsi
callq 0x33b0
leaq 0x618(%rsp), %rbp
movq %rbp, %rdi
movq %r12, %rsi
callq 0x36d5
movq %rbp, %rdi
callq 0x3478
movq %r12, %rdi
callq 0x3478
leaq 0x60(%rsp), %rdi
leaq 0x150(%rsp), %rsi
callq 0x37ed
movq 0x1b8(%rsp), %rsi
leaq 0x50(%rsp), %rax
movq %rax, 0x40(%rsp)
leaq 0x40(%rsp), %rdi
pushq $0x30
popq %rdx
callq 0x3280
movq 0x60(%rsp), %rcx
xorl %eax, %eax
movq 0x68(%rsp), %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
cmpq %rax, %rdx
jbe 0x4657
movslq (%rcx,%rax,8), %rdx
movslq 0x4(%rcx,%rax,8), %rsi
cmpq %rsi, %rdx
jge 0x4652
movq 0x40(%rsp), %rcx
movb $0x31, (%rcx,%rdx)
incq %rdx
movq 0x60(%rsp), %rcx
jmp 0x4635
incq %rax
jmp 0x4620
leaq 0x28(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x3a0a
xorl %r12d, %r12d
movq 0x30(%rsp), %rax
subq 0x28(%rsp), %rax
sarq $0x3, %rax
cmpq %r12, %rax
jbe 0x4747
movslq 0x6bc1(%rip), %rax      # 0xb248
cmpq %rax, 0x1b8(%rsp)
jb 0x473f
leaq 0x258(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0x32f0
movq %rbx, %rdi
movq %r15, %rsi
callq 0x32f0
movq 0x28(%rsp), %rax
movl (%rax,%r12,8), %ecx
movl 0x4(%rax,%r12,8), %r8d
movl 0x6b89(%rip), %r9d      # 0xb250
leaq 0x98(%rsp), %rdi
leaq 0x258(%rsp), %rbp
movq %rbp, %rsi
movq %rbx, %rdx
callq 0x3ac2
movq %rbx, %rdi
callq 0x3478
movq %rbp, %rdi
callq 0x3478
movq 0xb0(%rsp), %rsi
leaq 0x100(%rsp), %rdi
leaq 0xa0(%rsp), %rdx
callq 0x589e
cmpl $0x6, %r13d
jne 0x4732
movq 0xb0(%rsp), %rsi
leaq 0x1d0(%rsp), %rdi
leaq 0xa0(%rsp), %rdx
callq 0x589e
leaq 0x98(%rsp), %rdi
callq 0x4fe8
incq %r12
jmp 0x4669
movq 0xe8(%rsp), %rsi
leaq 0x78(%rsp), %rdi
callq 0x3170
movq 0x128(%rsp), %rsi
movq 0x6888(%rip), %rdi      # 0xaff0
callq 0x3180
movq %rax, %rdi
leaq 0x2da3(%rip), %rsi      # 0x751a
callq 0x3220
movq %rax, %rdi
leaq 0x78(%rsp), %rsi
callq 0x3200
movq %rax, %rdi
callq 0x3130
leaq 0x28(%rsp), %rdi
callq 0x531a
leaq 0x40(%rsp), %rdi
callq 0x3478
leaq 0x60(%rsp), %rdi
callq 0x531a
leaq 0x4a0(%rsp), %rdi
callq 0x3090
movq %r14, %rdi
callq 0x3350
movq %r15, %rdi
callq 0x3478
leaq 0x230(%rsp), %r12
leaq 0xe8(%rsp), %rdi
callq 0x4e42
movq 0x20(%rsp), %rdi
callq 0x3190
jmp 0x4320
cmpl $0x6, %r13d
jne 0x484b
movq 0x1e8(%rsp), %r14
movq 0x67cb(%rip), %rbx      # 0xafd0
leaq 0x1d8(%rsp), %r15
cmpq %r15, %r14
je 0x489c
leaq 0x20(%r14), %rsi
movq %rbx, %rdi
callq 0x3200
movq %rax, %rdi
callq 0x3130
leaq 0x40(%r14), %rsi
movq %rax, %rdi
callq 0x3200
movq %rax, %rdi
callq 0x3130
movq %r14, %rdi
callq 0x3190
movq %rax, %r14
jmp 0x480d
movq 0x118(%rsp), %r14
movq 0x6776(%rip), %rbx      # 0xafd0
leaq 0x108(%rsp), %rax
cmpq %rax, %r14
je 0x489c
leaq 0x20(%r14), %rsi
movq %rbx, %rdi
callq 0x3200
movq %rax, %rdi
callq 0x3130
leaq 0x40(%r14), %rsi
movq %rax, %rdi
callq 0x3200
movq %rax, %rdi
callq 0x3130
movq %r14, %rdi
callq 0x3190
movq %rax, %r14
jmp 0x485a
leaq 0x220(%rsp), %rdi
callq 0x61ec
movq %rsp, %rdi
callq 0x4e42
leaq 0x78(%rsp), %rdi
callq 0x3478
leaq 0x1d0(%rsp), %rdi
callq 0x4fe8
leaq 0x100(%rsp), %rdi
callq 0x4fe8
leaq 0xc8(%rsp), %rdi
callq 0x3478
leaq 0x130(%rsp), %rdi
callq 0x3478
leaq 0x200(%rsp), %rdi
callq 0x3478
leaq 0x150(%rsp), %rdi
callq 0x3478
leaq 0x170(%rsp), %rdi
callq 0x3478
leaq 0x190(%rsp), %rdi
callq 0x3478
xorl %eax, %eax
addq $0x638, %rsp            # imm = 0x638
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x6692(%rip), %rdi      # 0xafd0
leaq 0x2712(%rip), %rsi      # 0x7057
callq 0x3220
movq %rax, %r14
movq (%rbx), %rdi
callq 0x3340
movq %r14, %rdi
movq %rax, %rsi
callq 0x3220
leaq 0x26fb(%rip), %rsi      # 0x7062
movq %rax, %rdi
callq 0x3220
movq %rax, %rdi
callq 0x3130
movq 0x6652(%rip), %rdi      # 0xafd0
leaq 0x2731(%rip), %rsi      # 0x70b6
callq 0x3220
leaq 0x2771(%rip), %rsi      # 0x7102
movq %rax, %rdi
callq 0x3220
leaq 0x27fa(%rip), %rsi      # 0x719a
movq %rax, %rdi
callq 0x3220
leaq 0x2872(%rip), %rsi      # 0x7221
movq %rax, %rdi
callq 0x3220
leaq 0x28ca(%rip), %rsi      # 0x7288
movq %rax, %rdi
callq 0x3220
movq %rax, %r14
movq (%rbx), %rdi
callq 0x3340
movq %r14, %rdi
movq %rax, %rsi
callq 0x3220
leaq 0x28d9(%rip), %rsi      # 0x72bc
movq %rax, %rdi
callq 0x3220
leaq 0x28e2(%rip), %rsi      # 0x72d4
movq %rax, %rdi
callq 0x3220
leaq 0x2941(%rip), %rsi      # 0x7342
movq %rax, %rdi
callq 0x3220
movq %rax, %rdi
callq 0x3130
movq 0x65b8(%rip), %rdi      # 0xafd0
leaq 0x298d(%rip), %rsi      # 0x73ac
callq 0x3220
movq %rax, %rdi
callq 0x3130
pushq $0x1
popq %rdi
callq 0x32a0
jmp 0x4b27
jmp 0x4a53
movq %rdx, %rbx
movq %rax, %r14
leaq 0x298(%rsp), %rdi
callq 0x3478
jmp 0x4c0e
movq %rdx, %rbx
movq %rax, %r14
jmp 0x4c0e
jmp 0x4aa1
movq %rdx, %rbx
movq %rax, %r14
jmp 0x4c20
movq %rdx, %rbx
movq %rax, %r14
jmp 0x4c61
movq %rdx, %rbx
movq %rax, %r14
jmp 0x4c6e
movq %rdx, %rbx
movq %rax, %r14
jmp 0x4c7b
jmp 0x4aa1
movq %rdx, %rbx
movq %rax, %r14
leaq 0x4a0(%rsp), %rdi
jmp 0x4c83
movq %rdx, %rbx
movq %rax, %r14
jmp 0x4c88
movq %rdx, %rbx
movq %rax, %r14
leaq 0x98(%rsp), %rdi
callq 0x3478
jmp 0x4bbd
movq %rdx, %rbx
movq %rax, %r14
jmp 0x4bb3
jmp 0x4bd4
jmp 0x4b50
jmp 0x4b50
movq %rdx, %rbx
movq %rax, %r14
jmp 0x4ba9
movq %rdx, %rbx
movq %rax, %r14
leaq 0x98(%rsp), %rdi
callq 0x3478
jmp 0x4bda
jmp 0x4bcc
jmp 0x4b02
movq %rdx, %rbx
movq %rax, %r14
jmp 0x4bf4
jmp 0x4b43
movq %rdx, %rbx
movq %rax, %r14
leaq 0x298(%rsp), %rdi
callq 0x3478
jmp 0x4c01
movq %rdx, %rbx
movq %rax, %r14
leaq 0x298(%rsp), %rdi
callq 0x30a0
jmp 0x4c0e
jmp 0x4b43
jmp 0x4b43
movq %rdx, %rbx
movq %rax, %r14
jmp 0x4c01
jmp 0x4b5a
movq %rdx, %rbx
movq %rax, %r14
jmp 0x4bbd
jmp 0x4bd4
movq %rdx, %rbx
movq %rax, %r14
jmp 0x4b9f
movq %rdx, %rbx
movq %rax, %r14
leaq 0x278(%rsp), %rdi
callq 0x3478
jmp 0x4b7d
movq %rdx, %rbx
movq %rax, %r14
leaq 0x258(%rsp), %rdi
callq 0x3478
jmp 0x4b9f
movq %rdx, %rbx
movq %rax, %r14
leaq 0x98(%rsp), %rdi
callq 0x4fe8
leaq 0x28(%rsp), %rdi
callq 0x531a
leaq 0x40(%rsp), %rdi
callq 0x3478
leaq 0x60(%rsp), %rdi
callq 0x531a
leaq 0x4a0(%rsp), %rdi
callq 0x3090
jmp 0x4bda
movq %rdx, %rbx
movq %rax, %r14
jmp 0x4be7
movq %rdx, %rbx
movq %rax, %r14
leaq 0x298(%rsp), %rdi
callq 0x3350
leaq 0x1b0(%rsp), %rdi
callq 0x3478
leaq 0xe8(%rsp), %rdi
callq 0x4e42
leaq 0x220(%rsp), %rdi
callq 0x61ec
movq %rsp, %rdi
callq 0x4e42
leaq 0x78(%rsp), %rdi
callq 0x3478
leaq 0x1d0(%rsp), %rdi
callq 0x4fe8
leaq 0x100(%rsp), %rdi
callq 0x4fe8
leaq 0xc8(%rsp), %rdi
callq 0x3478
leaq 0x130(%rsp), %rdi
callq 0x3478
leaq 0x200(%rsp), %rdi
callq 0x3478
leaq 0x150(%rsp), %rdi
callq 0x3478
leaq 0x170(%rsp), %rdi
callq 0x3478
leaq 0x190(%rsp), %rdi
callq 0x3478
cmpl $0x3, %ebx
jne 0x4d11
movq %r14, %rdi
callq 0x32c0
leaq 0x298(%rsp), %rdi
movq %rax, %rsi
callq 0x635c
movq %r14, %rdi
callq 0x3100
movq 0x6338(%rip), %rdi      # 0xaff0
leaq 0x2888(%rip), %rsi      # 0x7547
callq 0x3220
movq %rax, %rbx
leaq 0x4a0(%rsp), %r14
leaq 0x298(%rsp), %rsi
movq %r14, %rdi
callq 0x64ae
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3200
movq %rax, %rdi
callq 0x3130
leaq 0x4a0(%rsp), %rdi
callq 0x3478
leaq 0x298(%rsp), %rdi
callq 0x4fd0
jmp 0x4da1
cmpl $0x2, %ebx
jne 0x4d7e
movq %r14, %rdi
callq 0x32c0
movq 0x62a3(%rip), %rax      # 0xafc8
addq $0x10, %rax
movq %rax, 0x298(%rsp)
movq %r14, %rdi
callq 0x3100
movq 0x62b0(%rip), %rdi      # 0xaff0
leaq 0x2800(%rip), %rsi      # 0x7547
callq 0x3220
movq %rax, %rbx
leaq 0x298(%rsp), %rdi
callq 0x3450
movq %rbx, %rdi
movq %rax, %rsi
callq 0x3220
movq %rax, %rdi
callq 0x3130
leaq 0x298(%rsp), %rdi
callq 0x3460
jmp 0x4da1
movq %r14, %rdi
callq 0x3100
movq 0x6263(%rip), %rdi      # 0xaff0
leaq 0x2794(%rip), %rsi      # 0x7528
callq 0x3220
movq %rax, %rdi
callq 0x3130
callq 0x33c0
pushq $0x1
popq %rax
jmp 0x4925
movq %rax, %rbx
callq 0x33c0
jmp 0x4df6
movq %rax, %rbx
jmp 0x4de4
movq %rax, %rbx
leaq 0x298(%rsp), %rdi
callq 0x3460
callq 0x33c0
jmp 0x4df6
movq %rax, %rbx
leaq 0x4a0(%rsp), %rdi
callq 0x3478
leaq 0x298(%rsp), %rdi
callq 0x4fd0
callq 0x33c0
movq %rbx, %rdi
callq 0x33f0
movq %rax, %rdi
callq 0x4e63