// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/header.c
// Function: sam_hdr_update_line
int sam_hdr_update_line(sam_hdr_t *bh, const char *type,
        const char *ID_key, const char *ID_value, ...) {
    sam_hrecs_t *hrecs;
    if (!bh)
        return -1;

    if (!(hrecs = bh->hrecs)) {
        if (sam_hdr_fill_hrecs(bh) != 0)
            return -1;
        hrecs = bh->hrecs;
    }

    int ret, rename;
    sam_hrec_type_t *ty = sam_hrecs_find_type_id(hrecs, type, ID_key, ID_value);
    if (!ty)
        return -1;

    va_list args;
    const char *old_name = "?", *new_name = "?";
    char id_tag[3];
    khash_t(m_s2i) *hash = NULL;
    va_start(args, ID_value);
    rename = check_for_name_update(hrecs, ty, args,
                                   &old_name, &new_name, id_tag, &hash);
    va_end(args);
    if (rename < 0) {
        hts_log_error("Cannot rename @%s \"%s\" to \"%s\" : already exists",
                      type, old_name, new_name);
        return -1;
    }
    if (rename > 0 && TYPEKEY(type) == TYPEKEY("PG")) {
        // This is just too complicated
        hts_log_error("Renaming @PG records is not supported");
        return -1;
    }
    va_start(args, ID_value);
    ret = sam_hrecs_vupdate(hrecs, ty, args);
    va_end(args);

    if (ret)
        return ret;

    // TODO Account for @SQ-AN altnames

    if (rename) {
        // Adjust the hash table to point to the new name
        // sam_hrecs_update_hashes() should sort out everything else
        khint_t k = kh_get(m_s2i, hash, old_name);
        sam_hrec_tag_t *new_tag = sam_hrecs_find_key(ty, id_tag, NULL);
        int r, pos;
        assert(k < kh_end(hash));        // Or we wouldn't have found it earlier
        assert(new_tag && new_tag->str); // id_tag should exist
        assert(new_tag->len > 3);
        pos = kh_val(hash, k);
        kh_del(m_s2i, hash, k);
        k = kh_put(m_s2i, hash, new_tag->str + 3, &r);
        if (r < 1) {
            hts_log_error("Failed to rename item in hash table");
            return -1;
        }
        kh_val(hash, k) = pos;
    }

    ret = sam_hrecs_update_hashes(hrecs, TYPEKEY(type), ty);

    if (!ret && hrecs->refs_changed >= 0)
        ret = rebuild_target_arrays(bh);

    if (!ret && hrecs->dirty)
        redact_header_text(bh);

    return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x158, %rsp            # imm = 0x158
movq %r8, 0xc0(%rsp)
movq %r9, 0xc8(%rsp)
testb %al, %al
je 0x869d3
movaps %xmm0, 0xd0(%rsp)
movaps %xmm1, 0xe0(%rsp)
movaps %xmm2, 0xf0(%rsp)
movaps %xmm3, 0x100(%rsp)
movaps %xmm4, 0x110(%rsp)
movaps %xmm5, 0x120(%rsp)
movaps %xmm6, 0x130(%rsp)
movaps %xmm7, 0x140(%rsp)
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testq %rdi, %rdi
je 0x86f93
movq %rcx, %r15
movq %rdx, %r12
movq %rsi, %rbx
movq %rdi, %r14
movq 0x38(%rdi), %r13
testq %r13, %r13
je 0x86a6f
movq %r13, %rdi
movq %rbx, %rsi
movq %r12, %rdx
movq %r15, %rcx
callq 0x85b55
testq %rax, %rax
je 0x86f93
movq %rax, %r15
leaq 0xa0(%rsp), %rax
movq %rax, 0x80(%rsp)
leaq 0x190(%rsp), %rax
movq %rax, 0x78(%rsp)
movabsq $0x3000000020, %rax     # imm = 0x3000000020
movq %rax, 0x70(%rsp)
movl 0x28(%r15), %eax
cmpl $0x5047, %eax           # imm = 0x5047
movq %rbx, 0x58(%rsp)
je 0x86a96
cmpl $0x5351, %eax           # imm = 0x5351
je 0x86a88
cmpl $0x5247, %eax           # imm = 0x5247
jne 0x86ae5
leaq 0x11693(%rip), %rdx     # 0x980fb
movl $0x50, %eax
jmp 0x86aa2
movq %r14, %rdi
callq 0x8413e
testl %eax, %eax
jne 0x86f93
movq 0x38(%r14), %r13
jmp 0x869f6
leaq 0x12976(%rip), %rdx     # 0x99405
movl $0x38, %eax
jmp 0x86aa2
leaq 0x1165e(%rip), %rdx     # 0x980fb
movl $0x70, %eax
movq (%r13,%rax), %rax
movq %rax, 0x10(%rsp)
movb (%rdx), %cl
movb 0x1(%rdx), %al
movq 0x20(%r15), %r12
testq %r12, %r12
movb %al, 0xf(%rsp)
movb %cl, 0xe(%rsp)
je 0x86ade
movq 0x8(%r12), %rbp
cmpb %cl, (%rbp)
jne 0x86ad5
cmpb %al, 0x1(%rbp)
je 0x86b86
movq (%r12), %r12
testq %r12, %r12
jne 0x86ac2
movq 0x10(%rsp), %r12
jmp 0x86ae8
xorl %r12d, %r12d
leaq 0x11510(%rip), %rbp     # 0x97fff
movb $0x1, %bl
leaq 0x70(%rsp), %rdx
leaq 0xa0(%rsp), %rax
movq %rax, 0x10(%rdx)
leaq 0x190(%rsp), %rax
movq %rax, 0x8(%rdx)
movabsq $0x3000000020, %rax     # imm = 0x3000000020
movq %rax, (%rdx)
movq %r13, %rdi
movq %r15, %rsi
callq 0x8708d
testl %eax, %eax
jne 0x86f8e
testb %bl, %bl
jne 0x86f70
movl (%r12), %edi
testl %edi, %edi
movq %r15, 0x30(%rsp)
je 0x86dd4
movq %rdi, 0x18(%rsp)
leal -0x1(%rdi), %edx
movb (%rbp), %cl
testb %cl, %cl
movq %r14, 0x28(%rsp)
movq %r13, 0x20(%rsp)
je 0x86e08
leaq 0x1(%rbp), %rax
movl $0x811c9dc5, %ebx       # imm = 0x811C9DC5
movzbl %cl, %ecx
xorl %ebx, %ecx
imull $0x1000193, %ecx, %ebx  # imm = 0x1000193
movb (%rax), %cl
incq %rax
testb %cl, %cl
jne 0x86b6d
jmp 0x86e0d
movq %r14, 0x28(%rsp)
cmpl $0x2, 0x10(%r12)
jle 0x8706e
movq %rdx, 0x60(%rsp)
movq %r15, 0x30(%rsp)
movq 0x80(%rsp), %rax
movq %rax, 0x38(%rsp)
movl 0x70(%rsp), %ebx
movl $0x0, 0x18(%rsp)
leaq 0x1143e(%rip), %r15     # 0x97fff
movq 0x78(%rsp), %r14
movq %r13, 0x20(%rsp)
movq %r15, 0x50(%rsp)
movq %r14, %r15
cmpl $0x28, %ebx
ja 0x86bec
movq %r15, %r13
movl %ebx, %r15d
addq 0x38(%rsp), %r15
addl $0x8, %ebx
movl %ebx, 0x70(%rsp)
jmp 0x86bf8
leaq 0x8(%r15), %r14
movq %r14, 0x78(%rsp)
movq %r14, %r13
movq (%r15), %rdi
testq %rdi, %rdi
je 0x86d76
cmpl $0x28, %ebx
ja 0x86c1d
movq %r13, %r15
movl %ebx, %r13d
addq 0x38(%rsp), %r13
addl $0x8, %ebx
movl %ebx, 0x70(%rsp)
jmp 0x86c29
leaq 0x8(%r13), %r14
movq %r14, 0x78(%rsp)
movq %r14, %r15
movq 0x60(%rsp), %rsi
callq 0x46c0
testl %eax, %eax
jne 0x86bd3
movq (%r13), %r15
testq %r15, %r15
leaq 0xf128(%rip), %rax      # 0x95d6d
cmoveq %rax, %r15
movq 0x8(%r12), %rsi
addq $0x3, %rsi
movq %r15, %rdi
callq 0x46c0
movl $0x0, 0x18(%rsp)
testl %eax, %eax
je 0x86bd0
movq 0x10(%rsp), %rax
movl (%rax), %eax
testl %eax, %eax
je 0x86ca5
movq %rax, 0x40(%rsp)
movb (%r15), %cl
testb %cl, %cl
movq %r15, 0x48(%rsp)
je 0x86cac
leaq 0x1(%r15), %rax
movl $0x811c9dc5, %edx       # imm = 0x811C9DC5
movzbl %cl, %ecx
xorl %edx, %ecx
imull $0x1000193, %ecx, %edx  # imm = 0x1000193
movb (%rax), %cl
incq %rax
testb %cl, %cl
jne 0x86c8f
jmp 0x86cb1
xorl %esi, %esi
jmp 0x86d61
movl $0x811c9dc5, %edx       # imm = 0x811C9DC5
movq 0x40(%rsp), %rax
leal -0x1(%rax), %edi
andl %edi, %edx
movq 0x10(%rsp), %rax
movq 0x10(%rax), %r8
movl $0x1, %r15d
movl %edx, %esi
movl %edx, 0x6c(%rsp)
movl %edi, 0x68(%rsp)
movq %r8, 0x90(%rsp)
movl %esi, %eax
shrl $0x4, %eax
movl (%r8,%rax,4), %r13d
leal (%rsi,%rsi), %ecx
andl $0x1e, %ecx
movl %r13d, %eax
shrl %cl, %eax
testb $0x2, %al
jne 0x86d4d
testb $0x1, %al
jne 0x86d38
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rax
movl %esi, %r9d
movq (%rax,%r9,8), %rdi
movq %rsi, 0x18(%rsp)
movq 0x48(%rsp), %rsi
movl %ecx, 0x50(%rsp)
callq 0x46c0
movl 0x50(%rsp), %ecx
movq 0x90(%rsp), %r8
movl 0x68(%rsp), %edi
movq 0x18(%rsp), %rsi
movl 0x6c(%rsp), %edx
testl %eax, %eax
je 0x86d4d
addl %r15d, %esi
andl %edi, %esi
incl %r15d
cmpl %edx, %esi
jne 0x86cdc
movq 0x40(%rsp), %rax
movl %eax, %esi
jmp 0x86d5c
shrl %cl, %r13d
testb $0x3, %r13b
movq 0x40(%rsp), %rax
cmovnel %eax, %esi
movq 0x48(%rsp), %r15
cmpl %eax, %esi
movl $0x0, %eax
sbbl %eax, %eax
orl $0x1, %eax
movl %eax, 0x18(%rsp)
jmp 0x86bcb
addq $0x3, %rbp
cmpl $0x0, 0x18(%rsp)
movq 0x30(%rsp), %r15
js 0x86ddc
je 0x86ff4
movq 0x58(%rsp), %rax
movzwl (%rax), %eax
rolw $0x8, %ax
movzwl %ax, %eax
cmpl $0x5047, %eax           # imm = 0x5047
movq 0x28(%rsp), %r14
movq 0x20(%rsp), %r13
movq 0x10(%rsp), %r12
jne 0x8700a
leaq 0x1b034(%rip), %rsi     # 0xa1df0
leaq 0x1b071(%rip), %rdx     # 0xa1e34
movl $0x1, %edi
xorl %eax, %eax
callq 0x13de5
jmp 0x86f8e
xorl %r15d, %r15d
jmp 0x86eac
leaq 0x1b00d(%rip), %rsi     # 0xa1df0
leaq 0x1b01a(%rip), %rdx     # 0xa1e04
movl $0x1, %edi
movq 0x58(%rsp), %rcx
movq %rbp, %r8
movq 0x50(%rsp), %r9
xorl %eax, %eax
callq 0x13de5
jmp 0x86f8e
movl $0x811c9dc5, %ebx       # imm = 0x811C9DC5
andl %edx, %ebx
movq %r12, 0x10(%rsp)
movq 0x10(%r12), %rsi
movl $0x1, %r14d
movl %ebx, %r15d
movl %edx, 0x38(%rsp)
movq %rsi, 0x60(%rsp)
movl %r15d, %eax
shrl $0x4, %eax
movl (%rsi,%rax,4), %r13d
leal (%r15,%r15), %r12d
andl $0x1e, %r12d
movl %r13d, %eax
movl %r12d, %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0x86e8a
testb $0x1, %al
jne 0x86e72
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rax
movl %r15d, %ecx
movq (%rax,%rcx,8), %rdi
movq %rbp, %rsi
callq 0x46c0
movq 0x60(%rsp), %rsi
movl 0x38(%rsp), %edx
testl %eax, %eax
je 0x86e8a
addl %r14d, %r15d
andl %edx, %r15d
incl %r14d
cmpl %ebx, %r15d
jne 0x86e2b
movq 0x18(%rsp), %rdi
movl %edi, %r15d
jmp 0x86e9d
movl %r12d, %ecx
shrl %cl, %r13d
testb $0x3, %r13b
movq 0x18(%rsp), %rdi
cmovnel %edi, %r15d
movq 0x28(%rsp), %r14
movq 0x20(%rsp), %r13
movq 0x10(%rsp), %r12
movb 0xf(%rsp), %dl
movb 0xe(%rsp), %sil
movq 0x30(%rsp), %rax
movq 0x20(%rax), %rax
testq %rax, %rax
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
je 0x86ede
movq 0x8(%rax), %rcx
cmpb %sil, (%rcx)
jne 0x86ed6
cmpb %dl, 0x1(%rcx)
je 0x86ee0
movq (%rax), %rax
testq %rax, %rax
jne 0x86ec8
xorl %eax, %eax
cmpl %edi, %r15d
jae 0x87030
testq %rax, %rax
je 0x87011
movq 0x8(%rax), %rsi
testq %rsi, %rsi
je 0x87011
cmpl $0x3, 0x10(%rax)
jle 0x8704f
movq 0x10(%r12), %rax
movq 0x20(%r12), %rcx
movl %r15d, %edx
movl (%rcx,%rdx,4), %ebx
movl %r15d, %edx
shrl $0x4, %edx
movl (%rax,%rdx,4), %edi
addl %r15d, %r15d
andl $0x1e, %r15d
movl %edi, %r8d
movl %r15d, %ecx
shrl %cl, %r8d
testb $0x3, %r8b
jne 0x86f44
btsl %r15d, %edi
movl %edi, (%rax,%rdx,4)
decl 0x4(%r12)
addq $0x3, %rsi
leaq 0x9c(%rsp), %r15
movq %r12, %rdi
movq %r15, %rdx
callq 0x8732d
cmpl $0x0, (%r15)
jle 0x86fd8
movq 0x20(%r12), %rcx
movl %eax, %eax
movl %ebx, (%rcx,%rax,4)
movq 0x30(%rsp), %r15
movq 0x58(%rsp), %rax
movzwl (%rax), %eax
rolw $0x8, %ax
movzwl %ax, %esi
movq %r13, %rdi
movq %r15, %rdx
callq 0x8753f
testl %eax, %eax
je 0x86fa7
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl %ebp, %eax
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x0, 0x94(%r13)
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
js 0x86fc2
movq %r14, %rdi
callq 0x84ce2
testl %eax, %eax
jne 0x86f93
xorl %ebp, %ebp
cmpl $0x0, 0x90(%r13)
je 0x86f93
movq %r14, %rdi
callq 0x853ed
jmp 0x86f93
leaq 0x1ae11(%rip), %rsi     # 0xa1df0
leaq 0x1af0b(%rip), %rdx     # 0xa1ef1
movl $0x1, %edi
xorl %eax, %eax
callq 0x13de5
jmp 0x86f93
movb $0x1, %bl
movq 0x28(%rsp), %r14
movq 0x20(%rsp), %r13
movq 0x10(%rsp), %r12
jmp 0x86af1
xorl %ebx, %ebx
jmp 0x86af1
leaq 0x1aeb0(%rip), %rdi     # 0xa1ec8
leaq 0x1ae4c(%rip), %rsi     # 0xa1e6b
leaq 0x1ae4e(%rip), %rcx     # 0xa1e74
movl $0x63f, %edx            # imm = 0x63F
callq 0x42f0
leaq 0x1ae23(%rip), %rdi     # 0xa1e5a
leaq 0x1ae2d(%rip), %rsi     # 0xa1e6b
leaq 0x1ae2f(%rip), %rcx     # 0xa1e74
movl $0x63e, %edx            # imm = 0x63E
callq 0x42f0
leaq 0x1ae8a(%rip), %rdi     # 0xa1ee0
leaq 0x1ae0e(%rip), %rsi     # 0xa1e6b
leaq 0x1ae10(%rip), %rcx     # 0xa1e74
movl $0x640, %edx            # imm = 0x640
callq 0x42f0
leaq 0x1b600(%rip), %rdi     # 0xa2675
leaq 0x1adef(%rip), %rsi     # 0xa1e6b
leaq 0x1b423(%rip), %rcx     # 0xa24a6
movl $0x5fd, %edx            # imm = 0x5FD
callq 0x42f0