// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/vcf.c
// Function: bcf_hdr_set_idx
static int bcf_hdr_set_idx(bcf_hdr_t *hdr, int dict_type, const char *tag, bcf_idinfo_t *idinfo)
{
    size_t new_n;

    // If available, preserve existing IDX
    if ( idinfo->id==-1 )
        idinfo->id = hdr->n[dict_type];
    else if ( idinfo->id < hdr->n[dict_type] && hdr->id[dict_type][idinfo->id].key )
    {
        hts_log_error("Conflicting IDX=%d lines in the header dictionary, the new tag is %s",
            idinfo->id, tag);
        errno = EINVAL;
        return -1;
    }

    new_n = idinfo->id >= hdr->n[dict_type] ? idinfo->id+1 : hdr->n[dict_type];
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
    // hts_resize() can attempt to allocate up to 2 * requested items
    if (new_n > FUZZ_ALLOC_LIMIT/(2 * sizeof(bcf_idpair_t)))
        return -1;
#endif
    if (hts_resize(bcf_idpair_t, new_n, &hdr->m[dict_type],
                   &hdr->id[dict_type], HTS_RESIZE_CLEAR)) {
        return -1;
    }
    hdr->n[dict_type] = new_n;

    // NB: the next kh_put call can invalidate the idinfo pointer, therefore
    // we leave it unassigned here. It must be set explicitly in bcf_hdr_sync.
    hdr->id[dict_type][idinfo->id].key = tag;

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x28(%rbp), %rax
cmpl $-0x1, 0x30(%rax)
jne 0x51d45
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movl (%rax,%rcx,4), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x30(%rax)
jmp 0x51db9
movq -0x28(%rbp), %rax
movl 0x30(%rax), %eax
movq -0x10(%rbp), %rcx
movslq -0x14(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
jge 0x51db7
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq 0x10(%rax,%rcx,8), %rax
movq -0x28(%rbp), %rcx
movslq 0x30(%rcx), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
cmpq $0x0, (%rax)
je 0x51db7
movq -0x28(%rbp), %rax
movl 0x30(%rax), %ecx
movq -0x20(%rbp), %r8
movl $0x1, %edi
leaq 0xb69da(%rip), %rsi     # 0x10876c
leaq 0xb69e3(%rip), %rdx     # 0x10877c
movb $0x0, %al
callq 0x9d90
callq 0x4050
movl $0x16, (%rax)
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x51eac
jmp 0x51db9
movq -0x28(%rbp), %rax
movl 0x30(%rax), %eax
movq -0x10(%rbp), %rcx
movslq -0x14(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
jl 0x51ddc
movq -0x28(%rbp), %rax
movl 0x30(%rax), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x51dea
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
cltq
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq -0x10(%rbp), %rcx
movslq -0x14(%rbp), %rdx
movslq 0x98(%rcx,%rdx,4), %rcx
cmpq %rcx, %rax
jbe 0x51e60
movq -0x30(%rbp), %rsi
movq -0x10(%rbp), %rcx
addq $0x98, %rcx
movslq -0x14(%rbp), %rax
shlq $0x2, %rax
addq %rax, %rcx
movq -0x10(%rbp), %r8
addq $0x10, %r8
movslq -0x14(%rbp), %rax
shlq $0x3, %rax
addq %rax, %r8
movl $0x10, %edi
movl $0x4, %edx
movl $0x1, %r9d
leaq 0xb691c(%rip), %rax     # 0x10876c
movq %rax, (%rsp)
callq 0xd200
cmpl $0x0, %eax
jne 0x51e68
jmp 0x51e71
xorl %eax, %eax
testb $0x1, %al
jne 0x51e68
jmp 0x51e71
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x51eac
movq -0x30(%rbp), %rax
movl %eax, %edx
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rdx
movq 0x10(%rax,%rdx,8), %rax
movq -0x28(%rbp), %rdx
movslq 0x30(%rdx), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, (%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)