// File: zeeev[P]DASVC/bamtools/src/api/internal/bam/BamMultiReader_p.cpp
// Function: BamTools::Internal::BamMultiReaderPrivate::UpdateAlignmentCache()
bool BamMultiReaderPrivate::UpdateAlignmentCache(void) {

    // create alignment cache if not created yet
    if ( m_alignmentCache == 0 ) {
        m_alignmentCache = CreateAlignmentCache();
        if ( m_alignmentCache == 0 ) {
            SetErrorString("BamMultiReader::UpdateAlignmentCache", "unable to create new alignment cache");
            return false;
        }
    }

    // clear any prior cache data
    m_alignmentCache->Clear();

    // iterate over readers
    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;
        BamAlignment* alignment = item.Alignment;
        if ( reader == 0 || alignment == 0 ) continue;

        // save next alignment from each reader in cache
        SaveNextAlignment(reader, alignment);
    }

    // if we get here, ok
    return true;
}

// Assembly:
subq $0xb8, %rsp
movq %rdi, 0xa8(%rsp)
movq 0xa8(%rsp), %rax
movq %rax, 0x18(%rsp)
cmpq $0x0, 0x18(%rax)
jne 0x9f98f
movq 0x18(%rsp), %rdi
callq 0x74be0
movq %rax, %rcx
movq 0x18(%rsp), %rax
movq %rcx, 0x18(%rax)
cmpq $0x0, 0x18(%rax)
jne 0x9f98d
leaq 0x87(%rsp), %rdi
movq %rdi, 0x10(%rsp)
callq 0x7b5f0
movq 0x10(%rsp), %rdx
leaq 0x4b04b(%rip), %rsi     # 0xea8e1
leaq 0x88(%rsp), %rdi
callq 0x78e70
jmp 0x9f8a5
leaq 0x4f(%rsp), %rdi
movq %rdi, 0x8(%rsp)
callq 0x7b5f0
movq 0x8(%rsp), %rdx
leaq 0x4b046(%rip), %rsi     # 0xea906
leaq 0x50(%rsp), %rdi
callq 0x78e70
jmp 0x9f8cc
movq 0x18(%rsp), %rdi
leaq 0x88(%rsp), %rsi
leaq 0x50(%rsp), %rdx
callq 0x77c30
jmp 0x9f8e5
leaq 0x50(%rsp), %rdi
callq 0x7cce8
jmp 0x9f8f1
leaq 0x4f(%rsp), %rdi
callq 0x76f80
leaq 0x88(%rsp), %rdi
callq 0x7cce8
jmp 0x9f90a
leaq 0x87(%rsp), %rdi
callq 0x76f80
movb $0x0, 0xb7(%rsp)
jmp 0x9fa35
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x78(%rsp)
movl %eax, 0x74(%rsp)
jmp 0x9f97b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x78(%rsp)
movl %eax, 0x74(%rsp)
jmp 0x9f960
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x78(%rsp)
movl %eax, 0x74(%rsp)
leaq 0x50(%rsp), %rdi
callq 0x7cce8
jmp 0x9f95e
jmp 0x9f960
leaq 0x4f(%rsp), %rdi
callq 0x76f80
leaq 0x88(%rsp), %rdi
callq 0x7cce8
jmp 0x9f979
jmp 0x9f97b
leaq 0x87(%rsp), %rdi
callq 0x76f80
jmp 0x9fa46
jmp 0x9f98f
movq 0x18(%rsp), %rax
movq 0x18(%rax), %rdi
movq (%rdi), %rax
callq *0x18(%rax)
movq 0x18(%rsp), %rdi
callq 0x73770
movq 0x18(%rsp), %rdi
movq %rax, 0x40(%rsp)
callq 0x74890
movq %rax, 0x38(%rsp)
leaq 0x40(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x74d10
testb $0x1, %al
jne 0x9f9d1
jmp 0x9fa2d
leaq 0x40(%rsp), %rdi
callq 0x762d0
movq %rax, 0x30(%rsp)
movq 0x30(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x28(%rsp)
movq 0x30(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x20(%rsp)
cmpq $0x0, 0x28(%rsp)
je 0x9fa0b
cmpq $0x0, 0x20(%rsp)
jne 0x9fa0d
jmp 0x9fa21
movq 0x18(%rsp), %rdi
movq 0x28(%rsp), %rsi
movq 0x20(%rsp), %rdx
callq 0x75480
leaq 0x40(%rsp), %rdi
callq 0x74ed0
jmp 0x9f9bc
movb $0x1, 0xb7(%rsp)
movb 0xb7(%rsp), %al
andb $0x1, %al
addq $0xb8, %rsp
retq
movq 0x78(%rsp), %rdi
callq 0x7b550
movq %rax, %rdi
callq 0x88ef0
nopl (%rax,%rax)