// File: /workspace/github_cpp_makefile_star2_O3/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 $0x78, %rsp
movq %rdi, %rbx
movq 0x8(%rdi), %rax
subq (%rdi), %rax
sarq $0x4, %rax
movq 0x8(%rsi), %rcx
subq (%rsi), %rcx
sarq $0x5, %rcx
cmpq %rcx, %rax
jne 0x37b3e
movq $0x0, 0x30(%rbx)
movq 0x28(%rbx), %rax
movb $0x0, (%rax)
movq (%rbx), %r12
movq 0x8(%rbx), %rbp
movb $0x1, %al
cmpq %rbp, %r12
je 0x37bb2
movq %rbx, 0x28(%rsp)
leaq 0x28(%rbx), %r14
movq 0x8(%rsi), %rbx
movq (%rsi), %r15
addq $0x10, %r12
movq $0x0, 0x30(%rsp)
movq -0x10(%r12), %r13
testq %r13, %r13
je 0x37a51
movq %r13, %rdi
movq %r15, %rsi
callq 0x279b0
testb %al, %al
jne 0x37a51
movq 0x28(%rsp), %rax
movq 0x30(%rax), %rsi
movl $0x1, %ecx
movq %r14, %rdi
xorl %edx, %edx
movl $0x9, %r8d
callq 0x28f20
leaq 0x8(%rsp), %rdi
movq %r13, %rsi
callq 0x26d30
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %r14, %rdi
callq 0x265d0
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x37a2c
callq 0x27560
movq 0x28(%rsp), %rax
movq 0x30(%rax), %rsi
movl $0x1, %ecx
movq %r14, %rdi
xorl %edx, %edx
movl $0xa, %r8d
callq 0x28f20
movb $0x1, %al
movq %rax, 0x30(%rsp)
addq $0x20, %r15
cmpq %rbx, %r15
je 0x37a6b
leaq 0x10(%r12), %rax
cmpq %rbp, %r12
movq %rax, %r12
jne 0x379be
testb $0x1, 0x30(%rsp)
movb $0x1, %al
je 0x37bb2
leaq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
movq %rax, (%rdi)
movq 0x28(%rsp), %rbx
movq 0x28(%rbx), %rsi
movq 0x30(%rbx), %rdx
addq %rsi, %rdx
callq 0x267c0
leaq 0x48(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x1db30(%rip), %rsi     # 0x555da
leaq 0x1db4b(%rip), %rdx     # 0x555fc
leaq 0x38(%rsp), %rdi
callq 0x26750
leaq 0x58(%rsp), %rdi
leaq 0x38(%rsp), %rsi
leaq 0x8(%rsp), %rdx
callq 0x29120
movq 0x38(%rsp), %rdi
cmpq %r14, %rdi
je 0x37ade
callq 0x27560
leaq 0x38(%rsp), %rdi
movq %r14, (%rdi)
leaq 0x1dad1(%rip), %rsi     # 0x555be
leaq 0x1dae5(%rip), %rdx     # 0x555d9
callq 0x26750
leaq 0x38(%rsp), %rsi
leaq 0x58(%rsp), %rdx
movq %rbx, %rdi
callq 0x27bd0
movq 0x38(%rsp), %rdi
cmpq %r14, %rdi
je 0x37b1a
callq 0x27560
leaq 0x68(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x37b2d
callq 0x27560
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
jne 0x37bab
jmp 0x37bb0
leaq 0x18(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x1da32(%rip), %rsi     # 0x55580
leaq 0x1da68(%rip), %rdx     # 0x555bd
leaq 0x8(%rsp), %rdi
callq 0x26750
leaq 0x68(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x1da4f(%rip), %rsi     # 0x555be
leaq 0x1da63(%rip), %rdx     # 0x555d9
leaq 0x58(%rsp), %rdi
callq 0x26750
leaq 0x58(%rsp), %rsi
leaq 0x8(%rsp), %rdx
movq %rbx, %rdi
callq 0x27bd0
movq 0x58(%rsp), %rdi
cmpq %r15, %rdi
je 0x37ba1
callq 0x27560
movq 0x8(%rsp), %rdi
cmpq %r14, %rdi
je 0x37bb0
callq 0x27560
xorl %eax, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x38(%rsp), %rdi
cmpq %r14, %rdi
je 0x37bd8
callq 0x27560
jmp 0x37bd8
movq %rax, %rbx
leaq 0x68(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
jne 0x37bf5
jmp 0x37c29
movq %rax, %rbx
movq 0x38(%rsp), %rdi
cmpq %r14, %rdi
je 0x37c29
callq 0x27560
jmp 0x37c29
jmp 0x37c26
movq %rax, %rbx
movq 0x58(%rsp), %rdi
cmpq %r15, %rdi
je 0x37c15
callq 0x27560
jmp 0x37c15
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r14, %rdi
jne 0x37c38
jmp 0x37c3d
movq %rax, %rbx
jmp 0x37c3d
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x37c3d
callq 0x27560
movq %rbx, %rdi
callq 0x28c10
nop