// File: /workspace/github_cpp_makefile_star2_O2/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 0x12a45d
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 0xefea7
movsd %xmm0, (%rsp)
movq 0x28(%rbx), %rdi
movq %r15, %rsi
movl %ebp, %edx
callq 0x123786
movq %rax, %r15
movq %rax, 0x8(%rsp)
movq 0x28(%rbx), %rdi
callq 0x12512f
movq 0x18(%r14), %rsi
movq %rbx, %rdi
callq 0x125338
movq %rax, %r12
movq %rbx, %rsi
movq %r15, %rdx
movq %rax, %rcx
callq 0x129c1f
movq %r12, %rdi
callq 0x12542d
movq 0x28(%rbx), %rax
movq 0x30(%rax), %rdi
callq 0x2220
movq 0x28(%rbx), %rax
andq $0x0, 0x30(%rax)
movq %r15, %rdi
callq 0x12a22a
movq 0x18(%r14), %rsi
movq %r15, %rdi
callq 0x125490
movq %rax, %r12
movl 0x8(%r14), %eax
movl %eax, 0x4(%r14)
xorl %ecx, %ecx
pushq $0x1
popq %rbp
movq 0x8(%r15), %rax
cmpl 0x38(%rax), %ebp
ja 0x12a537
je 0x12a51d
movq 0x30(%rax), %rax
movl %ecx, %edx
movl %ebp, %esi
movq (%rax,%rsi,8), %rsi
xorq (%rax,%rdx,8), %rsi
shrq $0x20, %rsi
je 0x12a533
movl %ebp, %r8d
subl %ecx, %r8d
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x1293a7
movl %ebp, %ecx
incl %ebp
jmp 0x12a4fc
movl 0xc(%r14), %eax
subl 0x8(%r14), %eax
movl %eax, 0x4(%r14)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x12a241
leaq 0x8(%rsp), %rdi
callq 0x123d53
movq %r12, %rdi
callq 0x125562
movq 0x128a79(%rip), %rax    # 0x252fe0
movq (%rax), %rbx
callq 0xefea7
subsd (%rsp), %xmm0
leaq 0xc4c11(%rip), %rsi     # 0x1ef18c
leaq 0xc4c27(%rip), %rdx     # 0x1ef1a9
movq %rbx, %rdi
movb $0x1, %al
callq 0x22b0
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq