// File: /workspace/github_c_makefile_star2_O1/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 0x8ba10
movq %rsi, %r12
movq %rdi, %r14
xorl %eax, %eax
testq %rsi, %rsi
je 0x8ba1a
movq 0x20(%r12), %rsi
testq %rsi, %rsi
je 0x8ba1c
movb (%rdx), %cl
xorl %r13d, %r13d
movq %rsi, %r15
movq 0x8(%rsi), %rsi
cmpb %cl, (%rsi)
jne 0x8ba00
movb 0x1(%rsi), %sil
cmpb 0x1(%rdx), %sil
je 0x8ba22
movq (%r15), %rsi
movq %r15, %r13
testq %rsi, %rsi
jne 0x8b9eb
movq %r15, %r13
jmp 0x8ba1f
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x8bbe5
jmp 0x8ba1f
xorl %r13d, %r13d
xorl %r15d, %r15d
testq %r15, %r15
je 0x8bbe5
cmpl $0x5351, 0x28(%r12)     # imm = 0x5351
jne 0x8bbb7
movq 0x8(%r15), %rdx
cmpb $0x41, (%rdx)
jne 0x8bbb7
cmpb $0x4e, 0x1(%rdx)
jne 0x8bbb7
cmpl $0x2, 0x10(%r15)
jle 0x8bbf4
testq %r12, %r12
je 0x8ba7f
movq 0x20(%r12), %rax
testq %rax, %rax
je 0x8ba7f
movq 0x8(%rax), %rcx
cmpb $0x53, (%rcx)
jne 0x8ba7a
cmpb $0x4e, 0x1(%rcx)
je 0x8ba81
movq (%rax), %rax
jmp 0x8ba66
xorl %eax, %eax
testq %rax, %rax
je 0x8bbb7
cmpl $0x2, 0x10(%rax)
jle 0x8bc13
movq 0x38(%r14), %rcx
movq %rcx, 0x8(%rsp)
movl (%rcx), %ecx
testl %ecx, %ecx
je 0x8baef
movq %r12, 0x28(%rsp)
movq 0x8(%rax), %rax
leaq 0x3(%rax), %rsi
movq %rcx, 0x18(%rsp)
leal -0x1(%rcx), %edi
movq %rsi, 0x40(%rsp)
movb (%rsi), %cl
testb %cl, %cl
movq %r14, 0x30(%rsp)
movq %rdx, 0x20(%rsp)
je 0x8baf6
addq $0x4, %rax
movl $0x811c9dc5, %r12d      # imm = 0x811C9DC5
movzbl %cl, %ecx
xorl %r12d, %ecx
imull $0x1000193, %ecx, %r12d # imm = 0x1000193
movb (%rax), %cl
incq %rax
testb %cl, %cl
jne 0x8bad7
jmp 0x8bafc
xorl %ebx, %ebx
jmp 0x8bb99
movl $0x811c9dc5, %r12d      # imm = 0x811C9DC5
andl %edi, %r12d
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rdx
movl $0x1, %r14d
movl %r12d, %ebx
movl %edi, 0x10(%rsp)
movq %rdx, 0x38(%rsp)
movl %ebx, %eax
shrl $0x4, %eax
movl (%rdx,%rax,4), %esi
leal (%rbx,%rbx), %ebp
andl $0x1e, %ebp
movl %esi, %eax
movl %ebp, %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0x8bb7a
testb $0x1, %al
jne 0x8bb64
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rax
movl %ebx, %ecx
movq (%rax,%rcx,8), %rdi
movl %esi, 0x14(%rsp)
movq 0x40(%rsp), %rsi
callq 0x46c0
movl 0x14(%rsp), %esi
movq 0x38(%rsp), %rdx
movl 0x10(%rsp), %edi
testl %eax, %eax
je 0x8bb7a
addl %r14d, %ebx
andl %edi, %ebx
incl %r14d
cmpl %r12d, %ebx
jne 0x8bb1a
movq 0x18(%rsp), %rcx
movl %ecx, %ebx
jmp 0x8bb8a
movl %ebp, %ecx
shrl %cl, %esi
testb $0x3, %sil
movq 0x18(%rsp), %rcx
cmovnel %ecx, %ebx
movq 0x30(%rsp), %r14
movq 0x28(%rsp), %r12
movq 0x20(%rsp), %rdx
cmpl %ecx, %ebx
je 0x8bbb7
movq 0x8(%rsp), %rax
movq 0x20(%rax), %rax
movl %ebx, %ecx
movl (%rax,%rcx,4), %esi
addq $0x3, %rdx
movq %r14, %rdi
callq 0x8c78f
addq $0x20, %r12
testq %r13, %r13
movq (%r15), %rax
cmovneq %r13, %r12
movq %rax, (%r12)
movq 0x20(%r14), %rdi
movq %r15, %rsi
callq 0x5a8fd
movl $0x1, 0x90(%r14)
movl $0x1, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x192fb(%rip), %rdi     # 0xa4ef6
leaq 0x18aea(%rip), %rsi     # 0xa46ec
leaq 0x18d3f(%rip), %rcx     # 0xa4948
movl $0xa78, %edx            # imm = 0xA78
callq 0x42f0
leaq 0x18d77(%rip), %rdi     # 0xa4991
leaq 0x18acb(%rip), %rsi     # 0xa46ec
leaq 0x18d20(%rip), %rcx     # 0xa4948
movl $0xa7b, %edx            # imm = 0xA7B
callq 0x42f0