// File: /workspace/github_cpp_makefile_star2_O2/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 %rbx
subq $0x58, %rsp
movq %rdi, %rbx
movq 0x60(%rdi), %rdi
movq (%rdi), %rax
leaq 0x10746(%rip), %rsi     # 0x5c481
pushq $0x4
popq %rdx
callq *0x40(%rax)
movq %rax, %r15
movl 0x58(%rbx), %eax
movl %eax, 0x14(%rsp)
cmpb $0x1, 0x30(%rbx)
jne 0x4bd5b
leaq 0x14(%rsp), %rdi
callq 0x32c90
movq 0x60(%rbx), %rdi
movq (%rdi), %rax
leaq 0x14(%rsp), %rsi
pushq $0x4
popq %rdx
callq *0x40(%rax)
movq %rax, %r14
addq %r15, %r14
movl 0x50(%rbx), %eax
movl %eax, 0x10(%rsp)
cmpb $0x1, 0x30(%rbx)
jne 0x4bd86
bswapl %eax
movl %eax, 0x10(%rsp)
movq 0x60(%rbx), %rdi
movq (%rdi), %rax
leaq 0x10(%rsp), %rsi
pushq $0x4
popq %rdx
callq *0x40(%rax)
addq %rax, %r14
movq 0x40(%rbx), %rax
subq 0x38(%rbx), %rax
shrq $0x4, %rax
movl %eax, 0xc(%rsp)
cmpb $0x1, 0x30(%rbx)
jne 0x4bdbb
leaq 0xc(%rsp), %rdi
callq 0x32c90
movq 0x60(%rbx), %rdi
movq (%rdi), %rax
leaq 0xc(%rsp), %rsi
pushq $0x4
popq %rdx
callq *0x40(%rax)
addq %rax, %r14
cmpq $0x10, %r14
jne 0x4bde1
addq $0x58, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
pushq $0x28
popq %rdi
callq 0x31e70
movq %rax, %rbx
leaq 0x10a63(%rip), %rsi     # 0x5c856
leaq 0x38(%rsp), %rdi
leaq 0xb(%rsp), %rdx
callq 0x31b30
leaq 0x10a68(%rip), %rsi     # 0x5c871
leaq 0x18(%rsp), %rdi
leaq 0xa(%rsp), %rdx
callq 0x31b30
movb $0x1, %bpl
leaq 0x38(%rsp), %rsi
leaq 0x18(%rsp), %rdx
movq %rbx, %rdi
callq 0x344c0
xorl %ebp, %ebp
movq 0x29102(%rip), %rsi     # 0x74f38
movq 0x2913b(%rip), %rdx     # 0x74f78
movq %rbx, %rdi
callq 0x34c90
movq %rax, %r14
leaq 0x18(%rsp), %rdi
callq 0x33a00
jmp 0x4be5a
movq %rax, %r14
movb $0x1, %bpl
leaq 0x38(%rsp), %rdi
callq 0x33a00
testb %bpl, %bpl
jne 0x4be76
jmp 0x4be7e
movq %rax, %rdi
callq 0x39b2f
movq %rax, %r14
movq %rbx, %rdi
callq 0x327c0
movq %r14, %rdi
callq 0x34ed0