// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/rcut.cpp
// Function: mc_solve(hap_overlaps_list*, trans_chain*, kv_u_trans_t*, ma_ug_t*, asg_t*, double, unsigned char*, unsigned int, signed char*, unsigned int, bubble_type*, kv_u_trans_t*, int, int)
void mc_solve(hap_overlaps_list* ovlp, trans_chain* t_ch, kv_u_trans_t *ta, ma_ug_t *ug, asg_t *read_g, double f_rate, uint8_t* trio_flag, uint32_t renew_s, int8_t *s, uint32_t is_sys, bubble_type* bub, kv_u_trans_t *ref, int clean_ov, int is_dump)
{
	if(is_dump) {
		dump_debug_phasing(MC_NAME, ta, ug, read_g, f_rate, renew_s, s, is_sys, bub, ref);
		// bub = NULL;
	}
	
	mc_opt_t opt;
	mc_opt_init(&opt, asm_opt.n_perturb, asm_opt.f_perturb, asm_opt.seed);
	mc_g_t *mg = init_mc_g_t(ug, read_g, s, renew_s);
	update_mc_edges(mg, ovlp, ta, t_ch, f_rate, is_sys);

	fprintf(stderr, "[M::%s:: # edges: %u]\n", __func__, (uint32_t)mg->e->ma.n);
	
	mb_solve_core(&opt, mg, ref, is_sys);
	///debug_mc_g_t(mg);
	// if(renew_s == 0) write_mc_g_t(&opt, mg, MC_NAME);
	// mc_solve_core(&opt, mg, bub);
	mc_solve_core_adv(&opt, mg, bub, ref);

	if((asm_opt.flag & HA_F_PARTITION) && t_ch)
	{
		p_nodes(mg, t_ch, trio_flag);
	}

	if(clean_ov){
		if(ovlp) clean_ovlp_by_mc(mg, ovlp);
		if(ta) clean_ta_by_mc(mg, ta);
	}
	// print_hap_s(s, ug->u.n);

	destory_mc_g_t(&mg);	
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %r9, 0x18(%rsp)
movsd %xmm0, 0x10(%rsp)
movq %r8, %r13
movq %rcx, %r15
movq %rdx, %r14
movq %rsi, %r12
movq %rdi, %rbx
movq 0x88(%rsp), %r9
movl 0x80(%rsp), %ecx
cmpl $0x0, 0xb0(%rsp)
je 0x1ee79
subq $0x8, %rsp
leaq 0x212300(%rip), %rdi    # 0x231136
movq %r14, %rsi
movq %r15, %rdx
movq %r13, %rcx
movsd 0x18(%rsp), %xmm0
movl 0x88(%rsp), %r8d
movq %r9, %rbp
pushq 0xa8(%rsp)
pushq 0xa8(%rsp)
movl 0xa8(%rsp), %eax
pushq %rax
callq 0x1efd0
movq %rbp, %r9
movl 0xa0(%rsp), %ecx
addq $0x20, %rsp
leaq 0x26b8d8(%rip), %rdx    # 0x28a758
movl 0x1d0(%rdx), %eax
movsd 0x1d8(%rdx), %xmm0
movq 0x1c8(%rdx), %rdx
xorps %xmm1, %xmm1
leaq 0x20(%rsp), %rbp
movaps %xmm1, (%rbp)
movaps %xmm1, 0x10(%rbp)
movl %eax, 0x4(%rbp)
movsd %xmm0, 0x10(%rbp)
movl $0x3e8, (%rbp)          # imm = 0x3E8
movq %rdx, 0x18(%rbp)
cvtsi2sd %eax, %xmm0
mulsd 0x20662c(%rip), %xmm0   # 0x2254f0
movl %eax, 0xc(%rbp)
cvttsd2si %xmm0, %eax
movl %eax, 0x8(%rbp)
movq %r15, %rdi
movq %r13, %rsi
movq %r9, %rdx
callq 0x160a18
movq %rax, 0x8(%rsp)
movq %rax, %rdi
movq %rbx, %r15
movq %rbx, %rsi
movq %r14, %rdx
movq %r12, %rcx
movsd 0x10(%rsp), %xmm0
movl 0x90(%rsp), %ebx
movl %ebx, %r8d
callq 0x1623a2
movq 0x26b0d4(%rip), %rax    # 0x289fe0
movq (%rax), %rdi
movq 0x8(%rsp), %rax
movq 0x28(%rax), %rax
movl 0x18(%rax), %ecx
leaq 0x212221(%rip), %rsi    # 0x231143
leaq 0x212231(%rip), %rdx    # 0x23115a
xorl %eax, %eax
callq 0x22b0
movq 0x8(%rsp), %rsi
movq %rbp, %rdi
movq 0xa0(%rsp), %r13
movq %r13, %rdx
movl %ebx, %ecx
callq 0x167ffd
movq 0x8(%rsp), %rsi
movq %rbp, %rdi
movq 0x98(%rsp), %rdx
movq %r13, %rcx
callq 0x1ec27
testq %r12, %r12
je 0x1ef89
movl $0x800, %eax            # imm = 0x800
leaq 0x26b7e5(%rip), %rcx    # 0x28a758
andl (%rcx), %eax
je 0x1ef89
movq 0x8(%rsp), %rdi
movq %r12, %rsi
movq 0x18(%rsp), %rdx
callq 0x168fbf
cmpl $0x0, 0xa8(%rsp)
je 0x1efb7
testq %r15, %r15
je 0x1efa5
movq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x168b84
testq %r14, %r14
je 0x1efb7
movq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x168e1e
leaq 0x8(%rsp), %rdi
callq 0x161f4e
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq