// File: /workspace/github_cpp_makefile_star2_O1/zeeev[P]DASVC/bamtools/src/api/internal/bam/BamMultiReader_p.cpp
// Function: BamTools::Internal::BamMultiReaderPrivate::Open(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::Open(const vector<string>& filenames) {

    m_errorString.clear();

    // put all current readers back at beginning (refreshes alignment cache)
    if ( !Rewind() ) {
        const string currentError = m_errorString;
        const string message = string("unable to rewind existing readers: \n\t") + currentError;
        SetErrorString("BamMultiReader::Open", message);
        return false;
    }

    // iterate over filenames
    bool errorsEncountered = false;
    vector<string>::const_iterator filenameIter = filenames.begin();
    vector<string>::const_iterator filenameEnd  = filenames.end();
    for ( ; filenameIter != filenameEnd; ++filenameIter ) {
        const string& filename = (*filenameIter);
        if ( filename.empty() ) continue;

        // attempt to open BamReader
        BamReader* reader = new BamReader;
        const bool readerOpened = reader->Open(filename);

        // if opened OK, store it
        if ( readerOpened )
            m_readers.push_back( MergeItem(reader, new BamAlignment) );

        // otherwise store error & clean up invalid reader
        else {
            m_errorString.append(1, '\t');
            m_errorString += string("unable to open file: ") + filename;
            m_errorString.append(1, '\n');
            errorsEncountered = true;

            delete reader;
            reader = 0;
        }
    }

    // check for errors while opening
    if ( errorsEncountered ) {
        const string currentError = m_errorString;
        const string message = string("unable to open all files: \t\n") + currentError;
        SetErrorString("BamMultiReader::Open", message);
        return false;
    }

    // check for BAM file consistency
    if ( !ValidateReaders() ) {
        const string currentError = m_errorString;
        const string message = string("unable to open inconsistent files: \t\n") + currentError;
        SetErrorString("BamMultiReader::Open", message);
        return false;
    }

    // update alignment cache
    return UpdateAlignmentCache();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rsi, %r15
