// File: 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
movq %rsp, %rbp
subq $0x80, %rsp
movl 0x40(%rbp), %eax
movl 0x38(%rbp), %eax
movq 0x30(%rbp), %rax
movq 0x28(%rbp), %rax
movl 0x20(%rbp), %eax
movq 0x18(%rbp), %rax
movl 0x10(%rbp), %eax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movsd %xmm0, -0x30(%rbp)
movq %r9, -0x38(%rbp)
cmpl $0x0, 0x40(%rbp)
je 0x2277f5
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movsd -0x30(%rbp), %xmm0
movl 0x10(%rbp), %r8d
movq 0x18(%rbp), %r9
movl 0x20(%rbp), %r11d
movq 0x28(%rbp), %r10
movq 0x30(%rbp), %rax
leaq 0x1667c4(%rip), %rdi    # 0x38dfa6
movl %r11d, (%rsp)
movq %r10, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x227930
leaq 0x19cffc(%rip), %rax    # 0x3c47f8
movl 0x1d0(%rax), %esi
leaq 0x19cfef(%rip), %rax    # 0x3c47f8
movsd 0x1d8(%rax), %xmm0
leaq 0x19cfe0(%rip), %rax    # 0x3c47f8
movq 0x1c8(%rax), %rdx
leaq -0x58(%rbp), %rdi
callq 0x216710
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq 0x18(%rbp), %rdx
movl 0x10(%rbp), %ecx
callq 0x216be0
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rdi
movq -0x8(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x10(%rbp), %rcx
movsd -0x30(%rbp), %xmm0
movl 0x20(%rbp), %r8d
callq 0x219bf0
movq 0x19c77b(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
movq -0x60(%rbp), %rax
movq 0x28(%rax), %rax
movq 0x18(%rax), %rax
movl %eax, %ecx
leaq 0x166736(%rip), %rsi    # 0x38dfb3
leaq 0x166746(%rip), %rdx    # 0x38dfca
movb $0x0, %al
callq 0x22a0
movq -0x60(%rbp), %rsi
movq 0x30(%rbp), %rdx
movl 0x20(%rbp), %ecx
leaq -0x58(%rbp), %rdi
callq 0x2253d0
movq -0x60(%rbp), %rsi
movq 0x28(%rbp), %rdx
movq 0x30(%rbp), %rcx
leaq -0x58(%rbp), %rdi
callq 0x2265f0
leaq 0x19cf3d(%rip), %rax    # 0x3c47f8
movl (%rax), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
je 0x2278df
cmpq $0x0, -0x10(%rbp)
je 0x2278df
movq -0x60(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x38(%rbp), %rdx
callq 0x227200
cmpl $0x0, 0x38(%rbp)
je 0x22790f
cmpq $0x0, -0x8(%rbp)
je 0x2278f9
movq -0x60(%rbp), %rdi
movq -0x8(%rbp), %rsi
callq 0x226ac0
cmpq $0x0, -0x18(%rbp)
je 0x22790d
movq -0x60(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x226f40
jmp 0x22790f
leaq -0x60(%rbp), %rdi
callq 0x218f10
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)