// File: /workspace/github_cpp_makefile_star2_O2/zeeev[P]DASVC/bamtools/src/toolkit/bamtools_revert.cpp
// Function: BamTools::RevertTool::RevertToolPrivate::Run()
bool RevertTool::RevertToolPrivate::Run(void) {
  
    // opens the BAM file without checking for indexes
    BamReader reader;
    if ( !reader.Open(m_settings->InputFilename) ) {
        cerr << "bamtools revert ERROR: could not open " << m_settings->InputFilename
             << " for reading... Aborting." << endl;
        return false;
    }

    // get BAM file metadata
    const string& headerText = reader.GetHeaderText();
    const RefVector& references = reader.GetReferenceData();
    
    // determine compression mode for BamWriter
    bool writeUncompressed = ( m_settings->OutputFilename == Options::StandardOut() &&
                              !m_settings->IsForceCompression );
    BamWriter::CompressionMode compressionMode = BamWriter::Compressed;
    if ( writeUncompressed ) compressionMode = BamWriter::Uncompressed;

    // open BamWriter
    BamWriter writer;
    writer.SetCompressionMode(compressionMode);
    if ( !writer.Open(m_settings->OutputFilename, headerText, references) ) {
        cerr << "bamtools revert ERROR: could not open " << m_settings->OutputFilename
             << " for writing... Aborting." << endl;
        reader.Close();
        return false;
    }

    // plow through file, reverting alignments
    BamAlignment al;
    while ( reader.GetNextAlignment(al) ) {
        RevertAlignment(al);
        writer.SaveAlignment(al);
    }
    
    // clean and exit
    reader.Close();
    writer.Close();
    return true; 
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x190, %rsp            # imm = 0x190
movq %rdi, %rbx
movq %rsp, %r14
movq %r14, %rdi
callq 0x353f0
movq (%rbx), %rsi
addq $0x8, %rsi
movq %r14, %rdi
callq 0x357b0
testb %al, %al
je 0x5417b
leaq 0x18(%rsp), %rdi
movq %rsp, %rsi
callq 0x351f0
movq %rsp, %rdi
callq 0x35080
movq %rax, %r14
movq (%rbx), %r15
callq 0x65ec6
addq $0x28, %r15
movq %r15, %rdi
movq %rax, %rsi
callq 0x3a2a9
xorl %ecx, %ecx
testb %al, %al
je 0x540fd
movq (%rbx), %rax
movzbl 0x2(%rax), %ecx
xorl $0x1, %ecx
movl %ecx, 0x14(%rsp)
leaq 0x8(%rsp), %rdi
callq 0x35350
leaq 0x8(%rsp), %rdi
leaq 0x14(%rsp), %rsi
callq 0x35230
movq (%rbx), %rsi
addq $0x28, %rsi
leaq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rdx
movq %r14, %rcx
callq 0x359d0
movl %eax, %ebp
testb %al, %al
je 0x541b8
leaq 0x38(%rsp), %rdi
callq 0x35200
movq %rsp, %r14
leaq 0x38(%rsp), %r15
leaq 0x8(%rsp), %r12
movq %r14, %rdi
movq %r15, %rsi
callq 0x359b0
testb %al, %al
je 0x541fb
movq %rbx, %rdi
movq %r15, %rsi
callq 0x53fec
movq %r12, %rdi
movq %r15, %rsi
callq 0x35c00
jmp 0x54150
movq 0x40e5e(%rip), %rdi     # 0x94fe0
leaq 0x20701(%rip), %rsi     # 0x7488a
callq 0x355b0
movq (%rbx), %rsi
addq $0x8, %rsi
movq %rax, %rdi
callq 0x35510
leaq 0x1e661(%rip), %rsi     # 0x72805
movq %rax, %rdi
callq 0x355b0
movq %rax, %rdi
callq 0x35300
xorl %ebp, %ebp
jmp 0x5422b
movq 0x40e21(%rip), %rdi     # 0x94fe0
leaq 0x206c4(%rip), %rsi     # 0x7488a
callq 0x355b0
movq (%rbx), %rsi
addq $0x28, %rsi
movq %rax, %rdi
callq 0x35510
leaq 0x1eb22(%rip), %rsi     # 0x72d03
movq %rax, %rdi
callq 0x355b0
movq %rax, %rdi
callq 0x35300
movq %rsp, %rdi
callq 0x350a0
jmp 0x54217
movq %rsp, %rdi
callq 0x350a0
leaq 0x8(%rsp), %rdi
callq 0x35360
leaq 0x38(%rsp), %rdi
callq 0x35940
leaq 0x8(%rsp), %rdi
callq 0x35420
leaq 0x18(%rsp), %rdi
callq 0x35730
movq %rsp, %rdi
callq 0x35620
movl %ebp, %eax
addq $0x190, %rsp            # imm = 0x190
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
jmp 0x54260
jmp 0x5425b
jmp 0x54256
jmp 0x54251
jmp 0x5425b
jmp 0x54251
movq %rax, %rbx
jmp 0x54277
movq %rax, %rbx
jmp 0x5426d
movq %rax, %rbx
jmp 0x54281
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x35940
leaq 0x8(%rsp), %rdi
callq 0x35420
leaq 0x18(%rsp), %rdi
callq 0x35730
movq %rsp, %rdi
callq 0x35620
movq %rbx, %rdi
callq 0x35b50
movq %rax, %rdi
callq 0x3a198
nop