// File: /workspace/github_cpp_makefile_star2_O1/zeeev[P]DASVC/bamtools/src/api/internal/index/BamToolsIndex_p.cpp
// Function: BamTools::Internal::BamToolsIndex::WriteHeader()
void BamToolsIndex::WriteHeader(void) {

    int64_t numBytesWritten = 0 ;

    // write BTI index format 'magic number'
    numBytesWritten += m_resources.Device->Write(BamToolsIndex::BTI_MAGIC, 4);

    // write BTI index format version
    int32_t currentVersion = (int32_t)m_outputVersion;
    if ( m_isBigEndian ) SwapEndian_32(currentVersion);
    numBytesWritten += m_resources.Device->Write((const char*)&currentVersion, sizeof(currentVersion));

    // write block size
    uint32_t blockSize = m_blockSize;
    if ( m_isBigEndian ) SwapEndian_32(blockSize);
    numBytesWritten += m_resources.Device->Write((const char*)&blockSize, sizeof(blockSize));

    // write number of references
    int32_t numReferences = m_indexFileSummary.size();
    if ( m_isBigEndian ) SwapEndian_32(numReferences);
    numBytesWritten += m_resources.Device->Write((const char*)&numReferences, sizeof(numReferences));

    // check header written ok
    const int expectedBytes = 4 +
                              sizeof(currentVersion) +
                              sizeof(blockSize) +
                              sizeof(numReferences);
    if ( numBytesWritten != expectedBytes )
        throw BamException("BamToolsIndex::WriteHeader", "could not write BTI header");
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x50, %rsp
movq %rdi, %rbx
movq 0x60(%rdi), %rdi
movq (%rdi), %rax
leaq 0x128eb(%rip), %rsi     # 0x56490
movl $0x4, %edx
callq *0x40(%rax)
movq %rax, %r15
movl 0x58(%rbx), %eax
movl %eax, 0xc(%rsp)
cmpb $0x1, 0x30(%rbx)
jne 0x43be5
movl %eax, %ecx
sarl $0x18, %ecx
movl %eax, %edx
shll $0x8, %edx
andl $0xff0000, %edx         # imm = 0xFF0000
movl %eax, %esi
shrl $0x8, %esi
andl $0xff00, %esi           # imm = 0xFF00
shll $0x18, %eax
orl %ecx, %eax
orl %edx, %eax
orl %esi, %eax
movl %eax, 0xc(%rsp)
movq 0x60(%rbx), %rdi
movq (%rdi), %rax
leaq 0xc(%rsp), %rsi
movl $0x4, %edx
callq *0x40(%rax)
movq %rax, %r14
addq %r15, %r14
movl 0x50(%rbx), %eax
movl %eax, 0x8(%rsp)
cmpb $0x1, 0x30(%rbx)
jne 0x43c12
bswapl %eax
movl %eax, 0x8(%rsp)
movq 0x60(%rbx), %rdi
movq (%rdi), %rax
leaq 0x8(%rsp), %rsi
movl $0x4, %edx
callq *0x40(%rax)
addq %rax, %r14
movq 0x40(%rbx), %rax
subq 0x38(%rbx), %rax
shrq $0x4, %rax
movl %eax, 0x4(%rsp)
cmpb $0x1, 0x30(%rbx)
jne 0x43c67
movl %eax, %ecx
sarl $0x18, %ecx
movl %eax, %edx
shll $0x8, %edx
andl $0xff0000, %edx         # imm = 0xFF0000
movl %eax, %esi
shrl $0x8, %esi
andl $0xff00, %esi           # imm = 0xFF00
shll $0x18, %eax
orl %ecx, %eax
orl %edx, %eax
orl %esi, %eax
movl %eax, 0x4(%rsp)
movq 0x60(%rbx), %rdi
movq (%rdi), %rax
leaq 0x4(%rsp), %rsi
movl $0x4, %edx
callq *0x40(%rax)
addq %rax, %r14
cmpq $0x10, %r14
jne 0x43c91
addq $0x50, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl $0x28, %edi
callq 0x269d0
movq %rax, %rbx
leaq 0x40(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x12bb7(%rip), %rsi     # 0x56865
leaq 0x12bca(%rip), %rdx     # 0x5687f
leaq 0x30(%rsp), %rdi
callq 0x26750
leaq 0x20(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x12bb0(%rip), %rsi     # 0x56880
leaq 0x12bc3(%rip), %rdx     # 0x5689a
leaq 0x10(%rsp), %rdi
callq 0x26750
movb $0x1, %bpl
leaq 0x30(%rsp), %rsi
leaq 0x10(%rsp), %rdx
movq %rbx, %rdi
callq 0x28490
xorl %ebp, %ebp
movq 0x27239(%rip), %rsi     # 0x6af38
movq 0x27272(%rip), %rdx     # 0x6af78
movq %rbx, %rdi
callq 0x28a30
movq %rax, %r14
movq 0x10(%rsp), %rdi
cmpq %r12, %rdi
je 0x43d28
callq 0x27560
jmp 0x43d28
movq %rax, %r14
movb $0x1, %bpl
movq 0x30(%rsp), %rdi
cmpq %r15, %rdi
je 0x43d3f
callq 0x27560
jmp 0x43d3f
movq %rax, %r14
movb $0x1, %bpl
testb %bpl, %bpl
je 0x43d4c
movq %rbx, %rdi
callq 0x27070
movq %r14, %rdi
callq 0x28c20