// File: /workspace/github_c_makefile_star2_O1/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 $0x138, %rsp            # imm = 0x138
movq %r8, 0xa0(%rsp)
movq %r9, 0xa8(%rsp)
testb %al, %al
je 0x890a2
movaps %xmm0, 0xb0(%rsp)
movaps %xmm1, 0xc0(%rsp)
movaps %xmm2, 0xd0(%rsp)
movaps %xmm3, 0xe0(%rsp)
movaps %xmm4, 0xf0(%rsp)
movaps %xmm5, 0x100(%rsp)
movaps %xmm6, 0x110(%rsp)
movaps %xmm7, 0x120(%rsp)
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
testq %rdi, %rdi
je 0x894dd
movq %rcx, %r15
movq %rdx, %r12
movq %rsi, %rbp
movq %rdi, %rbx
movq 0x38(%rdi), %r14
testq %r14, %r14
je 0x8913e
movq %r14, %rdi
movq %rbp, %rsi
movq %r12, %rdx
movq %r15, %rcx
callq 0x881f0
testq %rax, %rax
je 0x894dd
movq %rax, %r15
leaq 0x80(%rsp), %rax
movq %rax, 0x60(%rsp)
leaq 0x170(%rsp), %rax
movq %rax, 0x58(%rsp)
movabsq $0x3000000020, %rax     # imm = 0x3000000020
movq %rax, 0x50(%rsp)
movl 0x28(%r15), %eax
leaq 0x11ed5(%rip), %r9      # 0x9afec
cmpl $0x5047, %eax           # imm = 0x5047
je 0x89165
cmpl $0x5351, %eax           # imm = 0x5351
je 0x89157
cmpl $0x5247, %eax           # imm = 0x5247
jne 0x893c7
leaq 0x11fb1(%rip), %r13     # 0x9b0e8
movl $0x50, %eax
jmp 0x89171
movq %rbx, %rdi
callq 0x866a8
testl %eax, %eax
jne 0x894dd
movq 0x38(%rbx), %r14
jmp 0x890c6
leaq 0x1322b(%rip), %r13     # 0x9c389
movl $0x38, %eax
jmp 0x89171
leaq 0x11f7c(%rip), %r13     # 0x9b0e8
movl $0x70, %eax
movb (%r13), %cl
movb %cl, 0x7(%rsp)
movb 0x1(%r13), %cl
movb %cl, 0x6(%rsp)
movq 0x20(%r15), %r12
testq %r12, %r12
je 0x891a6
movq 0x8(%r12), %rcx
movb 0x7(%rsp), %dl
cmpb %dl, (%rcx)
jne 0x891a0
movb 0x6(%rsp), %dl
cmpb %dl, 0x1(%rcx)
je 0x891a9
movq (%r12), %r12
jmp 0x89185
xorl %r12d, %r12d
movq (%r14,%rax), %rax
movq %rax, 0x18(%rsp)
testq %r12, %r12
je 0x893c2
movq %rbp, 0x38(%rsp)
movq %r14, 0x28(%rsp)
movq %rbx, 0x30(%rsp)
cmpl $0x2, 0x10(%r12)
jle 0x896fc
movq %r15, 0x20(%rsp)
movq 0x8(%r12), %rax
movq %rax, 0x40(%rsp)
movq $0x0, 0x10(%rsp)
leaq 0x11df7(%rip), %rbp     # 0x9afec
movq 0x60(%rsp), %rbx
movq %rbp, 0x8(%rsp)
movl 0x50(%rsp), %r15d
movq 0x58(%rsp), %rbp
cmpl $0x28, %r15d
ja 0x89223
movq %rbp, %r14
movl %r15d, %ebp
addq %rbx, %rbp
addl $0x8, %r15d
movl %r15d, 0x50(%rsp)
jmp 0x8922c
leaq 0x8(%rbp), %r14
movq %r14, 0x58(%rsp)
movq (%rbp), %rdi
testq %rdi, %rdi
je 0x89399
cmpl $0x28, %r15d
ja 0x89253
movq %r14, %rbp
movl %r15d, %r14d
addq %rbx, %r14
addl $0x8, %r15d
movl %r15d, 0x50(%rsp)
jmp 0x8925c
leaq 0x8(%r14), %rbp
movq %rbp, 0x58(%rsp)
movq %r13, %rsi
callq 0x46c0
testl %eax, %eax
jne 0x89209
movq (%r14), %rbp
testq %rbp, %rbp
leaq 0xfa58(%rip), %rax      # 0x98ccd
cmoveq %rax, %rbp
movq 0x8(%r12), %rsi
addq $0x3, %rsi
movq %rbp, %rdi
callq 0x46c0
movq $0x0, 0x10(%rsp)
testl %eax, %eax
je 0x89204
movq 0x18(%rsp), %rax
movl (%rax), %edx
testl %edx, %edx
je 0x892cc
movb (%rbp), %cl
testb %cl, %cl
je 0x892d3
leaq 0x1(%rbp), %rax
movl $0x811c9dc5, %esi       # imm = 0x811C9DC5
movzbl %cl, %ecx
xorl %esi, %ecx
imull $0x1000193, %ecx, %esi  # imm = 0x1000193
movb (%rax), %cl
incq %rax
testb %cl, %cl
jne 0x892b6
jmp 0x892d8
xorl %edi, %edi
jmp 0x89383
movl $0x811c9dc5, %esi       # imm = 0x811C9DC5
movq %rdx, 0x68(%rsp)
decl %edx
andl %edx, %esi
movq 0x18(%rsp), %rax
movq 0x10(%rax), %r8
movl $0x1, %r14d
movl %esi, %edi
movl %esi, 0x4c(%rsp)
movl %edx, 0x48(%rsp)
movq %r8, 0x70(%rsp)
movl %edi, %eax
shrl $0x4, %eax
movl (%r8,%rax,4), %r9d
leal (%rdi,%rdi), %r15d
andl $0x1e, %r15d
movl %r9d, %eax
movl %r15d, %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0x89371
testb $0x1, %al
jne 0x8935c
movq 0x18(%rsp), %rax
movq 0x18(%rax), %rax
movl %edi, %ecx
movq %rdi, 0x10(%rsp)
movq (%rax,%rcx,8), %rdi
movq %rbp, %rsi
movl %r9d, 0x8(%rsp)
callq 0x46c0
movl 0x8(%rsp), %r9d
movq 0x70(%rsp), %r8
movl 0x48(%rsp), %edx
movq 0x10(%rsp), %rdi
movl 0x4c(%rsp), %esi
testl %eax, %eax
je 0x89371
addl %r14d, %edi
andl %edx, %edi
incl %r14d
cmpl %esi, %edi
jne 0x892ff
movq 0x68(%rsp), %rdx
movl %edx, %edi
jmp 0x89383
movl %r15d, %ecx
shrl %cl, %r9d
testb $0x3, %r9b
movq 0x68(%rsp), %rdx
cmovnel %edx, %edi
cmpl %edx, %edi
movl $0x0, %eax
sbbl %eax, %eax
orl $0x1, %eax
movq %rax, 0x10(%rsp)
jmp 0x891fa
movq 0x40(%rsp), %r12
addq $0x3, %r12
movq 0x30(%rsp), %rbx
movq 0x28(%rsp), %r14
movq 0x38(%rsp), %rbp
movq 0x20(%rsp), %r15
movq 0x8(%rsp), %r9
movq 0x10(%rsp), %rcx
jmp 0x893d5
movq %r9, %r12
jmp 0x893d3
movq $0x0, 0x18(%rsp)
movq %r9, %r12
xorl %ecx, %ecx
testl %ecx, %ecx
js 0x894b7
je 0x89410
movzwl (%rbp), %eax
rolw $0x8, %ax
movzwl %ax, %eax
cmpl $0x5047, %eax           # imm = 0x5047
jne 0x89410
leaq 0x1b279(%rip), %rsi     # 0xa4671
leaq 0x1b2b6(%rip), %rdx     # 0xa46b5
movl $0x1, %edi
xorl %eax, %eax
callq 0x14378
jmp 0x894d7
movq %rcx, 0x10(%rsp)
leaq 0x50(%rsp), %rdx
leaq 0x80(%rsp), %rax
movq %rax, 0x10(%rdx)
leaq 0x170(%rsp), %rax
movq %rax, 0x8(%rdx)
movabsq $0x3000000020, %rax     # imm = 0x3000000020
movq %rax, (%rdx)
movq %r14, %rdi
movq %r15, %rsi
callq 0x89778
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
testl %eax, %eax
jne 0x894dd
cmpl $0x0, 0x10(%rsp)
je 0x8969e
movq 0x18(%rsp), %rax
movl (%rax), %ecx
testl %ecx, %ecx
movq %rcx, 0x8(%rsp)
movq %rbp, 0x38(%rsp)
movq %r15, 0x20(%rsp)
je 0x894f2
leal -0x1(%rcx), %edx
movb (%r12), %cl
testb %cl, %cl
movq %rbx, 0x30(%rsp)
movq %r14, 0x28(%rsp)
movq %r12, 0x40(%rsp)
je 0x894fa
leaq 0x1(%r12), %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 0x894a1
jmp 0x894ff
leaq 0x1b1b3(%rip), %rsi     # 0xa4671
leaq 0x1b1c0(%rip), %rdx     # 0xa4685
movl $0x1, %edi
movq %rbp, %rcx
movq %r12, %r8
xorl %eax, %eax
callq 0x14378
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
movl %r13d, %eax
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r15d, %r15d
jmp 0x8959b
movl $0x811c9dc5, %ebx       # imm = 0x811C9DC5
andl %edx, %ebx
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rsi
movl $0x1, %r12d
movl %ebx, %r15d
movq %rsi, 0x10(%rsp)
movl %r15d, %eax
shrl $0x4, %eax
movl (%rsi,%rax,4), %r14d
leal (%r15,%r15), %ebp
andl $0x1e, %ebp
movl %r14d, %eax
movl %ebp, %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0x8957f
testb $0x1, %al
jne 0x89567
movq 0x18(%rsp), %rax
movq 0x18(%rax), %rax
movl %r15d, %ecx
movq (%rax,%rcx,8), %rdi
movq 0x40(%rsp), %rsi
movl %edx, %r13d
callq 0x46c0
movq 0x10(%rsp), %rsi
movl %r13d, %edx
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
testl %eax, %eax
je 0x8957f
addl %r12d, %r15d
andl %edx, %r15d
incl %r12d
cmpl %ebx, %r15d
jne 0x89518
movq 0x8(%rsp), %rcx
movl %ecx, %r15d
jmp 0x89591
movl %ebp, %ecx
shrl %cl, %r14d
testb $0x3, %r14b
movq 0x8(%rsp), %rcx
cmovnel %ecx, %r15d
movq 0x30(%rsp), %rbx
movq 0x28(%rsp), %r14
movq 0x20(%rsp), %rax
movq 0x20(%rax), %rax
testq %rax, %rax
je 0x895cf
movq 0x8(%rax), %rcx
movb 0x7(%rsp), %dl
cmpb %dl, (%rcx)
jne 0x895be
movb 0x6(%rsp), %dl
cmpb %dl, 0x1(%rcx)
je 0x895c8
movq (%rax), %rax
testq %rax, %rax
jne 0x895a9
xorl %eax, %eax
movq 0x8(%rsp), %rcx
jmp 0x895d1
xorl %eax, %eax
cmpl %ecx, %r15d
jae 0x8973a
testq %rax, %rax
je 0x8971b
movq 0x8(%rax), %rsi
testq %rsi, %rsi
je 0x8971b
cmpl $0x3, 0x10(%rax)
jle 0x89759
movq %r14, %r12
movq %rbx, %r14
movq 0x18(%rsp), %rbp
movq 0x20(%rbp), %rax
movl %r15d, %ecx
movl (%rax,%rcx,4), %ebx
cmpl %r15d, 0x8(%rsp)
je 0x89643
movq 0x10(%rbp), %rax
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 0x89643
btsl %r15d, %edi
movl %edi, (%rax,%rdx,4)
decl 0x4(%rbp)
addq $0x3, %rsi
leaq 0x7c(%rsp), %r15
movq %rbp, %rdi
movq %r15, %rdx
callq 0x89a57
movq %rbp, %rcx
movl (%r15), %ebp
testl %ebp, %ebp
jle 0x8966c
movq 0x20(%rcx), %rcx
movl %eax, %eax
movl %ebx, (%rcx,%rax,4)
jmp 0x89686
leaq 0x1affe(%rip), %rsi     # 0xa4671
leaq 0x1b0f8(%rip), %rdx     # 0xa4772
movl $0x1, %edi
xorl %eax, %eax
callq 0x14378
movq 0x20(%rsp), %r15
testl %ebp, %ebp
movq %r14, %rbx
movq %r12, %r14
movq 0x38(%rsp), %rbp
jle 0x894dd
movzwl (%rbp), %eax
rolw $0x8, %ax
movzwl %ax, %esi
movq %r14, %rdi
movq %r15, %rdx
callq 0x89c4a
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
testl %eax, %eax
jne 0x896d8
cmpl $0x0, 0x94(%r14)
js 0x896d5
movq %rbx, %rdi
callq 0x872c6
movl %eax, %r13d
jmp 0x896d8
xorl %r13d, %r13d
testl %r13d, %r13d
jne 0x894dd
cmpl $0x0, 0x90(%r14)
je 0x894dd
movq %rbx, %rdi
callq 0x879db
jmp 0x894dd
leaq 0x1b7f3(%rip), %rdi     # 0xa4ef6
leaq 0x1afe2(%rip), %rsi     # 0xa46ec
leaq 0x1b616(%rip), %rcx     # 0xa4d27
movl $0x5fd, %edx            # imm = 0x5FD
callq 0x42f0
leaq 0x1b027(%rip), %rdi     # 0xa4749
leaq 0x1afc3(%rip), %rsi     # 0xa46ec
leaq 0x1afc5(%rip), %rcx     # 0xa46f5
movl $0x63f, %edx            # imm = 0x63F
callq 0x42f0
leaq 0x1af9a(%rip), %rdi     # 0xa46db
leaq 0x1afa4(%rip), %rsi     # 0xa46ec
leaq 0x1afa6(%rip), %rcx     # 0xa46f5
movl $0x63e, %edx            # imm = 0x63E
callq 0x42f0
leaq 0x1b001(%rip), %rdi     # 0xa4761
leaq 0x1af85(%rip), %rsi     # 0xa46ec
leaq 0x1af87(%rip), %rcx     # 0xa46f5
movl $0x640, %edx            # imm = 0x640
callq 0x42f0