// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x170, %rsp            # imm = 0x170
testb %al, %al
je 0xda537
movaps %xmm0, -0x120(%rbp)
movaps %xmm1, -0x110(%rbp)
movaps %xmm2, -0x100(%rbp)
movaps %xmm3, -0xf0(%rbp)
movaps %xmm4, -0xe0(%rbp)
movaps %xmm5, -0xd0(%rbp)
movaps %xmm6, -0xc0(%rbp)
movaps %xmm7, -0xb0(%rbp)
movq %r9, -0x128(%rbp)
movq %r8, -0x130(%rbp)
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0xda568
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xda8d8
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, %rax
jne 0xda5a0
movq -0x10(%rbp), %rdi
callq 0xd7490
cmpl $0x0, %eax
je 0xda594
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xda8d8
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
callq 0xd9960
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0xda5cc
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xda8d8
leaq 0x17f4a(%rip), %rax     # 0xf251d
movq %rax, -0x68(%rbp)
leaq 0x17f3f(%rip), %rax     # 0xf251d
movq %rax, -0x70(%rbp)
movq $0x0, -0x80(%rbp)
leaq -0x60(%rbp), %rax
leaq -0x150(%rbp), %rcx
movq %rcx, 0x10(%rax)
leaq 0x10(%rbp), %rcx
movq %rcx, 0x8(%rax)
movl $0x30, 0x4(%rax)
movl $0x20, (%rax)
movq -0x30(%rbp), %rdi
movq -0x40(%rbp), %rsi
leaq -0x60(%rbp), %rdx
leaq -0x73(%rbp), %r9
leaq -0x68(%rbp), %rcx
leaq -0x70(%rbp), %r8
leaq -0x80(%rbp), %rax
movq %rax, (%rsp)
callq 0xda8f0
movl %eax, -0x38(%rbp)
leaq -0x60(%rbp), %rax
cmpl $0x0, -0x38(%rbp)
jge 0xda672
movq -0x18(%rbp), %rcx
movq -0x68(%rbp), %r8
movq -0x70(%rbp), %r9
movl $0x1, %edi
leaq 0x1da74(%rip), %rsi     # 0xf80cc
leaq 0x1da81(%rip), %rdx     # 0xf80e0
movb $0x0, %al
callq 0x1b030
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xda8d8
cmpl $0x0, -0x38(%rbp)
jle 0xda6c5
movq -0x18(%rbp), %rdi
callq 0xdabd0
movl %eax, -0x154(%rbp)
leaq 0x1d9e8(%rip), %rdi     # 0xf8076
callq 0xdabd0
movl %eax, %ecx
movl -0x154(%rbp), %eax
cmpl %ecx, %eax
jne 0xda6c5
movl $0x1, %edi
leaq 0x1da21(%rip), %rsi     # 0xf80cc
leaq 0x1da5e(%rip), %rdx     # 0xf8110
movb $0x0, %al
callq 0x1b030
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xda8d8
leaq -0x60(%rbp), %rax
leaq -0x150(%rbp), %rcx
movq %rcx, 0x10(%rax)
leaq 0x10(%rbp), %rcx
movq %rcx, 0x8(%rax)
movl $0x30, 0x4(%rax)
movl $0x20, (%rax)
movq -0x30(%rbp), %rdi
movq -0x40(%rbp), %rsi
leaq -0x60(%rbp), %rdx
callq 0xdac00
movl %eax, -0x34(%rbp)
leaq -0x60(%rbp), %rax
cmpl $0x0, -0x34(%rbp)
je 0xda712
movl -0x34(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0xda8d8
cmpl $0x0, -0x38(%rbp)
je 0xda86e
movq -0x80(%rbp), %rdi
movq -0x68(%rbp), %rsi
callq 0xdae00
movl %eax, -0x84(%rbp)
movq -0x40(%rbp), %rdi
leaq -0x73(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0xdaf50
movq %rax, -0x90(%rbp)
movl -0x84(%rbp), %eax
movq -0x80(%rbp), %rcx
cmpl (%rcx), %eax
jae 0xda757
jmp 0xda776
leaq 0x1d9d8(%rip), %rdi     # 0xf8136
leaq 0x1d9e2(%rip), %rsi     # 0xf8147
movl $0x63e, %edx            # imm = 0x63E
leaq 0x1d9df(%rip), %rcx     # 0xf8150
callq 0x42e0
cmpq $0x0, -0x90(%rbp)
je 0xda790
movq -0x90(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0xda790
jmp 0xda7af
leaq 0x1da0d(%rip), %rdi     # 0xf81a4
leaq 0x1d9a9(%rip), %rsi     # 0xf8147
movl $0x63f, %edx            # imm = 0x63F
leaq 0x1d9a6(%rip), %rcx     # 0xf8150
callq 0x42e0
movq -0x90(%rbp), %rax
cmpl $0x3, 0x10(%rax)
jle 0xda7be
jmp 0xda7dd
leaq 0x1d9f7(%rip), %rdi     # 0xf81bc
leaq 0x1d97b(%rip), %rsi     # 0xf8147
movl $0x640, %edx            # imm = 0x640
leaq 0x1d978(%rip), %rcx     # 0xf8150
callq 0x42e0
movq -0x80(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x84(%rbp), %ecx
movl (%rax,%rcx,4), %eax
movl %eax, -0x98(%rbp)
movq -0x80(%rbp), %rdi
movl -0x84(%rbp), %esi
callq 0xdb010
movq -0x80(%rbp), %rdi
movq -0x90(%rbp), %rax
movq 0x8(%rax), %rsi
addq $0x3, %rsi
leaq -0x94(%rbp), %rdx
callq 0xdb090
movl %eax, -0x84(%rbp)
cmpl $0x1, -0x94(%rbp)
jge 0xda857
movl $0x1, %edi
leaq 0x1d88f(%rip), %rsi     # 0xf80cc
leaq 0x1d989(%rip), %rdx     # 0xf81cd
movb $0x0, %al
callq 0x1b030
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xda8d8
movl -0x98(%rbp), %edx
movq -0x80(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x84(%rbp), %ecx
movl %edx, (%rax,%rcx,4)
movq -0x30(%rbp), %rax
movq %rax, -0x160(%rbp)
movq -0x18(%rbp), %rdi
callq 0xdabd0
movq -0x160(%rbp), %rdi
movl %eax, %esi
movq -0x40(%rbp), %rdx
callq 0xdb3f0
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
jne 0xda8b6
movq -0x30(%rbp), %rax
cmpl $0x0, 0x94(%rax)
jl 0xda8b6
movq -0x10(%rbp), %rdi
callq 0xd8500
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
jne 0xda8d2
movq -0x30(%rbp), %rax
cmpl $0x0, 0x90(%rax)
je 0xda8d2
movq -0x10(%rbp), %rdi
callq 0xd8e20
movl -0x34(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x170, %rsp            # imm = 0x170
popq %rbp
retq
nopw %cs:(%rax,%rax)