// File: chhylp123[P]hifiasm/hic.cpp
// Function: worker_for_sort(void*, long, int)
static void worker_for_sort(void *data, long i, int tid) // callback for kt_for()
{
    pldat_t *pl = (pldat_t*)data;
    hc_pt1_t *h = &(pl->h->idx_buf[i]);
    khint_t k;
    uint64_t beg, cnt = 0;
    uint64_t* pos_list;
    for (k = 0; k != kh_end(h->h); ++k) {
        if (kh_exist(h->h, k)) {
            beg = kh_val(h->h, k);
            pos_list = h->a + beg;
            if((kh_key(h->h, k)&HIC_MAX_COUNT)<HIC_MAX_COUNT)
            {
                cnt = kh_key(h->h, k)&HIC_MAX_COUNT;
            }
            else if(k == h->end)
            {
                cnt = h->n - beg;
            }
            else
            {
                for (k++; k != kh_end(h->h); ++k)
                {
                    if (kh_exist(h->h, k)) 
                    {
                        cnt = kh_val(h->h, k) - beg;
                        break;
                    }
                }
            }
            if(cnt > 0) radix_sort_hc_pos(pos_list, pos_list+cnt);
        }
    }

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x78(%rax), %rax
movq -0x10(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movq $0x0, -0x40(%rbp)
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movl %eax, -0x4c(%rbp)
movq -0x28(%rbp), %rax
movq (%rax), %rax
cmpq $0x0, 0x10(%rax)
je 0x1c069e
movq -0x28(%rbp), %rax
movq (%rax), %rax
movl (%rax), %ecx
movl $0x1, %eax
shll %cl, %eax
movl %eax, -0x50(%rbp)
jmp 0x1c06a5
xorl %eax, %eax
movl %eax, -0x50(%rbp)
jmp 0x1c06a5
movl -0x4c(%rbp), %eax
movl -0x50(%rbp), %ecx
cmpl %ecx, %eax
je 0x1c0850
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
movl -0x2c(%rbp), %ecx
shrl $0x5, %ecx
movl %ecx, %ecx
movl (%rax,%rcx,4), %eax
movl -0x2c(%rbp), %ecx
andl $0x1f, %ecx
shrl %cl, %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x1c0840
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movl -0x2c(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x38(%rbp), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movl -0x2c(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
andq $0xfff, %rax            # imm = 0xFFF
cmpq $0xfff, %rax            # imm = 0xFFF
jae 0x1c075e
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movl -0x2c(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
andq $0xfff, %rax            # imm = 0xFFF
movq %rax, -0x40(%rbp)
jmp 0x1c081f
movl -0x2c(%rbp), %eax
movq -0x28(%rbp), %rcx
cmpl 0x18(%rcx), %eax
jne 0x1c077f
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
subq -0x38(%rbp), %rax
movq %rax, -0x40(%rbp)
jmp 0x1c081d
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movl %eax, -0x54(%rbp)
movq -0x28(%rbp), %rax
movq (%rax), %rax
cmpq $0x0, 0x10(%rax)
je 0x1c07b1
movq -0x28(%rbp), %rax
movq (%rax), %rax
movl (%rax), %ecx
movl $0x1, %eax
shll %cl, %eax
movl %eax, -0x58(%rbp)
jmp 0x1c07b8
xorl %eax, %eax
movl %eax, -0x58(%rbp)
jmp 0x1c07b8
movl -0x54(%rbp), %eax
movl -0x58(%rbp), %ecx
cmpl %ecx, %eax
je 0x1c081b
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
movl -0x2c(%rbp), %ecx
shrl $0x5, %ecx
movl %ecx, %ecx
movl (%rax,%rcx,4), %eax
movl -0x2c(%rbp), %ecx
andl $0x1f, %ecx
shrl %cl, %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x1c080b
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movl -0x2c(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
subq -0x38(%rbp), %rax
movq %rax, -0x40(%rbp)
jmp 0x1c081b
jmp 0x1c080d
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x1c0788
jmp 0x1c081d
jmp 0x1c081f
cmpq $0x0, -0x40(%rbp)
jbe 0x1c083e
movq -0x48(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
callq 0x1bd6e0
jmp 0x1c0840
jmp 0x1c0842
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x1c0675
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)