// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/htab.cpp
// Function: ha_count(hifiasm_opt_t const*, int, int, int, int, ha_pt_s*, void const*, All_reads*, ma_utg_v*, int, int*, int)
ha_ct_t *ha_count(const hifiasm_opt_t *asm_o, int flag, int HPC, int k, int w, ha_pt_t *p0, const void *flt_tab, All_reads *rs, ma_utg_v *us, int keep_adapter, int *low_freq, int unique_only)
{
	int i;
	int64_t n_seq = 0;
	uint64_t n_bs = 0;
	yak_copt_t opt;
	ha_ct_t *h = 0;
	assert(!(flag & HAF_RS_WRITE_LEN) || !(flag & HAF_RS_WRITE_SEQ)); // not both
	///for 0-th counting, flag = HAF_COUNT_ALL|HAF_RS_WRITE_LEN
	if (rs) {
		if (flag & HAF_RS_WRITE_LEN)
			init_All_reads(rs);
		else if (flag & HAF_RS_WRITE_SEQ)
			malloc_All_reads(rs);
	}
	yak_copt_init(&opt);
	opt.k = k;
	opt.is_HPC = HPC;
	///for ft-counting, shoud be 1
	opt.w = flag & HAF_COUNT_ALL? 1 : w;
	///for ft-counting, shoud be 37
	///for ha_pt_gen, shoud be 0
	opt.bf_shift = flag & HAF_COUNT_EXACT? 0 : asm_o->bf_shift;
	opt.n_thread = asm_o->thread_num;
	opt.adaLen = (keep_adapter? asm_o->adapterLen : 0);
	opt.min_rcnt = (low_freq?*low_freq:-1);
	opt.uq = (unique_only?1:0);
	
	n_bs = 0;
	///pending for integration
	/**
	if(rs && asm_o->ar && asm_o->ul_mod) {
		for (i = 0; i < asm_o->ar->n; ++i){
			h = yak_count(&opt, asm_o->ar->a[i], flag|HAF_CREATE_NEW, p0, h, flt_tab, rs, us, &n_seq);
			if(h) n_bs += h->bs;
		}
	}**/
	///asm_opt->num_reads is the number of fastq files
	for (i = 0; i < (us?1:asm_o->num_reads); ++i){
		h = yak_count(&opt, asm_o->read_file_names[i], flag|HAF_CREATE_NEW, p0, h, flt_tab, rs, us, &n_seq);
		if(h) n_bs += h->bs;
	}
	if(h) h->bs = n_bs;	
	if (h && opt.bf_shift > 0)
		ha_ct_destroy_bf(h);
	return h;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movq %rdi, 0x10(%rsp)
movl %esi, %ebx
andl $0xc, %ebx
cmpl $0xc, %ebx
je 0xd5ba3
movq %r9, %r13
movl %r8d, %r14d
movl %ecx, %r12d
movl %edx, %r15d
movl %esi, %ebp
cmpq $0x0, 0x128(%rsp)
je 0xd56f9
testb $0x4, %bpl
jne 0xd56ec
testb $0x8, %bpl
je 0xd56f9
movq 0x128(%rsp), %rdi
callq 0x6956
jmp 0xd56f9
movq 0x128(%rsp), %rdi
callq 0x5848
movl 0x138(%rsp), %eax
movl $0x4, 0x2c(%rsp)
movl $0xc, 0x40(%rsp)
movq $0x1312d00, 0x48(%rsp)  # imm = 0x1312D00
movl %r12d, 0x30(%rsp)
movl %r15d, 0x38(%rsp)
testb $0x2, %bpl
pushq $0x1
popq %rcx
cmovnel %ecx, %r14d
movl %r14d, 0x34(%rsp)
xorl %ecx, %ecx
movl $0x0, %esi
testb $0x1, %bpl
movq 0x10(%rsp), %r14
jne 0xd574c
movl 0xac(%r14), %esi
movq 0x140(%rsp), %rdx
movl %esi, 0x28(%rsp)
movl 0x7c(%r14), %esi
movl %esi, 0x44(%rsp)
testl %eax, %eax
je 0xd576b
movl 0x100(%r14), %ecx
movl 0x148(%rsp), %eax
movl %ecx, 0x50(%rsp)
testq %rdx, %rdx
je 0xd577f
movl (%rdx), %ecx
jmp 0xd5782
pushq $-0x1
popq %rcx
leaq 0x28(%rsp), %rdx
movl %ecx, 0x2c(%rdx)
xorl %ecx, %ecx
testl %eax, %eax
setne %cl
movl %ecx, 0x14(%rdx)
movl %ebp, %eax
orl $0x20, %eax
movl %eax, 0x24(%rsp)
cmpq $0x0, 0x128(%rsp)
setne %al
movl %ebp, %ecx
shrb $0x4, %cl
andb %al, %cl
movb %cl, 0x1(%rsp)
cmpq $0x0, 0x130(%rsp)
setne %cl
testb %bpl, %bpl
sets %dl
andb %cl, %dl
movb %dl, 0x2(%rsp)
testl %ebx, %ebx
setne %cl
andb %al, %cl
movb %cl, 0x3(%rsp)
xorl %ebp, %ebp
xorl %r15d, %r15d
movq $0x0, 0x18(%rsp)
xorl %r12d, %r12d
pushq $0x1
popq %rax
cmpq $0x0, 0x130(%rsp)
jne 0xd57fa
movslq 0x4(%r14), %rax
cmpq %rax, %rbp
jge 0xd5b32
movq 0x8(%r14), %rax
movq (%rax,%rbp,8), %rdi
xorps %xmm0, %xmm0
movaps %xmm0, 0x80(%rsp)
movaps %xmm0, 0xd0(%rsp)
movaps %xmm0, 0xc0(%rsp)
movaps %xmm0, 0xb0(%rsp)
movaps %xmm0, 0xa0(%rsp)
movaps %xmm0, 0x90(%rsp)
movaps %xmm0, 0x70(%rsp)
movaps %xmm0, 0x60(%rsp)
movq %r15, 0x88(%rsp)
cmpb $0x0, 0x2(%rsp)
je 0xd5869
movq 0x130(%rsp), %rax
movq %rax, 0xd8(%rsp)
jmp 0xd5891
cmpb $0x0, 0x1(%rsp)
je 0xd5994
movq 0x128(%rsp), %rax
movq %rax, 0xc8(%rsp)
leaq 0x98(%rsp), %rdi
callq 0x6bd1
xorl %ebx, %ebx
cmpb $0x0, 0x3(%rsp)
je 0xd58aa
movq 0x128(%rsp), %rax
movq %rax, 0xd0(%rsp)
movq 0x120(%rsp), %rax
movq %rax, 0x68(%rsp)
leaq 0x28(%rsp), %rax
movq %rax, 0x60(%rsp)
movl 0x24(%rsp), %eax
movl %eax, 0x70(%rsp)
testq %r13, %r13
je 0xd5906
movq %r13, 0xc0(%rsp)
andl $0x0, 0x74(%rsp)
movl (%r13), %eax
cmpl 0x30(%rsp), %eax
jne 0xd5b65
movl 0x4(%r13), %eax
cmpl 0x40(%rsp), %eax
jne 0xd5b65
movq 0xb8(%rsp), %r12
testq %r12, %r12
jne 0xd593c
jmp 0xd5942
testq %r12, %r12
je 0xd5a12
movq %r12, 0xb8(%rsp)
movl $0x1, 0x74(%rsp)
movl (%r12), %eax
cmpl 0x30(%rsp), %eax
jne 0xd5b84
movl 0x4(%r12), %eax
cmpl 0x40(%rsp), %eax
jne 0xd5b84
andq $0x0, 0x18(%r12)
cmpb $0x0, 0x2(%rsp)
je 0xd5968
pushq $0x3
popq %rcx
movl %ecx, %edi
leaq 0x2e16(%rip), %rsi      # 0xd876b
leaq 0x60(%rsp), %rdx
callq 0xc6979
cmpb $0x0, 0x1(%rsp)
jne 0xd5985
jmp 0xd59d2
pushq $0x3
popq %rcx
movl %ecx, %edi
leaq 0x3ad1(%rip), %rsi      # 0xd9445
leaq 0x60(%rsp), %rdx
callq 0xc6979
cmpb $0x0, 0x1(%rsp)
je 0xd59bd
leaq 0x98(%rsp), %rdi
callq 0x6b07
jmp 0xd59d2
leaq 0x11bd1c(%rip), %rsi    # 0x1f16b7
callq 0x22d0
testq %rax, %rax
je 0xd5a07
movq %rax, %rbx
movq %rax, %rdi
callq 0xd5402
movq %rax, 0x90(%rsp)
jmp 0xd5893
movq 0x90(%rsp), %rdi
callq 0xd563b
movq %rbx, %rdi
callq 0x2390
movq 0x60(%rsp), %rax
movq 0x88(%rsp), %r15
cmpl $0x2, 0xc(%rax)
jge 0xd5aea
movq 0xb8(%rsp), %r12
testq %r12, %r12
je 0xd5a07
movq 0x18(%rsp), %rax
addq 0x18(%r12), %rax
movq %rax, 0x18(%rsp)
jmp 0xd5a0a
xorl %r12d, %r12d
incq %rbp
jmp 0xd57e8
movl $0x1, 0x74(%rsp)
movl 0x40(%rsp), %r15d
cmpl $0xc, %r15d
jge 0xd5a2d
xorl %r12d, %r12d
jmp 0xd5b25
movq %rbx, 0x58(%rsp)
movl 0x28(%rsp), %eax
movl %eax, 0x20(%rsp)
movl 0x2c(%rsp), %eax
movl %eax, 0x4(%rsp)
movl 0x30(%rsp), %ebx
pushq $0x1
popq %rdi
pushq $0x28
popq %rsi
callq 0x2120
movq %rax, %r12
movl %ebx, (%rax)
movl %r15d, 0x4(%rax)
pushq $0x1
popq %rax
movl %r15d, 0x8(%rsp)
movl %r15d, %ecx
shll %cl, %eax
movslq %eax, %r15
movq %r15, %rdi
pushq $0x10
popq %rsi
callq 0x2120
movq %rax, %r14
movq %rax, 0x20(%r12)
testl %r15d, %r15d
movl $0x0, %eax
cmovlel %eax, %r15d
shlq $0x4, %r15
xorl %ebx, %ebx
cmpq %rbx, %r15
je 0xd5aa3
callq 0xda119
movq %rax, (%r14,%rbx)
addq $0x10, %rbx
jmp 0xd5a8f
movl 0x4(%rsp), %edx
testl %edx, %edx
setle %al
movl 0x20(%rsp), %esi
movl %esi, %ebx
subl 0x8(%rsp), %ebx
setle %cl
orb %al, %cl
jne 0xd5b1b
movq %r13, 0x8(%rsp)
movl %edx, 0x8(%r12)
movl %esi, 0xc(%r12)
xorl %r13d, %r13d
cmpq %r13, %r15
je 0xd5b16
movl %ebx, %edi
movl 0x4(%rsp), %esi
callq 0xd435a
movq %rax, 0x8(%r14,%r13)
addq $0x10, %r13
jmp 0xd5acf
movq 0x17d4ef(%rip), %rax    # 0x252fe0
movq (%rax), %rdi
movq 0x80(%rsp), %rcx
leaq 0x1168a2(%rip), %rsi    # 0x1ec3a5
leaq 0x1168bd(%rip), %rdx    # 0x1ec3c7
xorl %eax, %eax
callq 0x22b0
jmp 0xd59e9
movq 0x8(%rsp), %r13
movq 0x10(%rsp), %r14
movq 0x58(%rsp), %rbx
movq %r12, 0xb8(%rsp)
jmp 0xd58ff
testq %r12, %r12
je 0xd5b50
movq 0x18(%rsp), %rax
movq %rax, 0x18(%r12)
cmpl $0x0, 0x28(%rsp)
jle 0xd5b50
movq %r12, %rdi
callq 0xd4712
movq %r12, %rax
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x116769(%rip), %rdi    # 0x1ec2d5
leaq 0x1160ac(%rip), %rsi    # 0x1ebc1f
leaq 0x116782(%rip), %rcx    # 0x1ec2fc
movl $0x3be, %edx            # imm = 0x3BE
callq 0x2110
leaq 0x1167f3(%rip), %rdi    # 0x1ec37e
leaq 0x11608d(%rip), %rsi    # 0x1ebc1f
leaq 0x116763(%rip), %rcx    # 0x1ec2fc
movl $0x3c1, %edx            # imm = 0x3C1
callq 0x2110
leaq 0x116207(%rip), %rdi    # 0x1ebdb1
leaq 0x11606e(%rip), %rsi    # 0x1ebc1f
leaq 0x116232(%rip), %rcx    # 0x1ebdea
movl $0x3de, %edx            # imm = 0x3DE
callq 0x2110