// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/sam.c
// Function: sam_hdr_change_HD
int sam_hdr_change_HD(sam_hdr_t *h, const char *key, const char *val)
{
    if (!h || !key)
        return -1;

    if (!h->hrecs)
        return old_sam_hdr_change_HD(h, key, val);

    if (val) {
        if (sam_hdr_update_line(h, "HD", NULL, NULL, key, val, NULL) != 0)
            return -1;
    } else {
        if (sam_hdr_remove_tag_id(h, "HD", NULL, NULL, key) != 0)
            return -1;
    }
    return sam_hdr_rebuild(h);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
testq %rdi, %rdi
sete %al
testq %rsi, %rsi
sete %cl
pushq $-0x1
popq %r13
orb %al, %cl
jne 0x216a1
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %rbx
cmpq $0x0, 0x38(%rdi)
je 0x215f6
testq %r15, %r15
je 0x21649
andq $0x0, (%rsp)
leaq 0x582e6(%rip), %rsi     # 0x798c6
movq %rbx, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
movq %r14, %r8
movq %r15, %r9
xorl %eax, %eax
callq 0x6b200
jmp 0x2165f
movq 0x8(%rbx), %r12
cmpq $0x4, %r12
jb 0x21684
movq 0x28(%rbx), %rdi
cmpb $0x40, (%rdi)
jne 0x2167e
cmpb $0x48, 0x1(%rdi)
jne 0x2167e
cmpb $0x44, 0x2(%rdi)
jne 0x2167e
pushq $0xa
popq %rsi
callq 0x4190
testq %rax, %rax
je 0x216a1
movq %rax, %r12
movb $0x0, (%rax)
movb $0x9, 0x23(%rsp)
movb (%r14), %al
movb %al, 0x24(%rsp)
testb %al, %al
je 0x21738
movb 0x1(%r14), %al
jmp 0x2173a
leaq 0x58276(%rip), %rsi     # 0x798c6
movq %rbx, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
movq %r14, %r8
callq 0x6cd5d
movl %eax, %ecx
movl %r13d, %eax
testl %ecx, %ecx
jne 0x216a4
movq %rbx, %rdi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x69ce9
cmpq $-0xd, %r12
ja 0x216a1
leaq 0xb(%r12), %rbp
testq %r15, %r15
je 0x216bb
movq %r15, %rdi
callq 0x41d0
pushq $-0x6
popq %rcx
subq %rax, %rcx
cmpq %rcx, %rbp
jbe 0x216b3
movl %r13d, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq (%r12,%rax), %rbp
addq $0xf, %rbp
leaq 0x1(%rbp), %r12
movq %r12, %rdi
callq 0x4680
movq %rax, %rcx
movl %r13d, %eax
testq %rcx, %rcx
je 0x216a4
movq %rcx, %r13
movq 0x28(%rbx), %r8
testq %r15, %r15
je 0x21705
movq %r8, (%rsp)
leaq 0x58d1f(%rip), %rdx     # 0x7a408
leaq 0x58d2b(%rip), %rcx     # 0x7a41b
movq %r13, %rdi
movq %r12, %rsi
movq %r14, %r8
movq %r15, %r9
xorl %eax, %eax
callq 0x4800
jmp 0x21720
leaq 0x58d13(%rip), %rdx     # 0x7a41f
leaq 0x58d08(%rip), %rcx     # 0x7a41b
movq %r13, %rdi
movq %r12, %rsi
xorl %eax, %eax
callq 0x4800
movq 0x28(%rbx), %rdi
callq 0x45c0
movq %r13, 0x28(%rbx)
movq %rbp, 0x8(%rbx)
xorl %eax, %eax
jmp 0x216a4
xorl %eax, %eax
leaq 0x23(%rsp), %rsi
movb %al, 0x2(%rsi)
movw $0x3a, 0x3(%rsi)
movq 0x28(%rbx), %rdi
callq 0x40e0
movq %rax, %rbp
movb $0xa, (%r12)
movq %r12, %rax
testq %rbp, %rbp
je 0x217a9
leaq 0x4(%rbp), %rdi
pushq $-0x3
popq %r12
pushq $-0x1
popq %rdx
movb 0x5(%rbp,%rdx), %al
addb $-0x9, %al
decq %r12
incq %rdx
cmpb $0x1, %al
ja 0x2176c
movq %rbp, %rax
subq %r12, %rax
testq %r15, %r15
je 0x217a6
movq %rax, 0x18(%rsp)
movq %r15, %rsi
callq 0x4210
testl %eax, %eax
je 0x21861
movq %rbp, %r12
movq 0x18(%rsp), %rax
jmp 0x217a9
movq %rbp, %r12
movq %rax, 0x18(%rsp)
movq 0x28(%rbx), %rcx
subq %rcx, %r12
movq 0x8(%rbx), %rbp
movq %rcx, 0x30(%rsp)
addq %rcx, %rbp
subq %rax, %rbp
addq %r12, %rbp
testq %r15, %r15
je 0x217ea
movq %r15, %rdi
callq 0x41d0
pushq $-0x6
popq %rcx
subq %rax, %rcx
cmpq %rcx, %rbp
ja 0x216a1
addq %rax, %rbp
addq $0x4, %rbp
leaq 0x1(%rbp), %rdi
movq %rdi, 0x28(%rsp)
callq 0x4680
movq %rax, %rcx
movl %r13d, %eax
testq %rcx, %rcx
je 0x216a4
movq %rcx, %r13
testq %r15, %r15
je 0x21839
movq 0x18(%rsp), %rax
movq %rax, 0x8(%rsp)
movq %r15, (%rsp)
leaq 0x58c08(%rip), %rdx     # 0x7a42c
movq %r13, %rdi
movq 0x28(%rsp), %rsi
movl %r12d, %ecx
movq 0x30(%rsp), %r8
movq %r14, %r9
jmp 0x21855
leaq 0x58bf9(%rip), %rdx     # 0x7a439
movq %r13, %rdi
movq 0x28(%rsp), %rsi
movl %r12d, %ecx
movq 0x30(%rsp), %r8
movq 0x18(%rsp), %r9
xorl %eax, %eax
callq 0x4800
jmp 0x21720
movq %r15, %rdi
callq 0x41d0
movq %rax, %rcx
addq %r12, %rcx
xorl %eax, %eax
cmpq $-0x4, %rcx
je 0x216a4
movq %rbp, %rax
subq %r12, %rax
movq %rbp, %r12
jmp 0x217ae