// File: /workspace/github_c_makefile_star2_O2/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, 0x40(%rsp)
movl %edx, 0x3c(%rsp)
movl %esi, %r15d
movq %rdi, %r12
movq 0x28(%rdi), %rax
movq 0x8(%rax), %r14
leaq 0x3f(%r14), %rbp
shrq $0x6, %rbp
pushq $0x8
popq %rbx
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x2130
movq %rax, %r13
movq %rax, 0x10(%rsp)
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x2130
movq %rax, %rbx
movq %rax, 0x18(%rsp)
movq %rbp, %rdi
movq 0x40(%rsp), %rbp
pushq $0x8
popq %rsi
callq 0x2130
movq %rax, 0x20(%rsp)
movq %r12, 0x28(%rsp)
leal (,%rbp,2), %eax
cltq
cmpq %rax, %r14
jb 0xa516
movslq %ebp, %rdi
movl $0x170, %esi            # imm = 0x170
callq 0x2130
movq %rax, %rcx
movq %rax, 0x30(%rsp)
xorl %esi, %esi
leaq 0xa7d1(%rip), %rdi      # 0x14a60
cmpq $0x28, %rsi
je 0xa4f7
movq (%rsi,%rdi), %r8
movq %r14, %rax
xorl %edx, %edx
divq %r8
addq $0x8, %rsi
testq %rdx, %rdx
je 0xa28f
movq %r8, 0x8(%rsp)
xorl %eax, %eax
testl %ebp, %ebp
movl $0x0, %edx
movq %rbp, %rdi
cmovgl %ebp, %edx
imulq $0x170, %rdx, %rbp      # imm = 0x170
movl 0x3c(%rsp), %edx
cmpq %rax, %rbp
je 0xa2f5
movq %r12, 0x8(%rcx,%rax)
movl %r15d, 0x10(%rcx,%rax)
movl %edx, 0x14(%rcx,%rax)
movq %r13, 0x78(%rcx,%rax)
movq %rbx, 0x80(%rcx,%rax)
addq $0x170, %rax            # imm = 0x170
jmp 0xa2cd
leaq 0x239(%rip), %rsi       # 0xa535
leaq 0x8(%rsp), %rdx
movq %r14, %rcx
callq 0x11b74
pushq $0x1
popq %rdi
pushq $0x28
popq %rsi
callq 0x2130
movq %rax, %rbx
xorl %r15d, %r15d
xorl %r14d, %r14d
xorl %r13d, %r13d
xorl %r12d, %r12d
movq 0x30(%rsp), %rdi
cmpq %r15, %rbp
je 0xa4a1
movq 0x158(%rdi,%r15), %rcx
leaq (%rcx,%r13), %rax
cmpq %rax, %r12
jae 0xa3a0
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, %r12
shrq $0x10, %r12
orq %rax, %r12
incq %r12
movq %r12, 0x8(%rbx)
imulq $0x68, %r12, %rsi
movq %r14, %rdi
callq 0x21c0
movq %rax, %r14
movq %rax, 0x10(%rbx)
movq (%rbx), %r13
movq 0x30(%rsp), %rdi
movq 0x158(%rdi,%r15), %rcx
imulq $0x68, %r13, %rax
addq %r14, %rax
movq 0x168(%rdi,%r15), %rsi
imulq $0x68, %rcx, %rdx
movq %rax, %rdi
callq 0x2170
movq 0x30(%rsp), %rax
movq (%rbx), %r13
addq 0x158(%rax,%r15), %r13
movq %r13, (%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
jmp 0xa323
callq 0x2040
movq 0x10(%rsp), %rdi
callq 0x2040
movq 0x18(%rsp), %rdi
callq 0x2040
movq 0x20(%rsp), %rdi
callq 0x2040
movq %rbx, %rdi
callq 0xd01c
movq %rbx, %rdi
callq 0xd12c
movq %rbx, %rdi
callq 0xf92c
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 0xa4fc(%rip), %rdi      # 0x149fa
leaq 0xa39c(%rip), %rsi      # 0x148a1
leaq 0xa4b8(%rip), %rcx      # 0x149c4
movl $0x1a9, %edx            # imm = 0x1A9
callq 0x20e0
leaq 0xa48b(%rip), %rdi      # 0x149a8
leaq 0xa37d(%rip), %rsi      # 0x148a1
leaq 0xa499(%rip), %rcx      # 0x149c4
movl $0x1a1, %edx            # imm = 0x1A1
callq 0x20e0