// File: zeeev[P]DASVC/bamtools/src/api/internal/bam/BamMultiReader_p.cpp
// Function: BamTools::Internal::BamMultiReaderPrivate::LocateIndexes(BamTools::BamIndex::IndexType const&)
bool BamMultiReaderPrivate::LocateIndexes(const BamIndex::IndexType& preferredType) {

    bool errorsEncountered = false;
    m_errorString.clear();

    // iterate over readers
    vector<MergeItem>::iterator readerIter = m_readers.begin();
    vector<MergeItem>::iterator readerEnd  = m_readers.end();
    for ( ; readerIter != readerEnd; ++readerIter ) {
        MergeItem& item = (*readerIter);
        BamReader* reader = item.Reader;
        if ( reader == 0 ) continue;

        // if reader has no index, try to locate one
        if ( !reader->HasIndex() ) {
            if ( !reader->LocateIndex(preferredType) ) {
                m_errorString.append(1, '\t');
                m_errorString.append(reader->GetErrorString());
                m_errorString.append(1, '\n');
                errorsEncountered = true;
            }
        }
    }

    // check for errors encountered before returning success/fail
    if ( errorsEncountered ) {
        const string currentError = m_errorString;
        const string message = string("error while locating index files: ") + "\n" + currentError;
        SetErrorString("BamMultiReader::LocatingIndexes", message);
        return false;
    } else
        return true;
}

// Assembly:
subq $0x148, %rsp            # imm = 0x148
movq %rdi, 0x138(%rsp)
movq %rsi, 0x130(%rsp)
movq 0x138(%rsp), %rdi
movq %rdi, 0x20(%rsp)
movb $0x0, 0x12f(%rsp)
addq $0x28, %rdi
callq 0x78800
movq 0x20(%rsp), %rdi
callq 0x73770
movq 0x20(%rsp), %rdi
movq %rax, 0x120(%rsp)
callq 0x74890
movq %rax, 0x118(%rsp)
leaq 0x120(%rsp), %rdi
leaq 0x118(%rsp), %rsi
callq 0x74d10
testb $0x1, %al
jne 0x9fad7
jmp 0x9fbf6
leaq 0x120(%rsp), %rdi
callq 0x762d0
movq %rax, 0x110(%rsp)
movq 0x110(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x108(%rsp)
cmpq $0x0, 0x108(%rsp)
jne 0x9fb0f
jmp 0x9fbe4
movq 0x108(%rsp), %rdi
callq 0x71900
testb $0x1, %al
jne 0x9fbe2
movq 0x108(%rsp), %rdi
movq 0x130(%rsp), %rsi
callq 0x72a90
testb $0x1, %al
jne 0x9fbe0
movq 0x20(%rsp), %rdi
addq $0x28, %rdi
movq %rdi, 0x10(%rsp)
movl $0x1, %esi
movl $0x9, %edx
callq 0x76f60
movq 0x108(%rsp), %rsi
leaq 0xe8(%rsp), %rdi
movq %rdi, 0x18(%rsp)
callq 0x74350
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
callq 0x7c8b0
jmp 0x9fb89
leaq 0xe8(%rsp), %rdi
callq 0x7cce8
movq 0x20(%rsp), %rdi
addq $0x28, %rdi
movl $0x1, %esi
movl $0xa, %edx
callq 0x76f60
movb $0x1, 0x12f(%rsp)
jmp 0x9fbe0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xe0(%rsp)
movl %eax, 0xdc(%rsp)
leaq 0xe8(%rsp), %rdi
callq 0x7cce8
jmp 0x9fbdb
jmp 0x9fe0f
jmp 0x9fbe2
jmp 0x9fbe4
leaq 0x120(%rsp), %rdi
callq 0x74ed0
jmp 0x9fab9
testb $0x1, 0x12f(%rsp)
je 0x9fdf6
movq 0x20(%rsp), %rsi
addq $0x28, %rsi
leaq 0xb8(%rsp), %rdi
callq 0x73370
leaq 0x57(%rsp), %rdi
movq %rdi, 0x8(%rsp)
callq 0x7b5f0
movq 0x8(%rsp), %rdx
leaq 0x4aaaf(%rip), %rsi     # 0xea6e4
leaq 0x58(%rsp), %rdi
callq 0x78e70
jmp 0x9fc41
leaq 0x4ab4b(%rip), %rdx     # 0xea793
leaq 0x78(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x785a0
jmp 0x9fc59
leaq 0x98(%rsp), %rdi
leaq 0x78(%rsp), %rsi
leaq 0xb8(%rsp), %rdx
callq 0x7c720
jmp 0x9fc75
leaq 0x78(%rsp), %rdi
callq 0x7cce8
jmp 0x9fc81
leaq 0x58(%rsp), %rdi
callq 0x7cce8
jmp 0x9fc8d
leaq 0x57(%rsp), %rdi
callq 0x76f80
leaq 0x2f(%rsp), %rdi
movq %rdi, (%rsp)
callq 0x7b5f0
movq (%rsp), %rdx
leaq 0x4aa57(%rip), %rsi     # 0xea707
leaq 0x30(%rsp), %rdi
callq 0x78e70
jmp 0x9fcbc
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rsi
leaq 0x98(%rsp), %rdx
callq 0x77c30
jmp 0x9fcd5
leaq 0x30(%rsp), %rdi
callq 0x7cce8
jmp 0x9fce1
leaq 0x2f(%rsp), %rdi
callq 0x76f80
movb $0x0, 0x147(%rsp)
leaq 0x98(%rsp), %rdi
callq 0x7cce8
jmp 0x9fdbe
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xe0(%rsp)
movl %eax, 0xdc(%rsp)
jmp 0x9fd61
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xe0(%rsp)
movl %eax, 0xdc(%rsp)
jmp 0x9fd53
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xe0(%rsp)
movl %eax, 0xdc(%rsp)
leaq 0x78(%rsp), %rdi
callq 0x7cce8
jmp 0x9fd51
jmp 0x9fd53
leaq 0x58(%rsp), %rdi
callq 0x7cce8
jmp 0x9fd5f
jmp 0x9fd61
leaq 0x57(%rsp), %rdi
callq 0x76f80
jmp 0x9fde5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xe0(%rsp)
movl %eax, 0xdc(%rsp)
jmp 0x9fda5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xe0(%rsp)
movl %eax, 0xdc(%rsp)
leaq 0x30(%rsp), %rdi
callq 0x7cce8
jmp 0x9fda3
jmp 0x9fda5
leaq 0x2f(%rsp), %rdi
callq 0x76f80
leaq 0x98(%rsp), %rdi
callq 0x7cce8
jmp 0x9fde3
leaq 0xb8(%rsp), %rdi
callq 0x7cce8
jmp 0x9fdfe
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xe0(%rsp)
movl %eax, 0xdc(%rsp)
jmp 0x9fde5
jmp 0x9fde5
leaq 0xb8(%rsp), %rdi
callq 0x7cce8
jmp 0x9fdf4
jmp 0x9fe0f
movb $0x1, 0x147(%rsp)
movb 0x147(%rsp), %al
andb $0x1, %al
addq $0x148, %rsp            # imm = 0x148
retq
movq 0xe0(%rsp), %rdi
callq 0x7b550
movq %rax, %rdi
callq 0x88ef0
nopw %cs:(%rax,%rax)