// File: /workspace/github_c_makefile_star2_O1/lh3[P]fermi-lite/unitig.c
// Function: fml_fmi2mag_core
mag_t *fml_fmi2mag_core(const rld_t *e, int min_match, int min_merge_len, int n_threads)
{
	extern void kt_for(int n_threads, void (*func)(void*,long,int), void *data, long n);
	worker_t w;
	int j;
	mag_t *g;

	w.used    = (uint64_t*)calloc((e->mcnt[1] + 63)/64, 8);
	w.bend    = (uint64_t*)calloc((e->mcnt[1] + 63)/64, 8);
	w.visited = (uint64_t*)calloc((e->mcnt[1] + 63)/64, 8);
	w.e       = e;
	assert(e->mcnt[1] >= n_threads * 2);
	w.d = calloc(n_threads, sizeof(thrdat_t));
	w.prime = 0;
	for (j = 0; utg_primes[j] > 0; ++j)
		if (e->mcnt[1] % utg_primes[j] != 0) {
			w.prime = utg_primes[j];
			break;
		}
	assert(w.prime);
	for (j = 0; j < n_threads; ++j) {
		w.d[j].a.e = e; w.d[j].a.min_match = min_match; w.d[j].a.min_merge_len = min_merge_len;
		w.d[j].a.used = w.used; w.d[j].a.bend = w.bend;
	}
	kt_for(n_threads, worker, &w, e->mcnt[1]);
	g = (mag_t*)calloc(1, sizeof(mag_t));
	for (j = 0; j < n_threads; ++j) {
		kv_resize(magv_t, g->v, g->v.n + w.d[j].v.n);
		memcpy(g->v.a + g->v.n, w.d[j].v.a, w.d[j].v.n * sizeof(magv_t));
		g->v.n += w.d[j].v.n;
		free(w.d[j].v.a);
		free(w.d[j].a.a[0].a); free(w.d[j].a.a[1].a); free(w.d[j].a.nei.a); free(w.d[j].a.cat.a);
		free(w.d[j].z.nei[0].a); free(w.d[j].z.nei[1].a); free(w.d[j].z.seq); free(w.d[j].z.cov);
		free(w.d[j].a.str.s); free(w.d[j].str.s); free(w.d[j].cov.s);
	}
	free(w.d); free(w.used); free(w.bend); free(w.visited);

	mag_g_build_hash(g);
	mag_g_amend(g);
	g->rdist = mag_cal_rdist(g);
	return g;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rcx, 0x38(%rsp)
movl %edx, %ebp
movl %esi, %r15d
movq %rdi, %r12
movq 0x28(%rdi), %rax
movq 0x8(%rax), %rbx
leaq 0x3f(%rbx), %r14
shrq $0x6, %r14
movl $0x8, %esi
movq %r14, %rdi
movq %r14, 0x40(%rsp)
callq 0x2130
movq %rax, %r13
movq %rax, 0x10(%rsp)
movl $0x8, %esi
movq %r14, %rdi
callq 0x2130
movq %rax, %r14
movq %rax, 0x18(%rsp)
movl $0x8, %esi
movq 0x40(%rsp), %rdi
callq 0x2130
movq 0x38(%rsp), %rcx
movq %rax, 0x20(%rsp)
movq %r12, 0x28(%rsp)
leal (%rcx,%rcx), %eax
cltq
cmpq %rax, %rbx
jb 0xbc17
movslq %ecx, %rdi
movl $0x170, %esi            # imm = 0x170
callq 0x2130
movq %rax, %rcx
movq %rax, 0x30(%rsp)
movq $0x0, 0x8(%rsp)
movl $0x1e241, %esi          # imm = 0x1E241
movl $0x1, %edi
leaq 0xc097(%rip), %r8       # 0x17a40
movq %rbx, %rax
xorl %edx, %edx
divq %rsi
testq %rdx, %rdx
jne 0xb9c5
movq (%r8,%rdi,8), %rsi
incq %rdi
cmpq $0x6, %rdi
jne 0xb9a9
jmp 0xb9ca
movq %rsi, 0x8(%rsp)
cmpq $0x0, 0x8(%rsp)
je 0xbc36
movq 0x38(%rsp), %rdi
movl %edi, %esi
testl %edi, %edi
jle 0xba11
imulq $0x170, %rsi, %rax      # imm = 0x170
xorl %edx, %edx
movq %r12, 0x8(%rcx,%rdx)
movl %r15d, 0x10(%rcx,%rdx)
movl %ebp, 0x14(%rcx,%rdx)
movq %r13, 0x78(%rcx,%rdx)
movq %r14, 0x80(%rcx,%rdx)
addq $0x170, %rdx            # imm = 0x170
cmpq %rdx, %rax
jne 0xb9ea
movq %rsi, %r15
leaq 0x23a(%rip), %rsi       # 0xbc55
leaq 0x8(%rsp), %rdx
movq %rdi, %r14
movq %rbx, %rcx
callq 0x13f60
movl $0x1, %edi
movl $0x28, %esi
callq 0x2130
movq %rax, %rbx
testl %r14d, %r14d
jle 0xbbbc
imulq $0x170, %r15, %r14      # imm = 0x170
xorl %r15d, %r15d
movq 0x30(%rsp), %rax
movq 0x158(%rax,%r15), %rax
addq (%rbx), %rax
cmpq %rax, 0x8(%rbx)
jae 0xbab2
decq %rax
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x10, %rcx
orq %rax, %rcx
incq %rcx
movq %rcx, 0x8(%rbx)
movq 0x10(%rbx), %rdi
imulq $0x68, %rcx, %rsi
callq 0x21d0
movq %rax, 0x10(%rbx)
imulq $0x68, (%rbx), %rdi
addq 0x10(%rbx), %rdi
movq 0x30(%rsp), %rax
movq 0x168(%rax,%r15), %rsi
imulq $0x68, 0x158(%rax,%r15), %rdx
callq 0x2180
movq 0x30(%rsp), %rax
movq 0x158(%rax,%r15), %rcx
addq %rcx, (%rbx)
movq 0x168(%rax,%r15), %rdi
callq 0x2040
movq 0x30(%rsp), %rax
movq 0x28(%rax,%r15), %rdi
callq 0x2040
movq 0x30(%rsp), %rax
movq 0x40(%rax,%r15), %rdi
callq 0x2040
movq 0x30(%rsp), %rax
movq 0x58(%rax,%r15), %rdi
callq 0x2040
movq 0x30(%rsp), %rax
movq 0x70(%rax,%r15), %rdi
callq 0x2040
movq 0x30(%rsp), %rax
movq 0x120(%rax,%r15), %rdi
callq 0x2040
movq 0x30(%rsp), %rax
movq 0x138(%rax,%r15), %rdi
callq 0x2040
movq 0x30(%rsp), %rax
movq 0x140(%rax,%r15), %rdi
callq 0x2040
movq 0x30(%rsp), %rax
movq 0x148(%rax,%r15), %rdi
callq 0x2040
movq 0x30(%rsp), %rax
movq 0x98(%rax,%r15), %rdi
callq 0x2040
movq 0x30(%rsp), %rax
movq 0xd0(%rax,%r15), %rdi
callq 0x2040
movq 0x30(%rsp), %rax
movq 0xe8(%rax,%r15), %rdi
callq 0x2040
addq $0x170, %r15            # imm = 0x170
cmpq %r15, %r14
jne 0xba50
movq 0x30(%rsp), %rdi
callq 0x2040
movq 0x10(%rsp), %rdi
callq 0x2040
movq 0x18(%rsp), %rdi
callq 0x2040
movq 0x20(%rsp), %rdi
callq 0x2040
movq %rbx, %rdi
callq 0xea7d
movq %rbx, %rdi
callq 0xeb8d
movq %rbx, %rdi
callq 0x11b34
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x18(%rbx)
movq %rbx, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xbd6a(%rip), %rdi      # 0x17988
leaq 0xbc5c(%rip), %rsi      # 0x17881
leaq 0xbd78(%rip), %rcx      # 0x179a4
movl $0x1a1, %edx            # imm = 0x1A1
callq 0x20e0
leaq 0xbd9d(%rip), %rdi      # 0x179da
leaq 0xbc3d(%rip), %rsi      # 0x17881
leaq 0xbd59(%rip), %rcx      # 0x179a4
movl $0x1a9, %edx            # imm = 0x1A9
callq 0x20e0