// File: /workspace/github_cpp_makefile_star2_O2/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 %r12
pushq %rbx
subq $0x30, %rsp
cmpl $0x1, %edi
jle 0x4c2a
movq %rsi, %r15
movl %edi, %ebx
callq 0x4220
movq %rax, %r14
movq 0x8(%r15), %rsi
leaq 0x10(%rsp), %r12
leaq 0xf(%rsp), %rdx
movq %r12, %rdi
callq 0x4d3e
leaq 0x247af(%rip), %rsi     # 0x291ea
movq %r12, %rdi
callq 0x4110
testl %eax, %eax
jne 0x4a59
movl %ebx, %edi
movq %r15, %rsi
callq 0x4e10
testb %al, %al
je 0x4ba0
leaq 0x28c52(%rip), %rsi     # 0x2d6b2
leaq 0x10(%rsp), %rdi
callq 0x4110
testl %eax, %eax
jne 0x4a80
movl %ebx, %edi
movq %r15, %rsi
callq 0x5eb4
testb %al, %al
je 0x4bab
leaq 0x247f9(%rip), %rsi     # 0x29280
leaq 0x10(%rsp), %rdi
callq 0x4110
testl %eax, %eax
jne 0x4aa7
movl %ebx, %edi
movq %r15, %rsi
callq 0xb6ec
testb %al, %al
je 0x4bb6
leaq 0x2480e(%rip), %rsi     # 0x292bc
leaq 0x10(%rsp), %rdi
callq 0x4110
pushq $0x7
popq %rbp
testl %eax, %eax
jne 0x4ad1
movl %ebx, %edi
movq %r15, %rsi
callq 0x1874c
testb %al, %al
je 0x4bc1
leaq 0x2482f(%rip), %rsi     # 0x29307
leaq 0x10(%rsp), %rdi
callq 0x4110
testl %eax, %eax
jne 0x4af8
movl %ebx, %edi
movq %r15, %rsi
callq 0x1a430
testb %al, %al
je 0x4bca
leaq 0x28c96(%rip), %rsi     # 0x2d795
leaq 0x10(%rsp), %rdi
callq 0x4110
testl %eax, %eax
jne 0x4b1f
movl %ebx, %edi
movq %r15, %rsi
callq 0x243a8
testb %al, %al
je 0x4bd3
leaq 0x24813(%rip), %rsi     # 0x29339
leaq 0x10(%rsp), %rdi
callq 0x4110
testl %eax, %eax
jne 0x4b46
movl %ebx, %edi
movq %r15, %rsi
callq 0x1e4ac
testb %al, %al
je 0x4bde
callq 0x4220
movq %rax, %rbx
movq 0x38473(%rip), %rdi     # 0x3cfc8
leaq 0x247e9(%rip), %rsi     # 0x29345
callq 0x4330
cvtsi2sd %r14, %xmm1
cvtsi2sd %rbx, %xmm0
subsd %xmm1, %xmm0
divsd 0x24491(%rip), %xmm0    # 0x29008
movq %rax, %rdi
callq 0x4510
leaq 0x247d2(%rip), %rsi     # 0x29358
movq %rax, %rdi
callq 0x4330
movq %rax, %rdi
callq 0x41c0
movq %rax, %rdi
callq 0x41c0
jmp 0x4c11
leaq 0x2466c(%rip), %rax     # 0x29213
pushq $0x4
jmp 0x4be7
leaq 0x246a6(%rip), %rax     # 0x29258
pushq $0x6
jmp 0x4be7
leaq 0x246cc(%rip), %rax     # 0x29289
pushq $0xd
jmp 0x4be7
leaq 0x246fd(%rip), %rax     # 0x292c5
jmp 0x4be8
leaq 0x2473f(%rip), %rax     # 0x29310
jmp 0x4be8
leaq 0x24736(%rip), %rax     # 0x29310
pushq $0x5
jmp 0x4be7
leaq 0x2472b(%rip), %rax     # 0x29310
pushq $0x8
popq %rbp
cmpl %ebx, %ebp
leaq 0x24604(%rip), %rsi     # 0x291f5
cmovbeq %rax, %rsi
movq 0x383cc(%rip), %rdi     # 0x3cfc8
callq 0x4330
movq %rax, %rdi
callq 0x41c0
movq %rax, %rdi
callq 0x41c0
leaq 0x10(%rsp), %rdi
callq 0x4638
xorl %eax, %eax
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq 0x38397(%rip), %rbx     # 0x3cfc8
movq %rbx, %rdi
callq 0x41c0
leaq 0x243d0(%rip), %rsi     # 0x29010
movq %rbx, %rdi
callq 0x4330
movq %rax, %rdi
callq 0x41c0
leaq 0x2442d(%rip), %rsi     # 0x29084
movq %rbx, %rdi
callq 0x4330
leaq 0x24408(%rip), %rsi     # 0x2906e
movq %rax, %rdi
callq 0x4330
leaq 0x286c3(%rip), %rsi     # 0x2d338
movq %rax, %rdi
callq 0x4330
movq %rax, %rdi
callq 0x41c0
movq %rax, %rdi
callq 0x41c0
leaq 0x2440f(%rip), %rsi     # 0x290a3
movq %rbx, %rdi
callq 0x4330
movq %rax, %rdi
callq 0x41c0
leaq 0x2441f(%rip), %rsi     # 0x290ca
movq %rbx, %rdi
callq 0x4330
movq %rax, %rdi
callq 0x41c0
leaq 0x2441a(%rip), %rsi     # 0x290dc
movq %rbx, %rdi
callq 0x4330
movq %rax, %rdi
callq 0x41c0
leaq 0x24448(%rip), %rsi     # 0x29121
movq %rbx, %rdi
callq 0x4330
movq %rax, %rdi
callq 0x41c0
leaq 0x24474(%rip), %rsi     # 0x29164
movq %rbx, %rdi
callq 0x4330
movq %rax, %rdi
callq 0x41c0
leaq 0x244a0(%rip), %rsi     # 0x291a7
movq %rbx, %rdi
callq 0x4330
movq %rax, %rdi
callq 0x41c0
movq %rax, %rdi
callq 0x41c0
pushq $0x1
popq %rdi
callq 0x43b0
jmp 0x4d29
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x4638
movq %rbx, %rdi
callq 0x45a0