movq %rdi, %rbx
movq $0x0, 0x30(%rdi)
movq 0x28(%rdi), %rax
movb $0x0, (%rax)
callq 0x29150
testb %al, %al
je 0x3686c
movq (%r15), %r14
movq 0x8(%r15), %r13
cmpq %r13, %r14
je 0x36900
leaq 0x28(%rbx), %r15
movq $0x0, 0x68(%rsp)
movq %r13, 0x70(%rsp)
cmpq $0x0, 0x8(%r14)
je 0x3678b
movl $0x8, %edi
callq 0x276b0
movq %rax, %rbp
movq %rax, %rdi
callq 0x26f90
movq %rbp, %rdi
movq %r14, %rsi
callq 0x27f40
testb %al, %al
je 0x366d3
movl $0x158, %edi            # imm = 0x158
callq 0x276b0
movq %rax, %r12
movq %rax, %rdi
callq 0x265e0
movq %rbp, 0x28(%rsp)
movq %r12, 0x30(%rsp)
movq %rbx, %rdi
leaq 0x28(%rsp), %rsi
callq 0x272a0
movq 0x70(%rsp), %r13
jmp 0x3678b
movq 0x30(%rbx), %rsi
movl $0x1, %ecx
movq %r15, %rdi
xorl %edx, %edx
movl $0x9, %r8d
callq 0x28f30
leaq 0x58(%rsp), %rax
movq %rax, 0x48(%rsp)
leaq 0x48(%rsp), %r12
movq %r12, %rdi
leaq 0x1edf3(%rip), %rsi     # 0x554f8
leaq 0x1ee01(%rip), %rdx     # 0x5550d
callq 0x26750
leaq 0x28(%rsp), %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x29130
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
movq %r15, %rdi
callq 0x265d0
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x36747
callq 0x27560
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x3675b
callq 0x27560
movq 0x30(%rbx), %rsi
movl $0x1, %ecx
movq %r15, %rdi
xorl %edx, %edx
movl $0xa, %r8d
callq 0x28f30
movq %rbp, %rdi
callq 0x278c0
movq %rbp, %rdi
callq 0x27560
movb $0x1, %al
movq %rax, 0x68(%rsp)
addq $0x20, %r14
cmpq %r13, %r14
jne 0x3666e
testb $0x1, 0x68(%rsp)
je 0x36900
leaq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
movq %rax, (%rdi)
movq 0x28(%rbx), %rsi
movq 0x30(%rbx), %rdx
addq %rsi, %rdx
callq 0x267c0
leaq 0x18(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x1ed3e(%rip), %rsi     # 0x5550e
leaq 0x1ed53(%rip), %rdx     # 0x5552a
leaq 0x8(%rsp), %rdi
callq 0x26750
leaq 0x48(%rsp), %rdi
leaq 0x8(%rsp), %rsi
leaq 0x28(%rsp), %rdx
callq 0x29130
movq 0x8(%rsp), %rdi
cmpq %r14, %rdi
je 0x36804
callq 0x27560
leaq 0x8(%rsp), %rdi
movq %r14, (%rdi)
leaq 0x1ecd0(%rip), %rsi     # 0x554e3
leaq 0x1ecdd(%rip), %rdx     # 0x554f7
callq 0x26750
leaq 0x8(%rsp), %rsi
leaq 0x48(%rsp), %rdx
movq %rbx, %rdi
callq 0x27be0
movq 0x8(%rsp), %rdi
cmpq %r14, %rdi
je 0x36840
callq 0x27560
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x36854
callq 0x27560
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
jne 0x369d4
jmp 0x369d9
leaq 0x38(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x28(%rbx), %rsi
movq 0x30(%rbx), %rdx
addq %rsi, %rdx
leaq 0x28(%rsp), %rdi
callq 0x267c0
leaq 0x18(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x1ec23(%rip), %rsi     # 0x554bd
leaq 0x1ec41(%rip), %rdx     # 0x554e2
leaq 0x8(%rsp), %rdi
callq 0x26750
leaq 0x48(%rsp), %rdi
leaq 0x8(%rsp), %rsi
leaq 0x28(%rsp), %rdx
callq 0x29130
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x368ce
callq 0x27560
leaq 0x8(%rsp), %rdi
movq %r15, (%rdi)
leaq 0x1ec06(%rip), %rsi     # 0x554e3
leaq 0x1ec13(%rip), %rdx     # 0x554f7
callq 0x26750
leaq 0x8(%rsp), %rsi
leaq 0x48(%rsp), %rdx
movq %rbx, %rdi
callq 0x27be0
jmp 0x369a8
movq %rbx, %rdi
callq 0x28f70
testb %al, %al
je 0x36919
movq %rbx, %rdi
callq 0x26060
jmp 0x369db
leaq 0x38(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x28(%rbx), %rsi
movq 0x30(%rbx), %rdx
addq %rsi, %rdx
leaq 0x28(%rsp), %rdi
callq 0x267c0
leaq 0x18(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x1ebe4(%rip), %rsi     # 0x5552b
leaq 0x1ec02(%rip), %rdx     # 0x55550
leaq 0x8(%rsp), %rdi
callq 0x26750
leaq 0x48(%rsp), %rdi
leaq 0x8(%rsp), %rsi
leaq 0x28(%rsp), %rdx
callq 0x29130
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x3697b
callq 0x27560
leaq 0x8(%rsp), %rdi
movq %r15, (%rdi)
leaq 0x1eb59(%rip), %rsi     # 0x554e3
leaq 0x1eb66(%rip), %rdx     # 0x554f7
callq 0x26750
leaq 0x8(%rsp), %rsi
leaq 0x48(%rsp), %rdx
movq %rbx, %rdi
callq 0x27be0
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x369b7
callq 0x27560
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x369ca
callq 0x27560
movq 0x28(%rsp), %rdi
cmpq %r14, %rdi
je 0x369d9
callq 0x27560
xorl %eax, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x58(%rsp), %r12
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r14, %rdi
je 0x36a0b
callq 0x27560
jmp 0x36a0b
leaq 0x58(%rsp), %r12
movq %rax, %rbx
movq 0x48(%rsp), %rdi
cmpq %r12, %rdi
jne 0x36a24
jmp 0x36a2e
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r14, %rdi
je 0x36a2e
callq 0x27560
jmp 0x36a2e
movq %rax, %rbx
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
jne 0x36ae1
jmp 0x36ae6
jmp 0x36a4e
jmp 0x36a62
jmp 0x36a75
jmp 0x36a89
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x36a65
callq 0x27560
jmp 0x36a65
movq %rax, %rbx
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
jne 0x36a82
jmp 0x36a8c
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x36a8c
callq 0x27560
jmp 0x36a8c
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %r14, %rdi
jne 0x36ae1
jmp 0x36ae6
jmp 0x36adb
leaq 0x58(%rsp), %r12
movq %rax, %rbx
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x36ac0
callq 0x27560
jmp 0x36ac0
leaq 0x58(%rsp), %r12
movq %rax, %rbx
movq 0x48(%rsp), %rdi
cmpq %r12, %rdi
jne 0x36ae1
jmp 0x36ae6
jmp 0x36ace
movq %rax, %rbx
jmp 0x36ae6
movq %rax, %rbx
movq %r12, %rdi
jmp 0x36ae1
movq %rax, %rbx
movq %rbp, %rdi
callq 0x27560
movq %rbx, %rdi
callq 0x28c20