// File: 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
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x10(%rbp)
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
leaq 0x25b065(%rip), %rax    # 0x3c52d0
cmpq %rcx, 0x50(%rax)
jae 0x16a273
jmp 0x16a292
leaq 0x21fd5e(%rip), %rdi    # 0x389fd8
leaq 0x21fd78(%rip), %rsi    # 0x389ff9
movl $0x18c, %edx            # imm = 0x18C
leaq 0x21fd75(%rip), %rcx    # 0x38a002
callq 0x2130
callq 0x16a750
movq %rax, -0x28(%rbp)
movq $0x0, -0x18(%rbp)
movq -0x18(%rbp), %rax
leaq 0x25b022(%rip), %rcx    # 0x3c52d0
cmpq 0x50(%rcx), %rax
jge 0x16a386
leaq 0x25b011(%rip), %rax    # 0x3c52d0
movq 0x40(%rax), %rax
movq -0x18(%rbp), %rcx
movq 0x8(%rax,%rcx,8), %rdi
leaq 0x25affd(%rip), %rax    # 0x3c52d0
movq 0x40(%rax), %rax
movq -0x18(%rbp), %rcx
subq (%rax,%rcx,8), %rdi
addq $0x1, %rdi
movl $0x1, %esi
callq 0x2140
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
leaq 0x25afd4(%rip), %rax    # 0x3c52d0
movq 0x8(%rax), %rsi
leaq 0x25afc9(%rip), %rax    # 0x3c52d0
movq 0x40(%rax), %rax
movq -0x18(%rbp), %rcx
addq (%rax,%rcx,8), %rsi
leaq 0x25afb6(%rip), %rax    # 0x3c52d0
movq 0x40(%rax), %rax
movq -0x18(%rbp), %rcx
movq 0x8(%rax,%rcx,8), %rdx
leaq 0x25afa2(%rip), %rax    # 0x3c52d0
movq 0x40(%rax), %rax
movq -0x18(%rbp), %rcx
subq (%rax,%rcx,8), %rdx
callq 0x20f0
movq -0x28(%rbp), %rdi
movq -0x38(%rbp), %rsi
leaq -0x2c(%rbp), %rdx
callq 0x16a760
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x2c(%rbp)
je 0x16a373
movq -0x18(%rbp), %rcx
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x1c(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, 0x8(%rax)
jmp 0x16a375
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x16a2a3
movq 0x259c53(%rip), %rax    # 0x3c3fe0
movq (%rax), %rax
movq %rax, -0xa8(%rbp)
callq 0x1b7ca0
movsd %xmm0, -0xa0(%rbp)
callq 0x1b7d20
movq -0xa8(%rbp), %rdi
movaps %xmm0, %xmm1
movsd -0xa0(%rbp), %xmm0
leaq 0x21fc71(%rip), %rsi    # 0x38a033
leaq 0x21fca4(%rip), %rdx    # 0x38a06d
movb $0x2, %al
callq 0x22a0
leaq -0x60(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x2100
movq $0x0, -0x68(%rbp)
movq $0x0, -0x78(%rbp)
movq $0x0, -0x88(%rbp)
movq $0x0, -0x90(%rbp)
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rdi
leaq 0x225fc1(%rip), %rsi    # 0x3903d6
callq 0x22c0
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x16a4f6
movq 0x259bb0(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rdx
leaq 0x21fc3b(%rip), %rsi    # 0x38a07d
movb $0x0, %al
callq 0x22a0
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0xac(%rbp)
movq -0x28(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x16a479
movq -0x28(%rbp), %rax
movl (%rax), %ecx
movl $0x1, %eax
shll %cl, %eax
movl %eax, -0xb0(%rbp)
jmp 0x16a483
xorl %eax, %eax
movl %eax, -0xb0(%rbp)
jmp 0x16a483
movl -0xac(%rbp), %eax
movl -0xb0(%rbp), %ecx
cmpl %ecx, %eax
jae 0x16a4e0
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x1c(%rbp), %ecx
shrl $0x5, %ecx
movl %ecx, %ecx
movl (%rax,%rcx,4), %eax
movl -0x1c(%rbp), %ecx
andl $0x1f, %ecx
shrl %cl, %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x16a4d0
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x1c(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rdi
callq 0x2210
jmp 0x16a4d2
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x16a450
movq -0x28(%rbp), %rdi
callq 0x16a7a0
movq $0x0, -0x8(%rbp)
jmp 0x16a734
leaq 0x25add3(%rip), %rax    # 0x3c52d0
movq 0x50(%rax), %rdi
movl $0x4, %esi
callq 0x2140
movq %rax, -0x78(%rbp)
movq -0x40(%rbp), %rdi
callq 0x16a190
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
movl $0x2, %esi
leaq -0x60(%rbp), %rdx
leaq -0x7c(%rbp), %rcx
callq 0x16a1e0
cmpl $0x0, %eax
jl 0x16a627
movq -0x88(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x88(%rbp)
movq -0x50(%rbp), %rdi
leaq -0x68(%rbp), %rsi
leaq -0x6c(%rbp), %rdx
callq 0x16d610
movq -0x68(%rbp), %rax
cmpb $0x0, (%rax)
je 0x16a56d
cmpl $-0x1, -0x6c(%rbp)
jne 0x16a587
movq 0x259a6c(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
leaq 0x21fb20(%rip), %rsi    # 0x38a09e
movb $0x0, %al
callq 0x22a0
jmp 0x16a51c
movq -0x28(%rbp), %rdi
movq -0x68(%rbp), %rsi
callq 0x16a7c0
movl %eax, -0x94(%rbp)
movl -0x94(%rbp), %eax
movl %eax, -0xb4(%rbp)
movq -0x28(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x16a5c6
movq -0x28(%rbp), %rax
movl (%rax), %ecx
movl $0x1, %eax
shll %cl, %eax
movl %eax, -0xb8(%rbp)
jmp 0x16a5d0
xorl %eax, %eax
movl %eax, -0xb8(%rbp)
jmp 0x16a5d0
movl -0xb4(%rbp), %eax
movl -0xb8(%rbp), %ecx
cmpl %ecx, %eax
je 0x16a622
movl -0x6c(%rbp), %ecx
subl $0x1, %ecx
movl $0x1, %edx
shll %cl, %edx
movq -0x78(%rbp), %rax
movq -0x28(%rbp), %rcx
movq 0x10(%rcx), %rcx
movl -0x94(%rbp), %esi
shlq $0x4, %rsi
addq %rsi, %rcx
movq 0x8(%rcx), %rcx
orl (%rax,%rcx,4), %edx
movl %edx, (%rax,%rcx,4)
movq -0x90(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x90(%rbp)
jmp 0x16a51c
movq -0x50(%rbp), %rdi
callq 0x2210
movq -0x48(%rbp), %rdi
callq 0x16a220
movq -0x40(%rbp), %rdi
callq 0x2380
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0xbc(%rbp)
movq -0x28(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x16a672
movq -0x28(%rbp), %rax
movl (%rax), %ecx
movl $0x1, %eax
shll %cl, %eax
movl %eax, -0xc0(%rbp)
jmp 0x16a67c
xorl %eax, %eax
movl %eax, -0xc0(%rbp)
jmp 0x16a67c
movl -0xbc(%rbp), %eax
movl -0xc0(%rbp), %ecx
cmpl %ecx, %eax
jae 0x16a6d9
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x1c(%rbp), %ecx
shrl $0x5, %ecx
movl %ecx, %ecx
movl (%rax,%rcx,4), %eax
movl -0x1c(%rbp), %ecx
andl $0x1f, %ecx
shrl %cl, %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x16a6c9
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x1c(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rdi
callq 0x2210
jmp 0x16a6cb
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x16a649
movq -0x28(%rbp), %rdi
callq 0x16a7a0
movq 0x2598f7(%rip), %rax    # 0x3c3fe0
movq (%rax), %rax
movq %rax, -0xd0(%rbp)
callq 0x1b7ca0
movsd %xmm0, -0xc8(%rbp)
callq 0x1b7d20
movq -0xd0(%rbp), %rdi
movaps %xmm0, %xmm1
movsd -0xc8(%rbp), %xmm0
leaq 0x21f999(%rip), %rsi    # 0x38a0b7
leaq 0x21f948(%rip), %rdx    # 0x38a06d
movb $0x2, %al
callq 0x22a0
movq -0x78(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xd0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)