// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/vcf.c
// Function: bcf_hdr_remove
void bcf_hdr_remove(bcf_hdr_t *hdr, int type, const char *key)
{
    int i = 0;
    bcf_hrec_t *hrec;
    if ( !key )
    {
        // no key, remove all entries of this type
        while ( i<hdr->nhrec )
        {
            if ( hdr->hrec[i]->type!=type ) { i++; continue; }
            hrec = hdr->hrec[i];
            bcf_hdr_unregister_hrec(hdr, hrec);
            bcf_hdr_remove_from_hdict(hdr, hrec);
            hdr->dirty = 1;
            hdr->nhrec--;
            if ( i < hdr->nhrec )
                memmove(&hdr->hrec[i],&hdr->hrec[i+1],(hdr->nhrec-i)*sizeof(bcf_hrec_t*));
            bcf_hrec_destroy(hrec);
        }
        return;
    }
    while (1)
    {
        if ( type==BCF_HL_FLT || type==BCF_HL_INFO || type==BCF_HL_FMT || type== BCF_HL_CTG )
        {
            hrec = bcf_hdr_get_hrec(hdr, type, "ID", key, NULL);
            if ( !hrec ) return;

            for (i=0; i<hdr->nhrec; i++)
                if ( hdr->hrec[i]==hrec ) break;
            assert( i<hdr->nhrec );

            vdict_t *d = type==BCF_HL_CTG ? (vdict_t*)hdr->dict[BCF_DT_CTG] : (vdict_t*)hdr->dict[BCF_DT_ID];
            khint_t k = kh_get(vdict, d, key);
            kh_val(d, k).hrec[type==BCF_HL_CTG?0:type] = NULL;
        }
        else
        {
            for (i=0; i<hdr->nhrec; i++)
            {
                if ( hdr->hrec[i]->type!=type ) continue;
                if ( type==BCF_HL_GEN )
                {
                    if ( !strcmp(hdr->hrec[i]->key,key) ) break;
                }
                else
                {
                    // not all structured lines have ID, we could be more sophisticated as in bcf_hdr_get_hrec()
                    int j = bcf_hrec_find_key(hdr->hrec[i], "ID");
                    if ( j>=0 && !strcmp(hdr->hrec[i]->vals[j],key) ) break;
                }
            }
            if ( i==hdr->nhrec ) return;
            hrec = hdr->hrec[i];
            bcf_hdr_remove_from_hdict(hdr, hrec);
        }

        hdr->nhrec--;
        if ( i < hdr->nhrec )
            memmove(&hdr->hrec[i],&hdr->hrec[i+1],(hdr->nhrec-i)*sizeof(bcf_hrec_t*));
        bcf_hrec_destroy(hrec);
        hdr->dirty = 1;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x3ed4e
jmp 0x3ec77
movl -0x1c(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x50(%rcx), %eax
jge 0x3ed49
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl (%rax), %eax
cmpl -0xc(%rbp), %eax
je 0x3eca9
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x3ec77
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x3e050
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x3eff0
movq -0x8(%rbp), %rax
movl $0x1, 0x54(%rax)
movq -0x8(%rbp), %rax
movl 0x50(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x50(%rax)
movl -0x1c(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x50(%rcx), %eax
jge 0x3ed3b
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movslq -0x1c(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdi
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rsi
movl -0x1c(%rbp), %eax
addl $0x1, %eax
cltq
shlq $0x3, %rax
addq %rax, %rsi
movq -0x8(%rbp), %rax
movl 0x50(%rax), %eax
subl -0x1c(%rbp), %eax
movslq %eax, %rdx
shlq $0x3, %rdx
callq 0x4830
movq -0x28(%rbp), %rdi
callq 0x3b040
jmp 0x3ec77
jmp 0x3efdf
jmp 0x3ed50
cmpl $0x0, -0xc(%rbp)
je 0x3ed6c
cmpl $0x1, -0xc(%rbp)
je 0x3ed6c
cmpl $0x2, -0xc(%rbp)
je 0x3ed6c
cmpl $0x3, -0xc(%rbp)
jne 0x3ee79
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
movq -0x18(%rbp), %rcx
leaq 0xc721a(%rip), %rdx     # 0x105f98
xorl %eax, %eax
movl %eax, %r8d
callq 0x3e160
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x3ed98
jmp 0x3efdf
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x50(%rcx), %eax
jge 0x3edd0
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
cmpq -0x28(%rbp), %rax
jne 0x3edc3
jmp 0x3edd0
jmp 0x3edc5
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x3ed9f
movl -0x1c(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x50(%rcx), %eax
jge 0x3edde
jmp 0x3edfd
leaq 0xc8b8e(%rip), %rdi     # 0x107973
leaq 0xc8877(%rip), %rsi     # 0x107663
movl $0x562, %edx            # imm = 0x562
leaq 0xc8b88(%rip), %rcx     # 0x107980
callq 0x42d0
cmpl $0x3, -0xc(%rbp)
jne 0x3ee11
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x40(%rbp)
jmp 0x3ee1d
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x3e520
movl %eax, -0x34(%rbp)
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x34(%rbp), %ecx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
addq $0x18, %rax
movq %rax, -0x48(%rbp)
cmpl $0x3, -0xc(%rbp)
jne 0x3ee5c
xorl %eax, %eax
movl %eax, -0x4c(%rbp)
jmp 0x3ee62
movl -0xc(%rbp), %eax
movl %eax, -0x4c(%rbp)
movq -0x48(%rbp), %rax
movl -0x4c(%rbp), %ecx
movslq %ecx, %rcx
movq $0x0, (%rax,%rcx,8)
jmp 0x3ef6d
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x50(%rcx), %eax
jge 0x3ef3b
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl (%rax), %eax
cmpl -0xc(%rbp), %eax
je 0x3eeac
jmp 0x3ef2d
cmpl $0x5, -0xc(%rbp)
jne 0x3eed8
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x8(%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x46b0
cmpl $0x0, %eax
jne 0x3eed6
jmp 0x3ef3b
jmp 0x3ef2b
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0xc70a9(%rip), %rsi     # 0x105f98
callq 0x3bb40
movl %eax, -0x38(%rbp)
cmpl $0x0, -0x38(%rbp)
jl 0x3ef29
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x28(%rax), %rax
movslq -0x38(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movq -0x18(%rbp), %rsi
callq 0x46b0
cmpl $0x0, %eax
jne 0x3ef29
jmp 0x3ef3b
jmp 0x3ef2b
jmp 0x3ef2d
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x3ee80
movl -0x1c(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x50(%rcx), %eax
jne 0x3ef4c
jmp 0x3efdf
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x3eff0
movq -0x8(%rbp), %rax
movl 0x50(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x50(%rax)
movl -0x1c(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x50(%rcx), %eax
jge 0x3efc6
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movslq -0x1c(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdi
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rsi
movl -0x1c(%rbp), %eax
addl $0x1, %eax
cltq
shlq $0x3, %rax
addq %rax, %rsi
movq -0x8(%rbp), %rax
movl 0x50(%rax), %eax
subl -0x1c(%rbp), %eax
movslq %eax, %rdx
shlq $0x3, %rdx
callq 0x4830
movq -0x28(%rbp), %rdi
callq 0x3b040
movq -0x8(%rbp), %rax
movl $0x1, 0x54(%rax)
jmp 0x3ed50
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)