// File: chhylp123[P]hifiasm/htab.cpp
// Function: gen_hh(ha_ct_t const*, int)
static yak_ft_t *gen_hh(const ha_ct_t *h, int max_cnt)
{
	int i;
	yak_ft_t *hh;
	if (max_cnt > YAK_MAX_COUNT - 1) max_cnt = YAK_MAX_COUNT - 1;
	if (max_cnt > INT16_MAX - 1) max_cnt = INT16_MAX - 1;
	hh = yak_ft_init();
	yak_ft_resize(hh, h->tot * 2);
	for (i = 0; i < 1<<h->pre; ++i) {
		yak_ct_t *ht = h->h[i].h;
		khint_t k, l;
		for (k = 0; k < kh_end(ht); ++k) {
			if (kh_exist(ht, k)) {
				uint64_t y = kh_key(ht, k) >> h->pre << YAK_COUNTER_BITS | i;
				int absent;
				l = yak_ft_put(hh, y, &absent);
				if (absent) {
					int cnt = kh_key(ht, k) & YAK_MAX_COUNT;
					kh_val(hh, l) = cnt > max_cnt? INT16_MAX : cnt;
				}
			}
		}
	}
	return hh;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
cmpl $0xffe, -0xc(%rbp)      # imm = 0xFFE
jle 0x18930f
movl $0xffe, -0xc(%rbp)      # imm = 0xFFE
cmpl $0x7ffe, -0xc(%rbp)     # imm = 0x7FFE
jle 0x18931f
movl $0x7ffe, -0xc(%rbp)     # imm = 0x7FFE
callq 0x190bc0
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
shlq %rax
movl %eax, %esi
callq 0x190bd0
movl $0x0, -0x10(%rbp)
movl -0x10(%rbp), %eax
movq -0x8(%rbp), %rcx
movl 0x4(%rcx), %ecx
movl $0x1, %edx
shll %cl, %edx
movl %edx, %ecx
cmpl %ecx, %eax
jge 0x189490
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x10(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0x3c(%rbp)
movq -0x20(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x1893a4
movq -0x20(%rbp), %rax
movl (%rax), %ecx
movl $0x1, %eax
shll %cl, %eax
movl %eax, -0x40(%rbp)
jmp 0x1893ab
xorl %eax, %eax
movl %eax, -0x40(%rbp)
jmp 0x1893ab
movl -0x3c(%rbp), %eax
movl -0x40(%rbp), %ecx
cmpl %ecx, %eax
jae 0x189480
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x24(%rbp), %ecx
shrl $0x5, %ecx
movl %ecx, %ecx
movl (%rax,%rcx,4), %eax
movl -0x24(%rbp), %ecx
andl $0x1f, %ecx
shrl %cl, %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x189470
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x24(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movq -0x8(%rbp), %rcx
movl 0x4(%rcx), %ecx
shrq %cl, %rax
shlq $0xc, %rax
movslq -0x10(%rbp), %rcx
orq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rdi
movq -0x30(%rbp), %rsi
leaq -0x34(%rbp), %rdx
callq 0x190c00
movl %eax, -0x28(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x18946e
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x24(%rbp), %ecx
movq (%rax,%rcx,8), %rax
andq $0xfff, %rax            # imm = 0xFFF
movl %eax, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0xc(%rbp), %eax
jle 0x18944c
movl $0x7fff, %eax           # imm = 0x7FFF
movl %eax, -0x44(%rbp)
jmp 0x189452
movl -0x38(%rbp), %eax
movl %eax, -0x44(%rbp)
movl -0x44(%rbp), %eax
movw %ax, %cx
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x28(%rbp), %edx
imulq $0xa, %rdx, %rdx
addq %rdx, %rax
movw %cx, 0x8(%rax)
jmp 0x189470
jmp 0x189472
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x189381
jmp 0x189482
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x189345
movq -0x18(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nopw (%rax,%rax)