// File: /workspace/github_cpp_makefile_star2_O1/zeeev[P]DASVC/bamtools/src/api/internal/index/BamStandardIndex_p.cpp
// Function: BamTools::Internal::BamStandardIndex::OpenFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, BamTools::IBamIODevice::OpenMode)
void BamStandardIndex::OpenFile(const std::string& filename, IBamIODevice::OpenMode mode) {

    // make sure any previous index file is closed
    CloseFile();

    m_resources.Device = BamDeviceFactory::CreateDevice(filename);
    if ( m_resources.Device == 0 ) {
        const string message = string("could not open file: ") + filename;
        throw BamException("BamStandardIndex::OpenFile", message);
    }

    // attempt to open file
    m_resources.Device->Open(mode);
    if ( !IsDeviceOpen() ) {
        const string message = string("could not open file: ") + filename;
        throw BamException("BamStandardIndex::OpenFile", message);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x48, %rsp
movl %edx, %ebp
movq %rsi, %rbx
movq %rdi, %r14
callq 0x27db0
movq %rbx, %rdi
callq 0x272b0
movq %rax, 0x58(%r14)
testq %rax, %rax
je 0x3f79f
movq (%rax), %rcx
movq %rax, %rdi
movl %ebp, %esi
callq *0x20(%rcx)
movq 0x58(%r14), %rdi
testq %rdi, %rdi
je 0x3f703
movq (%rdi), %rax
callq *0x50(%rax)
testb %al, %al
je 0x3f703
addq $0x48, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x18(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x15e3e(%rip), %rsi     # 0x55551
leaq 0x15e4c(%rip), %rdx     # 0x55566
leaq 0x8(%rsp), %rdi
callq 0x26750
leaq 0x28(%rsp), %rdi
leaq 0x8(%rsp), %rsi
movq %rbx, %rdx
callq 0x29130
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x3f745
callq 0x27560
movl $0x28, %edi
callq 0x269d0
movq %rax, %r14
leaq 0x8(%rsp), %rdi
movq %r15, (%rdi)
leaq 0x16957(%rip), %rsi     # 0x560b8
leaq 0x1696a(%rip), %rdx     # 0x560d2
callq 0x26750
movb $0x1, %bpl
leaq 0x8(%rsp), %rsi
leaq 0x28(%rsp), %rdx
movq %r14, %rdi
callq 0x28490
xorl %ebp, %ebp
movq 0x2b7ad(%rip), %rsi     # 0x6af38
movq 0x2b7e6(%rip), %rdx     # 0x6af78
movq %r14, %rdi
callq 0x28a30
jmp 0x3f836
leaq 0x18(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x15da2(%rip), %rsi     # 0x55551
leaq 0x15db0(%rip), %rdx     # 0x55566
leaq 0x8(%rsp), %rdi
callq 0x26750
leaq 0x28(%rsp), %rdi
leaq 0x8(%rsp), %rsi
movq %rbx, %rdx
callq 0x29130
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x3f7e1
callq 0x27560
movl $0x28, %edi
callq 0x269d0
movq %rax, %r14
leaq 0x8(%rsp), %rdi
movq %r15, (%rdi)
leaq 0x168bb(%rip), %rsi     # 0x560b8
leaq 0x168ce(%rip), %rdx     # 0x560d2
callq 0x26750
movb $0x1, %bpl
leaq 0x8(%rsp), %rsi
leaq 0x28(%rsp), %rdx
movq %r14, %rdi
callq 0x28490
xorl %ebp, %ebp
movq 0x2b711(%rip), %rsi     # 0x6af38
movq 0x2b74a(%rip), %rdx     # 0x6af78
movq %r14, %rdi
callq 0x28a30
jmp 0x3f83a
jmp 0x3f84e
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x3f854
callq 0x27560
jmp 0x3f854
movq %rax, %rbx
movb $0x1, %bpl
testb %bpl, %bpl
je 0x3f861
movq %r14, %rdi
callq 0x27070
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
jne 0x3f880
jmp 0x3f88c
jmp 0x3f873
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x3f88c
callq 0x27560
jmp 0x3f88c
jmp 0x3f889
movq %rax, %rbx
movq %rbx, %rdi
callq 0x28c20