// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/header.c
// Function: sam_hrecs_remove_key
int sam_hrecs_remove_key(sam_hrecs_t *hrecs,
                         sam_hrec_type_t *type,
                         const char *key) {
    sam_hrec_tag_t *tag, *prev;
    if (!hrecs)
        return -1;
    tag = sam_hrecs_find_key(type, key, &prev);
    if (!tag)
        return 0; // Not there anyway

    if (type->type == TYPEKEY("SQ") && tag->str[0] == 'A' && tag->str[1] == 'N') {
        assert(tag->len >= 3);
        sam_hrec_tag_t *sn_tag = sam_hrecs_find_key(type, "SN", NULL);
        if (sn_tag) {
            assert(sn_tag->len >= 3);
            khint_t k = kh_get(m_s2i, hrecs->ref_hash, sn_tag->str + 3);
            if (k != kh_end(hrecs->ref_hash))
                sam_hrecs_remove_ref_altnames(hrecs, kh_val(hrecs->ref_hash, k), tag->str + 3);
        }
    }

    if (!prev) { //first tag
        type->tag = tag->next;
    } else {
        prev->next = tag->next;
    }
    pool_free(hrecs->tag_pool, tag);
    hrecs->dirty = 1; //mark text as dirty and force a rebuild

    return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
testq %rdi, %rdi
je 0x89100
xorl %eax, %eax
testq %rsi, %rsi
je 0x89105
movq 0x20(%rsi), %rcx
testq %rcx, %rcx
je 0x89105
leaq 0x20(%rsi), %r9
movb (%rdx), %al
xorl %r12d, %r12d
movq %rcx, %r8
movq %r8, %r14
movq 0x8(%r8), %r15
cmpb %al, (%r15)
jne 0x890f1
movb 0x1(%r15), %r8b
cmpb 0x1(%rdx), %r8b
je 0x89114
movq (%r14), %r8
movq %r14, %r12
testq %r8, %r8
jne 0x890db
xorl %eax, %eax
jmp 0x89105
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rdi, 0x10(%rsp)
cmpl $0x5351, 0x28(%rsi)     # imm = 0x5351
jne 0x8914e
cmpb $0x41, %al
jne 0x8914e
cmpb $0x4e, %r8b
jne 0x8914e
cmpl $0x3, 0x10(%r14)
jl 0x892b8
movq 0x8(%rcx), %rax
cmpb $0x53, (%rax)
jne 0x89146
cmpb $0x4e, 0x1(%rax)
je 0x8917d
movq (%rcx), %rcx
testq %rcx, %rcx
jne 0x89137
testq %r12, %r12
movq (%r14), %rax
cmovneq %r12, %r9
movq %rax, (%r9)
movq 0x10(%rsp), %rbx
movq 0x20(%rbx), %rdi
movq %r14, %rsi
callq 0x57e84
movl $0x1, 0x90(%rbx)
movl $0x1, %eax
jmp 0x89105
cmpl $0x2, 0x10(%rcx)
jle 0x892d7
movq 0x10(%rsp), %rcx
movq 0x38(%rcx), %rcx
movq %rcx, 0x8(%rsp)
movl (%rcx), %ecx
testl %ecx, %ecx
movq %r9, 0x28(%rsp)
je 0x891d6
leaq 0x3(%rax), %rdx
movq %rcx, 0x30(%rsp)
leal -0x1(%rcx), %esi
movq %rdx, 0x40(%rsp)
movb (%rdx), %cl
testb %cl, %cl
je 0x891de
addq $0x4, %rax
movl $0x811c9dc5, %edx       # imm = 0x811C9DC5
movzbl %cl, %ecx
xorl %edx, %ecx
imull $0x1000193, %ecx, %edx  # imm = 0x1000193
movb (%rax), %cl
incq %rax
testb %cl, %cl
jne 0x891c0
jmp 0x891e3
xorl %r13d, %r13d
jmp 0x89285
movl $0x811c9dc5, %edx       # imm = 0x811C9DC5
andl %esi, %edx
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rdi
movl $0x1, %ebx
movl %edx, %r13d
movl %esi, 0x20(%rsp)
movl %edx, 0x1c(%rsp)
movq %rdi, 0x38(%rsp)
movl %r13d, %eax
shrl $0x4, %eax
movl (%rdi,%rax,4), %r8d
leal (,%r13,2), %ebp
andl $0x1e, %ebp
movl %r8d, %eax
movl %ebp, %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0x89273
testb $0x1, %al
jne 0x89261
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rax
movl %r13d, %ecx
movq (%rax,%rcx,8), %rdi
movq 0x40(%rsp), %rsi
movl %r8d, 0x24(%rsp)
callq 0x46c0
movl 0x24(%rsp), %r8d
movq 0x38(%rsp), %rdi
movl 0x1c(%rsp), %edx
movl 0x20(%rsp), %esi
movq 0x28(%rsp), %r9
testl %eax, %eax
je 0x89273
addl %ebx, %r13d
andl %esi, %r13d
incl %ebx
cmpl %edx, %r13d
jne 0x89203
jmp 0x8914e
movl %ebp, %ecx
shrl %cl, %r8d
testb $0x3, %r8b
movq 0x30(%rsp), %rcx
cmovnel %ecx, %r13d
cmpl %ecx, %r13d
je 0x8914e
movq 0x8(%rsp), %rax
movq 0x20(%rax), %rax
movl %r13d, %ecx
movl (%rax,%rcx,4), %esi
addq $0x3, %r15
movq 0x10(%rsp), %rdi
movq %r15, %rdx
callq 0x89e09
movq 0x28(%rsp), %r9
jmp 0x8914e
leaq 0x193b6(%rip), %rdi     # 0xa2675
leaq 0x18ba5(%rip), %rsi     # 0xa1e6b
leaq 0x18dfa(%rip), %rcx     # 0xa20c7
movl $0xa78, %edx            # imm = 0xA78
callq 0x42f0
leaq 0x18e32(%rip), %rdi     # 0xa2110
leaq 0x18b86(%rip), %rsi     # 0xa1e6b
leaq 0x18ddb(%rip), %rcx     # 0xa20c7
movl $0xa7b, %edx            # imm = 0xA7B
callq 0x42f0