// File: mshabbirhasan[P]ups-indel/include/seqan/bam_io/write_sam.h
// Function: int seqan::write2<std::ostream, seqan::StringSet<seqan::String<char, seqan::Alloc<void>>, seqan::Owner<seqan::Tag<seqan::Default_>>>, seqan::NameStoreCache<seqan::StringSet<seqan::String<char, seqan::Alloc<void>>, seqan::Owner<seqan::Tag<seqan::Default_>>>, seqan::String<char, seqan::Alloc<void>>>>(std::ostream&, seqan::BamHeader const&, seqan::BamIOContext<seqan::StringSet<seqan::String<char, seqan::Alloc<void>>, seqan::Owner<seqan::Tag<seqan::Default_>>>, seqan::NameStoreCache<seqan::StringSet<seqan::String<char, seqan::Alloc<void>>, seqan::Owner<seqan::Tag<seqan::Default_>>>, seqan::String<char, seqan::Alloc<void>>>> const&, seqan::Tag<seqan::Sam_> const&)
int write2(TStream & stream,
           BamHeader const & header,
           BamIOContext<TNameStore, TNameStoreCache> const & context,
           Sam const & tag)
{
    std::set<CharString> writtenSeqInfos;

    for (unsigned i = 0; i < length(header.records); ++i)
    {
        BamHeaderRecord const & record = header.records[i];
        if (record.type == BAM_HEADER_REFERENCE)
        {
            for (unsigned i = 0; i < length(record.tags); ++i)
            {
                if (record.tags[i].i1 == "SN")
                {
                    writtenSeqInfos.insert(record.tags[i].i2);
                    break;
                }
            }
        }

        int res = write2(stream, record, context, tag);
        if (res != 0)
            return res;
    }

    // Write missing @SQ header records.
    for (unsigned i = 0; i < length(header.sequenceInfos); ++i)
    {
        if (writtenSeqInfos.find(header.sequenceInfos[i].i1) != writtenSeqInfos.end())
            continue;
        int res = streamPut(stream, "@SQ\tSN:");
        if (res != 0)
            return res;

        res = streamPut(stream, header.sequenceInfos[i].i1);
        if (res != 0)
            return res;

        res = streamPut(stream, "\tLN:");
        if (res != 0)
            return res;

        res = streamPut(stream, header.sequenceInfos[i].i2);
        if (res != 0)
            return res;

        res = streamPut(stream, '\n');
        if (res != 0)
            return res;
    }

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x160, %rsp            # imm = 0x160
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x21ad0
movl $0x0, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
movq %rax, -0xc8(%rbp)
movq -0x18(%rbp), %rdi
addq $0x18, %rdi
callq 0x1b320
movq %rax, -0xc0(%rbp)
jmp 0x2169b
movq -0xc8(%rbp), %rax
movq -0xc0(%rbp), %rcx
cmpq %rcx, %rax
jae 0x21832
movq -0x18(%rbp), %rdi
addq $0x18, %rdi
movl -0x5c(%rbp), %esi
callq 0x21af0
movq %rax, -0xd0(%rbp)
jmp 0x216cb
movq -0xd0(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
cmpl $0x1, (%rax)
jne 0x217d8
movl $0x0, -0x7c(%rbp)
movl -0x7c(%rbp), %eax
movq %rax, -0xd8(%rbp)
movq -0x78(%rbp), %rdi
addq $0x8, %rdi
callq 0x19da0
movq %rax, %rcx
movq -0xd8(%rbp), %rax
cmpq %rcx, %rax
jae 0x217d6
movq -0x78(%rbp), %rdi
addq $0x8, %rdi
movl -0x7c(%rbp), %esi
callq 0x21b20
movq %rax, -0xe0(%rbp)
jmp 0x2172d
movq -0xe0(%rbp), %rdi
leaq 0x72da(%rip), %rsi      # 0x28a15
callq 0x19de0
movb %al, -0xe1(%rbp)
jmp 0x21748
movb -0xe1(%rbp), %al
testb $0x1, %al
jne 0x21754
jmp 0x217c6
movq -0x78(%rbp), %rdi
addq $0x8, %rdi
movl -0x7c(%rbp), %esi
callq 0x21b20
movq %rax, -0xf0(%rbp)
jmp 0x2176d
movq -0xf0(%rbp), %rsi
addq $0x18, %rsi
leaq -0x58(%rbp), %rdi
callq 0x21b50
movb %dl, -0xf9(%rbp)
movq %rax, -0xf8(%rbp)
jmp 0x21790
movb -0xf9(%rbp), %al
movq -0xf8(%rbp), %rcx
movq %rcx, -0x90(%rbp)
movb %al, -0x88(%rbp)
jmp 0x217d6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x21ee0
jmp 0x21abc
jmp 0x217c8
movl -0x7c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x7c(%rbp)
jmp 0x216ea
jmp 0x217d8
movq -0x10(%rbp), %rdi
movq -0x78(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
callq 0x21ba0
movl %eax, -0x100(%rbp)
jmp 0x217f5
movl -0x100(%rbp), %eax
movl %eax, -0x94(%rbp)
cmpl $0x0, -0x94(%rbp)
je 0x21822
movl -0x94(%rbp), %eax
movl %eax, -0x4(%rbp)
movl $0x1, -0x98(%rbp)
jmp 0x21aa7
jmp 0x21824
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x2167b
movl $0x0, -0x9c(%rbp)
movl -0x9c(%rbp), %eax
movq %rax, -0x110(%rbp)
movq -0x18(%rbp), %rdi
callq 0x1a050
movq %rax, -0x108(%rbp)
jmp 0x2185b
movq -0x110(%rbp), %rax
movq -0x108(%rbp), %rcx
cmpq %rcx, %rax
jae 0x21a96
movq -0x18(%rbp), %rdi
movl -0x9c(%rbp), %esi
callq 0x21d70
movq %rax, -0x118(%rbp)
jmp 0x2188a
movq -0x118(%rbp), %rsi
leaq -0x58(%rbp), %rdi
callq 0x21d30
movq %rax, -0x120(%rbp)
jmp 0x218a3
movq -0x120(%rbp), %rax
movq %rax, -0xa8(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x21da0
movq %rax, -0xb0(%rbp)
leaq -0xa8(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x21d00
testb $0x1, %al
jne 0x218da
jmp 0x218df
jmp 0x21a82
movq -0x10(%rbp), %rdi
leaq 0x7282(%rip), %rsi      # 0x28b6c
callq 0x21dd0
movl %eax, -0x124(%rbp)
jmp 0x218f7
movl -0x124(%rbp), %eax
movl %eax, -0xb4(%rbp)
cmpl $0x0, -0xb4(%rbp)
je 0x21924
movl -0xb4(%rbp), %eax
movl %eax, -0x4(%rbp)
movl $0x1, -0x98(%rbp)
jmp 0x21aa7
movq -0x10(%rbp), %rax
movq %rax, -0x138(%rbp)
movq -0x18(%rbp), %rdi
movl -0x9c(%rbp), %esi
callq 0x21d70
movq %rax, -0x130(%rbp)
jmp 0x21947
movq -0x130(%rbp), %rsi
movq -0x138(%rbp), %rdi
callq 0x21e30
movl %eax, -0x13c(%rbp)
jmp 0x21962
movl -0x13c(%rbp), %eax
movl %eax, -0xb4(%rbp)
cmpl $0x0, -0xb4(%rbp)
je 0x2198f
movl -0xb4(%rbp), %eax
movl %eax, -0x4(%rbp)
movl $0x1, -0x98(%rbp)
jmp 0x21aa7
movq -0x10(%rbp), %rdi
leaq 0x71da(%rip), %rsi      # 0x28b74
callq 0x21dd0
movl %eax, -0x140(%rbp)
jmp 0x219a7
movl -0x140(%rbp), %eax
movl %eax, -0xb4(%rbp)
cmpl $0x0, -0xb4(%rbp)
je 0x219d4
movl -0xb4(%rbp), %eax
movl %eax, -0x4(%rbp)
movl $0x1, -0x98(%rbp)
jmp 0x21aa7
movq -0x10(%rbp), %rax
movq %rax, -0x150(%rbp)
movq -0x18(%rbp), %rdi
movl -0x9c(%rbp), %esi
callq 0x21d70
movq %rax, -0x148(%rbp)
jmp 0x219f7
movq -0x150(%rbp), %rdi
movq -0x148(%rbp), %rsi
addq $0x18, %rsi
callq 0x21ea0
movl %eax, -0x154(%rbp)
jmp 0x21a16
movl -0x154(%rbp), %eax
movl %eax, -0xb4(%rbp)
cmpl $0x0, -0xb4(%rbp)
je 0x21a40
movl -0xb4(%rbp), %eax
movl %eax, -0x4(%rbp)
movl $0x1, -0x98(%rbp)
jmp 0x21aa7
movq -0x10(%rbp), %rdi
movl $0xa, %esi
callq 0x11ba0
movl %eax, -0x158(%rbp)
jmp 0x21a56
movl -0x158(%rbp), %eax
movl %eax, -0xb4(%rbp)
cmpl $0x0, -0xb4(%rbp)
je 0x21a80
movl -0xb4(%rbp), %eax
movl %eax, -0x4(%rbp)
movl $0x1, -0x98(%rbp)
jmp 0x21aa7
jmp 0x21a82
movl -0x9c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x9c(%rbp)
jmp 0x2183c
movl $0x0, -0x4(%rbp)
movl $0x1, -0x98(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x21ee0
movl -0x4(%rbp), %eax
addq $0x160, %rsp            # imm = 0x160
popq %rbp
retq
movq -0x68(%rbp), %rdi
callq 0x4770
nopw %cs:(%rax,%rax)
nop