// File: 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:
subq $0x148, %rsp            # imm = 0x148
movq %rdi, 0x140(%rsp)
movq %rsi, 0x138(%rsp)
movl %edx, 0x134(%rsp)
movq 0x140(%rsp), %rdi
movq %rdi, 0x38(%rsp)
callq 0x783d0
movq 0x138(%rsp), %rdi
callq 0x75a00
movq %rax, %rcx
movq 0x38(%rsp), %rax
movq %rcx, 0x58(%rax)
cmpq $0x0, 0x58(%rax)
jne 0xb31f0
leaq 0xef(%rsp), %rdi
movq %rdi, 0x30(%rsp)
callq 0x7b5f0
movq 0x30(%rsp), %rdx
leaq 0x37759(%rip), %rsi     # 0xea7bb
leaq 0xf0(%rsp), %rdi
callq 0x78e70
jmp 0xb3071
movq 0x138(%rsp), %rdx
leaq 0x110(%rsp), %rdi
leaq 0xf0(%rsp), %rsi
callq 0x7c720
jmp 0xb3090
leaq 0xf0(%rsp), %rdi
callq 0x7cce8
jmp 0xb309f
leaq 0xef(%rsp), %rdi
callq 0x76f80
movb $0x1, 0xb6(%rsp)
movl $0x28, %edi
callq 0x737c0
movq %rax, 0x20(%rsp)
leaq 0xb7(%rsp), %rdi
movq %rdi, 0x28(%rsp)
callq 0x7b5f0
movq 0x28(%rsp), %rdx
leaq 0x38224(%rip), %rsi     # 0xeb305
leaq 0xb8(%rsp), %rdi
callq 0x78e70
jmp 0xb30f0
movq 0x20(%rsp), %rdi
leaq 0xb8(%rsp), %rsi
leaq 0x110(%rsp), %rdx
callq 0x79cd0
jmp 0xb310c
movq 0x20(%rsp), %rdi
movb $0x0, 0xb6(%rsp)
movq 0x5edf0(%rip), %rsi     # 0x111f10
movq 0x5ee39(%rip), %rdx     # 0x111f60
callq 0x7b010
jmp 0xb33ae
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xe0(%rsp)
movl %eax, 0xdc(%rsp)
jmp 0xb316c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xe0(%rsp)
movl %eax, 0xdc(%rsp)
leaq 0xf0(%rsp), %rdi
callq 0x7cce8
jmp 0xb316a
jmp 0xb316c
leaq 0xef(%rsp), %rdi
callq 0x76f80
jmp 0xb3399
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xe0(%rsp)
movl %eax, 0xdc(%rsp)
jmp 0xb31b9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xe0(%rsp)
movl %eax, 0xdc(%rsp)
leaq 0xb8(%rsp), %rdi
callq 0x7cce8
jmp 0xb31b7
jmp 0xb31b9
leaq 0xb7(%rsp), %rdi
callq 0x76f80
testb $0x1, 0xb6(%rsp)
jne 0xb31d2
jmp 0xb31dc
movq 0x20(%rsp), %rdi
callq 0x74e00
leaq 0x110(%rsp), %rdi
callq 0x7cce8
jmp 0xb31eb
jmp 0xb3399
movq 0x38(%rsp), %rax
movq 0x58(%rax), %rdi
movl 0x134(%rsp), %esi
movq (%rdi), %rax
callq *0x20(%rax)
movq 0x38(%rsp), %rdi
callq 0x715c0
testb $0x1, %al
jne 0xb3391
leaq 0x6f(%rsp), %rdi
movq %rdi, 0x18(%rsp)
callq 0x7b5f0
movq 0x18(%rsp), %rdx
leaq 0x37588(%rip), %rsi     # 0xea7bb
leaq 0x70(%rsp), %rdi
callq 0x78e70
jmp 0xb323f
movq 0x138(%rsp), %rdx
leaq 0x90(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x7c720
jmp 0xb325b
leaq 0x70(%rsp), %rdi
callq 0x7cce8
jmp 0xb3267
leaq 0x6f(%rsp), %rdi
callq 0x76f80
movb $0x1, 0x46(%rsp)
movl $0x28, %edi
callq 0x737c0
movq %rax, 0x8(%rsp)
leaq 0x47(%rsp), %rdi
movq %rdi, 0x10(%rsp)
callq 0x7b5f0
movq 0x10(%rsp), %rdx
leaq 0x38065(%rip), %rsi     # 0xeb305
leaq 0x48(%rsp), %rdi
callq 0x78e70
jmp 0xb32ac
movq 0x8(%rsp), %rdi
leaq 0x48(%rsp), %rsi
leaq 0x90(%rsp), %rdx
callq 0x79cd0
jmp 0xb32c5
movq 0x8(%rsp), %rdi
movb $0x0, 0x46(%rsp)
movq 0x5ec3a(%rip), %rsi     # 0x111f10
movq 0x5ec83(%rip), %rdx     # 0x111f60
callq 0x7b010
jmp 0xb33ae
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xe0(%rsp)
movl %eax, 0xdc(%rsp)
jmp 0xb331f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xe0(%rsp)
movl %eax, 0xdc(%rsp)
leaq 0x70(%rsp), %rdi
callq 0x7cce8
jmp 0xb331d
jmp 0xb331f
leaq 0x6f(%rsp), %rdi
callq 0x76f80
jmp 0xb3399
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xe0(%rsp)
movl %eax, 0xdc(%rsp)
jmp 0xb3363
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xe0(%rsp)
movl %eax, 0xdc(%rsp)
leaq 0x48(%rsp), %rdi
callq 0x7cce8
jmp 0xb3361
jmp 0xb3363
leaq 0x47(%rsp), %rdi
callq 0x76f80
testb $0x1, 0x46(%rsp)
jne 0xb3376
jmp 0xb3380
movq 0x8(%rsp), %rdi
callq 0x74e00
leaq 0x90(%rsp), %rdi
callq 0x7cce8
jmp 0xb338f
jmp 0xb3399
addq $0x148, %rsp            # imm = 0x148
retq
movq 0xe0(%rsp), %rdi
callq 0x7b550
movq %rax, %rdi
callq 0x88ef0
nop