// File: chhylp123[P]hifiasm/hic.cpp
// Function: hc_pt_t_gen_single(hc_pt1_t*, unsigned long*, unsigned long*)
void hc_pt_t_gen_single(hc_pt1_t* pt, uint64_t* up_bound, uint64_t* low_bound)
{
    khint_t k;
    uint64_t c;

    if(up_bound || low_bound)
    {
        for (k = 0; k != kh_end(pt->h); ++k) {
            if (kh_exist(pt->h, k)) {
                if((up_bound && kh_val(pt->h, k) > (*up_bound)) || 
                            (low_bound && kh_val(pt->h, k) < (*low_bound)))
                {
                    kh_val(pt->h, k) = 0;
                    kh_key(pt->h, k) = (kh_key(pt->h, k)&HIC_KEY_MODE)|
                                (kh_val(pt->h, k)<HIC_MAX_COUNT?kh_val(pt->h, k):HIC_MAX_COUNT);
                }
            }
        }
    }
    

    for (k = 0, pt->n = 0; k != kh_end(pt->h); ++k) {
        if (kh_exist(pt->h, k)) {
            c = kh_val(pt->h, k);
            kh_val(pt->h, k) = pt->n;
            pt->n += c;
            pt->end = k;
        }
    }
    CALLOC(pt->a, pt->n);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x1bfaf6
cmpq $0x0, -0x18(%rbp)
je 0x1bfc7e
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0x2c(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
cmpq $0x0, 0x10(%rax)
je 0x1bfb26
movq -0x8(%rbp), %rax
movq (%rax), %rax
movl (%rax), %ecx
movl $0x1, %eax
shll %cl, %eax
movl %eax, -0x30(%rbp)
jmp 0x1bfb2d
xorl %eax, %eax
movl %eax, -0x30(%rbp)
jmp 0x1bfb2d
movl -0x2c(%rbp), %eax
movl -0x30(%rbp), %ecx
cmpl %ecx, %eax
je 0x1bfc7c
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
movl -0x1c(%rbp), %ecx
shrl $0x5, %ecx
movl %ecx, %ecx
movl (%rax,%rcx,4), %eax
movl -0x1c(%rbp), %ecx
andl $0x1f, %ecx
shrl %cl, %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x1bfc6c
cmpq $0x0, -0x10(%rbp)
je 0x1bfb8e
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movl -0x1c(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq -0x10(%rbp), %rcx
cmpq (%rcx), %rax
ja 0x1bfbbf
cmpq $0x0, -0x18(%rbp)
je 0x1bfc6a
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movl -0x1c(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq -0x18(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x1bfc6a
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movl -0x1c(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq $0x0, 0x8(%rax)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movl -0x1c(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
andq $-0x1000, %rax          # imm = 0xF000
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movl -0x1c(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
cmpq $0xfff, 0x8(%rax)       # imm = 0xFFF
jae 0x1bfc3c
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movl -0x1c(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq %rax, -0x40(%rbp)
jmp 0x1bfc47
movl $0xfff, %eax            # imm = 0xFFF
movq %rax, -0x40(%rbp)
jmp 0x1bfc47
movq -0x38(%rbp), %rcx
movq -0x40(%rbp), %rax
orq %rax, %rcx
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movl -0x1c(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, (%rax)
jmp 0x1bfc6c
jmp 0x1bfc6e
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x1bfafd
jmp 0x1bfc7e
movl $0x0, -0x1c(%rbp)
movq -0x8(%rbp), %rax
movq $0x0, 0x8(%rax)
movl -0x1c(%rbp), %eax
movl %eax, -0x44(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
cmpq $0x0, 0x10(%rax)
je 0x1bfcba
movq -0x8(%rbp), %rax
movq (%rax), %rax
movl (%rax), %ecx
movl $0x1, %eax
shll %cl, %eax
movl %eax, -0x48(%rbp)
jmp 0x1bfcc1
xorl %eax, %eax
movl %eax, -0x48(%rbp)
jmp 0x1bfcc1
movl -0x44(%rbp), %eax
movl -0x48(%rbp), %ecx
cmpl %ecx, %eax
je 0x1bfd5d
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
movl -0x1c(%rbp), %ecx
shrl $0x5, %ecx
movl %ecx, %ecx
movl (%rax,%rcx,4), %eax
movl -0x1c(%rbp), %ecx
andl $0x1f, %ecx
shrl %cl, %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x1bfd4d
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movl -0x1c(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movl -0x1c(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, 0x8(%rax)
movq -0x28(%rbp), %rcx
movq -0x8(%rbp), %rax
addq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
movl -0x1c(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x18(%rax)
jmp 0x1bfd4f
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x1bfc91
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
movl $0x8, %esi
callq 0x2140
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x10(%rax)
addq $0x50, %rsp
popq %rbp
retq