// File: zeeev[P]DASVC/bamtools/src/api/internal/index/BamIndexFactory_p.cpp
// Function: BamTools::Internal::BamIndexFactory::FindIndexFilename(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, BamTools::BamIndex::IndexType const&)
const string BamIndexFactory::FindIndexFilename(const string& bamFilename,
                                                const BamIndex::IndexType& preferredType)
{
    // skip if BAM filename provided is empty
    if ( bamFilename.empty() )
        return string();

    // try to find index of preferred type first
    // return index filename if found
    string indexFilename = CreateIndexFilename(bamFilename, preferredType);
    if ( !indexFilename.empty() )
        return indexFilename;

    // couldn't find preferred type, try the other supported types
    // return index filename if found
    if ( preferredType != BamIndex::STANDARD ) {
        indexFilename = CreateIndexFilename(bamFilename, BamIndex::STANDARD);
        if ( !indexFilename.empty() )
            return indexFilename;
    }
    if ( preferredType != BamIndex::BAMTOOLS ) {
        indexFilename = CreateIndexFilename(bamFilename, BamIndex::BAMTOOLS);
        if ( !indexFilename.empty() )
            return indexFilename;
    }

    // otherwise couldn't find any index matching this filename
    return string();
}

// Assembly:
subq $0xc8, %rsp
movq %rdi, 0x20(%rsp)
movq %rdi, %rax
movq %rax, 0x28(%rsp)
movq %rdi, 0xc0(%rsp)
movq %rsi, 0xb8(%rsp)
movq %rdx, 0xb0(%rsp)
movq 0xb8(%rsp), %rdi
callq 0x7aba0
testb $0x1, %al
jne 0xb05ef
jmp 0xb05fe
movq 0x20(%rsp), %rdi
callq 0x79100
jmp 0xb081c
movq 0xb8(%rsp), %rsi
movq 0xb0(%rsp), %rdx
leaq 0x90(%rsp), %rdi
movq %rdi, 0x10(%rsp)
callq 0x72ac0
movq 0x10(%rsp), %rdi
callq 0x7aba0
movb %al, 0x1f(%rsp)
jmp 0xb0630
movb 0x1f(%rsp), %al
testb $0x1, %al
jne 0xb0677
jmp 0xb063a
movq 0x20(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0x73370
jmp 0xb064e
movl $0x1, 0x80(%rsp)
jmp 0xb07fc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x88(%rsp)
movl %eax, 0x84(%rsp)
jmp 0xb080b
movq 0xb0(%rsp), %rax
cmpl $0x1, (%rax)
je 0xb0731
movq 0xb8(%rsp), %rsi
movl $0x1, 0x5c(%rsp)
leaq 0x60(%rsp), %rdi
leaq 0x5c(%rsp), %rdx
callq 0x72ac0
jmp 0xb06a9
leaq 0x90(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x71240
jmp 0xb06bd
leaq 0x60(%rsp), %rdi
callq 0x7cce8
jmp 0xb06c9
leaq 0x90(%rsp), %rdi
callq 0x7aba0
movb %al, 0xf(%rsp)
jmp 0xb06dc
movb 0xf(%rsp), %al
testb $0x1, %al
jne 0xb072f
jmp 0xb06e6
movq 0x20(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0x73370
jmp 0xb06fa
movl $0x1, 0x80(%rsp)
jmp 0xb07fc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x88(%rsp)
movl %eax, 0x84(%rsp)
leaq 0x60(%rsp), %rdi
callq 0x7cce8
jmp 0xb072a
jmp 0xb080b
jmp 0xb0731
movq 0xb0(%rsp), %rax
cmpl $0x0, (%rax)
je 0xb07e5
movq 0xb8(%rsp), %rsi
movl $0x0, 0x34(%rsp)
leaq 0x38(%rsp), %rdi
leaq 0x34(%rsp), %rdx
callq 0x72ac0
jmp 0xb0763
leaq 0x90(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x71240
jmp 0xb0777
leaq 0x38(%rsp), %rdi
callq 0x7cce8
jmp 0xb0783
leaq 0x90(%rsp), %rdi
callq 0x7aba0
movb %al, 0xe(%rsp)
jmp 0xb0796
movb 0xe(%rsp), %al
testb $0x1, %al
jne 0xb07e3
jmp 0xb07a0
movq 0x20(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0x73370
jmp 0xb07b4
movl $0x1, 0x80(%rsp)
jmp 0xb07fc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x88(%rsp)
movl %eax, 0x84(%rsp)
leaq 0x38(%rsp), %rdi
callq 0x7cce8
jmp 0xb07e1
jmp 0xb080b
jmp 0xb07e5
movq 0x20(%rsp), %rdi
callq 0x79100
jmp 0xb07f1
movl $0x1, 0x80(%rsp)
leaq 0x90(%rsp), %rdi
callq 0x7cce8
jmp 0xb081c
leaq 0x90(%rsp), %rdi
callq 0x7cce8
jmp 0xb081a
jmp 0xb0829
movq 0x28(%rsp), %rax
addq $0xc8, %rsp
retq
movq 0x88(%rsp), %rdi
callq 0x7b550
movq %rax, %rdi
callq 0x88ef0
nop