// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/rcut.cpp
// Function: mb_solve_core(mc_opt_t*, mc_g_t*, kv_u_trans_t*, unsigned int)
void mb_solve_core(mc_opt_t *opt, mc_g_t *mg, kv_u_trans_t *ref, uint32_t is_sys)
{
	if(!ref) return;
	double index_time = yak_realtime();
	uint32_t st, i;
	mb_g_t *mbg = init_mb_g_t(mg->e, ref, is_sys);
	mb_svaux_t *bb;
	/**************************init**************************/
	if(VERBOSE_CUT)
	{
		fprintf(stderr, "\n\n\n\n\n*************beg-[M::%s::score->%f] ==> Partition\n", __func__, mc_score_all_advance(mg->e, mg->s.a));
	} 
	
	mc_svaux_t *b;
	mc_g_cc(mg->e);
	b = mc_svaux_init(mg, opt->seed);
	mc_init_spin_all(opt, mg, mbg, b);
	mc_svaux_destroy(b);
	free(mg->e->cc); 
	mg->e->cc = NULL;
	/**************************init**************************/
	mb_g_cc(mbg);
	bb = mb_svaux_init(mbg, opt->seed);
	
	if(VERBOSE_CUT)
	{
		fprintf(stderr, "*********before-[M::%s::mc_score->%f] ==> Partition\n", __func__, mc_score_all_advance(mg->e, mg->s.a));
		fprintf(stderr, "*********before-[M::%s::mb_score->%f] ==> Partition\n", __func__, mb_score_all_advance(mg->e, mbg));
		/*******************************for debug************************************/
		// print_mb_g_blcok(mbg);
		/*******************************for debug************************************/
	}
	
	
	opt->n_perturb = opt->n_b_perturb;
	for (st = 0, i = 1; i <= mbg->e->n_seq; ++i) {
		if (i == mbg->e->n_seq || mbg->e->cc[st]>>32 != mbg->e->cc[i]>>32) {
			mb_solve_cc(opt, mbg, bb, st, i - st);
			st = i;
		}
	}
	opt->n_perturb = opt->n_s_perturb - opt->n_b_perturb;
	
	mc_set_by_mbg(mg, mbg);
	if(VERBOSE_CUT)
	{
		/*******************************for debug************************************/
		// debug_mb_solve_core(mbg);
		/*******************************for debug************************************/
		fprintf(stderr, "##############end-[M::%s::score->%f] ==> Partition\n", __func__, mc_score_all_advance(mg->e, mg->s.a));
	}
	destory_mb_g_t(&mbg);
	mb_svaux_destroy(bb);
	fprintf(stderr, "[M::%s::%.3f] ==> Partition\n", __func__, yak_realtime()-index_time);
}

// Assembly:
testq %rdx, %rdx
jne 0x16ea6b
retq
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movl %ecx, %ebp
movq %rdx, %r15
movq %rsi, %rbx
movq %rdi, %r14
callq 0x1365ef
movsd %xmm0, (%rsp)
movq 0x28(%rbx), %rdi
movq %r15, %rsi
movl %ebp, %edx
callq 0x168217
movq %rax, %r15
movq %rax, 0x8(%rsp)
movq 0x28(%rbx), %r12
movq %r12, %rdi
callq 0x1696cc
movq %rax, 0x30(%r12)
movq 0x18(%r14), %rsi
movq %rbx, %rdi
callq 0x16992c
movq %rax, %r12
movq %rbx, %rsi
movq %r15, %rdx
movq %rax, %rcx
callq 0x16e1ef
movq %r12, %rdi
callq 0x169a43
movq 0x28(%rbx), %rax
movq 0x30(%rax), %rdi
callq 0x2220
movq 0x28(%rbx), %rax
movq $0x0, 0x30(%rax)
movq 0x8(%r15), %rdi
callq 0x16e721
movq 0x8(%r15), %rcx
movq %rax, 0x30(%rcx)
movq 0x18(%r14), %rsi
movq %r15, %rdi
callq 0x169aa9
movq %rax, %r12
movl 0x8(%r14), %ecx
movl %ecx, 0x4(%r14)
movq 0x8(%r15), %rax
movl 0x38(%rax), %edx
testl %edx, %edx
je 0x16eb6c
movl $0x1, %ebp
xorl %ecx, %ecx
cmpl %edx, %ebp
je 0x16eb45
movq 0x30(%rax), %rdx
movl %ecx, %esi
movl %ebp, %edi
movq (%rdx,%rdi,8), %rdi
xorq (%rdx,%rsi,8), %rdi
shrq $0x20, %rdi
je 0x16eb5f
movl %ebp, %r8d
subl %ecx, %r8d
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x16d9e1
movq 0x8(%r15), %rax
movl %ebp, %ecx
incl %ebp
movl 0x38(%rax), %edx
cmpl %edx, %ebp
jbe 0x16eb2b
movl 0x8(%r14), %ecx
movl 0xc(%r14), %eax
subl %ecx, %eax
movl %eax, 0x4(%r14)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x16e92b
leaq 0x8(%rsp), %rdi
callq 0x1688c0
movq %r12, %rdi
callq 0x169ba1
movq 0x126446(%rip), %rax    # 0x294fe0
movq (%rax), %rbx
callq 0x1365ef
subsd (%rsp), %xmm0
leaq 0xce71e(%rip), %rsi     # 0x23d2cc
leaq 0xce734(%rip), %rdx     # 0x23d2e9
movq %rbx, %rdi
movb $0x1, %al
callq 0x22b0
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq