// File: chhylp123[P]hifiasm/htab.cpp
// Function: rs_sort_ha64(unsigned long*, unsigned long*, int, int)
KRADIX_SORT_INIT(ha64, uint64_t, generic_key, 8)

typedef struct {
	yak_pt_t *h;
	uint64_t n;
	ha_idxpos_t *a;
	ha_idxposl_t *al;
} ha_pt1_t;

struct ha_pt_s {
	int k, pre;
	uint64_t tot, tot_pos;
	ha_pt1_t *h;
};

typedef struct {
	const ha_ct_t *ct;
	ha_pt_t *pt;
	int is_l;
} pt_gen_aux_t;


static void worker_pt_shrink(void *data, long i, int tid) // callback for kt_for()
{
    ha_pt_t *h = (ha_pt_t*)data;
	ha_pt1_t *b = &h->h[i];
    yak_pt_t *f = NULL;
    khint_t k;
    f = yak_pt_init();
    for (k = 0, b->n = 0; k < kh_end(b->h); ++k) {
        if (kh_exist(b->h, k)) {
			if(kh_val(b->h, k) <= 0) continue;
			int absent; khint_t l;
			l = yak_pt_put(f, (kh_key(b->h, k) >> h->pre) << YAK_COUNTER_BITS, &absent);
			kh_val(f, l) = b->n; 
			b->n += kh_key(b->h, k) & YAK_MAX_COUNT;
        }
    }
    yak_pt_destroy(b->h);
    h->h[i].h = f;
	CALLOC(b->a, b->n);///need fix
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movb -0x14(%rbp), %cl
movl $0x1, %eax
shll %cl, %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
decl %eax
movl %eax, -0x28(%rbp)
movl -0x24(%rbp), %eax
movl %eax, %ecx
movq %rsp, %rax
movq %rax, -0x38(%rbp)
movq %rcx, %rdx
shlq $0x4, %rdx
movq %rsp, %rax
subq %rdx, %rax
movq %rax, -0x68(%rbp)
movq %rax, %rsp
movq %rcx, -0x40(%rbp)
movslq -0x24(%rbp), %rdx
shlq $0x4, %rdx
movq %rax, %rcx
addq %rdx, %rcx
movq %rcx, -0x48(%rbp)
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x48(%rbp), %rax
je 0x1867f0
movq -0x8(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x30(%rbp), %rax
movq %rcx, (%rax)
movq -0x30(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x30(%rbp)
jmp 0x1867c5
movq -0x8(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
cmpq -0x10(%rbp), %rax
je 0x18683e
movq -0x68(%rbp), %rax
movq -0x20(%rbp), %rcx
movq (%rcx), %rdx
movl -0x18(%rbp), %ecx
shrq %cl, %rdx
movq %rdx, %rcx
movslq -0x28(%rbp), %rdx
andq %rdx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rcx
addq $0x8, %rcx
movq %rcx, 0x8(%rax)
movq -0x20(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x20(%rbp)
jmp 0x1867f8
movq -0x68(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x48(%rbp), %rax
je 0x186894
movq -0x30(%rbp), %rax
movq -0x8(%rax), %rcx
movq -0x8(%rbp), %rax
subq %rax, %rcx
sarq $0x3, %rcx
movq -0x30(%rbp), %rax
shlq $0x3, %rcx
addq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
movq -0x30(%rbp), %rax
movq -0x8(%rax), %rcx
movq -0x30(%rbp), %rax
movq %rcx, (%rax)
movq -0x30(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x30(%rbp)
jmp 0x18684a
movq -0x68(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x48(%rbp), %rax
je 0x186996
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq -0x30(%rbp), %rcx
cmpq 0x8(%rcx), %rax
je 0x186985
movq -0x68(%rbp), %rax
movq -0x30(%rbp), %rcx
movq (%rcx), %rcx
movq (%rcx), %rdx
movl -0x18(%rbp), %ecx
shrq %cl, %rdx
movq %rdx, %rcx
movslq -0x28(%rbp), %rdx
andq %rdx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
cmpq -0x30(%rbp), %rax
je 0x186975
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq (%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x68(%rbp), %rax
movq -0x58(%rbp), %rcx
movq %rcx, -0x60(%rbp)
movq -0x50(%rbp), %rcx
movq (%rcx), %rcx
movq (%rcx), %rcx
movq %rcx, -0x58(%rbp)
movq -0x60(%rbp), %rdx
movq -0x50(%rbp), %rsi
movq (%rsi), %rcx
movq %rcx, %rdi
addq $0x8, %rdi
movq %rdi, (%rsi)
movq %rdx, (%rcx)
movq -0x58(%rbp), %rdx
movl -0x18(%rbp), %ecx
shrq %cl, %rdx
movq %rdx, %rcx
movslq -0x28(%rbp), %rdx
andq %rdx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
cmpq -0x30(%rbp), %rax
jne 0x186900
movq -0x58(%rbp), %rcx
movq -0x30(%rbp), %rdx
movq (%rdx), %rax
movq %rax, %rsi
addq $0x8, %rsi
movq %rsi, (%rdx)
movq %rcx, (%rax)
jmp 0x186983
movq -0x30(%rbp), %rax
movq (%rax), %rcx
addq $0x8, %rcx
movq %rcx, (%rax)
jmp 0x186991
movq -0x30(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x30(%rbp)
jmp 0x18689c
movq -0x68(%rbp), %rax
movq -0x8(%rbp), %rcx
movq %rcx, (%rax)
addq $0x10, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x48(%rbp), %rax
je 0x1869d0
movq -0x30(%rbp), %rax
movq -0x8(%rax), %rcx
movq -0x30(%rbp), %rax
movq %rcx, (%rax)
movq -0x30(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x30(%rbp)
jmp 0x1869a9
cmpl $0x0, -0x18(%rbp)
je 0x186a8b
movl -0x18(%rbp), %eax
cmpl -0x14(%rbp), %eax
jle 0x1869ed
movl -0x18(%rbp), %eax
subl -0x14(%rbp), %eax
movl %eax, -0x6c(%rbp)
jmp 0x1869f4
xorl %eax, %eax
movl %eax, -0x6c(%rbp)
jmp 0x1869f4
movq -0x68(%rbp), %rax
movl -0x6c(%rbp), %ecx
movl %ecx, -0x18(%rbp)
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x48(%rbp), %rax
je 0x186a89
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x30(%rbp), %rcx
movq (%rcx), %rcx
subq %rcx, %rax
sarq $0x3, %rax
cmpq $0x40, %rax
jle 0x186a44
movq -0x30(%rbp), %rax
movq (%rax), %rdi
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rsi
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
callq 0x186760
jmp 0x186a76
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x30(%rbp), %rcx
movq (%rcx), %rcx
subq %rcx, %rax
sarq $0x3, %rax
cmpq $0x1, %rax
jle 0x186a74
movq -0x30(%rbp), %rax
movq (%rax), %rdi
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x1866a0
jmp 0x186a76
jmp 0x186a78
movq -0x30(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x30(%rbp)
jmp 0x186a02
jmp 0x186a8b
movq -0x38(%rbp), %rax
movq %rax, %rsp
movq %rbp, %rsp
popq %rbp
retq
nopw (%rax,%rax)