// File: /workspace/github_cpp_makefile_star2_O1/zeeev[P]DASVC/bamtools/src/toolkit/bamtools_coverage.cpp
// Function: BamTools::CoverageTool::CoverageToolPrivate::Run()
bool CoverageTool::CoverageToolPrivate::Run(void) {  
  
    // if output filename given
    ofstream outFile;
    if ( m_settings->HasOutputFile ) {
      
        // open output file stream
        outFile.open(m_settings->OutputFilename.c_str());
        if ( !outFile ) {
            cerr << "bamtools coverage ERROR: could not open " << m_settings->OutputFilename
                 << " for output" << endl;
            return false; 
        }
        
        // set m_out to file's streambuf
        m_out.rdbuf(outFile.rdbuf()); 
    } 
    
    //open our BAM reader
    BamReader reader;
    if ( !reader.Open(m_settings->InputBamFilename) ) {
        cerr << "bamtools coverage ERROR: could not open input BAM file: " << m_settings->InputBamFilename << endl;
        return false;
    }

    // retrieve references
    m_references = reader.GetReferenceData();
    
    // set up our output 'visitor'
    CoverageVisitor* cv = new CoverageVisitor(m_references, &m_out);
    
    // set up pileup engine with 'visitor'
    PileupEngine pileup;
    pileup.AddVisitor(cv);
    
    // process input data
    BamAlignment al;    
    while ( reader.GetNextAlignment(al) ) 
        pileup.AddAlignment(al);
    pileup.Flush();
    
    // clean up 
    reader.Close();
    if ( m_settings->HasOutputFile )
        outFile.close();
    delete cv;
    cv = 0;
    
    // return success
    return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x368, %rsp            # imm = 0x368
movq %rdi, %r14
leaq 0x10(%rsp), %rdi
callq 0x27aa0
movq (%r14), %rax
cmpb $0x1, 0x1(%rax)
jne 0x30ef8
movq 0x28(%rax), %rsi
leaq 0x10(%rsp), %rdi
movl $0x10, %edx
callq 0x27080
movq 0x10(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x30(%rsp,%rax)
je 0x30ee2
movq 0x5f16b(%rip), %rdi     # 0x8ffe0
leaq 0x41bdd(%rip), %rsi     # 0x72a59
movl $0x28, %edx
callq 0x276c0
movq (%r14), %rax
movq 0x28(%rax), %rsi
movq 0x30(%rax), %rdx
movq 0x5f148(%rip), %rdi     # 0x8ffe0
callq 0x276c0
movq %rax, %rbx
leaq 0x413d7(%rip), %rsi     # 0x7227e
movl $0xb, %edx
movq %rax, %rdi
callq 0x276c0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x27590
movsbl %al, %esi
movq %rbx, %rdi
callq 0x27040
movq %rax, %rdi
callq 0x27410
xorl %ebx, %ebx
jmp 0x31059
leaq 0x8(%r14), %rdi
movq 0x8(%r14), %rax
addq -0x18(%rax), %rdi
leaq 0x18(%rsp), %rsi
callq 0x27bf0
movq %rsp, %rdi
callq 0x273f0
movq (%r14), %rsi
addq $0x8, %rsi
movq %rsp, %rdi
callq 0x277a0
movl %eax, %ebx
testb %al, %al
je 0x30fb1
movq %rsp, %rdi
callq 0x27090
leaq 0x118(%r14), %r12
movq %r12, %rdi
movq %rax, %rsi
callq 0x2e1f8
movl $0x28, %edi
callq 0x275c0
movq %rax, %r15
leaq 0x5e849(%rip), %rax     # 0x8f790
movq %rax, (%r15)
movq %r15, %rdi
addq $0x8, %rdi
movq %r12, %rsi
callq 0x2f04c
leaq 0x8(%r14), %rax
movq %rax, 0x20(%r15)
leaq 0x8(%rsp), %rdi
callq 0x658e6
leaq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x6596a
leaq 0x210(%rsp), %rdi
callq 0x27220
movq %rsp, %r12
leaq 0x210(%rsp), %r13
leaq 0x8(%rsp), %rbp
movq %r12, %rdi
movq %r13, %rsi
callq 0x27990
testb %al, %al
je 0x3100c
movq %rbp, %rdi
movq %r13, %rsi
callq 0x65962
jmp 0x30f95
movq 0x5f028(%rip), %rdi     # 0x8ffe0
leaq 0x41ac3(%rip), %rsi     # 0x72a82
movl $0x38, %edx
callq 0x276c0
movq (%r14), %rax
movq 0x8(%rax), %rsi
movq 0x10(%rax), %rdx
movq 0x5f005(%rip), %rdi     # 0x8ffe0
callq 0x276c0
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x27590
movsbl %al, %esi
movq %r14, %rdi
callq 0x27040
movq %rax, %rdi
callq 0x27410
jmp 0x31051
leaq 0x8(%rsp), %rdi
callq 0x65998
movq %rsp, %rdi
callq 0x270b0
movq (%r14), %rax
cmpb $0x1, 0x1(%rax)
jne 0x31031
leaq 0x10(%rsp), %rdi
callq 0x27850
movq (%r15), %rax
movq %r15, %rdi
callq *0x8(%rax)
leaq 0x210(%rsp), %rdi
callq 0x27930
leaq 0x8(%rsp), %rdi
callq 0x65920
movq %rsp, %rdi
callq 0x27620
leaq 0x10(%rsp), %rdi
callq 0x27890
movl %ebx, %eax
addq $0x368, %rsp            # imm = 0x368
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x31088
movq %rax, %rbx
movq %r15, %rdi
callq 0x27560
jmp 0x310b7
jmp 0x31098
movq %rax, %rbx
jmp 0x310ad
jmp 0x31098
jmp 0x3109d
jmp 0x31093
movq %rax, %rbx
jmp 0x310bf
movq %rax, %rbx
jmp 0x310b7
movq %rax, %rbx
leaq 0x210(%rsp), %rdi
callq 0x27930
leaq 0x8(%rsp), %rdi
callq 0x65920
movq %rsp, %rdi
callq 0x27620
leaq 0x10(%rsp), %rdi
callq 0x27890
movq %rbx, %rdi
callq 0x27b20
movq %rax, %rdi
callq 0x2e1ed
nop