// File: /workspace/github_cpp_makefile_star2_O1/schneebergerlab[P]DrLink/DrLink_v1.sp.cpp
// Function: main
int main(int argc, char* argv[])
{
    if(argc < 2)
    {
        cout << endl;
        cout << "   Given linked-read sequencing of recombinants, this tool identifies meiotic recombinations." << endl;
        const char *buildString = __DATE__ ", " __TIME__ "";
        cout << "   (version 1.0 - compiled on " << buildString << ")"                   << endl  << endl;
        cout << "   Usage: DrLink subprogram [options] "                                          << endl;
        cout << "\n   Subprograms: "                                                              << endl;
        cout << "   \tpreprocess \t(Usage: please check options with DrLink preprocess)"          << endl;  
        cout << "   \tmolecule   \t(Usage: please check options with DrLink molecule)"            << endl;
        cout << "   \trecombis   \t(Usage: please check options with DrLink recombis)"            << endl;
        cout << "   \tintersec   \t(Usage: please check options with DrLink intersec)"    << endl << endl;        
        exit(1);
    }
    double startT= clock();
    string subprogram = (string)argv[1];
    // step 1. select info from bam with samtools view
    if(subprogram.compare("preprocess")==0 && !convertBam(argc, argv))
    {
        if(argc < 4)
        {
            cout << "\n   Info: not enough inputs. "          << endl << endl;
        }
        else
        {
            cout << "   Error: no bam info coverted - please check you bam file with BX? " << endl << endl;
        }
        return false;
    }
    // step 2. analyze molecules with the selected information
    if(subprogram.compare("molecule")==0 && !analyze_molecule(argc, argv))
    {
        if(argc < 6) 
        {
            cout << "\n   Info: not enough inputs. "          << endl << endl;
        }
        else
        {
            cout << "   Error: failed in molecule analysis. " << endl << endl;
        }
        return false;
    }   
    // step 3. detect recombination sites with vcf and known markers
    if(subprogram.compare("recombis")==0 && !detect_recombsite(argc, argv))
    {
        if(argc < 13) 
        {
            cout << "\n   Info: not enough inputs. "          << endl << endl;
        }
        else
        {
            cout << "   Error: failed in recombination site detection. " << endl << endl;
        }
        return false;
    }     
    // func 4. find intersection of two sets of recombination site predictions
    if(subprogram.compare("intersec")==0 && !find_intersection(argc, argv))
    {
        if(argc < 7) 
        {
            cout << "\n   Info: not enough inputs. "          << endl << endl;
        }
        else
        {
            cout << "   Error: failed in finding intersection of the two predictions. " << endl << endl;
        }
        return false;
    }
    // func 5. sample molecules according to molecule size distribution (for >=2 pools)
    if(subprogram.compare("resample")==0 && !sample_molecule(argc, argv))
    {
        if(argc < 7) 
        {
            cout << "\n   Info: not enough inputs. "          << endl << endl;
        }
        else
        {
            cout << "   Error: failed in sampling molecules. " << endl << endl;
        }
        return false;
    }    
    // func 6. sample molecules - with both size and base coverage
    if(subprogram.compare("separate_kb")==0 && !separate_kb_molecule(argc, argv))
    {
        if(argc < 5) 
        {
            cout << "\n   Info: not enough inputs. "          << endl << endl;
        }
        else
        {
            cout << "   Error: failed in sampling molecules. " << endl << endl;
        }
        return false;
    }  
    // func 7. sample molecules according to base coverage distribution for 1kb,2kb,...
    if(subprogram.compare("resample_v2")==0 && !sample_molecule_v2(argc, argv))
    {
        if(argc < 8)
        {
            cout << "\n   Info: not enough inputs. "          << endl << endl;
        }
        else
        {
            cout << "   Error: failed in sampling molecules. " << endl << endl;
        }
        return false;
    }        
    //
    //
    double finishT= clock();
    cout << "   Time consumed: " << (finishT-startT)/1000000 << " seconds" << endl << endl;
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x28, %rsp
cmpl $0x1, %edi
jle 0x521e
movq %rsi, %r14
movl %edi, %ebp
callq 0x4200
movq %rax, %rbx
movq 0x8(%r14), %rsi
leaq 0x8(%rsp), %r15
leaq 0x7(%rsp), %rdx
movq %r15, %rdi
callq 0x5346
leaq 0x35751(%rip), %rsi     # 0x3a1ea
movq %r15, %rdi
callq 0x4100
testl %eax, %eax
jne 0x4ab7
movl %ebp, %edi
movq %r14, %rsi
callq 0x5414
testb %al, %al
je 0x4c50
leaq 0x39bfc(%rip), %rsi     # 0x3e6ba
leaq 0x8(%rsp), %rdi
callq 0x4100
testl %eax, %eax
jne 0x4ade
movl %ebp, %edi
movq %r14, %rsi
callq 0x6d1c
testb %al, %al
je 0x4cbb
leaq 0x3579b(%rip), %rsi     # 0x3a280
leaq 0x8(%rsp), %rdi
callq 0x4100
testl %eax, %eax
jne 0x4b05
movl %ebp, %edi
movq %r14, %rsi
callq 0xf274
testb %al, %al
je 0x4d26
leaq 0x357b0(%rip), %rsi     # 0x3a2bc
leaq 0x8(%rsp), %rdi
callq 0x4100
testl %eax, %eax
jne 0x4b2c
movl %ebp, %edi
movq %r14, %rsi
callq 0x22d0c
testb %al, %al
je 0x4d91
leaq 0x357d4(%rip), %rsi     # 0x3a307
leaq 0x8(%rsp), %rdi
callq 0x4100
testl %eax, %eax
jne 0x4b53
movl %ebp, %edi
movq %r14, %rsi
callq 0x25fd0
testb %al, %al
je 0x4e5e
leaq 0x39c43(%rip), %rsi     # 0x3e79d
leaq 0x8(%rsp), %rdi
callq 0x4100
testl %eax, %eax
jne 0x4b7a
movl %ebp, %edi
movq %r14, %rsi
callq 0x335ac
testb %al, %al
je 0x4f2b
leaq 0x357b8(%rip), %rsi     # 0x3a339
leaq 0x8(%rsp), %rdi
callq 0x4100
testl %eax, %eax
jne 0x4ba1
movl %ebp, %edi
movq %r14, %rsi
callq 0x2b830
testb %al, %al
je 0x4ff8
callq 0x4200
movq %rax, %r14
movq 0x47418(%rip), %rdi     # 0x4bfc8
leaq 0x3578e(%rip), %rsi     # 0x3a345
movl $0x12, %edx
callq 0x43a0
cvtsi2sd %rbx, %xmm1
cvtsi2sd %r14, %xmm0
subsd %xmm1, %xmm0
divsd 0x35431(%rip), %xmm0    # 0x3a008
movq 0x473ea(%rip), %rdi     # 0x4bfc8
callq 0x4510
movq %rax, %rbx
leaq 0x3576b(%rip), %rsi     # 0x3a358
movl $0x8, %edx
movq %rax, %rdi
callq 0x43a0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4310
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x4220
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4310
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x4220
jmp 0x51f6
cmpl $0x3, %ebp
jg 0x4dfc
movq 0x47368(%rip), %rbx     # 0x4bfc8
leaq 0x3558e(%rip), %rsi     # 0x3a1f5
movl $0x1d, %edx
movq %rbx, %rdi
callq 0x43a0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x4310
movsbl %al, %esi
movq 0x47336(%rip), %rdi     # 0x4bfc8
callq 0x4030
movq %rax, %rdi
callq 0x4220
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4310
jmp 0x51e3
cmpl $0x5, %ebp
jg 0x4ec9
movq 0x472fd(%rip), %rbx     # 0x4bfc8
leaq 0x35523(%rip), %rsi     # 0x3a1f5
movl $0x1d, %edx
movq %rbx, %rdi
callq 0x43a0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x4310
movsbl %al, %esi
movq 0x472cb(%rip), %rdi     # 0x4bfc8
callq 0x4030
movq %rax, %rdi
callq 0x4220
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4310
jmp 0x51e3
cmpl $0xc, %ebp
jg 0x4f96
movq 0x47292(%rip), %rbx     # 0x4bfc8
leaq 0x354b8(%rip), %rsi     # 0x3a1f5
movl $0x1d, %edx
movq %rbx, %rdi
callq 0x43a0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x4310
movsbl %al, %esi
movq 0x47260(%rip), %rdi     # 0x4bfc8
callq 0x4030
movq %rax, %rdi
callq 0x4220
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4310
jmp 0x51e3
cmpl $0x6, %ebp
jg 0x5063
movq 0x47227(%rip), %rbx     # 0x4bfc8
leaq 0x3544d(%rip), %rsi     # 0x3a1f5
movl $0x1d, %edx
movq %rbx, %rdi
callq 0x43a0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x4310
movsbl %al, %esi
movq 0x471f5(%rip), %rdi     # 0x4bfc8
callq 0x4030
movq %rax, %rdi
callq 0x4220
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4310
jmp 0x51e3
movq 0x471c5(%rip), %rbx     # 0x4bfc8
leaq 0x35409(%rip), %rsi     # 0x3a213
movl $0x44, %edx
movq %rbx, %rdi
callq 0x43a0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x4310
movsbl %al, %esi
movq 0x47193(%rip), %rdi     # 0x4bfc8
callq 0x4030
movq %rax, %rdi
callq 0x4220
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4310
jmp 0x51e3
cmpl $0x6, %ebp
jg 0x50c5
movq 0x4715a(%rip), %rbx     # 0x4bfc8
leaq 0x35380(%rip), %rsi     # 0x3a1f5
movl $0x1d, %edx
movq %rbx, %rdi
callq 0x43a0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x4310
movsbl %al, %esi
movq 0x47128(%rip), %rdi     # 0x4bfc8
callq 0x4030
movq %rax, %rdi
callq 0x4220
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4310
jmp 0x51e3
movq 0x470f8(%rip), %rbx     # 0x4bfc8
leaq 0x35381(%rip), %rsi     # 0x3a258
movl $0x27, %edx
movq %rbx, %rdi
callq 0x43a0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x4310
movsbl %al, %esi
movq 0x470c6(%rip), %rdi     # 0x4bfc8
callq 0x4030
movq %rax, %rdi
callq 0x4220
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4310
jmp 0x51e3
cmpl $0x4, %ebp
jg 0x5127
movq 0x4708d(%rip), %rbx     # 0x4bfc8
leaq 0x352b3(%rip), %rsi     # 0x3a1f5
movl $0x1d, %edx
movq %rbx, %rdi
callq 0x43a0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x4310
movsbl %al, %esi
movq 0x4705b(%rip), %rdi     # 0x4bfc8
callq 0x4030
movq %rax, %rdi
callq 0x4220
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4310
jmp 0x51e3
movq 0x4702b(%rip), %rbx     # 0x4bfc8
leaq 0x352e5(%rip), %rsi     # 0x3a289
movl $0x32, %edx
movq %rbx, %rdi
callq 0x43a0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x4310
movsbl %al, %esi
movq 0x46ff9(%rip), %rdi     # 0x4bfc8
callq 0x4030
movq %rax, %rdi
callq 0x4220
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4310
jmp 0x51e3
cmpl $0x7, %ebp
jg 0x5186
movq 0x46fc0(%rip), %rbx     # 0x4bfc8
leaq 0x351e6(%rip), %rsi     # 0x3a1f5
movl $0x1d, %edx
movq %rbx, %rdi
callq 0x43a0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x4310
movsbl %al, %esi
movq 0x46f8e(%rip), %rdi     # 0x4bfc8
callq 0x4030
movq %rax, %rdi
callq 0x4220
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4310
jmp 0x51e3
movq 0x46f5e(%rip), %rbx     # 0x4bfc8
leaq 0x35254(%rip), %rsi     # 0x3a2c5
movl $0x41, %edx
movq %rbx, %rdi
callq 0x43a0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x4310
movsbl %al, %esi
movq 0x46f2c(%rip), %rdi     # 0x4bfc8
callq 0x4030
movq %rax, %rdi
callq 0x4220
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4310
jmp 0x51e3
movq 0x46efc(%rip), %rbx     # 0x4bfc8
leaq 0x3523d(%rip), %rsi     # 0x3a310
movl $0x28, %edx
movq %rbx, %rdi
callq 0x43a0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x4310
movsbl %al, %esi
movq 0x46eca(%rip), %rdi     # 0x4bfc8
callq 0x4030
movq %rax, %rdi
callq 0x4220
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4310
jmp 0x51e3
movq 0x46e9a(%rip), %rbx     # 0x4bfc8
leaq 0x351db(%rip), %rsi     # 0x3a310
movl $0x28, %edx
movq %rbx, %rdi
callq 0x43a0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x4310
movsbl %al, %esi
movq 0x46e68(%rip), %rdi     # 0x4bfc8
callq 0x4030
movq %rax, %rdi
callq 0x4220
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4310
jmp 0x51e3
movq 0x46e3b(%rip), %rbx     # 0x4bfc8
leaq 0x3517c(%rip), %rsi     # 0x3a310
movl $0x28, %edx
movq %rbx, %rdi
callq 0x43a0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x4310
movsbl %al, %esi
movq 0x46e09(%rip), %rdi     # 0x4bfc8
callq 0x4030
movq %rax, %rdi
callq 0x4220
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4310
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x4220
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x5211
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x4340
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq 0x46da3(%rip), %rbx     # 0x4bfc8
movq %rbx, %rdi
callq 0x41a0
leaq 0x34ddc(%rip), %rsi     # 0x3a010
movq %rbx, %rdi
callq 0x4320
movq %rax, %rdi
callq 0x41a0
leaq 0x34e39(%rip), %rsi     # 0x3a084
movq %rbx, %rdi
callq 0x4320
leaq 0x34e14(%rip), %rsi     # 0x3a06e
movq %rax, %rdi
callq 0x4320
leaq 0x390d7(%rip), %rsi     # 0x3e340
movq %rax, %rdi
callq 0x4320
movq %rax, %rdi
callq 0x41a0
movq %rax, %rdi
callq 0x41a0
leaq 0x34e1b(%rip), %rsi     # 0x3a0a3
movq %rbx, %rdi
callq 0x4320
movq %rax, %rdi
callq 0x41a0
leaq 0x34e2b(%rip), %rsi     # 0x3a0ca
movq %rbx, %rdi
callq 0x4320
movq %rax, %rdi
callq 0x41a0
leaq 0x34e26(%rip), %rsi     # 0x3a0dc
movq %rbx, %rdi
callq 0x4320
movq %rax, %rdi
callq 0x41a0
leaq 0x34e54(%rip), %rsi     # 0x3a121
movq %rbx, %rdi
callq 0x4320
movq %rax, %rdi
callq 0x41a0
leaq 0x34e80(%rip), %rsi     # 0x3a164
movq %rbx, %rdi
callq 0x4320
movq %rax, %rdi
callq 0x41a0
leaq 0x34eac(%rip), %rsi     # 0x3a1a7
movq %rbx, %rdi
callq 0x4320
movq %rax, %rdi
callq 0x41a0
movq %rax, %rdi
callq 0x41a0
movl $0x1, %edi
callq 0x43d0
jmp 0x531f
movq %rax, %rbx
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x533d
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x4340
movq %rbx, %rdi
callq 0x45a0
nop