// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/rcut.cpp
// Function: to_mc_g_t(kv_u_trans_t*, kv_gg_status*, unsigned int)
mc_g_t* to_mc_g_t(kv_u_trans_t *ta, kv_gg_status *s, uint32_t un)
{
	fprintf(stderr, "[M::%s]\n", __func__);
	uint32_t i, k;
	mc_edge_t *ma = NULL;
	mc_g_t *mg = NULL; CALLOC(mg, 1);
    

	CALLOC(mg->e, 1);
	mg->e->n_seq = un;
	kv_init(mg->e->idx); kv_init(mg->e->ma); 
	// double sc = get_w_scale(ta);
	// fprintf(stderr, "sc: %f\n", sc);
	for (i = 0; i < ta->n; ++i)
	{
		if(ta->a[i].del) continue;
		kv_pushp(mc_edge_t, mg->e->ma, &ma);
		ma->x = (uint64_t)ta->a[i].qn << 32 | ta->a[i].tn;
		// ma->w = w_cast((ta->a[i].nw*sc));
		ma->w = w_cast((ta->a[i].nw));
	}
	

	for (i = k = 0; i < mg->e->ma.n; i++)
    {
		if(mg->e->ma.a[i].w == 0) continue;
		mg->e->ma.a[k] = mg->e->ma.a[i];
        k++;
    }
    mg->e->ma.n = k;
	
	radix_sort_mce(mg->e->ma.a, mg->e->ma.a + mg->e->ma.n);
	mc_merge_dup(mg);
	mc_edges_idx(mg->e);
	mc_edges_symm(mg->e);

	kv_init(mg->s); 
	mg->s.m = mg->s.n = s->n; CALLOC(mg->s.a, mg->s.n);
	for (i = 0; i < mg->s.n; ++i)
	{
		if(s->a[i].s != 1 && s->a[i].s != 2) continue;
		mg->s.a[i] = (s->a[i].s == 1? 1:-1);
	}
	return mg;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %ebp
movq %rsi, (%rsp)
movq %rdi, %r12
movq 0x26a5ff(%rip), %rax    # 0x289fe0
movq (%rax), %rdi
leaq 0x2108d5(%rip), %rsi    # 0x2302c0
leaq 0x211880(%rip), %rdx    # 0x231272
xorl %eax, %eax
callq 0x22b0
pushq $0x1
popq %r15
pushq $0x30
popq %rsi
movq %r15, %rdi
callq 0x2120
movq %rax, %rbx
pushq $0x40
popq %rsi
movq %r15, %rdi
callq 0x2120
movq %rax, %r15
movq %rax, 0x28(%rbx)
movl %ebp, 0x38(%rax)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x20(%rax)
movupd %xmm0, 0x10(%rax)
movupd %xmm0, (%rax)
cmpq $0x0, (%r12)
je 0x1fac6
pushq $0x1
popq %rbp
xorl %eax, %eax
pushq $0x2
popq %r13
movq 0x10(%r12), %rcx
imulq $0x30, %rax, %r14
cmpb $0x0, 0x28(%rcx,%r14)
js 0x1fabc
movq 0x20(%r15), %rax
cmpq %rax, 0x18(%r15)
jne 0x1fa81
leaq (%rax,%rax), %rsi
testq %rax, %rax
cmoveq %r13, %rsi
movq %rsi, 0x20(%r15)
movq 0x28(%r15), %rdi
shlq $0x4, %rsi
callq 0x2370
movq %rax, 0x28(%r15)
movq 0x18(%r15), %rax
movq 0x28(%r15), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x18(%r15)
shlq $0x4, %rax
movq 0x10(%r12), %rdx
movl 0x8(%rdx,%r14), %esi
movl 0x14(%rdx,%r14), %edi
shlq $0x20, %rsi
orq %rsi, %rdi
movq %rdi, (%rcx,%rax)
movsd 0x20(%rdx,%r14), %xmm0
movsd %xmm0, 0x8(%rcx,%rax)
movl %ebp, %eax
incl %ebp
cmpq %rax, (%r12)
ja 0x1fa46
xorl %esi, %esi
cmpq $0x0, 0x18(%r15)
je 0x1fb14
pushq $0x1
popq %rax
xorpd %xmm0, %xmm0
xorl %ecx, %ecx
movq (%rsp), %r14
movq 0x28(%r15), %rdx
shlq $0x4, %rcx
movsd 0x8(%rdx,%rcx), %xmm1
ucomisd %xmm0, %xmm1
jne 0x1faf2
jnp 0x1fb06
addq %rdx, %rcx
movl %esi, %edi
shlq $0x4, %rdi
movupd (%rcx), %xmm1
movupd %xmm1, (%rdx,%rdi)
incl %esi
movl %eax, %ecx
incl %eax
cmpq %rcx, 0x18(%r15)
ja 0x1fadc
movl %esi, %esi
jmp 0x1fb18
movq (%rsp), %r14
movq %rsi, 0x18(%r15)
movq 0x28(%r15), %rdi
shlq $0x4, %rsi
addq %rdi, %rsi
callq 0x160033
movq %rbx, %rdi
callq 0x1607ec
movq %r15, %rdi
callq 0x16219e
movq %r15, %rdi
callq 0x162057
xorpd %xmm0, %xmm0
andq $0x0, 0x10(%rbx)
movupd %xmm0, (%rbx)
movq 0x8(%r14), %r15
movq %r15, (%rbx)
movq %r15, 0x8(%rbx)
pushq $0x1
popq %rsi
movq %r15, %rdi
callq 0x2120
movq %rax, 0x10(%rbx)
testq %r15, %r15
je 0x1fb9f
movq (%r14), %rcx
xorl %edx, %edx
movl (%rcx), %esi
leal -0x1(%rsi), %edi
cmpl $0x1, %edi
ja 0x1fb91
cmpl $0x1, %esi
setne %sil
negb %sil
orb $0x1, %sil
movb %sil, (%rax,%rdx)
incq %rdx
movl %edx, %esi
addq $0x20, %rcx
cmpq %rsi, %r15
ja 0x1fb75
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq