// File: /workspace/github_c_makefile_star2_O1/lh3[P]miniprot/index.c
// Function: mp_idx_build
mp_idx_t *mp_idx_build(const char *fn, const mp_idxopt_t *io, int32_t n_threads)
{
	mp_ntdb_t *nt;
	mp_idx_t *mi;
	worker_aux_t aux;
	int32_t i;

	nt = mp_ntseq_read(fn);
	if (nt == 0) return 0;

	mi = Kcalloc(0, mp_idx_t, 1);
	mi->opt = *io;
	mi->nt = nt;
	mi->bo = mp_idx_boff(mi->nt, io->bbit, &mi->n_block);
	if (mp_verbose >= 3)
		fprintf(stderr, "[M::%s@%.3f*%.2f] %d blocks\n", __func__, mp_realtime(), mp_percent_cpu(), mi->n_block);

	memset(&aux, 0, sizeof(aux));
	aux.mi = mi;
	aux.km = Kcalloc(0, void*, n_threads);
	aux.km_tmp = Kcalloc(0, void*, n_threads);
	aux.a = Kcalloc(0, mp64_v, nt->n_ctg * 2);
	for (i = 0; i < n_threads; ++i) {
		aux.km[i] = km_init();
		aux.km_tmp[i] = km_init();
	}
	kt_for(n_threads, build_worker, &aux, nt->n_ctg * 2);
	if (mp_verbose >= 3)
		fprintf(stderr, "[M::%s@%.3f*%.2f] collected syncmers\n", __func__, mp_realtime(), mp_percent_cpu());
	build_bidx(io, mi, aux.a);
	if (mp_verbose >= 3)
		fprintf(stderr, "[M::%s@%.3f*%.2f] %ld kmer-block pairs\n", __func__, mp_realtime(), mp_percent_cpu(), (long)mi->n_kb);

	for (i = 0; i < n_threads; ++i) {
		km_destroy(aux.km[i]);
		km_destroy(aux.km_tmp[i]);
	}
	free(aux.a); free(aux.km);
	return mi;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %edx, %ebp
movq %rsi, %r14
callq 0xc03f
testq %rax, %rax
je 0x4f83
movq %rax, %r15
movl $0x1, %esi
movl $0x40, %edx
xorl %edi, %edi
callq 0x7f34
movq %rax, %rbx
movups (%r14), %xmm0
movups %xmm0, (%rax)
movl 0x10(%r14), %eax
movl %eax, 0x10(%rbx)
movq %r15, 0x18(%rbx)
movl (%r14), %esi
leaq 0x14(%rbx), %r12
movq %r15, %rdi
movq %r12, %rdx
callq 0x4b98
movq %rax, 0x30(%rbx)
leaq 0x136b1(%rip), %rax     # 0x183e0
cmpl $0x3, (%rax)
jge 0x4f98
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movaps %xmm0, 0x20(%rsp)
movq %rbx, 0x10(%rsp)
movslq %ebp, %r12
movl $0x8, %edx
xorl %edi, %edi
movq %r12, %rsi
callq 0x7f34
movq %rax, 0x18(%rsp)
movl $0x8, %edx
xorl %edi, %edi
movq %r12, %rsi
callq 0x7f34
movq %rax, 0x20(%rsp)
movslq (%r15), %rsi
addq %rsi, %rsi
movl $0x10, %edx
xorl %edi, %edi
callq 0x7f34
movq %rax, 0x28(%rsp)
movl %ebp, %r13d
testl %r12d, %r12d
jle 0x4dbb
xorl %r12d, %r12d
callq 0x7f77
movq 0x18(%rsp), %rcx
movq %rax, (%rcx,%r12,8)
callq 0x7f77
movq 0x20(%rsp), %rcx
movq %rax, (%rcx,%r12,8)
incq %r12
cmpq %r12, %r13
jne 0x4d97
movq %r13, 0x30(%rsp)
movslq (%r15), %rcx
addq %rcx, %rcx
leaq 0x1ec(%rip), %rsi       # 0x4fb9
leaq 0x10(%rsp), %rdx
movl %ebp, 0xc(%rsp)
movl %ebp, %edi
callq 0x835c
leaq 0x135fc(%rip), %rax     # 0x183e0
cmpl $0x3, (%rax)
jge 0x4fa5
movq 0x28(%rsp), %r12
movq 0x18(%rbx), %rax
movl (%rax), %ebp
leal (,%rbp,2), %r13d
movl 0x8(%r14), %ecx
shll $0x2, %ecx
subl 0xc(%r14), %ecx
movl $0x1, %r15d
movl $0x1, %r14d
shll %cl, %r14d
movl $0x8, %edx
xorl %edi, %edi
movq %r14, %rsi
callq 0x7f34
movq %rax, 0x28(%rbx)
testl %ebp, %ebp
jle 0x4e6d
cmpl $0x2, %r13d
cmovgel %r13d, %r15d
xorl %ecx, %ecx
movq %rcx, %rsi
shlq $0x4, %rsi
movslq (%r12,%rsi), %rdx
testq %rdx, %rdx
jle 0x4e65
addq %r12, %rsi
movq 0x8(%rsi), %rsi
xorl %edi, %edi
movl 0x4(%rsi,%rdi,8), %r8d
incq (%rax,%r8,8)
incq %rdi
cmpq %rdi, %rdx
jne 0x4e54
incq %rcx
cmpq %r15, %rcx
jne 0x4e3b
movl %r13d, 0x8(%rsp)
movq %rbx, %r15
addq $0x20, %r15
movq $0x0, 0x20(%rbx)
xorl %ecx, %ecx
movq (%r15), %rdx
addq (%rax,%rcx,8), %rdx
movq %rdx, (%r15)
subq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
incq %rcx
cmpq %rcx, %r14
jne 0x4e83
movq 0x20(%rbx), %rsi
shlq $0x2, %rsi
xorl %edi, %edi
callq 0x80a1
movq %rbx, %r13
movq %rax, 0x38(%rbx)
testl %ebp, %ebp
jle 0x4f12
movl 0x8(%rsp), %edx
cmpl $0x2, %edx
movl $0x1, %ecx
cmovgel %edx, %ecx
xorl %edx, %edx
movq %rdx, %rsi
shlq $0x4, %rsi
cmpl $0x0, (%r12,%rsi)
jle 0x4f0a
addq %r12, %rsi
movq 0x8(%rsi), %rdi
movq 0x28(%r13), %r8
xorl %r9d, %r9d
movq (%rdi,%r9,8), %r10
movq %r10, %r11
shrq $0x20, %r11
movq (%r8,%r11,8), %rbp
leaq 0x1(%rbp), %rbx
movq %rbx, (%r8,%r11,8)
movl %r10d, (%rax,%rbp,4)
incq %r9
movslq (%rsi), %r10
cmpq %r10, %r9
jl 0x4ee4
incq %rdx
cmpq %rcx, %rdx
jne 0x4ec8
movq 0x28(%r13), %rax
xorl %ecx, %ecx
xorl %edx, %edx
movq (%rax,%rcx,8), %rsi
movq %rdx, (%rax,%rcx,8)
incq %rcx
movq %rsi, %rdx
cmpq %rcx, %r14
jne 0x4f1a
leaq 0x134ac(%rip), %rax     # 0x183e0
cmpl $0x3, (%rax)
movl 0xc(%rsp), %ebp
jge 0x4faf
testl %ebp, %ebp
movq 0x30(%rsp), %r15
jle 0x4f6d
xorl %r14d, %r14d
movq 0x18(%rsp), %rax
movq (%rax,%r14,8), %rdi
callq 0x7f98
movq 0x20(%rsp), %rax
movq (%rax,%r14,8), %rdi
callq 0x7f98
incq %r14
cmpq %r14, %r15
jne 0x4f49
movq 0x28(%rsp), %rdi
callq 0x2050
movq 0x18(%rsp), %rdi
callq 0x2050
jmp 0x4f86
xorl %r13d, %r13d
movq %r13, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r12, %rdi
callq 0x2994
jmp 0x4d38
callq 0x29dd
jmp 0x4ded
movq %r15, %rdi
callq 0x2a23
jmp 0x4f3d