// File: /workspace/github_cpp_makefile_star2_O1/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 0x453fc
movl %eax, %eax
leaq 0x115a9(%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 0x4547a
movl %r14d, 0x8(%rbx)
movb $0x1, %al
jmp 0x45470
leaq 0x30(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x114fb(%rip), %rsi     # 0x56907
leaq 0x11501(%rip), %rdx     # 0x56914
leaq 0x20(%rsp), %rdi
callq 0x26750
leaq 0x50(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x114e8(%rip), %rsi     # 0x56915
leaq 0x114fc(%rip), %rdx     # 0x56930
leaq 0x40(%rsp), %rdi
callq 0x26750
leaq 0x20(%rsp), %rsi
leaq 0x40(%rsp), %rdx
movq %rbx, %rdi
callq 0x288c0
movq 0x40(%rsp), %rdi
cmpq %r15, %rdi
je 0x4545f
callq 0x27560
movq 0x20(%rsp), %rdi
cmpq %r14, %rdi
je 0x4546e
callq 0x27560
xorl %eax, %eax
addq $0x60, %rsp
popq %rbx
popq %r14
popq %r15
retq
leaq 0x30(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x114a7(%rip), %rsi     # 0x56931
leaq 0x114bf(%rip), %rdx     # 0x56950
leaq 0x20(%rsp), %rdi
callq 0x26750
movq 0x40(%rbx), %rdx
leaq 0x10(%rsp), %rax
testq %rdx, %rdx
je 0x454be
movq %rax, -0x10(%rax)
movq 0x38(%rbx), %rsi
addq %rsi, %rdx
movq %rsp, %rdi
callq 0x267c0
jmp 0x454d8
movq %rax, -0x10(%rax)
leaq 0x11488(%rip), %rsi     # 0x56951
leaq 0x1148f(%rip), %rdx     # 0x5695f
movq %rsp, %rdi
callq 0x26750
leaq 0x40(%rsp), %rdi
leaq 0x20(%rsp), %rsi
movq %rsp, %rdx
callq 0x29130
leaq 0x10(%rsp), %r15
movq -0x10(%r15), %rdi
cmpq %r15, %rdi
je 0x454fd
callq 0x27560
movq %rsp, %rdi
movq %r15, (%rdi)
leaq 0x113fd(%rip), %rsi     # 0x56907
leaq 0x11403(%rip), %rdx     # 0x56914
callq 0x26750
movq %rsp, %rsi
leaq 0x40(%rsp), %rdx
movq %rbx, %rdi
callq 0x288c0
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x45534
callq 0x27560
leaq 0x50(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
jne 0x4545a
jmp 0x4545f
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x45561
callq 0x27560
jmp 0x45561
movq %rax, %rbx
leaq 0x50(%rsp), %rax
jmp 0x45570
movq %rax, %rbx
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
jne 0x4558c
jmp 0x45596
jmp 0x45593
jmp 0x455a7
movq %rax, %rbx
movq 0x40(%rsp), %rdi
cmpq %r15, %rdi
je 0x45596
callq 0x27560
jmp 0x45596
movq %rax, %rbx
movq 0x20(%rsp), %rdi
cmpq %r14, %rdi
je 0x455aa
callq 0x27560
jmp 0x455aa
movq %rax, %rbx
movq %rbx, %rdi
callq 0x28c20