// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/htab.cpp
// Function: yak_pt_m_resize(yak_pt_t*, unsigned 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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
bsrl %esi, %eax
xorl %ebp, %ebp
cmpl $0x2, %esi
cmovbl %ebp, %eax
leal -0x1(%rsi), %ecx
andl %esi, %ecx
cmpl $0x1, %ecx
sbbl $-0x1, %eax
cmpl $0x3, %eax
movl $0x2, %ebx
cmovael %eax, %ebx
movl $0x1, %r13d
movl %ebx, %ecx
shll %cl, %r13d
movl %r13d, %ecx
shrl %ecx
movl %r13d, %edx
shrl $0x2, %edx
addl %ecx, %edx
cmpl %edx, 0x4(%rdi)
ja 0x11baf1
movq %rdi, %r14
movl %r13d, %ecx
shrl $0x3, %ecx
andl $-0x4, %ecx
cmpl $0x5, %eax
movl $0x4, %esi
cmovael %ecx, %esi
movl $0x1, %edi
callq 0x2120
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testq %rax, %rax
je 0x11baf1
movq %rax, %r15
movq 0x10(%r14), %rdi
movl %r13d, %esi
testq %rdi, %rdi
movq %rsi, 0x18(%rsp)
je 0x11b99c
movb (%r14), %cl
movl $0x1, %r12d
shll %cl, %r12d
cmpl %r13d, %r12d
jb 0x11b99f
jmp 0x11b9c1
xorl %r12d, %r12d
shlq $0x4, %rsi
callq 0x2370
testq %rax, %rax
je 0x11babb
movq %rax, %rdi
movq %rax, 0x10(%r14)
testl %r12d, %r12d
je 0x11bac5
movq %r13, 0x8(%rsp)
leal -0x1(%r13), %r8d
movq %r14, 0x10(%rsp)
movq 0x8(%r14), %r9
movl $0x20, %eax
movl %ebx, 0x4(%rsp)
subl %ebx, %eax
movl %r12d, %ecx
movq %rcx, 0x20(%rsp)
xorl %edx, %edx
movl %edx, %esi
shrl $0x5, %esi
movl (%r9,%rsi,4), %r13d
movl $0x1, %r14d
movl %edx, %ecx
shll %cl, %r14d
btl %edx, %r13d
jae 0x11ba9d
leaq (%r9,%rsi,4), %rcx
movq %rdx, %rsi
shlq $0x4, %rsi
movq (%rdi,%rsi), %rbp
movq 0x8(%rdi,%rsi), %r10
notl %r14d
andl %r13d, %r14d
movl %r14d, (%rcx)
movq %rbp, %rcx
shrq $0xc, %rcx
imull $0x9e3779b9, %ecx, %esi # imm = 0x9E3779B9
movl %eax, %ecx
shrl %cl, %esi
movl %esi, %ebx
shrl $0x5, %ebx
movl (%r15,%rbx,4), %r13d
movl $0x1, %r14d
movl %esi, %ecx
shll %cl, %r14d
btl %esi, %r13d
jae 0x11ba55
incl %esi
andl %r8d, %esi
jmp 0x11ba34
orl %r14d, %r13d
movl %r13d, (%r15,%rbx,4)
cmpl %r12d, %esi
jae 0x11ba8e
movl (%r9,%rbx,4), %r13d
testl %r14d, %r13d
je 0x11ba8e
leaq (%r9,%rbx,4), %rcx
movl %esi, %esi
shlq $0x4, %rsi
movq (%rdi,%rsi), %rbx
movq 0x8(%rdi,%rsi), %r11
movq %rbp, (%rdi,%rsi)
movq %r10, 0x8(%rdi,%rsi)
movq %r11, %r10
movq %rbx, %rbp
jmp 0x11ba1a
movl %esi, %ecx
shlq $0x4, %rcx
movq %rbp, (%rdi,%rcx)
movq %r10, 0x8(%rdi,%rcx)
incq %rdx
cmpq 0x20(%rsp), %rdx
jne 0x11b9e8
movl 0x4(%rsp), %ebx
movq 0x10(%rsp), %r14
movq 0x8(%rsp), %r13
jmp 0x11bac8
movq %r15, %rdi
callq 0x2220
jmp 0x11baf1
xorl %r12d, %r12d
cmpl %r13d, %r12d
movq 0x18(%rsp), %rsi
jbe 0x11badf
shlq $0x4, %rsi
callq 0x2370
movq %rax, 0x10(%r14)
movq 0x8(%r14), %rdi
callq 0x2220
movq %r15, 0x8(%r14)
movl %ebx, (%r14)
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq