// File: zeeev[P]DASVC/bamtools/src/api/internal/bam/BamMultiReader_p.cpp
// Function: BamTools::Internal::BamMultiReaderPrivate::OpenIndexes(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>> const&)
bool BamMultiReaderPrivate::OpenIndexes(const vector<string>& indexFilenames) {

    // TODO: This needs to be cleaner - should not assume same order.
    //       And either way, shouldn't start at first reader.  Should start at
    //       first reader without an index?

    // make sure same number of index filenames as readers
    if ( m_readers.size() != indexFilenames.size() ) {
        const string message("size of index file list does not match current BAM file count");
        SetErrorString("BamMultiReader::OpenIndexes", message);
        return false;
    }

    bool errorsEncountered = false;
    m_errorString.clear();

    // iterate over BamReaders
    vector<string>::const_iterator indexFilenameIter = indexFilenames.begin();
    vector<string>::const_iterator indexFilenameEnd  = indexFilenames.end();
    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;

        // open index filename on reader
        if ( reader ) {
            const string& indexFilename = (*indexFilenameIter);
            if ( !reader->OpenIndex(indexFilename) ) {
                m_errorString.append(1, '\t');
                m_errorString += reader->GetErrorString();
                m_errorString.append(1, '\n');
                errorsEncountered = true;
            }
        }

        // increment filename iterator, skip if no more index files to open
        if ( ++indexFilenameIter == indexFilenameEnd )
            break;
    }

    // return success/fail
    if ( errorsEncountered ) {
        const string currentError = m_errorString;
        const string message = string("could not open all index files: \n\t") + currentError;
        SetErrorString("BamMultiReader::OpenIndexes", message);
        return false;
    } else
        return true;
}

