// File: /workspace/github_c_makefile_star2_O3/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 0xc2eb
testq %rax, %rax
je 0x52dc
movq %rax, %r15
movl $0x1, %esi
movl $0x40, %edx
xorl %edi, %edi
callq 0x8344
movq %rax, %rbx
movups (%r14), %xmm0
movups %xmm0, (%rax)
movl 0x10(%r14), %eax
movl %eax, 0x10(%rbx)
movq %r15, 0x18(%rbx)
movq %r14, 0x8(%rsp)
movl (%r14), %esi
leaq 0x14(%rbx), %r12
movq %r15, %rdi
movq %r12, %rdx
callq 0x4efc
movq %rax, 0x30(%rbx)
leaq 0x14352(%rip), %rax     # 0x193e0
cmpl $0x3, (%rax)
jge 0x52f0
movq %rbx, 0x10(%rsp)
movslq %ebp, %r14
movl $0x8, %edx
xorl %edi, %edi
movq %r14, %rsi
callq 0x8344
movq %rax, %r12
movq %rax, 0x18(%rsp)
movl $0x8, %edx
xorl %edi, %edi
movq %r14, %rsi
callq 0x8344
movq %rax, %r13
movq %rax, 0x20(%rsp)
movslq (%r15), %rsi
addq %rsi, %rsi
movl $0x10, %edx
xorl %edi, %edi
callq 0x8344
movq %rax, 0x28(%rsp)
movl %ebp, 0x4(%rsp)
movl %ebp, %ebp
testl %r14d, %r14d
jle 0x510d
xorl %r14d, %r14d
callq 0x8387
movq %rax, (%r12,%r14,8)
callq 0x8387
movq %rax, (%r13,%r14,8)
incq %r14
cmpq %r14, %rbp
jne 0x50f2
movq %rbp, 0x30(%rsp)
movslq (%r15), %rcx
addq %rcx, %rcx
leaq 0x1f2(%rip), %rsi       # 0x5311
leaq 0x10(%rsp), %rdx
movl 0x4(%rsp), %edi
callq 0x8760
leaq 0x142ac(%rip), %rax     # 0x193e0
cmpl $0x3, (%rax)
movq 0x8(%rsp), %r14
jge 0x52fd
movq 0x28(%rsp), %r12
movl 0x8(%r14), %ecx
movq 0x18(%rbx), %rax
movl (%rax), %r13d
leal (,%r13,2), %ebp
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 0x8344
movq %rax, 0x28(%rbx)
testl %r13d, %r13d
jle 0x51c3
cmpl $0x2, %ebp
cmovgel %ebp, %r15d
xorl %ecx, %ecx
movq %rcx, %rsi
shlq $0x4, %rsi
movslq (%r12,%rsi), %rdx
testq %rdx, %rdx
jle 0x51bb
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 0x51aa
incq %rcx
cmpq %r15, %rcx
jne 0x5191
movl %ebp, 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 0x51d8
movq 0x20(%rbx), %rsi
shlq $0x2, %rsi
xorl %edi, %edi
callq 0x84a5
movq %rbx, %rbp
movq %rax, 0x38(%rbx)
testl %r13d, %r13d
jle 0x5268
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 0x5260
addq %r12, %rsi
movq 0x8(%rsi), %rdi
movq 0x28(%rbp), %r8
xorl %r9d, %r9d
movq (%rdi,%r9,8), %r10
movq %r10, %r11
shrq $0x20, %r11
movq (%r8,%r11,8), %r13
leaq 0x1(%r13), %rbx
movq %rbx, (%r8,%r11,8)
movl %r10d, (%rax,%r13,4)
incq %r9
movslq (%rsi), %r10
cmpq %r10, %r9
jl 0x523a
incq %rdx
cmpq %rcx, %rdx
jne 0x521e
movq %rbp, %rbx
movq 0x28(%rbp), %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 0x5273
leaq 0x14153(%rip), %rax     # 0x193e0
cmpl $0x3, (%rax)
movl 0x4(%rsp), %ebp
jge 0x5307
testl %ebp, %ebp
movq 0x30(%rsp), %r15
jle 0x52c6
xorl %r14d, %r14d
movq 0x18(%rsp), %rax
movq (%rax,%r14,8), %rdi
callq 0x83a1
movq 0x20(%rsp), %rax
movq (%rax,%r14,8), %rdi
callq 0x83a1
incq %r14
cmpq %r14, %r15
jne 0x52a2
movq 0x28(%rsp), %rdi
callq 0x2050
movq 0x18(%rsp), %rdi
callq 0x2050
jmp 0x52de
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r12, %rdi
callq 0x296c
jmp 0x5097
callq 0x29b5
jmp 0x5142
movq %r15, %rdi
callq 0x29fb
jmp 0x5296