// File: zeeev[P]DASVC/bamtools/src/api/internal/bam/BamMultiReader_p.cpp
// Function: BamTools::Internal::BamMultiReaderPrivate::CreateIndexes(BamTools::BamIndex::IndexType const&)
bool BamMultiReaderPrivate::CreateIndexes(const BamIndex::IndexType& type) {

    bool errorsEncountered = false;
    m_errorString.clear();

    // iterate over readers
    vector<MergeItem>::iterator itemIter = m_readers.begin();
    vector<MergeItem>::iterator itemEnd  = m_readers.end();
    for ( ; itemIter != itemEnd; ++itemIter ) {
        MergeItem& item = (*itemIter);
        BamReader* reader = item.Reader;
        if ( reader == 0 ) continue;

        // if reader doesn't have an index, create one
        if ( !reader->HasIndex() ) {
            if ( !reader->CreateIndex(type) ) {
                m_errorString.append(1, '\t');
                m_errorString.append(reader->GetErrorString());
                m_errorString.append(1, '\n');
                errorsEncountered = true;
            }
        }
    }

    // check for errors encountered before returning success/fail
    if ( errorsEncountered ) {
        const string currentError = m_errorString;
        const string message = string("error while creating index files: ") + "\n" + currentError;
        SetErrorString("BamMultiReader::CreateIndexes", message);
        return false;
    } else
        return true;
}

// Assembly:
subq $0x148, %rsp            # imm = 0x148
movq %rdi, 0x138(%rsp)
movq %rsi, 0x130(%rsp)
movq 0x138(%rsp), %rdi
movq %rdi, 0x20(%rsp)
movb $0x0, 0x12f(%rsp)
addq $0x28, %rdi
callq 0x78800
movq 0x20(%rsp), %rdi
callq 0x73770
movq 0x20(%rsp), %rdi
movq %rax, 0x120(%rsp)
callq 0x74890
movq %rax, 0x118(%rsp)
leaq 0x120(%rsp), %rdi
leaq 0x118(%rsp), %rsi
callq 0x74d10
testb $0x1, %al
jne 0x9ea27
jmp 0x9eb46
leaq 0x120(%rsp), %rdi
callq 0x762d0
movq %rax, 0x110(%rsp)
movq 0x110(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x108(%rsp)
cmpq $0x0, 0x108(%rsp)
jne 0x9ea5f
jmp 0x9eb34
movq 0x108(%rsp), %rdi
callq 0x71900
testb $0x1, %al
jne 0x9eb32
movq 0x108(%rsp), %rdi
movq 0x130(%rsp), %rsi
callq 0x7b5d0
testb $0x1, %al
jne 0x9eb30
movq 0x20(%rsp), %rdi
addq $0x28, %rdi
movq %rdi, 0x10(%rsp)
movl $0x1, %esi
movl $0x9, %edx
callq 0x76f60
movq 0x108(%rsp), %rsi
leaq 0xe8(%rsp), %rdi
movq %rdi, 0x18(%rsp)
callq 0x74350
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
callq 0x7c8b0
jmp 0x9ead9
leaq 0xe8(%rsp), %rdi
callq 0x7cce8
movq 0x20(%rsp), %rdi
addq $0x28, %rdi
movl $0x1, %esi
movl $0xa, %edx
callq 0x76f60
movb $0x1, 0x12f(%rsp)
jmp 0x9eb30
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xe0(%rsp)
movl %eax, 0xdc(%rsp)
leaq 0xe8(%rsp), %rdi
callq 0x7cce8
jmp 0x9eb2b
jmp 0x9ed5f
jmp 0x9eb32
jmp 0x9eb34
leaq 0x120(%rsp), %rdi
callq 0x74ed0
jmp 0x9ea09
testb $0x1, 0x12f(%rsp)
je 0x9ed46
movq 0x20(%rsp), %rsi
addq $0x28, %rsi
leaq 0xb8(%rsp), %rdi
callq 0x73370
leaq 0x57(%rsp), %rdi
movq %rdi, 0x8(%rsp)
callq 0x7b5f0
movq 0x8(%rsp), %rdx
leaq 0x4bb1e(%rip), %rsi     # 0xea6a3
leaq 0x58(%rsp), %rdi
callq 0x78e70
jmp 0x9eb91
leaq 0x4bbfb(%rip), %rdx     # 0xea793
leaq 0x78(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x785a0
jmp 0x9eba9
leaq 0x98(%rsp), %rdi
leaq 0x78(%rsp), %rsi
leaq 0xb8(%rsp), %rdx
callq 0x7c720
jmp 0x9ebc5
leaq 0x78(%rsp), %rdi
callq 0x7cce8
jmp 0x9ebd1
leaq 0x58(%rsp), %rdi
callq 0x7cce8
jmp 0x9ebdd
leaq 0x57(%rsp), %rdi
callq 0x76f80
leaq 0x2f(%rsp), %rdi
movq %rdi, (%rsp)
callq 0x7b5f0
movq (%rsp), %rdx
leaq 0x4bac6(%rip), %rsi     # 0xea6c6
leaq 0x30(%rsp), %rdi
callq 0x78e70
jmp 0x9ec0c
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rsi
leaq 0x98(%rsp), %rdx
callq 0x77c30
jmp 0x9ec25
leaq 0x30(%rsp), %rdi
callq 0x7cce8
jmp 0x9ec31
leaq 0x2f(%rsp), %rdi
callq 0x76f80
movb $0x0, 0x147(%rsp)
leaq 0x98(%rsp), %rdi
callq 0x7cce8
jmp 0x9ed0e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xe0(%rsp)
movl %eax, 0xdc(%rsp)
jmp 0x9ecb1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xe0(%rsp)
movl %eax, 0xdc(%rsp)
jmp 0x9eca3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xe0(%rsp)
movl %eax, 0xdc(%rsp)
leaq 0x78(%rsp), %rdi
callq 0x7cce8
jmp 0x9eca1
jmp 0x9eca3
leaq 0x58(%rsp), %rdi
callq 0x7cce8
jmp 0x9ecaf
jmp 0x9ecb1
leaq 0x57(%rsp), %rdi
callq 0x76f80
jmp 0x9ed35
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xe0(%rsp)
movl %eax, 0xdc(%rsp)
jmp 0x9ecf5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xe0(%rsp)
movl %eax, 0xdc(%rsp)
leaq 0x30(%rsp), %rdi
callq 0x7cce8
jmp 0x9ecf3
jmp 0x9ecf5
leaq 0x2f(%rsp), %rdi
callq 0x76f80
leaq 0x98(%rsp), %rdi
callq 0x7cce8
jmp 0x9ed33
leaq 0xb8(%rsp), %rdi
callq 0x7cce8
jmp 0x9ed4e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xe0(%rsp)
movl %eax, 0xdc(%rsp)
jmp 0x9ed35
jmp 0x9ed35
leaq 0xb8(%rsp), %rdi
callq 0x7cce8
jmp 0x9ed44
jmp 0x9ed5f
movb $0x1, 0x147(%rsp)
movb 0x147(%rsp), %al
andb $0x1, %al
addq $0x148, %rsp            # imm = 0x148
retq
movq 0xe0(%rsp), %rdi
callq 0x7b550
movq %rax, %rdi
callq 0x88ef0
nopw %cs:(%rax,%rax)