// File: zeeev[P]DASVC/bamtools/src/api/internal/bam/BamRandomAccessController_p.cpp
// Function: BamTools::Internal::BamRandomAccessController::LocateIndex(BamTools::Internal::BamReaderPrivate*, BamTools::BamIndex::IndexType const&)
bool BamRandomAccessController::LocateIndex(BamReaderPrivate* reader,
                                            const BamIndex::IndexType& preferredType)
{
    // look up index filename, deferring to preferredType if possible
    assert(reader);
    const string& indexFilename = BamIndexFactory::FindIndexFilename(reader->Filename(), preferredType);

    // if no index file found (of any type)
    if ( indexFilename.empty() ) {
        const string message = string("could not find index file for:") + reader->Filename();
        SetErrorString("BamRandomAccessController::LocateIndex", message);
        return false;
    }

    // otherwise open & use index file that was found
    return OpenIndex(indexFilename, reader);
}

// Assembly:
subq $0x138, %rsp            # imm = 0x138
movq %rdi, 0x128(%rsp)
movq %rsi, 0x120(%rsp)
movq %rdx, 0x118(%rsp)
movq 0x128(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x120(%rsp), %rsi
leaq 0xd0(%rsp), %rdi
movq %rdi, 0x28(%rsp)
callq 0x78400
movq 0x28(%rsp), %rsi
movq 0x118(%rsp), %rdx
leaq 0xf0(%rsp), %rdi
callq 0x74e70
jmp 0xa8bc2
leaq 0xd0(%rsp), %rdi
callq 0x7cce8
leaq 0xf0(%rsp), %rax
movq %rax, 0x110(%rsp)
movq 0x110(%rsp), %rdi
callq 0x7aba0
movb %al, 0x1f(%rsp)
jmp 0xa8bf2
movb 0x1f(%rsp), %al
testb $0x1, %al
jne 0xa8bff
jmp 0xa8dfa
leaq 0x7f(%rsp), %rdi
movq %rdi, 0x10(%rsp)
callq 0x7b5f0
movq 0x10(%rsp), %rdx
leaq 0x41f0a(%rip), %rsi     # 0xeab24
leaq 0x80(%rsp), %rdi
callq 0x78e70
jmp 0xa8c29
movq 0x120(%rsp), %rsi
leaq 0x58(%rsp), %rdi
callq 0x78400
jmp 0xa8c3d
leaq 0xa0(%rsp), %rdi
leaq 0x80(%rsp), %rsi
leaq 0x58(%rsp), %rdx
callq 0x7c720
jmp 0xa8c59
leaq 0x58(%rsp), %rdi
callq 0x7cce8
jmp 0xa8c65
leaq 0x80(%rsp), %rdi
callq 0x7cce8
jmp 0xa8c74
leaq 0x7f(%rsp), %rdi
callq 0x76f80
leaq 0x37(%rsp), %rdi
movq %rdi, 0x8(%rsp)
callq 0x7b5f0
movq 0x8(%rsp), %rdx
leaq 0x41eaa(%rip), %rsi     # 0xeab43
leaq 0x38(%rsp), %rdi
callq 0x78e70
jmp 0xa8ca5
movq 0x20(%rsp), %rdi
leaq 0x38(%rsp), %rsi
leaq 0xa0(%rsp), %rdx
callq 0x71e80
jmp 0xa8cbe
leaq 0x38(%rsp), %rdi
callq 0x7cce8
jmp 0xa8cca
leaq 0x37(%rsp), %rdi
callq 0x76f80
movb $0x0, 0x137(%rsp)
movl $0x1, 0x30(%rsp)
leaq 0xa0(%rsp), %rdi
callq 0x7cce8
jmp 0xa8df6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xc8(%rsp)
movl %eax, 0xc4(%rsp)
leaq 0xd0(%rsp), %rdi
callq 0x7cce8
jmp 0xa8d19
jmp 0xa8e5e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xc8(%rsp)
movl %eax, 0xc4(%rsp)
jmp 0xa8e4d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xc8(%rsp)
movl %eax, 0xc4(%rsp)
jmp 0xa8d96
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xc8(%rsp)
movl %eax, 0xc4(%rsp)
jmp 0xa8d85
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xc8(%rsp)
movl %eax, 0xc4(%rsp)
leaq 0x58(%rsp), %rdi
callq 0x7cce8
jmp 0xa8d83
jmp 0xa8d85
leaq 0x80(%rsp), %rdi
callq 0x7cce8
jmp 0xa8d94
jmp 0xa8d96
leaq 0x7f(%rsp), %rdi
callq 0x76f80
jmp 0xa8e4d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xc8(%rsp)
movl %eax, 0xc4(%rsp)
jmp 0xa8ddd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xc8(%rsp)
movl %eax, 0xc4(%rsp)
leaq 0x38(%rsp), %rdi
callq 0x7cce8
jmp 0xa8ddb
jmp 0xa8ddd
leaq 0x37(%rsp), %rdi
callq 0x76f80
leaq 0xa0(%rsp), %rdi
callq 0x7cce8
jmp 0xa8df8
jmp 0xa8e2f
jmp 0xa8e4d
movq 0x20(%rsp), %rdi
movq 0x110(%rsp), %rsi
movq 0x120(%rsp), %rdx
callq 0x75a70
movb %al, 0x7(%rsp)
jmp 0xa8e1a
movb 0x7(%rsp), %al
andb $0x1, %al
movb %al, 0x137(%rsp)
movl $0x1, 0x30(%rsp)
leaq 0xf0(%rsp), %rdi
callq 0x7cce8
movb 0x137(%rsp), %al
andb $0x1, %al
addq $0x138, %rsp            # imm = 0x138
retq
leaq 0xf0(%rsp), %rdi
callq 0x7cce8
jmp 0xa8e5c
jmp 0xa8e5e
movq 0xc8(%rsp), %rdi
callq 0x7b550
movq %rax, %rdi
callq 0x88ef0
nopw %cs:(%rax,%rax)