// File: /workspace/github_cpp_makefile_star2_O3/zeeev[P]DASVC/bamtools/src/api/internal/io/BamFile_p.cpp
// Function: BamTools::Internal::BamFile::Open(BamTools::IBamIODevice::OpenMode)
bool BamFile::Open(const IBamIODevice::OpenMode mode) {

    // make sure we're starting with a fresh file stream
    Close();

    // attempt to open FILE* depending on requested openmode
    if ( mode == IBamIODevice::ReadOnly )
        m_stream = fopen(m_filename.c_str(), "rb");
    else if ( mode == IBamIODevice::WriteOnly )
        m_stream = fopen(m_filename.c_str(), "wb");
    else if ( mode == IBamIODevice::ReadWrite )
        m_stream = fopen(m_filename.c_str(), "w+b");
    else {
        SetErrorString("BamFile::Open", "unknown open mode requested");
        return false;
    }

    // check that we obtained a valid FILE*
    if ( m_stream == 0 ) {
        const string message_base = string("could not open file handle for ");
        const string message = message_base + ( (m_filename.empty()) ? "empty filename" : m_filename );
        SetErrorString("BamFile::Open", message);
        return false;
    }

    // store current IO mode & return success
    m_mode = mode;
    return true;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x60, %rsp
movl %esi, %r14d
movq %rdi, %rbx
movq (%rdi), %rax
callq *0x10(%rax)
leal -0x1(%r14), %eax
cmpl $0x3, %eax
jae 0x453d4
movl %eax, %eax
leaq 0x115d1(%rip), %rcx     # 0x56980
movslq (%rcx,%rax,4), %rsi
addq %rcx, %rsi
movq 0x38(%rbx), %rdi
callq 0x27a20
movq %rax, 0x30(%rbx)
testq %rax, %rax
je 0x45452
movl %r14d, 0x8(%rbx)
movb $0x1, %al
jmp 0x45448
leaq 0x30(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x11523(%rip), %rsi     # 0x56907
leaq 0x11529(%rip), %rdx     # 0x56914
leaq 0x20(%rsp), %rdi
callq 0x26750
leaq 0x50(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x11510(%rip), %rsi     # 0x56915
leaq 0x11524(%rip), %rdx     # 0x56930
leaq 0x40(%rsp), %rdi
callq 0x26750
leaq 0x20(%rsp), %rsi
leaq 0x40(%rsp), %rdx
movq %rbx, %rdi
callq 0x288b0
movq 0x40(%rsp), %rdi
cmpq %r15, %rdi
je 0x45437
callq 0x27560
movq 0x20(%rsp), %rdi
cmpq %r14, %rdi
je 0x45446
callq 0x27560
xorl %eax, %eax
addq $0x60, %rsp
popq %rbx
popq %r14
popq %r15
retq
leaq 0x30(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x114cf(%rip), %rsi     # 0x56931
leaq 0x114e7(%rip), %rdx     # 0x56950
leaq 0x20(%rsp), %rdi
callq 0x26750
movq 0x40(%rbx), %rdx
leaq 0x10(%rsp), %rax
testq %rdx, %rdx
je 0x45496
movq %rax, -0x10(%rax)
movq 0x38(%rbx), %rsi
addq %rsi, %rdx
movq %rsp, %rdi
callq 0x267c0
jmp 0x454b0
movq %rax, -0x10(%rax)
leaq 0x114b0(%rip), %rsi     # 0x56951
leaq 0x114b7(%rip), %rdx     # 0x5695f
movq %rsp, %rdi
callq 0x26750
leaq 0x40(%rsp), %rdi
leaq 0x20(%rsp), %rsi
movq %rsp, %rdx
callq 0x29120
leaq 0x10(%rsp), %r15
movq -0x10(%r15), %rdi
cmpq %r15, %rdi
je 0x454d5
callq 0x27560
movq %rsp, %rdi
movq %r15, (%rdi)
leaq 0x11425(%rip), %rsi     # 0x56907
leaq 0x1142b(%rip), %rdx     # 0x56914
callq 0x26750
movq %rsp, %rsi
leaq 0x40(%rsp), %rdx
movq %rbx, %rdi
callq 0x288b0
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x4550c
callq 0x27560
leaq 0x50(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
jne 0x45432
jmp 0x45437
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x45539
callq 0x27560
jmp 0x45539
movq %rax, %rbx
leaq 0x50(%rsp), %rax
jmp 0x45548
movq %rax, %rbx
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
jne 0x45564
jmp 0x4556e
jmp 0x4556b
jmp 0x4557f
movq %rax, %rbx
movq 0x40(%rsp), %rdi
cmpq %r15, %rdi
je 0x4556e
callq 0x27560
jmp 0x4556e
movq %rax, %rbx
movq 0x20(%rsp), %rdi
cmpq %r14, %rdi
je 0x45582
callq 0x27560
jmp 0x45582
movq %rax, %rbx
movq %rbx, %rdi
callq 0x28c10