// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/header.c
// Function: sam_hrecs_remove_ref_altnames
static void sam_hrecs_remove_ref_altnames(sam_hrecs_t *hrecs, int expected, const char *list) {
    const char *token, *sn;
    ks_tokaux_t aux;
    kstring_t str = KS_INITIALIZE;

    if (expected < 0 || expected >= hrecs->nref)
        return;
    sn = hrecs->ref[expected].name;

    for (token = kstrtok(list, ",", &aux); token; token = kstrtok(NULL, NULL, &aux)) {
        kputsn(token, aux.p - token, ks_clear(&str));
        khint_t k = kh_get(m_s2i, hrecs->ref_hash, str.s);
        if (k != kh_end(hrecs->ref_hash)
            && kh_val(hrecs->ref_hash, k) == expected
            && strcmp(sn, str.s) != 0)
            kh_del(m_s2i, hrecs->ref_hash, k);
    }

    free(str.s);
}

// Assembly:
testl %esi, %esi
js 0x8c9ea
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rdi, %rbx
cmpl %esi, 0x28(%rdi)
jle 0x8c9dc
movq 0x30(%rbx), %rax
movl %esi, 0x24(%rsp)
movl %esi, %ecx
leaq (%rcx,%rcx,2), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, 0x38(%rsp)
leaq 0xe6e9(%rip), %rsi      # 0x9aeb8
leaq 0x48(%rsp), %rax
movq %rdx, %rdi
movq %rax, %rdx
callq 0x9b2f
testq %rax, %rax
je 0x8c9d1
movq %rax, %rbp
xorl %r14d, %r14d
xorl %r12d, %r12d
movq %rbx, 0x28(%rsp)
movq 0x70(%rsp), %r15
subq %rbp, %r15
movq %r15, %rax
addq $0x2, %rax
je 0x8c843
cmpq %rax, %r12
jae 0x8c855
movq %r12, 0x8(%rsp)
movq %rax, %rcx
shrq $0x3e, %rcx
movq %rax, %rdx
shrq %rdx
testq %rcx, %rcx
movl $0x0, %r12d
cmoveq %rdx, %r12
addq %rax, %r12
movq %r14, %rdi
movq %r12, %rsi
callq 0x4840
movq %rax, %r13
testq %rax, %rax
jne 0x8c858
jmp 0x8c874
movq %r12, 0x8(%rsp)
callq 0x4050
movl $0x4b, (%rax)
jmp 0x8c874
movq %r14, %r13
movq %r13, %rdi
movq %rbp, %rsi
movq %r15, %rdx
callq 0x43c0
movb $0x0, (%r13,%r15)
movq %r12, 0x8(%rsp)
movq %r13, %r14
movq 0x38(%rbx), %rax
movq %rax, 0x10(%rsp)
movl (%rax), %edx
testl %edx, %edx
je 0x8c8b1
movb (%r14), %cl
testb %cl, %cl
movq %r14, 0x18(%rsp)
je 0x8c8b8
leaq 0x1(%r14), %rax
movl $0x811c9dc5, %r14d      # imm = 0x811C9DC5
movzbl %cl, %ecx
xorl %r14d, %ecx
imull $0x1000193, %ecx, %r14d # imm = 0x1000193
movb (%rax), %cl
incq %rax
testb %cl, %cl
jne 0x8c899
jmp 0x8c8be
xorl %ebp, %ebp
jmp 0x8c957
movl $0x811c9dc5, %r14d      # imm = 0x811C9DC5
movq %rdx, 0x30(%rsp)
leal -0x1(%rdx), %r13d
andl %r13d, %r14d
movq 0x10(%rsp), %rax
movq 0x10(%rax), %rsi
movl $0x1, %r12d
movl %r14d, %ebp
movq %rsi, 0x40(%rsp)
movl %ebp, %eax
shrl $0x4, %eax
movl (%rsi,%rax,4), %ebx
leal (,%rbp,2), %r15d
andl $0x1e, %r15d
movl %ebx, %eax
movl %r15d, %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0x8c93d
testb $0x1, %al
jne 0x8c926
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rax
movl %ebp, %ecx
movq (%rax,%rcx,8), %rdi
movq 0x18(%rsp), %rsi
callq 0x46c0
movq 0x40(%rsp), %rsi
testl %eax, %eax
je 0x8c93d
addl %r12d, %ebp
andl %r13d, %ebp
incl %r12d
cmpl %r14d, %ebp
jne 0x8c8e1
movq 0x30(%rsp), %rdx
movl %edx, %ebp
jmp 0x8c94d
movl %r15d, %ecx
shrl %cl, %ebx
testb $0x3, %bl
movq 0x30(%rsp), %rdx
cmovnel %edx, %ebp
movq 0x28(%rsp), %rbx
movq 0x18(%rsp), %r14
movq 0x8(%rsp), %r12
cmpl %edx, %ebp
je 0x8c9b5
movq 0x10(%rsp), %rax
movq 0x20(%rax), %rax
movl %ebp, %ecx
movl 0x24(%rsp), %edx
cmpl %edx, (%rax,%rcx,4)
jne 0x8c9b5
movq 0x38(%rsp), %rdi
movq %r14, %rsi
callq 0x46c0
testl %eax, %eax
je 0x8c9b5
movq 0x10(%rsp), %rax
movq 0x10(%rax), %rax
movl %ebp, %edx
shrl $0x4, %edx
movl (%rax,%rdx,4), %esi
addl %ebp, %ebp
andl $0x1e, %ebp
movl %esi, %edi
movl %ebp, %ecx
shrl %cl, %edi
testb $0x3, %dil
jne 0x8c9b5
btsl %ebp, %esi
movl %esi, (%rax,%rdx,4)
movq 0x10(%rsp), %rax
decl 0x4(%rax)
xorl %edi, %edi
xorl %esi, %esi
leaq 0x48(%rsp), %rdx
callq 0x9b2f
movq %rax, %rbp
testq %rax, %rax
jne 0x8c7f6
jmp 0x8c9d4
xorl %r14d, %r14d
movq %r14, %rdi
callq 0x45c0
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq