// File: /workspace/github_c_makefile_star2_O3/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 $0x68, %rsp
movl %esi, %ebp
movq %rdi, %r14
testq %rdx, %rdx
movq %rdi, 0x8(%rsp)
je 0x2da14
movq %rdx, %r15
xorl %eax, %eax
xorl %ecx, %ecx
cmpl $0x3, %ebp
movl %ebp, %edx
cmovel %eax, %edx
movq %rdx, 0x58(%rsp)
sete %cl
leaq 0x28(,%rcx,8), %rax
movq %rax, 0x50(%rsp)
leaq 0x1(%r15), %rax
movq %rax, 0x48(%rsp)
movl %ebp, 0x14(%rsp)
movq %r15, 0x18(%rsp)
cmpl $0x4, %ebp
jae 0x2d815
movq %r14, %rdi
movl %ebp, %esi
leaq 0x7c537(%rip), %rdx     # 0xa9d0a
movq %r15, %rcx
xorl %r8d, %r8d
callq 0x2ce51
testq %rax, %rax
je 0x2da9b
movq 0x8(%rsp), %r14
movl 0x50(%r14), %edx
testl %edx, %edx
jle 0x2daaa
movq %rax, %rbx
movq 0x48(%r14), %rax
xorl %r12d, %r12d
cmpq %rbx, (%rax,%r12,8)
je 0x2d878
incq %r12
cmpq %r12, %rdx
jne 0x2d802
jmp 0x2daaa
movslq 0x50(%r14), %rbx
testq %rbx, %rbx
jle 0x2d95c
movq 0x48(%r14), %r14
xorl %r12d, %r12d
movq (%r14,%r12,8), %r13
cmpl %ebp, (%r13)
jne 0x2d86b
cmpl $0x5, %ebp
jne 0x2d83e
movq 0x8(%r13), %rdi
jmp 0x2d85b
movq %r13, %rdi
leaq 0x7c4c2(%rip), %rsi     # 0xa9d0a
callq 0x2b32b
testl %eax, %eax
js 0x2d86b
movq 0x28(%r13), %rcx
movl %eax, %eax
movq (%rcx,%rax,8), %rdi
movq %r15, %rsi
callq 0x46e0
testl %eax, %eax
je 0x2d95f
incq %r12
cmpq %r12, %rbx
jne 0x2d829
jmp 0x2da9b
movq 0x50(%rsp), %rax
movq (%r14,%rax), %rax
movq %rax, 0x20(%rsp)
movl (%rax), %esi
testl %esi, %esi
je 0x2d9b6
movq %rbx, 0x40(%rsp)
movb (%r15), %al
testb %al, %al
movq %rdx, 0x38(%rsp)
movl $0x811c9dc5, %ebx       # imm = 0x811C9DC5
je 0x2d8bf
movq 0x48(%rsp), %rcx
movzbl %al, %eax
xorl %ebx, %eax
imull $0x1000193, %eax, %ebx  # imm = 0x1000193
movb (%rcx), %al
incq %rcx
testb %al, %al
jne 0x2d8ab
movq %rsi, 0x30(%rsp)
leal -0x1(%rsi), %edx
andl %edx, %ebx
movq 0x20(%rsp), %rax
movq 0x10(%rax), %rsi
movl $0x1, %r13d
movl %ebx, %r14d
movl %edx, 0x2c(%rsp)
movq %rsi, 0x60(%rsp)
movl %r14d, %eax
shrl $0x4, %eax
movl (%rsi,%rax,4), %r15d
leal (%r14,%r14), %ebp
andl $0x1e, %ebp
movl %r15d, %eax
movl %ebp, %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0x2d98a
testb $0x1, %al
jne 0x2d92f
movq 0x20(%rsp), %rax
movq 0x18(%rax), %rax
movl %r14d, %ecx
movq (%rax,%rcx,8), %rdi
movq 0x18(%rsp), %rsi
callq 0x46e0
movq 0x60(%rsp), %rsi
movl 0x2c(%rsp), %edx
testl %eax, %eax
je 0x2d98a
addl %r13d, %r14d
andl %edx, %r14d
incl %r13d
cmpl %ebx, %r14d
jne 0x2d8e4
movl 0x14(%rsp), %ebp
movq 0x8(%rsp), %r14
movq 0x18(%rsp), %r15
movq 0x40(%rsp), %rbx
movq 0x38(%rsp), %rdx
movq 0x30(%rsp), %rax
jmp 0x2d9b8
xorl %r12d, %r12d
cmpl %ebx, %r12d
je 0x2da9b
movq 0x8(%rsp), %r14
movq 0x28(%r14), %rdi
movq 0x48(%r14), %rax
movl %r12d, %ecx
movq (%rax,%rcx,8), %rbx
movq %rbx, %rsi
callq 0x2dac9
movl 0x50(%r14), %edx
jmp 0x2d9d5
movl %ebp, %ecx
shrl %cl, %r15d
testb $0x3, %r15b
movq 0x30(%rsp), %rax
cmovel %r14d, %eax
movl 0x14(%rsp), %ebp
movq 0x8(%rsp), %r14
movq 0x18(%rsp), %r15
movq 0x40(%rsp), %rbx
movq 0x38(%rsp), %rdx
jmp 0x2d9b8
xorl %eax, %eax
movl %eax, %eax
imulq $0x38, %rax, %rax
movq 0x20(%rsp), %rcx
addq 0x20(%rcx), %rax
movq 0x58(%rsp), %rcx
movq $0x0, 0x18(%rax,%rcx,8)
decl %edx
movl %edx, 0x50(%r14)
subl %r12d, %edx
jle 0x2d9ff
movq 0x48(%r14), %rax
movl %r12d, %ecx
leaq (%rax,%rcx,8), %rdi
leaq (%rax,%rcx,8), %rsi
addq $0x8, %rsi
movslq %edx, %rdx
shlq $0x3, %rdx
callq 0x4850
movq %rbx, %rdi
callq 0x2ac82
movl $0x1, 0x54(%r14)
jmp 0x2d7c2
movl 0x50(%r14), %eax
testl %eax, %eax
jle 0x2da9b
xorl %ebx, %ebx
movq 0x8(%rsp), %r14
movq 0x48(%r14), %rcx
movq (%rcx,%rbx,8), %r15
cmpl %ebp, (%r15)
jne 0x2da90
movq %r14, %rdi
movq %r15, %rsi
callq 0x2ccee
movq 0x28(%r14), %rdi
movq %r15, %rsi
callq 0x2dac9
movl $0x1, 0x54(%r14)
movslq 0x50(%r14), %rax
decq %rax
movl %eax, 0x50(%r14)
cmpq %rax, %rbx
jge 0x2da7d
movq 0x48(%r14), %rcx
leaq (%rcx,%rbx,8), %rdi
leaq (%rcx,%rbx,8), %rsi
addq $0x8, %rsi
subl %ebx, %eax
movslq %eax, %rdx
shlq $0x3, %rdx
callq 0x4850
movq %r15, %rdi
callq 0x2ac82
movslq 0x50(%r14), %rax
cmpq %rax, %rbx
jl 0x2da1e
jmp 0x2da9b
incq %rbx
movslq %eax, %rcx
cmpq %rcx, %rbx
jl 0x2da1e
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x7ddfe(%rip), %rdi     # 0xab8af
leaq 0x7db1b(%rip), %rsi     # 0xab5d3
leaq 0x7ddfd(%rip), %rcx     # 0xab8bc
movl $0x562, %edx            # imm = 0x562
callq 0x42e0