// File: /workspace/github_cpp_makefile_star2_O2/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rdi, %r12
movq 0x8(%rdi), %rax
subq (%rdi), %rax
sarq $0x4, %rax
movq 0x8(%rsi), %rcx
subq (%rsi), %rcx
sarq $0x5, %rcx
cmpq %rcx, %rax
jne 0x40f11
andq $0x0, 0x30(%r12)
leaq 0x28(%r12), %rax
movq %rax, 0x10(%rsp)
movq 0x28(%r12), %rax
movb $0x0, (%rax)
movq (%rsi), %r15
movq 0x8(%rsi), %rbx
movq (%r12), %r13
movq %r12, 0x78(%rsp)
movq 0x8(%r12), %rbp
movl $0x0, 0xc(%rsp)
pushq $0x1
popq %r14
movq %rbp, 0x80(%rsp)
cmpq %rbp, %r13
je 0x40e6f
movq (%r13), %r12
testq %r12, %r12
je 0x40e5e
movq %r12, %rdi
movq %r15, %rsi
callq 0x33530
testb %al, %al
jne 0x40e5e
movq %rbx, %rbp
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
pushq $0x9
popq %rdx
callq 0x333e0
leaq 0x18(%rsp), %rdi
movq %r12, %rsi
movq %rbx, %r12
movq %rdi, %rbx
callq 0x32330
movq %r12, %rdi
movq %rbx, %rsi
callq 0x35680
movq %rbx, %rdi
callq 0x33a00
movq %r12, %rdi
movq %r14, %rsi
pushq $0xa
popq %rdx
callq 0x333e0
movb $0x1, %al
movl %eax, 0xc(%rsp)
movq %rbp, %rbx
movq 0x80(%rsp), %rbp
addq $0x20, %r15
addq $0x10, %r13
cmpq %rbx, %r15
jne 0x40de2
movl 0xc(%rsp), %ebp
testb $0x1, %bpl
je 0x40f0b
leaq 0x18(%rsp), %rdi
movq 0x10(%rsp), %rsi
callq 0x33ff0
leaq 0x1a78c(%rip), %rsi     # 0x5b61f
leaq 0x38(%rsp), %rdi
leaq 0xb(%rsp), %rdx
callq 0x31b30
movq 0x78(%rsp), %rbx
leaq 0x58(%rsp), %rdi
leaq 0x38(%rsp), %rsi
leaq 0x18(%rsp), %rdx
callq 0x355e0
leaq 0x38(%rsp), %rdi
callq 0x33a00
leaq 0x1a737(%rip), %rsi     # 0x5b603
leaq 0x38(%rsp), %rdi
leaq 0xb(%rsp), %rdx
callq 0x31b30
leaq 0x38(%rsp), %rsi
leaq 0x58(%rsp), %rdx
movq %rbx, %rdi
callq 0x338e0
leaq 0x38(%rsp), %rdi
callq 0x33a00
leaq 0x58(%rsp), %rdi
callq 0x33a00
leaq 0x18(%rsp), %rdi
callq 0x33a00
xorb $0x1, %bpl
jmp 0x40f65
leaq 0x1a6ad(%rip), %rsi     # 0x5b5c5
leaq 0x18(%rsp), %rdi
leaq 0x58(%rsp), %rdx
callq 0x31b30
leaq 0x1a6d5(%rip), %rsi     # 0x5b603
leaq 0x58(%rsp), %rdi
leaq 0x38(%rsp), %rdx
callq 0x31b30
leaq 0x58(%rsp), %rsi
leaq 0x18(%rsp), %rdx
movq %r12, %rdi
callq 0x338e0
leaq 0x58(%rsp), %rdi
callq 0x33a00
leaq 0x18(%rsp), %rdi
callq 0x33a00
xorl %ebp, %ebp
andb $0x1, %bpl
movl %ebp, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x40fac
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x33a00
jmp 0x40fa0
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x33a00
jmp 0x40faf
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x33a00
jmp 0x40faf
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x33a00
jmp 0x40feb
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x33a00
jmp 0x40fd2
movq %rax, %rbx
jmp 0x40feb
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x33a00
jmp 0x40feb
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x33a00
movq %rbx, %rdi
callq 0x34ed0
movq %rax, %rdi
callq 0x39b2f
nop