// File: /workspace/github_cpp_makefile_star2_O1/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rdi, %r14
leaq 0x1e8(%rdi), %r15
leaq 0xb(%rsp), %rbx
movl $0x4, %edx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x283d0
movl (%rbx), %eax
movl %eax, %r13d
bswapl %r13d
cmpb $0x0, 0x40(%r14)
cmovel %eax, %r13d
movq %r14, 0x30(%rsp)
leaq 0x28(%r14), %rdi
movslq %r13d, %rbx
movq %rdi, 0x60(%rsp)
movq %rbx, %rsi
callq 0x27130
testl %ebx, %ebx
je 0x3b726
leaq 0xb(%rsp), %rbp
movl $0x4, %edx
movq %r15, %rdi
movq %rbp, %rsi
callq 0x283d0
movl 0xb(%rsp), %eax
movl %eax, %r12d
bswapl %r12d
movq 0x30(%rsp), %rcx
cmpb $0x0, 0x40(%rcx)
cmovel %eax, %r12d
movq %r12, %rdi
callq 0x26070
movq %rax, %rbx
movq %rax, %rdi
xorl %esi, %esi
movq %r12, %rdx
callq 0x26bc0
movq %r15, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x283d0
movl $0x4, %edx
movq %r15, %rdi
movq %rbp, %rsi
callq 0x283d0
movzbl 0xb(%rsp), %eax
movzbl 0xc(%rsp), %r12d
movzbl 0xd(%rsp), %edx
movsbl 0xe(%rsp), %ecx
movq 0x30(%rsp), %rsi
cmpb $0x1, 0x40(%rsi)
jne 0x3b649
shll $0x10, %r12d
shll $0x8, %edx
shll $0x18, %eax
orl %r12d, %eax
orl %edx, %ecx
orl %eax, %ecx
movl %ecx, %r12d
jmp 0x3b65c
shll $0x18, %ecx
shll $0x10, %edx
shll $0x8, %r12d
orl %edx, %r12d
orl %ecx, %r12d
orl %eax, %r12d
leaq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
movq %rax, 0x10(%rsp)
leaq 0x1a81d(%rip), %rdx     # 0x55e8f
movq %rdx, %rsi
callq 0x26750
leaq 0x48(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
addq %rsi, %rdx
leaq 0x38(%rsp), %rdi
callq 0x267c0
movl $0x0, 0x58(%rsp)
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x3b6b7
callq 0x27560
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
leaq 0xf(%rsp), %rdx
callq 0x26770
leaq 0x38(%rsp), %rdi
movq %r14, %rsi
callq 0x26b80
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x3b6ed
callq 0x27560
movl %r12d, 0x58(%rsp)
movq 0x60(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x269b0
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x3b715
callq 0x27560
movq %rbx, %rdi
callq 0x27e70
decl %r13d
jne 0x3b5b6
movb $0x1, %al
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3b77c
movq %rax, %r14
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
jmp 0x3b770
jmp 0x3b763
movq %rax, %r14
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x3b766
callq 0x27560
jmp 0x3b766
movq %rax, %r14
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x3b77f
callq 0x27560
jmp 0x3b77f
movq %rax, %r14
movq %rbx, %rdi
callq 0x27e70
movq %r14, %rdi
callq 0x28c20
nop