// File: /workspace/github_c_makefile_star2_O2/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, %r12
callq 0xaaeb
testq %rax, %rax
je 0x42ab
movq %rax, %r15
xorl %r14d, %r14d
pushq $0x1
popq %rsi
pushq $0x40
popq %rdx
xorl %edi, %edi
callq 0x72e4
movq %rax, %rbx
movups (%r12), %xmm0
movups %xmm0, (%rax)
movl 0x10(%r12), %eax
movl %eax, 0x10(%rbx)
movq %r15, 0x18(%rbx)
movq %r12, 0x30(%rsp)
movl (%r12), %esi
leaq 0x14(%rbx), %r12
movq %r15, %rdi
movq %r12, %rdx
callq 0x3f0c
movq %rax, 0x30(%rbx)
leaq 0x14366(%rip), %rax     # 0x183f0
cmpl $0x3, (%rax)
movq %r15, (%rsp)
jge 0x42bf
movq %rbx, 0x10(%rsp)
movl %ebp, %r15d
movslq %ebp, %rbp
pushq $0x8
popq %r13
xorl %edi, %edi
movq %rbp, %rsi
movq %r13, %rdx
callq 0x72e4
movq %rax, %r12
movq %rax, 0x18(%rsp)
xorl %edi, %edi
movq %rbp, %rsi
movq %r13, %rdx
callq 0x72e4
movq %rax, %r13
movq %rax, 0x20(%rsp)
movq (%rsp), %rax
movslq (%rax), %rsi
addq %rsi, %rsi
pushq $0x10
popq %rdx
xorl %edi, %edi
callq 0x72e4
movq %rax, 0x28(%rsp)
testl %ebp, %ebp
movl $0x0, %ebp
movl %r15d, 0x8(%rsp)
cmovgl %r15d, %ebp
cmpq %r14, %rbp
je 0x4116
callq 0x7327
movq %rax, (%r12,%r14,8)
callq 0x7327
movq %rax, (%r13,%r14,8)
incq %r14
jmp 0x40f9
movq (%rsp), %rax
movslq (%rax), %rcx
addq %rcx, %rcx
leaq 0x25c(%rip), %rsi       # 0x4383
leaq 0x10(%rsp), %rdx
movl 0x8(%rsp), %edi
callq 0x775c
leaq 0x142b4(%rip), %rax     # 0x183f0
cmpl $0x3, (%rax)
jge 0x4303
movq 0x28(%rsp), %r15
movq 0x18(%rbx), %rax
movl (%rax), %r12d
addl %r12d, %r12d
movq 0x30(%rsp), %rax
movl 0x8(%rax), %ecx
shll $0x2, %ecx
subl 0xc(%rax), %ecx
pushq $0x1
popq %r14
shll %cl, %r14d
xorl %r13d, %r13d
pushq $0x8
popq %rdx
xorl %edi, %edi
movq %r14, %rsi
callq 0x72e4
movq %rax, 0x28(%rbx)
testl %r12d, %r12d
cmovlel %r13d, %r12d
xorl %ecx, %ecx
cmpq %r12, %rcx
je 0x41be
movq %rcx, %rsi
shlq $0x4, %rsi
leaq (%r15,%rsi), %rdx
movl (%r15,%rsi), %esi
testl %esi, %esi
cmovlel %r13d, %esi
xorl %edi, %edi
cmpq %rdi, %rsi
je 0x41b9
movq 0x8(%rdx), %r8
movl 0x4(%r8,%rdi,8), %r8d
incq (%rax,%r8,8)
incq %rdi
jmp 0x41a2
incq %rcx
jmp 0x4186
andq $0x0, 0x20(%rbx)
xorl %ecx, %ecx
cmpq %rcx, %r14
je 0x41e3
movq 0x20(%rbx), %rdx
addq (%rax,%rcx,8), %rdx
movq %rdx, 0x20(%rbx)
subq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
incq %rcx
jmp 0x41c5
movq 0x20(%rbx), %rsi
shlq $0x2, %rsi
xorl %r13d, %r13d
xorl %edi, %edi
callq 0x7460
movq %rax, 0x38(%rbx)
cmpq %r12, %r13
je 0x423f
movq %r13, %rcx
shlq $0x4, %rcx
addq %r15, %rcx
xorl %edx, %edx
movslq (%rcx), %rsi
cmpq %rsi, %rdx
jge 0x423a
movq 0x8(%rcx), %rsi
movq (%rsi,%rdx,8), %rsi
movq 0x28(%rbx), %rdi
movq %rsi, %r8
shrq $0x20, %r8
movq (%rdi,%r8,8), %r9
leaq 0x1(%r9), %r10
movq %r10, (%rdi,%r8,8)
movl %esi, (%rax,%r9,4)
incq %rdx
jmp 0x420a
incq %r13
jmp 0x41f9
movq 0x28(%rbx), %rax
xorl %ecx, %ecx
xorl %edx, %edx
cmpq %rcx, %r14
je 0x425c
movq (%rax,%rcx,8), %rsi
movq %rdx, (%rax,%rcx,8)
incq %rcx
movq %rsi, %rdx
jmp 0x4247
leaq 0x1418d(%rip), %rax     # 0x183f0
cmpl $0x3, (%rax)
jge 0x4341
xorl %r14d, %r14d
cmpq %r14, %rbp
je 0x4295
movq 0x18(%rsp), %rax
movq (%rax,%r14,8), %rdi
callq 0x7330
movq 0x20(%rsp), %rax
movq (%rax,%r14,8), %rdi
callq 0x7330
incq %r14
jmp 0x426f
movq 0x28(%rsp), %rdi
callq 0x2050
movq 0x18(%rsp), %rdi
callq 0x2050
jmp 0x42ad
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x13d2a(%rip), %rax     # 0x17ff0
movq (%rax), %r13
callq 0x3801
movsd %xmm0, 0x8(%rsp)
callq 0x3852
movaps %xmm0, %xmm1
movl (%r12), %ecx
leaq 0xe2e1(%rip), %rsi      # 0x125c8
leaq 0xe2f7(%rip), %rdx      # 0x125e5
movq %r13, %rdi
movsd 0x8(%rsp), %xmm0
movb $0x2, %al
callq 0x21e0
jmp 0x4097
movq 0x13ce6(%rip), %rax     # 0x17ff0
movq (%rax), %r15
callq 0x3801
movsd %xmm0, (%rsp)
callq 0x3852
movaps %xmm0, %xmm1
leaq 0xe2cc(%rip), %rsi      # 0x125f2
leaq 0xe2b8(%rip), %rdx      # 0x125e5
movq %r15, %rdi
movsd (%rsp), %xmm0
movb $0x2, %al
callq 0x21e0
jmp 0x4145
movq 0x13ca8(%rip), %rax     # 0x17ff0
movq (%rax), %r14
callq 0x3801
movsd %xmm0, (%rsp)
callq 0x3852
movaps %xmm0, %xmm1
movq 0x20(%rbx), %rcx
leaq 0xe2b0(%rip), %rsi      # 0x12618
leaq 0xe276(%rip), %rdx      # 0x125e5
movq %r14, %rdi
movsd (%rsp), %xmm0
movb $0x2, %al
callq 0x21e0
jmp 0x426c