// Assembly:
subq $0x1a8, %rsp            # imm = 0x1A8
movq %rdi, 0x198(%rsp)
movq %rsi, 0x190(%rsp)
movq 0x198(%rsp), %rdi
movq %rdi, 0x38(%rsp)
callq 0x79560
movq %rax, 0x40(%rsp)
movq 0x190(%rsp), %rdi
callq 0x7bb00
movq %rax, %rcx
movq 0x40(%rsp), %rax
cmpq %rcx, %rax
je 0xa20e7
leaq 0x16f(%rsp), %rdi
movq %rdi, 0x30(%rsp)
callq 0x7b5f0
movq 0x30(%rsp), %rdx
leaq 0x48820(%rip), %rsi     # 0xea7ea
leaq 0x170(%rsp), %rdi
callq 0x78e70
jmp 0xa1fd9
leaq 0x16f(%rsp), %rdi
callq 0x76f80
leaq 0x137(%rsp), %rdi
movq %rdi, 0x28(%rsp)
callq 0x7b5f0
movq 0x28(%rsp), %rdx
leaq 0x48824(%rip), %rsi     # 0xea828
leaq 0x138(%rsp), %rdi
callq 0x78e70
jmp 0xa2013
movq 0x38(%rsp), %rdi
leaq 0x138(%rsp), %rsi
leaq 0x170(%rsp), %rdx
callq 0x77c30
jmp 0xa202f
leaq 0x138(%rsp), %rdi
callq 0x7cce8
jmp 0xa203e
leaq 0x137(%rsp), %rdi
callq 0x76f80
movb $0x0, 0x1a7(%rsp)
leaq 0x170(%rsp), %rdi
callq 0x7cce8
jmp 0xa246e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x160(%rsp)
movl %eax, 0x15c(%rsp)
leaq 0x16f(%rsp), %rdi
callq 0x76f80
jmp 0xa247f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x160(%rsp)
movl %eax, 0x15c(%rsp)
jmp 0xa20c6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x160(%rsp)
movl %eax, 0x15c(%rsp)
leaq 0x138(%rsp), %rdi
callq 0x7cce8
jmp 0xa20c4
jmp 0xa20c6
leaq 0x137(%rsp), %rdi
callq 0x76f80
leaq 0x170(%rsp), %rdi
callq 0x7cce8
jmp 0xa20e2
jmp 0xa247f
movq 0x38(%rsp), %rdi
movb $0x0, 0x136(%rsp)
addq $0x28, %rdi
callq 0x78800
movq 0x190(%rsp), %rdi
callq 0x71c40
movq %rax, 0x128(%rsp)
movq 0x190(%rsp), %rdi
callq 0x74ae0
movq 0x38(%rsp), %rdi
movq %rax, 0x120(%rsp)
callq 0x73770
movq 0x38(%rsp), %rdi
movq %rax, 0x118(%rsp)
callq 0x74890
movq %rax, 0x110(%rsp)
leaq 0x118(%rsp), %rdi
leaq 0x110(%rsp), %rsi
callq 0x74d10
testb $0x1, %al
jne 0xa2169
jmp 0xa22ac
leaq 0x118(%rsp), %rdi
callq 0x762d0
movq %rax, 0x108(%rsp)
movq 0x108(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x100(%rsp)
cmpq $0x0, 0x100(%rsp)
je 0xa2273
leaq 0x128(%rsp), %rdi
callq 0x71410
movq %rax, 0xf8(%rsp)
movq 0x100(%rsp), %rdi
movq 0xf8(%rsp), %rsi
callq 0x77370
testb $0x1, %al
jne 0xa2271
movq 0x38(%rsp), %rdi
addq $0x28, %rdi
movq %rdi, 0x18(%rsp)
movl $0x1, %esi
movl $0x9, %edx
callq 0x76f60
movq 0x100(%rsp), %rsi
leaq 0xd8(%rsp), %rdi
movq %rdi, 0x20(%rsp)
callq 0x74350
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %rsi
callq 0x78530
jmp 0xa221a
leaq 0xd8(%rsp), %rdi
callq 0x7cce8
movq 0x38(%rsp), %rdi
addq $0x28, %rdi
movl $0x1, %esi
movl $0xa, %edx
callq 0x76f60
movb $0x1, 0x136(%rsp)
jmp 0xa2271
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x160(%rsp)
movl %eax, 0x15c(%rsp)
leaq 0xd8(%rsp), %rdi
callq 0x7cce8
jmp 0xa226c
jmp 0xa247f
jmp 0xa2273
leaq 0x128(%rsp), %rdi
callq 0x75880
movq %rax, %rdi
leaq 0x120(%rsp), %rsi
callq 0x79b20
testb $0x1, %al
jne 0xa2296
jmp 0xa2298
jmp 0xa22ac
jmp 0xa229a
leaq 0x118(%rsp), %rdi
callq 0x74ed0
jmp 0xa214b
testb $0x1, 0x136(%rsp)
je 0xa2466
movq 0x38(%rsp), %rsi
addq $0x28, %rsi
leaq 0xb8(%rsp), %rdi
callq 0x73370
leaq 0x77(%rsp), %rdi
movq %rdi, 0x10(%rsp)
callq 0x7b5f0
movq 0x10(%rsp), %rdx
leaq 0x48559(%rip), %rsi     # 0xea844
leaq 0x78(%rsp), %rdi
callq 0x78e70
jmp 0xa22f7
leaq 0x98(%rsp), %rdi
leaq 0x78(%rsp), %rsi
leaq 0xb8(%rsp), %rdx
callq 0x7c720
jmp 0xa2313
leaq 0x78(%rsp), %rdi
callq 0x7cce8
jmp 0xa231f
leaq 0x77(%rsp), %rdi
callq 0x76f80
leaq 0x4f(%rsp), %rdi
movq %rdi, 0x8(%rsp)
callq 0x7b5f0
movq 0x8(%rsp), %rdx
leaq 0x484e4(%rip), %rsi     # 0xea828
leaq 0x50(%rsp), %rdi
callq 0x78e70
jmp 0xa2350
movq 0x38(%rsp), %rdi
leaq 0x50(%rsp), %rsi
leaq 0x98(%rsp), %rdx
callq 0x77c30
jmp 0xa2369
leaq 0x50(%rsp), %rdi
callq 0x7cce8
jmp 0xa2375
leaq 0x4f(%rsp), %rdi
callq 0x76f80
movb $0x0, 0x1a7(%rsp)
leaq 0x98(%rsp), %rdi
callq 0x7cce8
jmp 0xa242e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x160(%rsp)
movl %eax, 0x15c(%rsp)
jmp 0xa23d1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x160(%rsp)
movl %eax, 0x15c(%rsp)
leaq 0x78(%rsp), %rdi
callq 0x7cce8
jmp 0xa23cf
jmp 0xa23d1
leaq 0x77(%rsp), %rdi
callq 0x76f80
jmp 0xa2455
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x160(%rsp)
movl %eax, 0x15c(%rsp)
jmp 0xa2415
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x160(%rsp)
movl %eax, 0x15c(%rsp)
leaq 0x50(%rsp), %rdi
callq 0x7cce8
jmp 0xa2413
jmp 0xa2415
leaq 0x4f(%rsp), %rdi
callq 0x76f80
leaq 0x98(%rsp), %rdi
callq 0x7cce8
jmp 0xa2453
leaq 0xb8(%rsp), %rdi
callq 0x7cce8
jmp 0xa246e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x160(%rsp)
movl %eax, 0x15c(%rsp)
jmp 0xa2455
jmp 0xa2455
leaq 0xb8(%rsp), %rdi
callq 0x7cce8
jmp 0xa2464
jmp 0xa247f
movb $0x1, 0x1a7(%rsp)
movb 0x1a7(%rsp), %al
andb $0x1, %al
addq $0x1a8, %rsp            # imm = 0x1A8
retq
movq 0x160(%rsp), %rdi
callq 0x7b550
movq %rax, %rdi
callq 0x88ef0
nopw %cs:(%rax,%rax)