// File: /workspace/github_cpp_makefile_star2_O1/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 0x277a0
testb %al, %al
je 0x4d54f
leaq 0x18(%rsp), %rdi
movq %rsp, %rsi
callq 0x27200
movq %rsp, %rdi
callq 0x27090
movq %rax, %r14
movq (%rbx), %r15
callq 0x646ea
movq 0x30(%r15), %rdx
xorl %ebp, %ebp
cmpq 0x8(%rax), %rdx
jne 0x4d4cd
testq %rdx, %rdx
je 0x4d4c3
movq (%rax), %rsi
movq 0x28(%r15), %rdi
callq 0x275f0
testl %eax, %eax
jne 0x4d4cd
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 0x279b0
movl %eax, %ebp
testb %al, %al
je 0x4d5c3
leaq 0x38(%rsp), %rdi
callq 0x27220
movq %rsp, %r14
leaq 0x38(%rsp), %r15
leaq 0x8(%rsp), %r12
movq %r14, %rdi
movq %r15, %rsi
callq 0x27990
testb %al, %al
je 0x4d63a
movq %rbx, %rdi
movq %r15, %rsi
callq 0x4d320
movq %r12, %rdi
movq %r15, %rsi
callq 0x27be0
jmp 0x4d524
movq 0x42a8a(%rip), %rdi     # 0x8ffe0
leaq 0x2839c(%rip), %rsi     # 0x758f9
movl $0x26, %edx
callq 0x276c0
movq (%rbx), %rax
movq 0x8(%rax), %rsi
movq 0x10(%rax), %rdx
movq 0x42a67(%rip), %rdi     # 0x8ffe0
callq 0x276c0
movq %rax, %rbx
leaq 0x262ed(%rip), %rsi     # 0x73875
movl $0x19, %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 %ebp, %ebp
jmp 0x4d673
movq 0x42a16(%rip), %rdi     # 0x8ffe0
leaq 0x28328(%rip), %rsi     # 0x758f9
movl $0x26, %edx
callq 0x276c0
movq (%rbx), %rax
movq 0x28(%rax), %rsi
movq 0x30(%rax), %rdx
movq 0x429f3(%rip), %rdi     # 0x8ffe0
callq 0x276c0
movq %rax, %rbx
leaq 0x26777(%rip), %rsi     # 0x73d73
movl $0x19, %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
movq %rsp, %rdi
callq 0x270b0
jmp 0x4d656
movq %rsp, %rdi
callq 0x270b0
leaq 0x8(%rsp), %rdi
callq 0x27370
leaq 0x38(%rsp), %rdi
callq 0x27930
leaq 0x8(%rsp), %rdi
callq 0x27430
leaq 0x28(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4d673
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 0x4d6a6
jmp 0x4d69c
jmp 0x4d697
jmp 0x4d697
jmp 0x4d6a1
movq %rax, %rbx
jmp 0x4d6bd
movq %rax, %rbx
jmp 0x4d6b3
movq %rax, %rbx
jmp 0x4d6d0
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x27930
leaq 0x8(%rsp), %rdi
callq 0x27430
leaq 0x28(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4d6d0
callq 0x27560
movq %rsp, %rdi
callq 0x27620
movq %rbx, %rdi
callq 0x27b20
movq %rax, %rdi
callq 0x2e1ed