// File: zeeev[P]DASVC/bamtools/src/api/internal/sam/SamFormatPrinter_p.cpp
// Function: BamTools::Internal::SamFormatPrinter::PrintHD(std::__cxx11::basic_stringstream<char, std::char_traits<char>, std::allocator<char>>&) const
void SamFormatPrinter::PrintHD(std::stringstream& out) const {

    // if header has @HD data
    if ( m_header.HasVersion() ) {

        // @HD VN:<Version>
        out << Constants::SAM_HD_BEGIN_TOKEN
            << FormatTag(Constants::SAM_HD_VERSION_TAG, m_header.Version);

        // SO:<SortOrder>
        if ( m_header.HasSortOrder() )
            out << FormatTag(Constants::SAM_HD_SORTORDER_TAG, m_header.SortOrder);

        // GO:<GroupOrder>
        if ( m_header.HasGroupOrder() )
            out << FormatTag(Constants::SAM_HD_GROUPORDER_TAG, m_header.GroupOrder);

        // custom tags
        if ( !m_header.CustomTags.empty() ) {
            for (size_t i = 0; i < m_header.CustomTags.size(); ++i) {
                const CustomHeaderTag& customTag = m_header.CustomTags[i];
                out << FormatTag(customTag.TagName, customTag.TagValue);
            }
        }
        // newline
        out << endl;
    }
}

// Assembly:
subq $0x108, %rsp            # imm = 0x108
movq %rdi, 0x100(%rsp)
movq %rsi, 0xf8(%rsp)
movq 0x100(%rsp), %rax
movq %rax, 0x50(%rsp)
movq (%rax), %rdi
callq 0x780e0
testb $0x1, %al
jne 0xe4605
jmp 0xe48bf
movq 0xf8(%rsp), %rdi
addq $0x10, %rdi
leaq 0x34ed8(%rip), %rsi     # 0x1194f0
callq 0x75e40
movq %rax, %rcx
movq 0x50(%rsp), %rax
movq %rcx, 0x40(%rsp)
movq (%rax), %rdx
leaq 0x34edc(%rip), %rsi     # 0x119510
leaq 0xd8(%rsp), %rdi
movq %rdi, 0x48(%rsp)
callq 0xe5c90
movq 0x40(%rsp), %rdi
movq 0x48(%rsp), %rsi
callq 0x75e40
jmp 0xe4657
leaq 0xd8(%rsp), %rdi
callq 0x7cce8
movq 0x50(%rsp), %rax
movq (%rax), %rdi
callq 0x79910
testb $0x1, %al
jne 0xe467a
jmp 0xe4720
movq 0x50(%rsp), %rax
movq 0xf8(%rsp), %rcx
addq $0x10, %rcx
movq %rcx, 0x30(%rsp)
movq (%rax), %rdx
addq $0x20, %rdx
leaq 0x34e92(%rip), %rsi     # 0x119530
leaq 0xa8(%rsp), %rdi
movq %rdi, 0x38(%rsp)
callq 0xe5c90
movq 0x30(%rsp), %rdi
movq 0x38(%rsp), %rsi
callq 0x75e40
jmp 0xe46c1
leaq 0xa8(%rsp), %rdi
callq 0x7cce8
jmp 0xe4720
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd0(%rsp)
movl %eax, 0xcc(%rsp)
leaq 0xd8(%rsp), %rdi
callq 0x7cce8
jmp 0xe46f3
jmp 0xe48c7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd0(%rsp)
movl %eax, 0xcc(%rsp)
leaq 0xa8(%rsp), %rdi
callq 0x7cce8
jmp 0xe471b
jmp 0xe48c7
movq 0x50(%rsp), %rax
movq (%rax), %rdi
callq 0x74240
testb $0x1, %al
jne 0xe4733
jmp 0xe47b1
movq 0x50(%rsp), %rax
movq 0xf8(%rsp), %rcx
addq $0x10, %rcx
movq %rcx, 0x20(%rsp)
movq (%rax), %rdx
addq $0x40, %rdx
leaq 0x34df9(%rip), %rsi     # 0x119550
leaq 0x88(%rsp), %rdi
movq %rdi, 0x28(%rsp)
callq 0xe5c90
movq 0x20(%rsp), %rdi
movq 0x28(%rsp), %rsi
callq 0x75e40
jmp 0xe477a
leaq 0x88(%rsp), %rdi
callq 0x7cce8
jmp 0xe47b1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd0(%rsp)
movl %eax, 0xcc(%rsp)
leaq 0x88(%rsp), %rdi
callq 0x7cce8
jmp 0xe47ac
jmp 0xe48c7
movq 0x50(%rsp), %rax
movq (%rax), %rdi
addq $0x60, %rdi
callq 0x73ec0
testb $0x1, %al
jne 0xe48a7
movq $0x0, 0x80(%rsp)
movq 0x50(%rsp), %rax
movq 0x80(%rsp), %rcx
movq %rcx, 0x18(%rsp)
movq (%rax), %rdi
addq $0x60, %rdi
callq 0x77e40
movq %rax, %rcx
movq 0x18(%rsp), %rax
cmpq %rcx, %rax
jae 0xe48a5
movq 0x50(%rsp), %rax
movq (%rax), %rdi
addq $0x60, %rdi
movq 0x80(%rsp), %rsi
callq 0x76620
movq %rax, 0x78(%rsp)
movq 0xf8(%rsp), %rax
addq $0x10, %rax
movq %rax, 0x8(%rsp)
movq 0x78(%rsp), %rsi
movq %rsi, %rdx
addq $0x20, %rdx
leaq 0x58(%rsp), %rdi
movq %rdi, 0x10(%rsp)
callq 0xe5c90
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rsi
callq 0x75e40
jmp 0xe4860
leaq 0x58(%rsp), %rdi
callq 0x7cce8
movq 0x80(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x80(%rsp)
jmp 0xe47d6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd0(%rsp)
movl %eax, 0xcc(%rsp)
leaq 0x58(%rsp), %rdi
callq 0x7cce8
jmp 0xe48a3
jmp 0xe48c7
jmp 0xe48a7
movq 0xf8(%rsp), %rdi
addq $0x10, %rdi
movq 0x2d65e(%rip), %rsi     # 0x111f18
callq 0x76cc0
addq $0x108, %rsp            # imm = 0x108
retq
movq 0xd0(%rsp), %rdi
callq 0x7b550
movq %rax, %rdi
callq 0x88ef0
nopl (%rax)