// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/header.c
// Function: sam_hrecs_remove_hash_entry
static int sam_hrecs_remove_hash_entry(sam_hrecs_t *hrecs, khint32_t type, sam_hrec_type_t *h_type) {
    if (!hrecs || !h_type)
        return -1;

    sam_hrec_tag_t *tag;
    const char *key = NULL;
    khint_t k;

    /* Remove name and any alternative names from reference hash */
    if (type == TYPEKEY("SQ")) {
        const char *altnames = NULL;

        tag = h_type->tag;

        while (tag) {
            if (tag->str[0] == 'S' && tag->str[1] == 'N') {
                assert(tag->len >= 3);
                key = tag->str + 3;
            } else if (tag->str[0] == 'A' && tag->str[1] == 'N') {
                assert(tag->len >= 3);
                altnames = tag->str + 3;
            }
            tag = tag->next;
        }

        if (key) {
            k = kh_get(m_s2i, hrecs->ref_hash, key);
            if (k != kh_end(hrecs->ref_hash)) {
                int idx = kh_val(hrecs->ref_hash, k);
                if (idx + 1 < hrecs->nref)
                    memmove(&hrecs->ref[idx], &hrecs->ref[idx+1],
                            sizeof(sam_hrec_sq_t)*(hrecs->nref - idx - 1));
                if (altnames)
                    sam_hrecs_remove_ref_altnames(hrecs, idx, altnames);
                kh_del(m_s2i, hrecs->ref_hash, k);
                hrecs->nref--;
                if (hrecs->refs_changed < 0 || hrecs->refs_changed > idx)
                    hrecs->refs_changed = idx;
                for (k = 0; k < kh_end(hrecs->ref_hash); k++) {
                    if (kh_exist(hrecs->ref_hash, k)
                        && kh_value(hrecs->ref_hash, k) > idx) {
                        kh_value(hrecs->ref_hash, k)--;
                    }
                }
            }
        }
    }

    /* Remove from read-group hash */
    if (type == TYPEKEY("RG")) {
        tag = h_type->tag;

        while (tag) {
            if (tag->str[0] == 'I' && tag->str[1] == 'D') {
                assert(tag->len >= 3);
                key = tag->str + 3;
                k = kh_get(m_s2i, hrecs->rg_hash, key);
                if (k != kh_end(hrecs->rg_hash)) {
                    int idx = kh_val(hrecs->rg_hash, k);
                    if (idx + 1 < hrecs->nrg)
                        memmove(&hrecs->rg[idx], &hrecs->rg[idx+1], sizeof(sam_hrec_rg_t)*(hrecs->nrg - idx - 1));
                    kh_del(m_s2i, hrecs->rg_hash, k);
                    hrecs->nrg--;
                    for (k = 0; k < kh_end(hrecs->rg_hash); k++) {
                        if (kh_exist(hrecs->rg_hash, k)
                            && kh_value(hrecs->rg_hash, k) > idx) {
                            kh_value(hrecs->rg_hash, k)--;
                        }
                    }
                }
                break;
            }
            tag = tag->next;
        }
    }

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0xdf751
cmpq $0x0, -0x20(%rbp)
jne 0xdf75d
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xdfbc1
movq $0x0, -0x30(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0x4c(%rbp)
leaq 0x12f7a(%rip), %rdi     # 0xf26ec
callq 0xdabd0
movl %eax, %ecx
movl -0x4c(%rbp), %eax
cmpl %ecx, %eax
jne 0xdf9e5
movq $0x0, -0x40(%rbp)
movq -0x20(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0xdf86f
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movsbl (%rax), %eax
cmpl $0x53, %eax
jne 0xdf801
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movsbl 0x1(%rax), %eax
cmpl $0x4e, %eax
jne 0xdf801
movq -0x28(%rbp), %rax
cmpl $0x3, 0x10(%rax)
jl 0xdf7d0
jmp 0xdf7ef
leaq 0x1917a(%rip), %rdi     # 0xf8951
leaq 0x18969(%rip), %rsi     # 0xf8147
movl $0x1aa, %edx            # imm = 0x1AA
leaq 0x18f4b(%rip), %rcx     # 0xf8735
callq 0x42e0
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
addq $0x3, %rax
movq %rax, -0x30(%rbp)
jmp 0xdf85f
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movsbl (%rax), %eax
cmpl $0x41, %eax
jne 0xdf85d
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movsbl 0x1(%rax), %eax
cmpl $0x4e, %eax
jne 0xdf85d
movq -0x28(%rbp), %rax
cmpl $0x3, 0x10(%rax)
jl 0xdf82e
jmp 0xdf84d
leaq 0x1911c(%rip), %rdi     # 0xf8951
leaq 0x1890b(%rip), %rsi     # 0xf8147
movl $0x1ad, %edx            # imm = 0x1AD
leaq 0x18eed(%rip), %rcx     # 0xf8735
callq 0x42e0
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
addq $0x3, %rax
movq %rax, -0x40(%rbp)
jmp 0xdf85f
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x28(%rbp)
jmp 0xdf798
cmpq $0x0, -0x30(%rbp)
je 0xdf9e3
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rdi
movq -0x30(%rbp), %rsi
callq 0xdae00
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x10(%rbp), %rcx
movq 0x38(%rcx), %rcx
cmpl (%rcx), %eax
je 0xdf9e1
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x20(%rax), %rax
movl -0x34(%rbp), %ecx
movl (%rax,%rcx,4), %eax
movl %eax, -0x44(%rbp)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movq -0x10(%rbp), %rcx
cmpl 0x28(%rcx), %eax
jge 0xdf907
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rdi
movslq -0x44(%rbp), %rax
imulq $0x18, %rax, %rax
addq %rax, %rdi
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rsi
movl -0x44(%rbp), %eax
addl $0x1, %eax
cltq
imulq $0x18, %rax, %rax
addq %rax, %rsi
movq -0x10(%rbp), %rax
movl 0x28(%rax), %eax
subl -0x44(%rbp), %eax
subl $0x1, %eax
cltq
imulq $0x18, %rax, %rdx
callq 0x4810
cmpq $0x0, -0x40(%rbp)
je 0xdf91e
movq -0x10(%rbp), %rdi
movl -0x44(%rbp), %esi
movq -0x40(%rbp), %rdx
callq 0xde660
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rdi
movl -0x34(%rbp), %esi
callq 0xdb010
movq -0x10(%rbp), %rax
movl 0x28(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x28(%rax)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x94(%rax)
jl 0xdf957
movq -0x10(%rbp), %rax
movl 0x94(%rax), %eax
cmpl -0x44(%rbp), %eax
jle 0xdf964
movl -0x44(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x94(%rax)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x10(%rbp), %rcx
movq 0x38(%rcx), %rcx
cmpl (%rcx), %eax
jae 0xdf9df
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x10(%rax), %rax
movl -0x34(%rbp), %ecx
shrl $0x4, %ecx
movl %ecx, %ecx
movl (%rax,%rcx,4), %eax
movl -0x34(%rbp), %ecx
andl $0xf, %ecx
shll %ecx
shrl %cl, %eax
andl $0x3, %eax
cmpl $0x0, %eax
jne 0xdf9d2
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x20(%rax), %rax
movl -0x34(%rbp), %ecx
movl (%rax,%rcx,4), %eax
cmpl -0x44(%rbp), %eax
jle 0xdf9d2
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x20(%rax), %rax
movl -0x34(%rbp), %ecx
movl (%rax,%rcx,4), %edx
addl $-0x1, %edx
movl %edx, (%rax,%rcx,4)
jmp 0xdf9d4
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0xdf96b
jmp 0xdf9e1
jmp 0xdf9e3
jmp 0xdf9e5
movl -0x14(%rbp), %eax
movl %eax, -0x50(%rbp)
leaq 0x12c24(%rip), %rdi     # 0xf2616
callq 0xdabd0
movl %eax, %ecx
movl -0x50(%rbp), %eax
cmpl %ecx, %eax
jne 0xdfbba
movq -0x20(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0xdfbb8
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movsbl (%rax), %eax
cmpl $0x49, %eax
jne 0xdfba8
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movsbl 0x1(%rax), %eax
cmpl $0x44, %eax
jne 0xdfba8
movq -0x28(%rbp), %rax
cmpl $0x3, 0x10(%rax)
jl 0xdfa50
jmp 0xdfa6f
leaq 0x18efa(%rip), %rdi     # 0xf8951
leaq 0x186e9(%rip), %rsi     # 0xf8147
movl $0x1d0, %edx            # imm = 0x1D0
leaq 0x18ccb(%rip), %rcx     # 0xf8735
callq 0x42e0
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
addq $0x3, %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rdi
movq -0x30(%rbp), %rsi
callq 0xdae00
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x10(%rbp), %rcx
movq 0x50(%rcx), %rcx
cmpl (%rcx), %eax
je 0xdfba6
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movq 0x20(%rax), %rax
movl -0x34(%rbp), %ecx
movl (%rax,%rcx,4), %eax
movl %eax, -0x48(%rbp)
movl -0x48(%rbp), %eax
addl $0x1, %eax
movq -0x10(%rbp), %rcx
cmpl 0x40(%rcx), %eax
jge 0xdfb0c
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movslq -0x48(%rbp), %rax
imulq $0x18, %rax, %rax
addq %rax, %rdi
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rsi
movl -0x48(%rbp), %eax
addl $0x1, %eax
cltq
imulq $0x18, %rax, %rax
addq %rax, %rsi
movq -0x10(%rbp), %rax
movl 0x40(%rax), %eax
subl -0x48(%rbp), %eax
subl $0x1, %eax
cltq
imulq $0x18, %rax, %rdx
callq 0x4810
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rdi
movl -0x34(%rbp), %esi
callq 0xdb010
movq -0x10(%rbp), %rax
movl 0x40(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x40(%rax)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x10(%rbp), %rcx
movq 0x50(%rcx), %rcx
cmpl (%rcx), %eax
jae 0xdfba4
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movq 0x10(%rax), %rax
movl -0x34(%rbp), %ecx
shrl $0x4, %ecx
movl %ecx, %ecx
movl (%rax,%rcx,4), %eax
movl -0x34(%rbp), %ecx
andl $0xf, %ecx
shll %ecx
shrl %cl, %eax
andl $0x3, %eax
cmpl $0x0, %eax
jne 0xdfb97
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movq 0x20(%rax), %rax
movl -0x34(%rbp), %ecx
movl (%rax,%rcx,4), %eax
cmpl -0x48(%rbp), %eax
jle 0xdfb97
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movq 0x20(%rax), %rax
movl -0x34(%rbp), %ecx
movl (%rax,%rcx,4), %edx
addl $-0x1, %edx
movl %edx, (%rax,%rcx,4)
jmp 0xdfb99
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0xdfb30
jmp 0xdfba6
jmp 0xdfbb8
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x28(%rbp)
jmp 0xdfa10
jmp 0xdfbba
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw (%rax,%rax)