// File: chhylp123[P]hifiasm/hic.cpp
// Function: get_hc_pt1_count(ha_ug_index*, unsigned long, unsigned long**)
inline uint64_t get_hc_pt1_count(ha_ug_index* index, uint64_t key, uint64_t** pos_list)
{
    uint64_t bucket_mask = (1ULL<<index->pre) - 1;
    hc_pt1_t* h = &(index->idx_buf[key & bucket_mask]);
    uint64_t beg;
    khint_t k;
    k = hc_pt_get(h->h, key);
    if (k == kh_end(h->h))
    {
        return 0;
    }
    beg = kh_val(h->h, k);
    if(pos_list) *pos_list = h->a + beg;
    if((kh_key(h->h, k)&HIC_MAX_COUNT)<HIC_MAX_COUNT) return kh_key(h->h, k)&HIC_MAX_COUNT;
    if(k == h->end) return h->n - beg;
    for (k++; k != kh_end(h->h); ++k)
    {
        if (kh_exist(h->h, k)) 
        {
            return kh_val(h->h, k) - beg;
        }
    }
    return h->n - beg;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rcx
movl $0x1, %eax
shlq %cl, %rax
subq $0x1, %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq 0x78(%rax), %rax
movq -0x18(%rbp), %rcx
andq -0x28(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x211870
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movl %eax, -0x40(%rbp)
movq -0x30(%rbp), %rax
movq (%rax), %rax
cmpq $0x0, 0x10(%rax)
je 0x2130e3
movq -0x30(%rbp), %rax
movq (%rax), %rax
movl (%rax), %ecx
movl $0x1, %eax
shll %cl, %eax
movl %eax, -0x44(%rbp)
jmp 0x2130ea
xorl %eax, %eax
movl %eax, -0x44(%rbp)
jmp 0x2130ea
movl -0x40(%rbp), %eax
movl -0x44(%rbp), %ecx
cmpl %ecx, %eax
jne 0x213101
movq $0x0, -0x8(%rbp)
jmp 0x213259
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movl -0x3c(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x21313f
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rcx
movq -0x38(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movl -0x3c(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
andq $0xfff, %rax            # imm = 0xFFF
cmpq $0xfff, %rax            # imm = 0xFFF
jae 0x21318c
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movl -0x3c(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
andq $0xfff, %rax            # imm = 0xFFF
movq %rax, -0x8(%rbp)
jmp 0x213259
movl -0x3c(%rbp), %eax
movq -0x30(%rbp), %rcx
cmpl 0x18(%rcx), %eax
jne 0x2131ad
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
subq -0x38(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x213259
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movl %eax, -0x48(%rbp)
movq -0x30(%rbp), %rax
movq (%rax), %rax
cmpq $0x0, 0x10(%rax)
je 0x2131df
movq -0x30(%rbp), %rax
movq (%rax), %rax
movl (%rax), %ecx
movl $0x1, %eax
shll %cl, %eax
movl %eax, -0x4c(%rbp)
jmp 0x2131e6
xorl %eax, %eax
movl %eax, -0x4c(%rbp)
jmp 0x2131e6
movl -0x48(%rbp), %eax
movl -0x4c(%rbp), %ecx
cmpl %ecx, %eax
je 0x213249
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
movl -0x3c(%rbp), %ecx
shrl $0x5, %ecx
movl %ecx, %ecx
movl (%rax,%rcx,4), %eax
movl -0x3c(%rbp), %ecx
andl $0x1f, %ecx
shrl %cl, %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x213239
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movl -0x3c(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
subq -0x38(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x213259
jmp 0x21323b
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x2131b6
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
subq -0x38(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax)