// File: chhylp123[P]hifiasm/htab.cpp
// Function: ha_pt_ul_gen(hifiasm_opt_t const*, void const*, ma_utg_v*, int, int, int)
ha_pt_t *ha_pt_ul_gen(const hifiasm_opt_t *asm_opt, const void *flt_tab, ma_utg_v *us, int k, int w, int cutoff)
{
	ha_ct_t *ct;
	ha_pt_t *pt;
	///HAF_COUNT_EXACT: no bf
	ct = ha_count(asm_opt, HAF_COUNT_EXACT|HAF_UG_READ, !(asm_opt->flag&HA_F_NO_HPC), k, w, NULL, flt_tab, NULL, us, 0, NULL, 0);
	fprintf(stderr, "[M::%s::%.3f*%.2f] ==> counted %ld distinct minimizer k-mers\n", __func__,
			yak_realtime(), yak_cpu_usage(), (long)ct->tot);
	///minimizer with YAK_MAX_COUNT occ may apper > YAK_MAX_COUNT times, so it may lead to overflow at ha_pt_gen
	if (flt_tab == 0) {
        if (cutoff > YAK_MAX_COUNT - 1) cutoff = YAK_MAX_COUNT - 1;
        ha_ct_shrink(ct, /**2**/1, cutoff, asm_opt->thread_num);
    } else {
        ///Note: here is just to remove minimizer appearing YAK_MAX_COUNT times
        ///minimizer with YAK_MAX_COUNT occ may apper > YAK_MAX_COUNT times, so it may lead to overflow at ha_pt_gen
        ha_ct_shrink(ct, /**2**/1, YAK_MAX_COUNT - 1, asm_opt->thread_num);
    }
	
	pt = ha_pt_gen(ct, asm_opt->thread_num, 1);
	ha_count(asm_opt, HAF_COUNT_EXACT|HAF_UG_READ, !(asm_opt->flag&HA_F_NO_HPC), k, w, pt, flt_tab, NULL, us, 0, NULL, 0);
	//ha_pt_sort(pt, asm_opt->thread_num);
	fprintf(stderr, "[M::%s::%.3f*%.2f] ==> indexed %ld positions\n", __func__,
			yak_realtime(), yak_cpu_usage(), (long)pt->tot_pos);
	return pt;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movl %r9d, -0x24(%rbp)
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movl (%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %edx
movl -0x1c(%rbp), %ecx
movl -0x20(%rbp), %r8d
movq -0x10(%rbp), %r10
movq -0x18(%rbp), %rax
movl $0x81, %esi
xorl %r9d, %r9d
xorl %r11d, %r11d
movq %r10, (%rsp)
movq $0x0, 0x8(%rsp)
movq %rax, 0x10(%rsp)
movl $0x0, 0x18(%rsp)
movq $0x0, 0x20(%rsp)
movl $0x0, 0x28(%rsp)
callq 0x1886f0
movq %rax, -0x30(%rbp)
movq 0x23a3df(%rip), %rax    # 0x3c3fe0
movq (%rax), %rax
movq %rax, -0x48(%rbp)
callq 0x1b7ca0
movsd %xmm0, -0x40(%rbp)
callq 0x1b7d20
movq -0x48(%rbp), %rdi
movaps %xmm0, %xmm1
movsd -0x40(%rbp), %xmm0
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rcx
leaq 0x200fb9(%rip), %rsi    # 0x38abeb
leaq 0x200ff0(%rip), %rdx    # 0x38ac29
movb $0x2, %al
callq 0x22a0
cmpq $0x0, -0x10(%rbp)
jne 0x189c71
cmpl $0xffe, -0x24(%rbp)     # imm = 0xFFE
jle 0x189c57
movl $0xffe, -0x24(%rbp)     # imm = 0xFFE
movq -0x30(%rbp), %rdi
movl -0x24(%rbp), %edx
movq -0x8(%rbp), %rax
movl 0x7c(%rax), %ecx
movl $0x1, %esi
callq 0x1891f0
jmp 0x189c8b
movq -0x30(%rbp), %rdi
movq -0x8(%rbp), %rax
movl 0x7c(%rax), %ecx
movl $0x1, %esi
movl $0xffe, %edx            # imm = 0xFFE
callq 0x1891f0
movq -0x30(%rbp), %rdi
movq -0x8(%rbp), %rax
movl 0x7c(%rax), %esi
movl $0x1, %edx
callq 0x186b00
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movl (%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %edx
movl -0x1c(%rbp), %ecx
movl -0x20(%rbp), %r8d
movq -0x38(%rbp), %r9
movq -0x10(%rbp), %r10
movq -0x18(%rbp), %rax
movl $0x81, %esi
xorl %r11d, %r11d
xorl %r11d, %r11d
movq %r10, (%rsp)
movq $0x0, 0x8(%rsp)
movq %rax, 0x10(%rsp)
movl $0x0, 0x18(%rsp)
movq $0x0, 0x20(%rsp)
movl $0x0, 0x28(%rsp)
callq 0x1886f0
movq 0x23a2cd(%rip), %rax    # 0x3c3fe0
movq (%rax), %rax
movq %rax, -0x58(%rbp)
callq 0x1b7ca0
movsd %xmm0, -0x50(%rbp)
callq 0x1b7d20
movq -0x58(%rbp), %rdi
movaps %xmm0, %xmm1
movsd -0x50(%rbp), %xmm0
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rcx
leaq 0x200ef2(%rip), %rsi    # 0x38ac36
leaq 0x200ede(%rip), %rdx    # 0x38ac29
movb $0x2, %al
callq 0x22a0
movq -0x38(%rbp), %rax
addq $0x90, %rsp
popq %rbp
retq
nop