// File: /workspace/github_cpp_makefile_star2_O3/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 0x27a90
movq (%r14), %rax
cmpb $0x1, 0x1(%rax)
jne 0x30ee0
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 0x30eca
movq 0x5e183(%rip), %rdi     # 0x8efe0
leaq 0x40bf5(%rip), %rsi     # 0x71a59
movl $0x28, %edx
callq 0x276b0
movq (%r14), %rax
movq 0x28(%rax), %rsi
movq 0x30(%rax), %rdx
movq 0x5e160(%rip), %rdi     # 0x8efe0
callq 0x276b0
movq %rax, %rbx
leaq 0x403ef(%rip), %rsi     # 0x7127e
movl $0xb, %edx
movq %rax, %rdi
callq 0x276b0
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 0x31041
leaq 0x8(%r14), %rdi
movq 0x8(%r14), %rax
addq -0x18(%rax), %rdi
leaq 0x18(%rsp), %rsi
callq 0x27be0
movq %rsp, %rdi
callq 0x273f0
movq (%r14), %rsi
addq $0x8, %rsi
movq %rsp, %rdi
callq 0x27790
movl %eax, %ebx
testb %al, %al
je 0x30f99
movq %rsp, %rdi
callq 0x27090
leaq 0x118(%r14), %r12
movq %r12, %rdi
movq %rax, %rsi
callq 0x2e1d8
movl $0x28, %edi
callq 0x275c0
movq %rax, %r15
leaq 0x5d861(%rip), %rax     # 0x8e790
movq %rax, (%r15)
movq %r15, %rdi
addq $0x8, %rdi
movq %r12, %rsi
callq 0x2f02e
leaq 0x8(%r14), %rax
movq %rax, 0x20(%r15)
leaq 0x8(%rsp), %rdi
callq 0x6533c
leaq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x653c0
leaq 0x210(%rsp), %rdi
callq 0x27220
movq %rsp, %r12
leaq 0x210(%rsp), %r13
leaq 0x8(%rsp), %rbp
movq %r12, %rdi
movq %r13, %rsi
callq 0x27980
testb %al, %al
je 0x30ff4
movq %rbp, %rdi
movq %r13, %rsi
callq 0x653b8
jmp 0x30f7d
movq 0x5e040(%rip), %rdi     # 0x8efe0
leaq 0x40adb(%rip), %rsi     # 0x71a82
movl $0x38, %edx
callq 0x276b0
movq (%r14), %rax
movq 0x8(%rax), %rsi
movq 0x10(%rax), %rdx
movq 0x5e01d(%rip), %rdi     # 0x8efe0
callq 0x276b0
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 0x31039
leaq 0x8(%rsp), %rdi
callq 0x653ee
movq %rsp, %rdi
callq 0x270b0
movq (%r14), %rax
cmpb $0x1, 0x1(%rax)
jne 0x31019
leaq 0x10(%rsp), %rdi
callq 0x27840
movq (%r15), %rax
movq %r15, %rdi
callq *0x8(%rax)
leaq 0x210(%rsp), %rdi
callq 0x27920
leaq 0x8(%rsp), %rdi
callq 0x65376
movq %rsp, %rdi
callq 0x27620
leaq 0x10(%rsp), %rdi
callq 0x27880
movl %ebx, %eax
addq $0x368, %rsp            # imm = 0x368
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x31070
movq %rax, %rbx
movq %r15, %rdi
callq 0x27560
jmp 0x3109f
jmp 0x31080
movq %rax, %rbx
jmp 0x31095
jmp 0x31080
jmp 0x31085
jmp 0x3107b
movq %rax, %rbx
jmp 0x310a7
movq %rax, %rbx
jmp 0x3109f
movq %rax, %rbx
leaq 0x210(%rsp), %rdi
callq 0x27920
leaq 0x8(%rsp), %rdi
callq 0x65376
movq %rsp, %rdi
callq 0x27620
leaq 0x10(%rsp), %rdi
callq 0x27880
movq %rbx, %rdi
callq 0x27b10
movq %rax, %rdi
callq 0x2e1cd
nop