// File: chhylp123[P]hifiasm/htab.cpp
// Function: yak_count(yak_copt_t const*, char const*, int, ha_pt_s*, ha_ct_t*, void const*, All_reads*, ma_utg_v*, long*)
static ha_ct_t *yak_count(const yak_copt_t *opt, const char *fn, int flag, ha_pt_t *p0, ha_ct_t *c0, const void *flt_tab, All_reads *rs, ma_utg_v *us, int64_t *n_seq)
{
	///for 0-th counting, flag = HAF_COUNT_ALL|HAF_RS_WRITE_LEN|HAF_CREATE_NEW
	int read_rs = (rs && (flag & HAF_RS_READ));
	int ug_rs = (us && (flag & HAF_UG_READ));
	pl_data_t pl;
	gzFile fp = 0;
	memset(&pl, 0, sizeof(pl_data_t));
	pl.n_seq = *n_seq; 
	if(ug_rs) {
		pl.us_in = us;
	} else if (read_rs) {
		pl.rs_in = rs;
		init_UC_Read(&pl.ucr);
	} else {///for 0-th counting, go into here
		if ((fp = gzopen(fn, "r")) == 0) return 0;
		pl.ks = kseq_init(fp);
	}
	///for 0-th counting, read all reads into pl.rs_out
	if (rs && (flag & (HAF_RS_WRITE_LEN|HAF_RS_WRITE_SEQ)))
		pl.rs_out = rs;
	///for 0-th counting, flt_tab = NULL
	///for 1-th counting, flt_tab = NULL
	pl.flt_tab = flt_tab;
	pl.opt = opt;
	pl.flag = flag;
	if (p0) {///for 1-th counting, p0 = NULL
		pl.pt = p0, pl.create_new = 0; // never create new elements in a position table
		assert(p0->k == opt->k && p0->pre == opt->pre);
	} else if (c0) {
		pl.ct = c0, pl.create_new = !!(flag&HAF_CREATE_NEW);
		assert(c0->k == opt->k && c0->pre == opt->pre);
	} else {///for ft-th counting and 1-th counting, go into here
		pl.create_new = 1; // alware create new elements if the count table is empty
		///for 0-th counting, opt.k = 51, opt->pre = 12, opt->bf_n_hash = 4, opt.bf_shift = 37
		///for 1-th counting, opt.k = 51, opt->pre = 12, opt->bf_n_hash = 4, opt.bf_shift = 0
		///building a large hash table consisting of 4096 small hash tables
		pl.ct = ha_ct_init(opt->k, opt->pre, opt->bf_n_hash, opt->bf_shift);
	}
	if(pl.ct) pl.ct->bs = 0;
	if(ug_rs) kt_pipeline(3, mz2_worker_count, &pl, 3);
	else kt_pipeline(3, mz1_worker_count, &pl, 3);
	if (read_rs) {
		destory_UC_Read(&pl.ucr);
	} else if(!read_rs && !ug_rs) {
		kseq_destroy(pl.ks);
		gzclose(fp);
	}
	*n_seq = pl.n_seq;
	if (pl.opt->w > 1) fprintf(stderr, "[M::%s] collected %ld minimizers\n", __func__, (long)pl.n_mz);
	return pl.ct;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
xorl %eax, %eax
cmpq $0x0, 0x10(%rbp)
movb %al, -0xc9(%rbp)
je 0x1889cf
movl -0x1c(%rbp), %eax
andl $0x10, %eax
cmpl $0x0, %eax
setne %al
movb %al, -0xc9(%rbp)
movb -0xc9(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x3c(%rbp)
xorl %eax, %eax
cmpq $0x0, 0x18(%rbp)
movb %al, -0xca(%rbp)
je 0x188a00
movl -0x1c(%rbp), %eax
andl $0x80, %eax
cmpl $0x0, %eax
setne %al
movb %al, -0xca(%rbp)
movb -0xca(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x40(%rbp)
movq $0x0, -0xc8(%rbp)
leaq -0xc0(%rbp), %rdi
xorl %esi, %esi
movl $0x80, %edx
callq 0x2100
movq 0x20(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x98(%rbp)
cmpl $0x0, -0x40(%rbp)
je 0x188a4a
movq 0x18(%rbp), %rax
movq %rax, -0x48(%rbp)
jmp 0x188aa9
cmpl $0x0, -0x3c(%rbp)
je 0x188a6a
movq 0x10(%rbp), %rax
movq %rax, -0x58(%rbp)
leaq -0xc0(%rbp), %rdi
addq $0x38, %rdi
callq 0x9850
jmp 0x188aa7
movq -0x18(%rbp), %rdi
leaq 0x207961(%rip), %rsi    # 0x3903d6
callq 0x22c0
movq %rax, -0xc8(%rbp)
cmpq $0x0, %rax
jne 0x188a94
movq $0x0, -0x8(%rbp)
jmp 0x188cec
movq -0xc8(%rbp), %rdi
callq 0x188250
movq %rax, -0x90(%rbp)
jmp 0x188aa9
cmpq $0x0, 0x10(%rbp)
je 0x188ac3
movl -0x1c(%rbp), %eax
andl $0xc, %eax
cmpl $0x0, %eax
je 0x188ac3
movq 0x10(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xc0(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0xb0(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x188b5b
movq -0x28(%rbp), %rax
movq %rax, -0x60(%rbp)
movl $0x0, -0xac(%rbp)
movq -0x28(%rbp), %rax
movl (%rax), %ecx
movq -0x10(%rbp), %rdx
xorl %eax, %eax
cmpl 0x8(%rdx), %ecx
movb %al, -0xcb(%rbp)
jne 0x188b29
movq -0x28(%rbp), %rax
movl 0x4(%rax), %eax
movq -0x10(%rbp), %rcx
cmpl 0x18(%rcx), %eax
sete %al
movb %al, -0xcb(%rbp)
movb -0xcb(%rbp), %al
testb $0x1, %al
jne 0x188b35
jmp 0x188b37
jmp 0x188b56
leaq 0x202477(%rip), %rdi    # 0x38afb5
leaq 0x201dba(%rip), %rsi    # 0x38a8ff
movl $0x3be, %edx            # imm = 0x3BE
leaq 0x20248b(%rip), %rcx    # 0x38afdc
callq 0x2130
jmp 0x188c16
cmpq $0x0, -0x30(%rbp)
je 0x188be6
movq -0x30(%rbp), %rax
movq %rax, -0x68(%rbp)
movl -0x1c(%rbp), %eax
andl $0x20, %eax
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0xac(%rbp)
movq -0x30(%rbp), %rax
movl (%rax), %ecx
movq -0x10(%rbp), %rdx
xorl %eax, %eax
cmpl 0x8(%rdx), %ecx
movb %al, -0xcc(%rbp)
jne 0x188bb7
movq -0x30(%rbp), %rax
movl 0x4(%rax), %eax
movq -0x10(%rbp), %rcx
cmpl 0x18(%rcx), %eax
sete %al
movb %al, -0xcc(%rbp)
movb -0xcc(%rbp), %al
testb $0x1, %al
jne 0x188bc3
jmp 0x188bc5
jmp 0x188be4
leaq 0x202492(%rip), %rdi    # 0x38b05e
leaq 0x201d2c(%rip), %rsi    # 0x38a8ff
movl $0x3c1, %edx            # imm = 0x3C1
leaq 0x2023fd(%rip), %rcx    # 0x38afdc
callq 0x2130
jmp 0x188c14
movl $0x1, -0xac(%rbp)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %edi
movq -0x10(%rbp), %rax
movl 0x18(%rax), %esi
movq -0x10(%rbp), %rax
movl 0x4(%rax), %edx
movq -0x10(%rbp), %rax
movl (%rax), %ecx
callq 0x18cb50
movq %rax, -0x68(%rbp)
jmp 0x188c16
cmpq $0x0, -0x68(%rbp)
je 0x188c29
movq -0x68(%rbp), %rax
movq $0x0, 0x18(%rax)
cmpl $0x0, -0x40(%rbp)
je 0x188c4b
movl $0x3, %ecx
leaq 0x4075(%rip), %rsi      # 0x18ccb0
leaq -0xc0(%rbp), %rdx
movl %ecx, %edi
callq 0x16d950
jmp 0x188c65
movl $0x3, %ecx
leaq 0x5079(%rip), %rsi      # 0x18dcd0
leaq -0xc0(%rbp), %rdx
movl %ecx, %edi
callq 0x16d950
cmpl $0x0, -0x3c(%rbp)
je 0x188c7d
leaq -0xc0(%rbp), %rdi
addq $0x38, %rdi
callq 0x9670
jmp 0x188ca3
cmpl $0x0, -0x3c(%rbp)
jne 0x188ca1
cmpl $0x0, -0x40(%rbp)
jne 0x188ca1
movq -0x90(%rbp), %rdi
callq 0x188680
movq -0xc8(%rbp), %rdi
callq 0x2380
jmp 0x188ca3
movq -0x98(%rbp), %rcx
movq 0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0xc0(%rbp), %rax
cmpl $0x1, 0xc(%rax)
jle 0x188ce4
movq 0x23b31b(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
movq -0xa0(%rbp), %rcx
leaq 0x2023af(%rip), %rsi    # 0x38b085
leaq 0x2023ca(%rip), %rdx    # 0x38b0a7
movb $0x0, %al
callq 0x22a0
movq -0x68(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xd0, %rsp
popq %rbp
retq
nopl (%rax)