// File: /workspace/github_cpp_makefile_star2_O1/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, %r14d
cmovael %eax, %r14d
movl $0x1, %esi
movl %r14d, %ecx
shll %cl, %esi
movl %esi, %ecx
shrl %ecx
movl %esi, %edx
shrl $0x2, %edx
addl %ecx, %edx
cmpl %edx, 0x4(%rdi)
ja 0x115fd0
movq %rdi, 0x8(%rsp)
movq %rsi, 0x18(%rsp)
movl %esi, %ecx
shrl $0x3, %ecx
andl $-0x4, %ecx
cmpl $0x5, %eax
movl $0x4, %r12d
cmovael %ecx, %r12d
movq %r12, %rdi
callq 0x2280
movq %rax, %r15
xorl %ebx, %ebx
movq %rax, %rdi
xorl %esi, %esi
movq %r12, %rdx
callq 0x20e0
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testq %r15, %r15
je 0x115fd0
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rdi
testq %rdi, %rdi
je 0x115e5c
movb (%rax), %cl
movl $0x1, %ebx
shll %cl, %ebx
movq 0x18(%rsp), %rax
cmpl %eax, %ebx
jae 0x115e94
movl %eax, %esi
shlq $0x4, %rsi
callq 0x2370
movq %rax, %r12
testq %rax, %rax
je 0x115e83
movq 0x8(%rsp), %rax
movq %r12, 0x10(%rax)
jmp 0x115e8b
movq %r15, %rdi
callq 0x2220
testq %r12, %r12
je 0x115fd0
movl %r14d, 0x14(%rsp)
testl %ebx, %ebx
je 0x115f9a
movq 0x18(%rsp), %rax
leal -0x1(%rax), %edi
movq 0x8(%rsp), %rax
movq 0x8(%rax), %r8
movl $0x20, %eax
subl 0x14(%rsp), %eax
movl %ebx, %ecx
movq %rcx, 0x20(%rsp)
xorl %edx, %edx
movl %edx, %esi
shrl $0x5, %esi
movl (%r8,%rsi,4), %ebp
movl $0x1, %r14d
movl %edx, %ecx
shll %cl, %r14d
btl %edx, %ebp
jae 0x115f8c
movq 0x8(%rsp), %rcx
movq 0x10(%rcx), %r10
movq %rdx, %rcx
shlq $0x4, %rcx
movq (%r10,%rcx), %r12
movq 0x8(%r10,%rcx), %r9
notl %r14d
andl %r14d, %ebp
movl %ebp, (%r8,%rsi,4)
movq %r12, %rcx
shrq $0xc, %rcx
imull $0x9e3779b9, %ecx, %esi # imm = 0x9E3779B9
movl %eax, %ecx
shrl %cl, %esi
movl %esi, %ebp
shrl $0x5, %ebp
movl (%r15,%rbp,4), %r14d
movl $0x1, %r13d
movl %esi, %ecx
shll %cl, %r13d
btl %esi, %r14d
jae 0x115f35
incl %esi
andl %edi, %esi
jmp 0x115f15
orl %r13d, %r14d
movl %r14d, (%r15,%rbp,4)
movl %esi, %ecx
cmpl %ebx, %esi
jae 0x115f75
movl (%r8,%rbp,4), %esi
testl %r13d, %esi
je 0x115f75
shlq $0x4, %rcx
movq (%r10,%rcx), %r14
movq 0x8(%r10,%rcx), %r11
movq %r12, (%r10,%rcx)
movq %r9, 0x8(%r10,%rcx)
notl %r13d
andl %r13d, %esi
movl %esi, (%r8,%rbp,4)
movb $0x1, %cl
movq %r11, %r9
movq %r14, %r12
jmp 0x115f84
shlq $0x4, %rcx
movq %r12, (%r10,%rcx)
movq %r9, 0x8(%r10,%rcx)
xorl %ecx, %ecx
testb %cl, %cl
jne 0x115f04
incq %rdx
cmpq 0x20(%rsp), %rdx
jne 0x115ec4
movq 0x18(%rsp), %rax
cmpl %eax, %ebx
movq 0x8(%rsp), %rbx
jbe 0x115fbb
movq 0x10(%rbx), %rdi
movl %eax, %esi
shlq $0x4, %rsi
callq 0x2370
movq %rax, 0x10(%rbx)
movq 0x8(%rbx), %rdi
callq 0x2220
movq %r15, 0x8(%rbx)
movl 0x14(%rsp), %eax
movl %eax, (%rbx)
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq