// File: zeeev[P]DASVC/bamtools/src/api/internal/bam/BamReader_p.cpp
// Function: BamTools::Internal::BamReaderPrivate::LoadReferenceData()
bool BamReaderPrivate::LoadReferenceData(void) {

    // get number of reference sequences
    char buffer[sizeof(uint32_t)];
    m_stream.Read(buffer, sizeof(uint32_t));
    uint32_t numberRefSeqs = BamTools::UnpackUnsignedInt(buffer);
    if ( m_isBigEndian ) BamTools::SwapEndian_32(numberRefSeqs);
    m_references.reserve((int)numberRefSeqs);

    // iterate over all references in header
    for ( unsigned int i = 0; i != numberRefSeqs; ++i ) {

        // get length of reference name
        m_stream.Read(buffer, sizeof(uint32_t));
        uint32_t refNameLength = BamTools::UnpackUnsignedInt(buffer);
        if ( m_isBigEndian ) BamTools::SwapEndian_32(refNameLength);
        RaiiBuffer refName(refNameLength);

        // get reference name and reference sequence length
        m_stream.Read(refName.Buffer, refNameLength);
        m_stream.Read(buffer, sizeof(int32_t));
        int32_t refLength = BamTools::UnpackSignedInt(buffer);
        if ( m_isBigEndian ) BamTools::SwapEndian_32(refLength);

        // store data for reference
        RefData aReference;
        aReference.RefName   = (string)((const char*)refName.Buffer);
        aReference.RefLength = refLength;
        m_references.push_back(aReference);
    }

    // return success
    return true;
}

// Assembly:
subq $0xd8, %rsp
movq %rdi, 0xd0(%rsp)
movq 0xd0(%rsp), %rdi
movq %rdi, 0x20(%rsp)
addq $0x1e8, %rdi            # imm = 0x1E8
leaq 0xcc(%rsp), %rsi
movl $0x4, %edx
callq 0x79a30
leaq 0xcc(%rsp), %rdi
callq 0x754e0
movl %eax, %ecx
movq 0x20(%rsp), %rax
movl %ecx, 0xc8(%rsp)
testb $0x1, 0x40(%rax)
je 0xab333
leaq 0xc8(%rsp), %rdi
callq 0x77400
movq 0x20(%rsp), %rdi
addq $0x28, %rdi
movslq 0xc8(%rsp), %rsi
callq 0x75280
movl $0x0, 0xc4(%rsp)
movl 0xc4(%rsp), %eax
cmpl 0xc8(%rsp), %eax
je 0xab620
movq 0x20(%rsp), %rdi
addq $0x1e8, %rdi            # imm = 0x1E8
leaq 0xcc(%rsp), %rsi
movl $0x4, %edx
callq 0x79a30
leaq 0xcc(%rsp), %rdi
callq 0x754e0
movl %eax, %ecx
movq 0x20(%rsp), %rax
movl %ecx, 0xc0(%rsp)
testb $0x1, 0x40(%rax)
je 0xab3b4
leaq 0xc0(%rsp), %rdi
callq 0x77400
movl 0xc0(%rsp), %eax
movl %eax, %esi
leaq 0xb0(%rsp), %rdi
callq 0x76550
movq 0x20(%rsp), %rdi
addq $0x1e8, %rdi            # imm = 0x1E8
movq 0xb0(%rsp), %rsi
movl 0xc0(%rsp), %eax
movl %eax, %edx
callq 0x79a30
jmp 0xab3ee
movq 0x20(%rsp), %rdi
addq $0x1e8, %rdi            # imm = 0x1E8
leaq 0xcc(%rsp), %rsi
movl $0x4, %edx
callq 0x79a30
jmp 0xab40e
leaq 0xcc(%rsp), %rdi
callq 0x7c910
movl %eax, 0x1c(%rsp)
jmp 0xab421
movq 0x20(%rsp), %rax
movl 0x1c(%rsp), %ecx
movl %ecx, 0xa0(%rsp)
testb $0x1, 0x40(%rax)
je 0xab461
leaq 0xa0(%rsp), %rdi
callq 0x75b80
jmp 0xab446
jmp 0xab461
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa8(%rsp)
movl %eax, 0xa4(%rsp)
jmp 0xab60f
leaq 0x57(%rsp), %rdi
movq %rdi, 0x10(%rsp)
callq 0x7b5f0
movq 0x10(%rsp), %rdx
leaq 0x3fc60(%rip), %rsi     # 0xeb0dc
leaq 0x58(%rsp), %rdi
callq 0x78e70
jmp 0xab488
movl $0x0, 0x50(%rsp)
leaq 0x78(%rsp), %rdi
leaq 0x58(%rsp), %rsi
leaq 0x50(%rsp), %rdx
callq 0x74170
jmp 0xab4a6
leaq 0x58(%rsp), %rdi
callq 0x7cce8
jmp 0xab4b2
leaq 0x57(%rsp), %rdi
callq 0x76f80
movq 0xb0(%rsp), %rax
movq %rax, (%rsp)
leaq 0x2f(%rsp), %rdi
movq %rdi, 0x8(%rsp)
callq 0x7b5f0
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
leaq 0x30(%rsp), %rdi
callq 0x78e70
jmp 0xab4ec
leaq 0x78(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x71240
jmp 0xab4fd
leaq 0x30(%rsp), %rdi
callq 0x7cce8
jmp 0xab509
leaq 0x2f(%rsp), %rdi
callq 0x76f80
movq 0x20(%rsp), %rdi
movl 0xa0(%rsp), %eax
movl %eax, 0x98(%rsp)
addq $0x28, %rdi
leaq 0x78(%rsp), %rsi
callq 0x73780
jmp 0xab536
leaq 0x78(%rsp), %rdi
callq 0x744a0
jmp 0xab542
leaq 0xb0(%rsp), %rdi
callq 0x7a450
movl 0xc4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc4(%rsp)
jmp 0xab354
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa8(%rsp)
movl %eax, 0xa4(%rsp)
jmp 0xab59d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa8(%rsp)
movl %eax, 0xa4(%rsp)
leaq 0x58(%rsp), %rdi
callq 0x7cce8
jmp 0xab59b
jmp 0xab59d
leaq 0x57(%rsp), %rdi
callq 0x76f80
jmp 0xab60f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa8(%rsp)
movl %eax, 0xa4(%rsp)
jmp 0xab5e1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa8(%rsp)
movl %eax, 0xa4(%rsp)
leaq 0x30(%rsp), %rdi
callq 0x7cce8
jmp 0xab5df
jmp 0xab5e1
leaq 0x2f(%rsp), %rdi
callq 0x76f80
jmp 0xab601
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa8(%rsp)
movl %eax, 0xa4(%rsp)
leaq 0x78(%rsp), %rdi
callq 0x744a0
jmp 0xab60d
jmp 0xab60f
leaq 0xb0(%rsp), %rdi
callq 0x7a450
jmp 0xab61e
jmp 0xab62c
movb $0x1, %al
andb $0x1, %al
addq $0xd8, %rsp
retq
movq 0xa8(%rsp), %rdi
callq 0x7b550
movq %rax, %rdi
callq 0x88ef0
nopw %cs:(%rax,%rax)