// File: /workspace/github_c_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %esi, %ebp
movq %rdi, %rbx
testq %rdx, %rdx
je 0x2ebe5
movq %rdx, %r15
xorl %eax, %eax
xorl %ecx, %ecx
cmpl $0x3, %ebp
movl %ebp, %edx
cmovel %eax, %edx
movq %rdx, 0x48(%rsp)
sete %cl
leaq 0x28(,%rcx,8), %rax
movq %rax, 0x40(%rsp)
leaq 0x1(%r15), %rax
movq %rax, 0x38(%rsp)
movl %ebp, 0xc(%rsp)
movq %rbx, (%rsp)
movq %r15, 0x10(%rsp)
cmpl $0x4, %ebp
jae 0x2e9f4
movq %rbx, %rdi
movl %ebp, %esi
leaq 0x7e3bf(%rip), %rdx     # 0xacd57
movq %r15, %rcx
xorl %r8d, %r8d
callq 0x2dff0
testq %rax, %rax
je 0x2ec5e
movq %rax, %r14
movslq 0x50(%rbx), %rax
testq %rax, %rax
setg %dl
jle 0x2ec6d
movq 0x48(%rbx), %rcx
cmpq %r14, (%rcx)
je 0x2ea7a
leaq -0x1(%rax), %rdx
xorl %esi, %esi
cmpq %rsi, %rdx
je 0x2ec6d
leaq 0x1(%rsi), %r12
cmpq %r14, 0x8(%rcx,%rsi,8)
movq %r12, %rsi
jne 0x2e9d2
cmpq %rax, %r12
setb %dl
jmp 0x2ea7d
movl 0x50(%rbx), %r14d
testl %r14d, %r14d
jle 0x2ea53
movq 0x48(%rbx), %rbx
xorl %r12d, %r12d
movq (%rbx,%r12,8), %r13
cmpl %ebp, (%r13)
jne 0x2ea42
cmpl $0x5, %ebp
jne 0x2ea19
movq 0x8(%r13), %rdi
jmp 0x2ea36
movq %r13, %rdi
leaq 0x7e334(%rip), %rsi     # 0xacd57
callq 0x2c40b
testl %eax, %eax
js 0x2ea42
movq 0x28(%r13), %rcx
movl %eax, %eax
movq (%rcx,%rax,8), %rdi
movq %r15, %rsi
callq 0x46e0
testl %eax, %eax
je 0x2ea4d
incq %r12
cmpq %r12, %r14
jne 0x2ea04
movl %r14d, %r12d
movq (%rsp), %rbx
jmp 0x2ea56
xorl %r12d, %r12d
cmpl %r14d, %r12d
je 0x2ec5e
movq 0x48(%rbx), %rax
movl %r12d, %ecx
movq (%rax,%rcx,8), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2ec8c
jmp 0x2eba0
xorl %r12d, %r12d
testb %dl, %dl
je 0x2ec6d
movq 0x40(%rsp), %rax
movq (%rbx,%rax), %rax
movq %rax, 0x18(%rsp)
movl (%rax), %edx
testl %edx, %edx
je 0x2eb81
movq %r14, 0x30(%rsp)
movb (%r15), %al
movl $0x811c9dc5, %r14d      # imm = 0x811C9DC5
testb %al, %al
je 0x2eaca
movq 0x38(%rsp), %rcx
movzbl %al, %eax
xorl %r14d, %eax
imull $0x1000193, %eax, %r14d # imm = 0x1000193
movb (%rcx), %al
incq %rcx
testb %al, %al
jne 0x2eab4
movq %rdx, 0x28(%rsp)
decl %edx
andl %edx, %r14d
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rsi
movl $0x1, %ebx
movl %r14d, %r15d
movl %edx, 0x24(%rsp)
movq %rsi, 0x50(%rsp)
movl %r15d, %eax
shrl $0x4, %eax
movl (%rsi,%rax,4), %r13d
leal (%r15,%r15), %ebp
andl $0x1e, %ebp
movl %r13d, %eax
movl %ebp, %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0x2eb5b
testb $0x1, %al
jne 0x2eb35
movq 0x18(%rsp), %rax
movq 0x18(%rax), %rax
movl %r15d, %ecx
movq (%rax,%rcx,8), %rdi
movq 0x10(%rsp), %rsi
callq 0x46e0
movq 0x50(%rsp), %rsi
movl 0x24(%rsp), %edx
testl %eax, %eax
je 0x2eb5b
addl %ebx, %r15d
andl %edx, %r15d
incl %ebx
cmpl %r14d, %r15d
jne 0x2eaee
movl 0xc(%rsp), %ebp
movq (%rsp), %rbx
movq 0x10(%rsp), %r15
movq 0x30(%rsp), %r14
movq 0x28(%rsp), %rax
jmp 0x2eb83
movl %ebp, %ecx
shrl %cl, %r13d
testb $0x3, %r13b
movq 0x28(%rsp), %rax
cmovel %r15d, %eax
movl 0xc(%rsp), %ebp
movq (%rsp), %rbx
movq 0x10(%rsp), %r15
movq 0x30(%rsp), %r14
jmp 0x2eb83
xorl %eax, %eax
movl %eax, %eax
imulq $0x38, %rax, %rax
movq 0x18(%rsp), %rcx
addq 0x20(%rcx), %rax
movq 0x48(%rsp), %rcx
movq $0x0, 0x18(%rax,%rcx,8)
movslq 0x50(%rbx), %rdx
decq %rdx
movl %edx, 0x50(%rbx)
cmpl %r12d, %edx
jle 0x2ebd1
movq 0x48(%rbx), %rax
movl %r12d, %ecx
leaq (%rax,%rcx,8), %rdi
leaq (%rax,%rcx,8), %rsi
addq $0x8, %rsi
movslq %r12d, %rax
subq %rax, %rdx
shlq $0x3, %rdx
callq 0x4850
movq %r14, %rdi
callq 0x2bd39
movl $0x1, 0x54(%rbx)
jmp 0x2e987
cmpl $0x0, 0x50(%rbx)
jle 0x2ec5e
xorl %r14d, %r14d
movq 0x48(%rbx), %rax
movq (%rax,%r14,8), %r15
cmpl %ebp, (%r15)
jne 0x2ec59
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2de87
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2ec8c
movl $0x1, 0x54(%rbx)
movslq 0x50(%rbx), %rax
decq %rax
movl %eax, 0x50(%rbx)
cmpq %rax, %r14
jge 0x2ec46
movq 0x48(%rbx), %rcx
leaq (%rcx,%r14,8), %rdi
leaq (%rcx,%r14,8), %rsi
addq $0x8, %rsi
subl %r14d, %eax
movslq %eax, %rdx
shlq $0x3, %rdx
callq 0x4850
movq %r15, %rdi
callq 0x2bd39
movslq 0x50(%rbx), %rax
cmpq %rax, %r14
jl 0x2ebee
jmp 0x2ec5e
incq %r14
jmp 0x2ec4e
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x7fc8b(%rip), %rdi     # 0xae8ff
leaq 0x7f9a8(%rip), %rsi     # 0xae623
leaq 0x7fc8a(%rip), %rcx     # 0xae90c
movl $0x562, %edx            # imm = 0x562
callq 0x42e0