// File: /workspace/github_cpp_makefile_star2_O3/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 0x273f0
movq (%rbx), %rsi
addq $0x8, %rsi
movq %r14, %rdi
callq 0x27790
testb %al, %al
je 0x4d3e3
leaq 0x18(%rsp), %rdi
movq %rsp, %rsi
callq 0x27200
movq %rsp, %rdi
callq 0x27090
movq %rax, %r14
movq (%rbx), %r15
callq 0x641aa
movq 0x30(%r15), %rdx
xorl %ebp, %ebp
cmpq 0x8(%rax), %rdx
jne 0x4d361
testq %rdx, %rdx
je 0x4d357
movq (%rax), %rsi
movq 0x28(%r15), %rdi
callq 0x275f0
testl %eax, %eax
jne 0x4d361
movq (%rbx), %rax
movzbl 0x2(%rax), %ebp
xorl $0x1, %ebp
movl %ebp, 0x14(%rsp)
leaq 0x8(%rsp), %rdi
callq 0x27360
leaq 0x8(%rsp), %rdi
leaq 0x14(%rsp), %rsi
callq 0x27250
movq (%rbx), %rsi
addq $0x28, %rsi
leaq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rdx
movq %r14, %rcx
callq 0x279a0
movl %eax, %ebp
testb %al, %al
je 0x4d457
leaq 0x38(%rsp), %rdi
callq 0x27220
movq %rsp, %r14
leaq 0x38(%rsp), %r15
leaq 0x8(%rsp), %r12
movq %r14, %rdi
movq %r15, %rsi
callq 0x27980
testb %al, %al
je 0x4d4ce
movq %rbx, %rdi
movq %r15, %rsi
callq 0x4d1b8
movq %r12, %rdi
movq %r15, %rsi
callq 0x27bd0
jmp 0x4d3b8
movq 0x41bf6(%rip), %rdi     # 0x8efe0
leaq 0x27520(%rip), %rsi     # 0x74911
movl $0x26, %edx
callq 0x276b0
movq (%rbx), %rax
movq 0x8(%rax), %rsi
movq 0x10(%rax), %rdx
movq 0x41bd3(%rip), %rdi     # 0x8efe0
callq 0x276b0
movq %rax, %rbx
leaq 0x25470(%rip), %rsi     # 0x7288c
movl $0x19, %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 %ebp, %ebp
jmp 0x4d507
movq 0x41b82(%rip), %rdi     # 0x8efe0
leaq 0x274ac(%rip), %rsi     # 0x74911
movl $0x26, %edx
callq 0x276b0
movq (%rbx), %rax
movq 0x28(%rax), %rsi
movq 0x30(%rax), %rdx
movq 0x41b5f(%rip), %rdi     # 0x8efe0
callq 0x276b0
movq %rax, %rbx
leaq 0x258fb(%rip), %rsi     # 0x72d8b
movl $0x19, %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
movq %rsp, %rdi
callq 0x270b0
jmp 0x4d4ea
movq %rsp, %rdi
callq 0x270b0
leaq 0x8(%rsp), %rdi
callq 0x27370
leaq 0x38(%rsp), %rdi
callq 0x27920
leaq 0x8(%rsp), %rdi
callq 0x27430
leaq 0x28(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4d507
callq 0x27560
movq %rsp, %rdi
callq 0x27620
movl %ebp, %eax
addq $0x190, %rsp            # imm = 0x190
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
jmp 0x4d53a
jmp 0x4d530
jmp 0x4d52b
jmp 0x4d52b
jmp 0x4d535
movq %rax, %rbx
jmp 0x4d551
movq %rax, %rbx
jmp 0x4d547
movq %rax, %rbx
jmp 0x4d564
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x27920
leaq 0x8(%rsp), %rdi
callq 0x27430
leaq 0x28(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4d564
callq 0x27560
movq %rsp, %rdi
callq 0x27620
movq %rbx, %rdi
callq 0x27b10
movq %rax, %rdi
callq 0x2e1cd