// File: /workspace/github_c_makefile_star2_O0/lh3[P]fermi-lite/misc.c
// Function: fml_mag2utg
fml_utg_t *fml_mag2utg(struct mag_t *g, int *n)
{
	size_t i, j;
	fml_utg_t *utg;
	khash_t(64) *h;
	khint_t k;

	h = kh_init(64);
	for (i = j = 0; i < g->v.n; ++i) {
		int absent;
		magv_t *p = &g->v.a[i];
		if (p->len < 0) continue;
		k = kh_put(64, h, p->k[0], &absent);
		kh_val(h, k) = j<<1 | 0;
		k = kh_put(64, h, p->k[1], &absent);
		kh_val(h, k) = j<<1 | 1;
		++j;
	}
	*n = j;
	kh_destroy(64, g->h);

	utg = (fml_utg_t*)calloc(*n, sizeof(fml_utg_t));
	for (i = j = 0; i < g->v.n; ++i) {
		magv_t *p = &g->v.a[i];
		fml_utg_t *q;
		int from, a, b;
		if (p->len < 0) continue;
		q = &utg[j++];
		q->len = p->len, q->nsr = p->nsr;
		q->seq = p->seq, q->cov = p->cov;
		for (a = 0; a < q->len; ++a)
			q->seq[a] = "$ACGTN"[(int)q->seq[a]];
		q->seq[q->len] = q->cov[q->len] = 0;
		for (from = 0; from < 2; ++from) {
			ku128_v *r = &p->nei[from];
			for (b = q->n_ovlp[from] = 0; b < r->n; ++b)
				if (!edge_is_del(r->a[b])) ++q->n_ovlp[from];
		}
		q->ovlp = (fml_ovlp_t*)calloc(q->n_ovlp[0] + q->n_ovlp[1], sizeof(fml_ovlp_t));
		for (from = a = 0; from < 2; ++from) {
			ku128_v *r = &p->nei[from];
			for (b = 0; b < r->n; ++b) {
				ku128_t *s = &r->a[b];
				fml_ovlp_t *t;
				if (edge_is_del(*s)) continue;
				t = &q->ovlp[a++];
				k = kh_get(64, h, s->x);
				assert(k != kh_end(h));
				t->id = kh_val(h, k) >> 1;
				t->to = kh_val(h, k) & 1;
				t->len = s->y;
				t->from = from;
			}
			free(p->nei[from].a);
		}
	}
	kh_destroy(64, h);
	free(g->v.a);
	free(g);
	return utg;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
callq 0x12470
movq %rax, -0x30(%rbp)
movq $0x0, -0x20(%rbp)
movq $0x0, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq -0x8(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x31ad
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
imulq $0x68, -0x18(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
cmpl $0x0, (%rax)
jge 0x312c
jmp 0x319c
movq -0x30(%rbp), %rdi
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rsi
leaq -0x38(%rbp), %rdx
callq 0x12b20
movl %eax, -0x34(%rbp)
movq -0x20(%rbp), %rdx
shlq %rdx
orq $0x0, %rdx
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x34(%rbp), %ecx
movq %rdx, (%rax,%rcx,8)
movq -0x30(%rbp), %rdi
movq -0x40(%rbp), %rax
movq 0x18(%rax), %rsi
leaq -0x38(%rbp), %rdx
callq 0x12b20
movl %eax, -0x34(%rbp)
movq -0x20(%rbp), %rdx
shlq %rdx
orq $0x1, %rdx
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x34(%rbp), %ecx
movq %rdx, (%rax,%rcx,8)
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x30fc
movq -0x20(%rbp), %rax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x12490
movq -0x10(%rbp), %rax
movslq (%rax), %rdi
movl $0x28, %esi
callq 0x2140
movq %rax, -0x28(%rbp)
movq $0x0, -0x20(%rbp)
movq $0x0, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq -0x8(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x35a7
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
imulq $0x68, -0x18(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
cmpl $0x0, (%rax)
jge 0x321e
jmp 0x3596
movq -0x28(%rbp), %rax
movq -0x20(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x20(%rbp)
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x48(%rbp), %rax
movl (%rax), %ecx
movq -0x50(%rbp), %rax
movl %ecx, (%rax)
movq -0x48(%rbp), %rax
movl 0x4(%rax), %ecx
movq -0x50(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x48(%rbp), %rax
movq 0x50(%rax), %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x48(%rbp), %rax
movq 0x58(%rax), %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x10(%rax)
movl $0x0, -0x58(%rbp)
movl -0x58(%rbp), %eax
movq -0x50(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x32bf
movq -0x50(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x58(%rbp), %rcx
movsbl (%rax,%rcx), %eax
movslq %eax, %rcx
leaq 0x220ae(%rip), %rax     # 0x25350
movb (%rax,%rcx), %dl
movq -0x50(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x58(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0x327d
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x50(%rbp), %rcx
movslq (%rcx), %rcx
movb $0x0, (%rax,%rcx)
movq -0x50(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x50(%rbp), %rcx
movslq (%rcx), %rcx
movb $0x0, (%rax,%rcx)
movl $0x0, -0x54(%rbp)
cmpl $0x2, -0x54(%rbp)
jge 0x3394
movq -0x48(%rbp), %rax
addq $0x20, %rax
movslq -0x54(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x68(%rbp)
movq -0x50(%rbp), %rax
movslq -0x54(%rbp), %rcx
movl $0x0, 0x18(%rax,%rcx,4)
movl $0x0, -0x5c(%rbp)
movslq -0x5c(%rbp), %rax
movq -0x68(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x3384
movq -0x68(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x5c(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
cmpq $-0x2, (%rax)
je 0x3377
movq -0x68(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x5c(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
cmpq $0x0, 0x8(%rax)
je 0x3377
movq -0x50(%rbp), %rax
movslq -0x54(%rbp), %rcx
movl 0x18(%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, 0x18(%rax,%rcx,4)
jmp 0x3379
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x3324
jmp 0x3386
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x32ec
movq -0x50(%rbp), %rax
movl 0x18(%rax), %eax
movq -0x50(%rbp), %rcx
addl 0x1c(%rcx), %eax
movslq %eax, %rdi
movl $0x8, %esi
callq 0x2140
movq %rax, %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x20(%rax)
movl $0x0, -0x58(%rbp)
movl $0x0, -0x54(%rbp)
cmpl $0x2, -0x54(%rbp)
jge 0x3594
movq -0x48(%rbp), %rax
addq $0x20, %rax
movslq -0x54(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x70(%rbp)
movl $0x0, -0x5c(%rbp)
movslq -0x5c(%rbp), %rax
movq -0x70(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x356a
movq -0x70(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x5c(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
cmpq $-0x2, (%rax)
je 0x342d
movq -0x78(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0x3432
jmp 0x355c
movq -0x50(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x58(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x58(%rbp)
movslq %ecx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x80(%rbp)
movq -0x30(%rbp), %rdi
movq -0x78(%rbp), %rax
movq (%rax), %rsi
callq 0x12560
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x30(%rbp), %rcx
cmpl (%rcx), %eax
je 0x3473
jmp 0x3492
leaq 0x21edd(%rip), %rdi     # 0x25357
leaq 0x21ee5(%rip), %rsi     # 0x25366
movl $0xc8, %edx
leaq 0x21ee0(%rip), %rcx     # 0x2536d
callq 0x20f0
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x34(%rbp), %ecx
movq (%rax,%rcx,8), %rax
shrq %rax
movl %eax, %ecx
movq -0x80(%rbp), %rax
movl %ecx, %ecx
movl %ecx, %edx
movq (%rax), %rcx
andq $0x7fffffff, %rdx       # imm = 0x7FFFFFFF
shlq $0x20, %rdx
movabsq $-0x7fffffff00000001, %rsi # imm = 0x80000000FFFFFFFF
andq %rsi, %rcx
orq %rdx, %rcx
movq %rcx, (%rax)
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x34(%rbp), %ecx
movq (%rax,%rcx,8), %rax
andq $0x1, %rax
movl %eax, %ecx
movq -0x80(%rbp), %rax
movl %ecx, %ecx
movl %ecx, %edx
movq (%rax), %rcx
andq $0x1, %rdx
shlq $0x3f, %rdx
movabsq $0x7fffffffffffffff, %rsi # imm = 0x7FFFFFFFFFFFFFFF
andq %rsi, %rcx
orq %rdx, %rcx
movq %rcx, (%rax)
movq -0x78(%rbp), %rax
movq 0x8(%rax), %rax
movl %eax, %ecx
movq -0x80(%rbp), %rax
movl %ecx, %ecx
movl %ecx, %edx
movq (%rax), %rcx
andq $0x7fffffff, %rdx       # imm = 0x7FFFFFFF
andq $-0x80000000, %rcx      # imm = 0x80000000
orq %rdx, %rcx
movq %rcx, (%rax)
movl -0x54(%rbp), %ecx
movq -0x80(%rbp), %rax
movl %ecx, %ecx
movl %ecx, %edx
movq (%rax), %rcx
andq $0x1, %rdx
shlq $0x1f, %rdx
movabsq $-0x80000001, %rsi      # imm = 0xFFFFFFFF7FFFFFFF
andq %rsi, %rcx
orq %rdx, %rcx
movq %rcx, (%rax)
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x33f0
movq -0x48(%rbp), %rax
addq $0x20, %rax
movslq -0x54(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rdi
callq 0x2040
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x33c8
jmp 0x3596
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x31eb
movq -0x30(%rbp), %rdi
callq 0x12490
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x2040
movq -0x8(%rbp), %rdi
callq 0x2040
movq -0x28(%rbp), %rax
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)