// File: 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:
subq $0x2c8, %rsp            # imm = 0x2C8
movq %rdi, 0x2b8(%rsp)
movq %rsi, 0x2b0(%rsp)
movq 0x2b8(%rsp), %rdi
movq %rdi, 0x68(%rsp)
addq $0x28, %rdi
callq 0x78800
movq 0x68(%rsp), %rdi
callq 0x7c760
testb $0x1, %al
jne 0xa004e
movq 0x68(%rsp), %rsi
addq $0x28, %rsi
leaq 0x290(%rsp), %rdi
callq 0x73370
leaq 0x24f(%rsp), %rdi
movq %rdi, 0x60(%rsp)
callq 0x7b5f0
movq 0x60(%rsp), %rdx
leaq 0x4a884(%rip), %rsi     # 0xea727
leaq 0x250(%rsp), %rdi
callq 0x78e70
jmp 0x9feb2
leaq 0x270(%rsp), %rdi
leaq 0x250(%rsp), %rsi
leaq 0x290(%rsp), %rdx
callq 0x7c720
jmp 0x9fed1
leaq 0x250(%rsp), %rdi
callq 0x7cce8
jmp 0x9fee0
leaq 0x24f(%rsp), %rdi
callq 0x76f80
leaq 0x217(%rsp), %rdi
movq %rdi, 0x58(%rsp)
callq 0x7b5f0
movq 0x58(%rsp), %rdx
leaq 0x4a842(%rip), %rsi     # 0xea74d
leaq 0x218(%rsp), %rdi
callq 0x78e70
jmp 0x9ff1a
movq 0x68(%rsp), %rdi
leaq 0x218(%rsp), %rsi
leaq 0x270(%rsp), %rdx
callq 0x77c30
jmp 0x9ff36
leaq 0x218(%rsp), %rdi
callq 0x7cce8
jmp 0x9ff45
leaq 0x217(%rsp), %rdi
callq 0x76f80
movb $0x0, 0x2c7(%rsp)
leaq 0x270(%rsp), %rdi
callq 0x7cce8
jmp 0xa0010
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x240(%rsp)
movl %eax, 0x23c(%rsp)
jmp 0x9ffa7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x240(%rsp)
movl %eax, 0x23c(%rsp)
leaq 0x250(%rsp), %rdi
callq 0x7cce8
jmp 0x9ffa5
jmp 0x9ffa7
leaq 0x24f(%rsp), %rdi
callq 0x76f80
jmp 0xa003a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x240(%rsp)
movl %eax, 0x23c(%rsp)
jmp 0x9fff4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x240(%rsp)
movl %eax, 0x23c(%rsp)
leaq 0x218(%rsp), %rdi
callq 0x7cce8
jmp 0x9fff2
jmp 0x9fff4
leaq 0x217(%rsp), %rdi
callq 0x76f80
leaq 0x270(%rsp), %rdi
callq 0x7cce8
jmp 0xa0038
leaq 0x290(%rsp), %rdi
callq 0x7cce8
jmp 0xa077d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x240(%rsp)
movl %eax, 0x23c(%rsp)
jmp 0xa003a
jmp 0xa003a
leaq 0x290(%rsp), %rdi
callq 0x7cce8
jmp 0xa0049
jmp 0xa078e
movb $0x0, 0x216(%rsp)
movq 0x2b0(%rsp), %rdi
callq 0x71c40
movq %rax, 0x208(%rsp)
movq 0x2b0(%rsp), %rdi
callq 0x74ae0
movq %rax, 0x200(%rsp)
leaq 0x208(%rsp), %rdi
leaq 0x200(%rsp), %rsi
callq 0x750f0
testb $0x1, %al
jne 0xa009e
jmp 0xa03ac
leaq 0x208(%rsp), %rdi
callq 0x71410
movq %rax, 0x1f8(%rsp)
movq 0x1f8(%rsp), %rdi
callq 0x7aba0
testb $0x1, %al
jne 0xa00c6
jmp 0xa00cb
jmp 0xa039a
movl $0x8, %edi
callq 0x76970
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x50(%rsp)
callq 0x74a90
jmp 0xa00e7
movq 0x50(%rsp), %rax
movq %rax, 0x1f0(%rsp)
movq 0x1f0(%rsp), %rdi
movq 0x1f8(%rsp), %rsi
callq 0x78900
andb $0x1, %al
movb %al, 0x1ef(%rsp)
testb $0x1, 0x1ef(%rsp)
je 0xa0200
movq 0x68(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0x1f0(%rsp), %rax
movq %rax, 0x40(%rsp)
movl $0x158, %edi            # imm = 0x158
callq 0x76970
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x48(%rsp)
callq 0x72830
jmp 0xa0153
movq 0x48(%rsp), %rdx
movq 0x40(%rsp), %rsi
leaq 0x1d8(%rsp), %rdi
movq %rdi, 0x30(%rsp)
callq 0x71910
movq 0x38(%rsp), %rdi
movq 0x30(%rsp), %rsi
callq 0x758d0
jmp 0xa0180
leaq 0x1d8(%rsp), %rdi
callq 0x7bb70
jmp 0xa0398
movq 0x50(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x240(%rsp)
movl %eax, 0x23c(%rsp)
callq 0x764d0
jmp 0xa078e
movq 0x48(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x240(%rsp)
movl %eax, 0x23c(%rsp)
callq 0x764d0
jmp 0xa078e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x240(%rsp)
movl %eax, 0x23c(%rsp)
leaq 0x1d8(%rsp), %rdi
callq 0x7bb70
jmp 0xa01fb
jmp 0xa078e
movq 0x68(%rsp), %rdi
addq $0x28, %rdi
movl $0x1, %esi
movl $0x9, %edx
callq 0x76f60
leaq 0x197(%rsp), %rdi
movq %rdi, 0x28(%rsp)
callq 0x7b5f0
movq 0x28(%rsp), %rdx
leaq 0x4a52c(%rip), %rsi     # 0xea762
leaq 0x198(%rsp), %rdi
callq 0x78e70
jmp 0xa0245
movq 0x1f8(%rsp), %rdx
leaq 0x1b8(%rsp), %rdi
leaq 0x198(%rsp), %rsi
callq 0x7c720
jmp 0xa0264
movq 0x68(%rsp), %rdi
addq $0x28, %rdi
leaq 0x1b8(%rsp), %rsi
callq 0x78530
jmp 0xa027c
leaq 0x1b8(%rsp), %rdi
callq 0x7cce8
jmp 0xa028b
leaq 0x198(%rsp), %rdi
callq 0x7cce8
jmp 0xa029a
leaq 0x197(%rsp), %rdi
callq 0x76f80
movq 0x68(%rsp), %rdi
addq $0x28, %rdi
movl $0x1, %esi
movl $0xa, %edx
callq 0x76f60
movb $0x1, 0x216(%rsp)
movq 0x1f0(%rsp), %rax
movq %rax, 0x20(%rsp)
cmpq $0x0, %rax
je 0xa02f0
movq 0x20(%rsp), %rdi
callq 0x76ec0
jmp 0xa02e6
movq 0x20(%rsp), %rdi
callq 0x764d0
movq $0x0, 0x1f0(%rsp)
jmp 0xa0398
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x240(%rsp)
movl %eax, 0x23c(%rsp)
jmp 0xa0363
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x240(%rsp)
movl %eax, 0x23c(%rsp)
jmp 0xa0352
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x240(%rsp)
movl %eax, 0x23c(%rsp)
leaq 0x1b8(%rsp), %rdi
callq 0x7cce8
jmp 0xa0350
jmp 0xa0352
leaq 0x198(%rsp), %rdi
callq 0x7cce8
jmp 0xa0361
jmp 0xa0363
leaq 0x197(%rsp), %rdi
callq 0x76f80
jmp 0xa078e
movq 0x20(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x240(%rsp)
movl %eax, 0x23c(%rsp)
callq 0x764d0
jmp 0xa078e
jmp 0xa039a
leaq 0x208(%rsp), %rdi
callq 0x75880
jmp 0xa0080
testb $0x1, 0x216(%rsp)
je 0xa0599
movq 0x68(%rsp), %rsi
addq $0x28, %rsi
leaq 0x170(%rsp), %rdi
callq 0x73370
leaq 0x12f(%rsp), %rdi
movq %rdi, 0x18(%rsp)
callq 0x7b5f0
movq 0x18(%rsp), %rdx
leaq 0x4a38a(%rip), %rsi     # 0xea778
leaq 0x130(%rsp), %rdi
callq 0x78e70
jmp 0xa03fd
leaq 0x150(%rsp), %rdi
leaq 0x130(%rsp), %rsi
leaq 0x170(%rsp), %rdx
callq 0x7c720
jmp 0xa041c
leaq 0x130(%rsp), %rdi
callq 0x7cce8
jmp 0xa042b
leaq 0x12f(%rsp), %rdi
callq 0x76f80
leaq 0x107(%rsp), %rdi
movq %rdi, 0x10(%rsp)
callq 0x7b5f0
movq 0x10(%rsp), %rdx
leaq 0x4a2f7(%rip), %rsi     # 0xea74d
leaq 0x108(%rsp), %rdi
callq 0x78e70
jmp 0xa0465
movq 0x68(%rsp), %rdi
leaq 0x108(%rsp), %rsi
leaq 0x150(%rsp), %rdx
callq 0x77c30
jmp 0xa0481
leaq 0x108(%rsp), %rdi
callq 0x7cce8
jmp 0xa0490
leaq 0x107(%rsp), %rdi
callq 0x76f80
movb $0x0, 0x2c7(%rsp)
leaq 0x150(%rsp), %rdi
callq 0x7cce8
jmp 0xa055b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x240(%rsp)
movl %eax, 0x23c(%rsp)
jmp 0xa04f2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x240(%rsp)
movl %eax, 0x23c(%rsp)
leaq 0x130(%rsp), %rdi
callq 0x7cce8
jmp 0xa04f0
jmp 0xa04f2
leaq 0x12f(%rsp), %rdi
callq 0x76f80
jmp 0xa0585
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x240(%rsp)
movl %eax, 0x23c(%rsp)
jmp 0xa053f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x240(%rsp)
movl %eax, 0x23c(%rsp)
leaq 0x108(%rsp), %rdi
callq 0x7cce8
jmp 0xa053d
jmp 0xa053f
leaq 0x107(%rsp), %rdi
callq 0x76f80
leaq 0x150(%rsp), %rdi
callq 0x7cce8
jmp 0xa0583
leaq 0x170(%rsp), %rdi
callq 0x7cce8
jmp 0xa077d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x240(%rsp)
movl %eax, 0x23c(%rsp)
jmp 0xa0585
jmp 0xa0585
leaq 0x170(%rsp), %rdi
callq 0x7cce8
jmp 0xa0594
jmp 0xa078e
movq 0x68(%rsp), %rdi
callq 0x7c0c0
testb $0x1, %al
jne 0xa076a
movq 0x68(%rsp), %rsi
addq $0x28, %rsi
leaq 0xe0(%rsp), %rdi
callq 0x73370
leaq 0x9f(%rsp), %rdi
movq %rdi, 0x8(%rsp)
callq 0x7b5f0
movq 0x8(%rsp), %rdx
leaq 0x4a1b6(%rip), %rsi     # 0xea795
leaq 0xa0(%rsp), %rdi
callq 0x78e70
jmp 0xa05ee
leaq 0xc0(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
leaq 0xe0(%rsp), %rdx
callq 0x7c720
jmp 0xa060d
leaq 0xa0(%rsp), %rdi
callq 0x7cce8
jmp 0xa061c
leaq 0x9f(%rsp), %rdi
callq 0x76f80
leaq 0x77(%rsp), %rdi
movq %rdi, (%rsp)
callq 0x7b5f0
movq (%rsp), %rdx
leaq 0x4a10b(%rip), %rsi     # 0xea74d
leaq 0x78(%rsp), %rdi
callq 0x78e70
jmp 0xa064e
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rsi
leaq 0xc0(%rsp), %rdx
callq 0x77c30
jmp 0xa0667
leaq 0x78(%rsp), %rdi
callq 0x7cce8
jmp 0xa0673
leaq 0x77(%rsp), %rdi
callq 0x76f80
movb $0x0, 0x2c7(%rsp)
leaq 0xc0(%rsp), %rdi
callq 0x7cce8
jmp 0xa0732
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x240(%rsp)
movl %eax, 0x23c(%rsp)
jmp 0xa06d2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x240(%rsp)
movl %eax, 0x23c(%rsp)
leaq 0xa0(%rsp), %rdi
callq 0x7cce8
jmp 0xa06d0
jmp 0xa06d2
leaq 0x9f(%rsp), %rdi
callq 0x76f80
jmp 0xa0759
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x240(%rsp)
movl %eax, 0x23c(%rsp)
jmp 0xa0719
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x240(%rsp)
movl %eax, 0x23c(%rsp)
leaq 0x78(%rsp), %rdi
callq 0x7cce8
jmp 0xa0717
jmp 0xa0719
leaq 0x77(%rsp), %rdi
callq 0x76f80
leaq 0xc0(%rsp), %rdi
callq 0x7cce8
jmp 0xa0757
leaq 0xe0(%rsp), %rdi
callq 0x7cce8
jmp 0xa077d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x240(%rsp)
movl %eax, 0x23c(%rsp)
jmp 0xa0759
jmp 0xa0759
leaq 0xe0(%rsp), %rdi
callq 0x7cce8
jmp 0xa0768
jmp 0xa078e
movq 0x68(%rsp), %rdi
callq 0x710d0
andb $0x1, %al
movb %al, 0x2c7(%rsp)
movb 0x2c7(%rsp), %al
andb $0x1, %al
addq $0x2c8, %rsp            # imm = 0x2C8
retq
movq 0x240(%rsp), %rdi
callq 0x7b550
movq %rax, %rdi
callq 0x88ef0
nopw %cs:(%rax,%rax)