// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/Trio.cpp
// Function: ha_polybin_list(hifiasm_opt_t const*)
uint32_t *ha_polybin_list(const hifiasm_opt_t *opt)
{
	int64_t i;
	khint_t k;
	cstr_ht_t *h;
	assert(R_INF.total_reads < (uint32_t)-1);
	h = cstr_ht_init();
	for (i = 0; i < (int64_t)R_INF.total_reads; ++i) {
		int absent;
		char *str = (char*)calloc(Get_NAME_LENGTH(R_INF, i) + 1, 1);
		strncpy(str, Get_NAME(R_INF, i), Get_NAME_LENGTH(R_INF, i));
		k = cstr_ht_put(h, str, &absent);
		if (absent) kh_val(h, k) = i;
	}
	fprintf(stderr, "[M::%s::%.3f*%.2f] created the hash table for read names\n", __func__, yak_realtime(), yak_cpu_usage());

	gzFile fp;
	kstream_t *ks;
	kstring_t str = {0,0,0};
	char *rname = NULL;
	uint32_t hid, *ss = NULL;
	int dret;
	int64_t n_tot = 0, n_bin = 0;
	fp = gzopen(opt->fn_bin_poy, "r");
	if (fp == 0) {
		fprintf(stderr, "ERROR: failed to open file '%s'\n", opt->fn_bin_poy);
		for (k = 0; k < kh_end(h); ++k)
			if (kh_exist(h, k))
				free((char*)kh_key(h, k));
		cstr_ht_destroy(h);
		return NULL;
	}
	CALLOC(ss, R_INF.total_reads);
	ks = ks_init(fp);
	while (ks_getuntil(ks, KS_SEP_LINE, &str, &dret) >= 0) {
		khint_t k; ++n_tot;
		phrase_hstatus(str.s, &rname, &hid);
		if((!(*rname)) || hid == (uint32_t)-1) {
			fprintf(stderr, "ERROR: wrong hap status\n");
			continue;
		}
		k = cstr_ht_get(h, rname);
		if (k != kh_end(h)) {
			ss[kh_val(h, k)] |= (((uint32_t)1)<<(hid-1));
			++n_bin;
		}
	}
	free(str.s);
	ks_destroy(ks);
	gzclose(fp);
	
	for (k = 0; k < kh_end(h); ++k)
		if (kh_exist(h, k))
			free((char*)kh_key(h, k));
	cstr_ht_destroy(h);
	fprintf(stderr, "[M::%s::%.3f*%.2f] ==> partitioned reads with external lists\n", __func__, yak_realtime(), yak_cpu_usage());
	return ss;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, 0x10(%rsp)
leaq 0x18e976(%rip), %r14    # 0x296230
movq 0x50(%r14), %r15
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq %rax, %r15
jae 0x107bbc
movl $0x1, %edi
movl $0x18, %esi
callq 0x2120
movq %rax, %rbx
testq %r15, %r15
je 0x107948
xorl %r15d, %r15d
movq 0x40(%r14), %rax
movq (%rax,%r15,8), %r12
movq 0x8(%rax,%r15,8), %r13
subq %r12, %r13
leaq 0x1(%r13), %rdi
movl $0x1, %esi
callq 0x2120
movq %rax, %rbp
addq 0x8(%r14), %r12
movq %rax, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x20d0
movq %rbx, %rdi
movq %rbp, %rsi
leaq 0x20(%rsp), %rdx
callq 0x107bdb
cmpl $0x0, 0x20(%rsp)
je 0x10793f
movq 0x10(%rbx), %rcx
movl %eax, %eax
shlq $0x4, %rax
movq %r15, 0x8(%rcx,%rax)
incq %r15
cmpq 0x50(%r14), %r15
jl 0x1078e6
movq 0x18d691(%rip), %rax    # 0x294fe0
movq (%rax), %r15
callq 0x1365ef
movsd %xmm0, 0x8(%rsp)
callq 0x1366b8
movaps %xmm0, %xmm1
leaq 0x131aaf(%rip), %rsi    # 0x23941b
leaq 0x131ae2(%rip), %rdx    # 0x239455
movq %r15, %rdi
movsd 0x8(%rsp), %xmm0
movb $0x2, %al
callq 0x22b0
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movq $0x0, 0x30(%rsp)
movq 0x10(%rsp), %r12
movq 0x40(%r12), %rdi
leaq 0x137e52(%rip), %rsi    # 0x23f7f7
callq 0x22d0
testq %rax, %rax
jne 0x1079c5
addq $0x40, %r12
movq %r12, %rdi
movq %rbx, %rsi
callq 0x11c3b
xorl %eax, %eax
jmp 0x107bad
movq %rax, %r15
movq 0x50(%r14), %rdi
movl $0x4, %esi
callq 0x2120
movq %rax, 0x10(%rsp)
movl $0x1, %edi
movl $0x20, %esi
callq 0x2120
movq %rax, %r12
movq %r15, 0x8(%rsp)
movq %r15, 0x18(%rax)
movl $0x10000, %edi          # imm = 0x10000
callq 0x2280
movq %rax, (%r12)
leaq 0x20(%rsp), %rsi
leaq 0x1c(%rsp), %rdx
movq %r12, %rdi
callq 0x1076bb
testl %eax, %eax
js 0x107af7
leaq 0x20(%rsp), %r13
leaq 0x1c(%rsp), %rbp
movq 0x30(%rsp), %rax
incq %rax
movq %rax, %rcx
xorl %r15d, %r15d
xorl %edx, %edx
movzbl -0x1(%rcx), %esi
cmpl $0x9, %esi
je 0x107a4f
cmpl $0x20, %esi
je 0x107a4f
testl %esi, %esi
je 0x107a67
movq %r15, %rsi
jmp 0x107a5f
movb $0x0, -0x1(%rcx)
movq %rcx, %rsi
testl %edx, %edx
movl $0x1, %edx
jne 0x107a67
incq %rcx
movq %rsi, %r15
jmp 0x107a38
xorl %edi, %edi
movzbl -0x1(%rax), %ecx
cmpl $0x5f, %ecx
je 0x107a78
testl %ecx, %ecx
jne 0x107a7b
jmp 0x107a80
movq %rax, %rdi
incq %rax
jmp 0x107a69
callq 0x2330
cmpb $0x0, (%r15)
je 0x107af0
movl %eax, %r14d
cmpl $-0x1, %eax
je 0x107af0
movq %rbx, %rdi
movq %r15, %rsi
callq 0x107f82
movq 0x10(%rbx), %rdx
testq %rdx, %rdx
je 0x107ab2
movb (%rbx), %cl
movl $0x1, %esi
shll %cl, %esi
jmp 0x107ab4
xorl %esi, %esi
cmpl %esi, %eax
je 0x107ad8
decb %r14b
movl $0x1, %esi
movl %r14d, %ecx
shll %cl, %esi
movl %eax, %eax
shlq $0x4, %rax
movq 0x8(%rdx,%rax), %rax
movq 0x10(%rsp), %rcx
orl %esi, (%rcx,%rax,4)
movq %r12, %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0x1076bb
testl %eax, %eax
jns 0x107a28
jmp 0x107af7
callq 0x11c19
jmp 0x107ad8
movq 0x30(%rsp), %rdi
callq 0x2220
movq (%r12), %rdi
callq 0x2220
movq %r12, %rdi
callq 0x2220
movq 0x8(%rsp), %rdi
callq 0x2390
xorl %r14d, %r14d
xorl %r15d, %r15d
movq 0x18d4b7(%rip), %r12    # 0x294fe0
movq 0x10(%rbx), %rax
testq %rax, %rax
je 0x107b3e
movb (%rbx), %cl
movl $0x1, %edx
shlq %cl, %rdx
jmp 0x107b40
xorl %edx, %edx
cmpq %rdx, %r15
jae 0x107b6b
movq 0x8(%rbx), %rcx
movq %r15, %rdx
shrq $0x5, %rdx
movl (%rcx,%rdx,4), %ecx
btl %r15d, %ecx
jae 0x107b62
movq (%rax,%r14), %rdi
callq 0x2220
incq %r15
addq $0x10, %r14
jmp 0x107b29
movq %rbx, %rdi
callq 0x107f5d
movq (%r12), %rbx
callq 0x1365ef
movsd %xmm0, 0x8(%rsp)
callq 0x1366b8
movaps %xmm0, %xmm1
leaq 0x13190e(%rip), %rsi    # 0x23949f
leaq 0x1318bd(%rip), %rdx    # 0x239455
movq %rbx, %rdi
movsd 0x8(%rsp), %xmm0
movb $0x2, %al
callq 0x22b0
movq 0x10(%rsp), %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1317fd(%rip), %rdi    # 0x2393c0
leaq 0x131817(%rip), %rsi    # 0x2393e1
leaq 0x131819(%rip), %rcx    # 0x2393ea
movl $0x18c, %edx            # imm = 0x18C
callq 0x2110