// File: /workspace/github_cpp_makefile_star2_O2/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 %r14
pushq %rbx
subq $0x68, %rsp
movl %esi, %r14d
movq %rdi, %rbx
movq (%rdi), %rax
callq *0x10(%rax)
leal -0x1(%r14), %eax
cmpl $0x3, %eax
jae 0x4d295
movl %eax, %eax
leaq 0xf703(%rip), %rcx      # 0x5c974
movslq (%rcx,%rax,4), %rsi
addq %rcx, %rsi
movq 0x38(%rbx), %rdi
callq 0x335c0
movq %rax, 0x30(%rbx)
testq %rax, %rax
je 0x4d2ec
movl %r14d, 0x8(%rbx)
movb $0x1, %al
jmp 0x4d39a
leaq 0xf65c(%rip), %rsi      # 0x5c8f8
leaq 0x48(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0x31b30
leaq 0xf654(%rip), %rsi      # 0x5c906
leaq 0x28(%rsp), %rdi
leaq 0x6(%rsp), %rdx
callq 0x31b30
leaq 0x48(%rsp), %rsi
leaq 0x28(%rsp), %rdx
movq %rbx, %rdi
callq 0x34ab0
leaq 0x28(%rsp), %rdi
callq 0x33a00
leaq 0x48(%rsp), %rdi
callq 0x33a00
jmp 0x4d398
leaq 0xf62f(%rip), %rsi      # 0x5c922
leaq 0x48(%rsp), %rdi
leaq 0x28(%rsp), %rdx
callq 0x31b30
movq 0x40(%rbx), %r14
testq %r14, %r14
je 0x4d31b
leaq 0x38(%rbx), %rsi
leaq 0x8(%rsp), %rdi
callq 0x33ff0
jmp 0x4d331
leaq 0xf620(%rip), %rsi      # 0x5c942
leaq 0x8(%rsp), %rdi
leaq 0x6(%rsp), %rdx
callq 0x31b30
leaq 0x28(%rsp), %rdi
leaq 0x48(%rsp), %rsi
leaq 0x8(%rsp), %rdx
callq 0x355e0
leaq 0x8(%rsp), %rdi
callq 0x33a00
testq %r14, %r14
leaq 0xf59f(%rip), %rsi      # 0x5c8f8
leaq 0x8(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x31b30
leaq 0x8(%rsp), %rsi
leaq 0x28(%rsp), %rdx
movq %rbx, %rdi
callq 0x34ab0
leaq 0x8(%rsp), %rdi
callq 0x33a00
leaq 0x28(%rsp), %rdi
callq 0x33a00
leaq 0x48(%rsp), %rdi
callq 0x33a00
xorl %eax, %eax
addq $0x68, %rsp
popq %rbx
popq %r14
retq
jmp 0x4d3a6
jmp 0x4d3a6
movq %rax, %rbx
jmp 0x4d3e0
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x33a00
jmp 0x4d3d6
movq %rax, %rbx
jmp 0x4d3cc
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x33a00
testq %r14, %r14
jmp 0x4d3e0
jmp 0x4d3fb
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x33a00
leaq 0x48(%rsp), %rdi
callq 0x33a00
jmp 0x4d40d
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x33a00
jmp 0x4d403
movq %rax, %rbx
jmp 0x4d40d
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x33a00
movq %rbx, %rdi
callq 0x34ed0
movq %rax, %rdi
callq 0x39b2f
nop