// File: /workspace/github_cpp_makefile_star2_O3/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 0x8(%rsp), %rbx
movl $0x4, %edx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x283c0
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 0x3b66e
leaq 0x8(%rsp), %rbp
movl $0x4, %edx
movq %r15, %rdi
movq %rbp, %rsi
callq 0x283c0
movl 0x8(%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 0x283c0
movl $0x4, %edx
movq %r15, %rdi
movq %rbp, %rsi
callq 0x283c0
movl 0x8(%rsp), %r12d
movq 0x30(%rsp), %rax
cmpb $0x1, 0x40(%rax)
jne 0x3b5a4
movl %r12d, %eax
sarl $0x18, %eax
movl %r12d, %ecx
shll $0x8, %ecx
andl $0xff0000, %ecx         # imm = 0xFF0000
movl %r12d, %edx
shrl $0x8, %edx
andl $0xff00, %edx           # imm = 0xFF00
shll $0x18, %r12d
orl %eax, %r12d
orl %ecx, %r12d
orl %edx, %r12d
leaq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
movq %rax, 0x10(%rsp)
leaq 0x1a8d5(%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 0x3b5ff
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 0x3b635
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 0x3b65d
callq 0x27560
movq %rbx, %rdi
callq 0x27e60
decl %r13d
jne 0x3b50c
movb $0x1, %al
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3b6c4
movq %rax, %r14
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
jmp 0x3b6b8
jmp 0x3b6ab
movq %rax, %r14
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x3b6ae
callq 0x27560
jmp 0x3b6ae
movq %rax, %r14
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x3b6c7
callq 0x27560
jmp 0x3b6c7
movq %rax, %r14
movq %rbx, %rdi
callq 0x27e60
movq %r14, %rdi
callq 0x28c10
nop