// File: /workspace/github_cpp_makefile_star2_O2/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 0x35ae0
movq (%r14), %rax
cmpb $0x1, 0x1(%rax)
jne 0x3c6a2
movq 0x28(%rax), %rsi
leaq 0x10(%rsp), %rdi
pushq $0x10
popq %rdx
callq 0x35070
movq 0x10(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x30(%rsp,%rax)
je 0x3c68c
movq 0x5898d(%rip), %rdi     # 0x94fe0
leaq 0x3539b(%rip), %rsi     # 0x719f5
callq 0x355b0
movq (%r14), %rsi
addq $0x28, %rsi
movq %rax, %rdi
callq 0x35510
leaq 0x34c13(%rip), %rsi     # 0x71288
movq %rax, %rdi
callq 0x355b0
movq %rax, %rdi
callq 0x35300
xorl %ebx, %ebx
jmp 0x3c7c0
leaq 0x8(%r14), %rdi
movq 0x8(%r14), %rax
addq -0x18(%rax), %rdi
leaq 0x18(%rsp), %rsi
callq 0x35c10
movq %rsp, %rdi
callq 0x353f0
movq (%r14), %rsi
addq $0x8, %rsi
movq %rsp, %rdi
callq 0x357b0
movl %eax, %ebx
testb %al, %al
je 0x3c747
movq %rsp, %rdi
callq 0x35080
leaq 0x118(%r14), %r12
movq %r12, %rdi
movq %rax, %rsi
callq 0x3a1a4
pushq $0x28
popq %rdi
callq 0x355d0
movq %rax, %r15
leaq 0x8(%r14), %rdx
movq %rax, %rdi
movq %r12, %rsi
callq 0x3cc64
leaq 0x8(%rsp), %rdi
callq 0x66b92
leaq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x66c10
leaq 0x210(%rsp), %rdi
callq 0x35200
movq %rsp, %r12
leaq 0x210(%rsp), %r13
leaq 0x8(%rsp), %rbp
movq %r12, %rdi
movq %r13, %rsi
callq 0x359b0
testb %al, %al
je 0x3c773
movq %rbp, %rdi
movq %r13, %rsi
callq 0x66c08
jmp 0x3c72b
movq 0x58892(%rip), %rdi     # 0x94fe0
leaq 0x352c9(%rip), %rsi     # 0x71a1e
callq 0x355b0
movq (%r14), %rsi
addq $0x8, %rsi
movq %rax, %rdi
callq 0x35510
movq %rax, %rdi
callq 0x35300
jmp 0x3c7b8
leaq 0x8(%rsp), %rdi
callq 0x66c28
movq %rsp, %rdi
callq 0x350a0
movq (%r14), %rax
cmpb $0x1, 0x1(%rax)
jne 0x3c798
leaq 0x10(%rsp), %rdi
callq 0x35870
movq (%r15), %rax
movq %r15, %rdi
callq *0x8(%rax)
leaq 0x210(%rsp), %rdi
callq 0x35940
leaq 0x8(%rsp), %rdi
callq 0x66bca
movq %rsp, %rdi
callq 0x35620
leaq 0x10(%rsp), %rdi
callq 0x358b0
movl %ebx, %eax
addq $0x368, %rsp            # imm = 0x368
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3c7ef
movq %rax, %rbx
movq %r15, %rdi
callq 0x35570
jmp 0x3c81e
jmp 0x3c7ff
movq %rax, %rbx
jmp 0x3c814
jmp 0x3c7ff
jmp 0x3c804
jmp 0x3c7fa
movq %rax, %rbx
jmp 0x3c826
movq %rax, %rbx
jmp 0x3c81e
movq %rax, %rbx
leaq 0x210(%rsp), %rdi
callq 0x35940
leaq 0x8(%rsp), %rdi
callq 0x66bca
movq %rsp, %rdi
callq 0x35620
leaq 0x10(%rsp), %rdi
callq 0x358b0
movq %rbx, %rdi
callq 0x35b50
movq %rax, %rdi
callq 0x3a198