// File: /workspace/github_c_makefile_star2_O3/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 0x8a05e
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movl %esi, %ebx
movq %rdi, %r14
cmpl %esi, 0x28(%rdi)
jle 0x8a050
movq 0x30(%r14), %rax
movl %ebx, %ecx
leaq (%rcx,%rcx,2), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, 0x28(%rsp)
leaq 0xe084(%rip), %rsi      # 0x97ecb
leaq 0x48(%rsp), %rax
movq %rdx, %rdi
movq %rax, %rdx
callq 0x9b3b
testq %rax, %rax
je 0x8a046
movq %rax, %rbp
movl %ebx, 0x24(%rsp)
xorl %ebx, %ebx
xorl %r12d, %r12d
movq %r14, 0x38(%rsp)
movq 0x70(%rsp), %r15
subq %rbp, %r15
movq %r15, %rax
addq $0x2, %rax
je 0x89ebe
cmpq %rax, %r12
jae 0x89ed0
movq %r12, 0x10(%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 %rbx, %rdi
movq %r12, %rsi
callq 0x4840
movq %rax, %r13
testq %rax, %rax
jne 0x89ed3
jmp 0x89eef
movq %r12, 0x10(%rsp)
callq 0x4050
movl $0x4b, (%rax)
jmp 0x89eef
movq %rbx, %r13
movq %r13, %rdi
movq %rbp, %rsi
movq %r15, %rdx
callq 0x43c0
movb $0x0, (%r13,%r15)
movq %r12, 0x10(%rsp)
movq %r13, %rbx
movq 0x38(%r14), %rax
movq %rax, 0x8(%rsp)
movl (%rax), %edx
testl %edx, %edx
movq %rbx, 0x18(%rsp)
je 0x89f2b
movb (%rbx), %cl
testb %cl, %cl
je 0x89f32
leaq 0x1(%rbx), %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 0x89f13
jmp 0x89f38
xorl %ebp, %ebp
jmp 0x89fc0
movl $0x811c9dc5, %r14d      # imm = 0x811C9DC5
movq %rdx, 0x30(%rsp)
leal -0x1(%rdx), %r13d
andl %r13d, %r14d
movq 0x8(%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 0x89fb0
testb $0x1, %al
jne 0x89fa0
movq 0x8(%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 0x89fb0
addl %r12d, %ebp
andl %r13d, %ebp
incl %r12d
cmpl %r14d, %ebp
jne 0x89f5b
jmp 0x8a01b
movl %r15d, %ecx
shrl %cl, %ebx
testb $0x3, %bl
movq 0x30(%rsp), %rdx
cmovnel %edx, %ebp
cmpl %edx, %ebp
je 0x8a01b
movq 0x8(%rsp), %rax
movq 0x20(%rax), %rax
movl %ebp, %ecx
movl 0x24(%rsp), %edx
cmpl %edx, (%rax,%rcx,4)
jne 0x8a01b
movq 0x28(%rsp), %rdi
movq 0x18(%rsp), %rsi
callq 0x46c0
testl %eax, %eax
je 0x8a01b
movq 0x8(%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 0x8a01b
btsl %ebp, %esi
movl %esi, (%rax,%rdx,4)
movq 0x8(%rsp), %rax
decl 0x4(%rax)
xorl %edi, %edi
xorl %esi, %esi
leaq 0x48(%rsp), %rdx
callq 0x9b3b
movq %rax, %rbp
testq %rax, %rax
movq 0x38(%rsp), %r14
movq 0x18(%rsp), %rbx
movq 0x10(%rsp), %r12
jne 0x89e71
jmp 0x8a048
xorl %ebx, %ebx
movq %rbx, %rdi
callq 0x45c0
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq