// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/header.c
// Function: check_for_name_update
static int check_for_name_update(sam_hrecs_t *hrecs, sam_hrec_type_t *rec,
                                 va_list ap, const char **old_name,
                                 const char **new_name,
                                 char id_tag_out[3],
                                 khash_t(m_s2i) **hash_out) {
    char *key, *val;
    const char *id_tag;
    sam_hrec_tag_t *tag, *prev;
    khash_t(m_s2i) *hash;
    khint_t k;
    int ret = 0;

    if        (rec->type == TYPEKEY("SQ")) {
        id_tag = "SN"; hash = hrecs->ref_hash;
    } else if (rec->type == TYPEKEY("RG")) {
        id_tag = "ID"; hash = hrecs->rg_hash;
    } else if (rec->type == TYPEKEY("PG")) {
        id_tag = "ID"; hash = hrecs->pg_hash;
    } else {
        return 0;
    }

    memcpy(id_tag_out, id_tag, 3);
    *hash_out = hash;

    tag = sam_hrecs_find_key(rec, id_tag, &prev);
    if (!tag)
        return 0;
    assert(tag->len >= 3);
    *old_name = tag->str + 3;

    while ((key = va_arg(ap, char *)) != NULL) {
        val = va_arg(ap, char *);
        if (!val) val = "";
        if (strcmp(key, id_tag) != 0) continue;
        if (strcmp(val, tag->str + 3) == 0) { ret = 0; continue; }
        k = kh_get(m_s2i, hash, val);
        ret = k < kh_end(hash) ? -1 : 1;
        *new_name = val;
    }
    return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq 0x10(%rbp), %rax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movl $0x0, -0x70(%rbp)
movq -0x18(%rbp), %rax
movl 0x28(%rax), %eax
movl %eax, -0x74(%rbp)
leaq 0x17dbd(%rip), %rdi     # 0xf26ec
callq 0xdabd0
movl %eax, %ecx
movl -0x74(%rbp), %eax
cmpl %ecx, %eax
jne 0xda959
leaq 0x19019(%rip), %rax     # 0xf395d
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0x68(%rbp)
jmp 0xda9d9
movq -0x18(%rbp), %rax
movl 0x28(%rax), %eax
movl %eax, -0x78(%rbp)
leaq 0x17cac(%rip), %rdi     # 0xf2616
callq 0xdabd0
movl %eax, %ecx
movl -0x78(%rbp), %eax
cmpl %ecx, %eax
jne 0xda991
leaq 0x17c9a(%rip), %rax     # 0xf2619
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movq %rax, -0x68(%rbp)
jmp 0xda9d7
movq -0x18(%rbp), %rax
movl 0x28(%rax), %eax
movl %eax, -0x7c(%rbp)
leaq 0x1d6d4(%rip), %rdi     # 0xf8076
callq 0xdabd0
movl %eax, %ecx
movl -0x7c(%rbp), %eax
cmpl %ecx, %eax
jne 0xda9c9
leaq 0x17c62(%rip), %rax     # 0xf2619
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rax
movq 0x70(%rax), %rax
movq %rax, -0x68(%rbp)
jmp 0xda9d5
movl $0x0, -0x4(%rbp)
jmp 0xdabbc
jmp 0xda9d7
jmp 0xda9d9
movq -0x38(%rbp), %rax
movq -0x50(%rbp), %rcx
movw (%rcx), %dx
movw %dx, (%rax)
movb 0x2(%rcx), %cl
movb %cl, 0x2(%rax)
movq -0x68(%rbp), %rcx
movq 0x10(%rbp), %rax
movq %rcx, (%rax)
movq -0x18(%rbp), %rdi
movq -0x50(%rbp), %rsi
leaq -0x60(%rbp), %rdx
callq 0xdaf50
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
jne 0xdaa20
movl $0x0, -0x4(%rbp)
jmp 0xdabbc
movq -0x58(%rbp), %rax
cmpl $0x3, 0x10(%rax)
jl 0xdaa2c
jmp 0xdaa4b
leaq 0x1df1e(%rip), %rdi     # 0xf8951
leaq 0x1d70d(%rip), %rsi     # 0xf8147
movl $0x5fd, %edx            # imm = 0x5FD
leaq 0x1dd3c(%rip), %rcx     # 0xf8782
callq 0x42e0
movq -0x58(%rbp), %rax
movq 0x8(%rax), %rcx
addq $0x3, %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rax
movq %rax, -0x88(%rbp)
movl (%rax), %eax
movl %eax, -0x80(%rbp)
cmpl $0x28, %eax
ja 0xdaa92
movq -0x88(%rbp), %rcx
movl -0x80(%rbp), %edx
movslq %edx, %rax
addq 0x10(%rcx), %rax
addl $0x8, %edx
movl %edx, (%rcx)
movq %rax, -0x90(%rbp)
jmp 0xdaaaf
movq -0x88(%rbp), %rcx
movq 0x8(%rcx), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, 0x8(%rcx)
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x40(%rbp)
cmpq $0x0, %rax
je 0xdabb6
movq -0x20(%rbp), %rax
movq %rax, -0xa0(%rbp)
movl (%rax), %eax
movl %eax, -0x94(%rbp)
cmpl $0x28, %eax
ja 0xdab01
movq -0xa0(%rbp), %rcx
movl -0x94(%rbp), %edx
movslq %edx, %rax
addq 0x10(%rcx), %rax
addl $0x8, %edx
movl %edx, (%rcx)
movq %rax, -0xa8(%rbp)
jmp 0xdab1e
movq -0xa0(%rbp), %rcx
movq 0x8(%rcx), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, 0x8(%rcx)
movq %rax, -0xa8(%rbp)
movq -0xa8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0xdab3e
leaq 0x1543b(%rip), %rax     # 0xeff75
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rdi
movq -0x50(%rbp), %rsi
callq 0x4690
cmpl $0x0, %eax
je 0xdab55
jmp 0xdaa5e
movq -0x48(%rbp), %rdi
movq -0x58(%rbp), %rax
movq 0x8(%rax), %rsi
addq $0x3, %rsi
callq 0x4690
cmpl $0x0, %eax
jne 0xdab7b
movl $0x0, -0x70(%rbp)
jmp 0xdaa5e
movq -0x68(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0xdae00
movl %eax, -0x6c(%rbp)
movl -0x6c(%rbp), %edx
movq -0x68(%rbp), %rax
movl (%rax), %esi
movl $0x1, %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpl %esi, %edx
cmovbl %ecx, %eax
movl %eax, -0x70(%rbp)
movq -0x48(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, (%rax)
jmp 0xdaa5e
movl -0x70(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xb0, %rsp
popq %rbp
retq
nopl (%rax,%rax)