// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/rcut.cpp
// Function: mcgg_solve_cc(mc_opt_t const*, mc_gg_t const*, mcgg_svaux_t*, unsigned int, unsigned int)
uint32_t mcgg_solve_cc(const mc_opt_t *opt, const mc_gg_t *mg, mcgg_svaux_t *b, uint32_t cc_off, uint32_t cc_size)
{
	// double t0, t1, tt0, tt1;
	uint32_t j, k, n_iter = 0, flush = opt->max_iter * 50;
    t_w_t sc_opt = -(1<<30), sc;///problem-w
    b->cc_off = cc_off, b->cc_size = cc_size;
    if (b->cc_size < 2) return 0;
	sc_opt = mcgg_init_spin(mg->e, b);
	if (b->cc_size == 2) return 0;
	for (j = 0; j < b->cc_size; ++j) back_status(b, b->cc_node[j], 1);

	sc = mcgg_optimize_local(opt, mg->e, b, &n_iter);
	if (sc > sc_opt)
	{
		for (j = 0; j < b->cc_size; ++j) back_status(b, b->cc_node[j], 1);
		sc_opt = sc;
	}
	else
	{
		for (j = 0; j < b->cc_size; ++j) back_status(b, b->cc_node[j], 0);
	}
	fprintf(stderr, "\nBeg-[M::%s::score->%f]\n", __func__, mcgg_score(mg->e, b));
	// print_mcgg_node(mg->e, b, 3838);
	// print_mcgg_node(mg->e, b, 36880);

	// tt0 = tt1 = 0;
	for (k = 0; k < (uint32_t)opt->n_perturb; ++k) {
		// t0 = yak_realtime();
        if (k&1) mcgg_perturb(opt, mg->e, b);
        else mcgg_perturb_node(opt, mg->e, b, 3);
		// tt0 += yak_realtime()-t0;

		// t1 = yak_realtime();
        sc = mcgg_optimize_local(opt, mg->e, b, &n_iter);
		// tt1 += yak_realtime()-t1;
		// fprintf(stderr, "++(%u) sc_after: %f\n", k, mcgg_score(mg->e, b));

        if (sc > sc_opt) {
            for (j = 0; j < b->cc_size; ++j) back_status(b, b->cc_node[j], 1);
			sc_opt = sc;
        } else {
            for (j = 0; j < b->cc_size; ++j) back_status(b, b->cc_node[j], 0);
        }

		
        if((n_iter%flush) == 0)
        {
            mcgg_reset_z(mg->e, b);
            sc = mcgg_score(mg->e, b);
            for (j = 0; j < b->cc_size; ++j) back_status(b, b->cc_node[j], 1);
			sc_opt = sc;
        }
		// fprintf(stderr, "\n");
		// print_mcgg_node(mg->e, b, 3838);
		// print_mcgg_node(mg->e, b, 36880);
		// if((k&31)==0)fprintf(stderr, "+++(%u) sc: %f, sc_opt: %f, tt0: %.3f, tt1: %.3f\n", k, sc, sc_opt, tt0, tt1);
    }

	for (j = 0; j < b->cc_size; ++j) back_status(b, b->cc_node[j], 0);
	fprintf(stderr, "End-[M::%s::score->%f]\n", __func__, mcgg_score(mg->e, b));
	return n_iter;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl $0x0, 0xc(%rsp)
imull $0x32, (%rdi), %eax
movl %eax, 0x24(%rsp)
movl %ecx, 0x8(%rdx)
movl %r8d, 0xc(%rdx)
xorl %ebp, %ebp
cmpl $0x2, %r8d
jb 0x170c13
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
movq 0x10(%rsi), %rdi
movq %rdx, %rsi
callq 0x17052b
movl 0xc(%rbx), %eax
cmpl $0x2, %eax
jne 0x170c24
movl %ebp, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movsd %xmm0, (%rsp)
leaq 0xc(%rbx), %rcx
movq %rcx, 0x18(%rsp)
testl %eax, %eax
je 0x170c43
movq %rbx, %rdi
movq 0x18(%rsp), %rsi
callq 0x1f5e9
movq 0x10(%r15), %rsi
leaq 0xc(%rsp), %rcx
movq %r14, %rdi
movq %rbx, %rdx
callq 0x1714ed
ucomisd (%rsp), %xmm0
movl 0xc(%rbx), %eax
jbe 0x170c6f
testl %eax, %eax
jne 0x170ce4
movsd %xmm0, (%rsp)
jmp 0x170d63
testl %eax, %eax
je 0x170d63
movq %r14, %r12
xorl %r14d, %r14d
movq 0x28(%rbx), %rax
movq 0x50(%rbx), %rcx
movl (%rax,%r14,4), %esi
movq 0x58(%rbx), %rax
movq %rsi, %rdx
shlq $0x5, %rdx
movupd (%rax,%rdx), %xmm0
movupd 0x10(%rax,%rdx), %xmm1
movupd %xmm1, 0x10(%rcx,%rdx)
movupd %xmm0, (%rcx,%rdx)
movq 0x40(%rbx), %rax
movq 0x48(%rbx), %rdx
movb 0x8(%rax), %cl
shll %cl, %esi
shlq $0x3, %rsi
movq (%rax), %rdi
addq %rsi, %rdi
movl $0x1, %eax
shll %cl, %eax
addq (%rdx), %rsi
movslq %eax, %rdx
shlq $0x3, %rdx
callq 0x2160
incq %r14
movl 0xc(%rbx), %eax
cmpq %rax, %r14
jb 0x170c7d
jmp 0x170d60
movsd %xmm0, 0x10(%rsp)
movq %r14, %r12
xorl %r14d, %r14d
movq 0x28(%rbx), %rax
movq 0x50(%rbx), %rcx
movl (%rax,%r14,4), %esi
movq %rsi, %rax
shlq $0x5, %rax
movq 0x58(%rbx), %rdx
movupd (%rcx,%rax), %xmm0
movupd 0x10(%rcx,%rax), %xmm1
movupd %xmm1, 0x10(%rdx,%rax)
movupd %xmm0, (%rdx,%rax)
movq 0x40(%rbx), %rax
movq 0x48(%rbx), %rdx
movb 0x8(%rax), %cl
shll %cl, %esi
shlq $0x3, %rsi
movq (%rdx), %rdi
addq %rsi, %rdi
movl $0x1, %edx
shll %cl, %edx
addq (%rax), %rsi
movslq %edx, %rdx
shlq $0x3, %rdx
callq 0x2160
incq %r14
movl 0xc(%rbx), %eax
cmpq %rax, %r14
jb 0x170cf0
movsd 0x10(%rsp), %xmm0
movsd %xmm0, (%rsp)
movq %r12, %r14
movq 0x124276(%rip), %rax    # 0x294fe0
movq (%rax), %r13
movq 0x10(%r15), %rdi
movq %rbx, %rsi
callq 0x1704b0
leaq 0xcc683(%rip), %rsi     # 0x23d403
leaq 0xcc695(%rip), %rdx     # 0x23d41c
movq %r13, %rdi
movb $0x1, %al
callq 0x22b0
cmpl $0x0, 0x4(%r14)
movq %r15, 0x28(%rsp)
jne 0x170da9
movq 0x18(%rsp), %rax
movl (%rax), %ecx
jmp 0x171445
movabsq $-0x40a7b892e31b1a47, %r11 # imm = 0xBF58476D1CE4E5B9
xorl %eax, %eax
movsd (%rsp), %xmm0
movq %rbx, 0x38(%rsp)
movq %r14, 0x30(%rsp)
movsd %xmm0, (%rsp)
movq 0x10(%r15), %rbp
movq %rax, 0x40(%rsp)
testb $0x1, %al
jne 0x171087
movq (%rbx), %rax
movabsq $-0x61c8864680b583eb, %rcx # imm = 0x9E3779B97F4A7C15
addq %rcx, %rax
movq %rax, %rcx
shrq $0x1e, %rcx
xorq %rax, %rcx
imulq %r11, %rcx
movq %rcx, %rax
shrq $0x1b, %rax
xorq %rcx, %rax
movabsq $-0x6b2fb644ecceee15, %rcx # imm = 0x94D049BB133111EB
imulq %rcx, %rax
movq %rax, %rcx
shrq $0x1f, %rcx
movl 0xc(%rbx), %edx
xorps %xmm1, %xmm1
cvtsi2sd %rdx, %xmm1
xorq %rax, %rcx
movsd 0x10(%r14), %xmm0
movq %rcx, (%rbx)
shrq $0xc, %rcx
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
orq %rax, %rcx
movq %rcx, %xmm2
addsd 0xc07ec(%rip), %xmm2    # 0x231638
mulsd %xmm1, %xmm2
addsd 0xbd1b8(%rip), %xmm2    # 0x22e010
cvttsd2si %xmm2, %rax
leal -0x1(%rdx), %ecx
cmpl %eax, %edx
cmoval %eax, %ecx
mulsd %xmm1, %xmm0
addl 0x8(%rbx), %ecx
movq 0x30(%rbp), %rax
movq (%rax,%rcx,8), %rax
cvttsd2si %xmm0, %ecx
movl %ecx, 0x10(%rsp)
movl %eax, %ecx
movq 0x30(%rbx), %rdx
movq 0x38(%rbx), %rsi
movl %eax, (%rdx)
movl %eax, (%rsi,%rcx,4)
xorl %r11d, %r11d
movl $0x1, %edi
xorl %r8d, %r8d
movl %edi, %r9d
cmpl %edi, %r11d
jae 0x170ef2
movq 0x10(%rbp), %r10
movl %r11d, %r11d
movl %r9d, %r12d
movl %r9d, %edi
movl (%rdx,%r11,4), %ecx
movq (%r10,%rcx,8), %r13
movq %r13, %r14
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
andq %rcx, %r14
je 0x170eea
shrq $0x20, %r13
movq 0x28(%rbp), %r15
movl %r13d, %ecx
shlq $0x4, %rcx
movl (%r15,%rcx), %ecx
cmpl %eax, (%rsi,%rcx,4)
je 0x170ee2
movl %edi, %ebx
incl %edi
movl %ecx, (%rdx,%rbx,4)
movl %eax, (%rsi,%rcx,4)
incq %r13
decq %r14
jne 0x170ec8
incq %r11
cmpq %r12, %r11
jne 0x170eab
movl 0x10(%rsp), %r10d
testl %r10d, %r10d
setne %cl
cmpl %r10d, %edi
seta %r10b
testb %r10b, %cl
jne 0x170f15
incl %r8d
movl %r9d, %r11d
cmpl $0x3, %r8d
jne 0x170e96
testl %edi, %edi
movq 0x38(%rsp), %rbx
movq 0x28(%rsp), %r15
movq 0x30(%rsp), %r14
movabsq $-0x40a7b892e31b1a47, %r11 # imm = 0xBF58476D1CE4E5B9
je 0x171259
movl %edi, %r13d
xorl %r12d, %r12d
movq (%rbx), %rax
movq 0x30(%rbx), %rcx
movl (%rcx,%r12,4), %r8d
movq 0x50(%rbx), %rdi
movq %r8, %r9
shlq $0x5, %r9
movzwl 0x4(%rdi,%r9), %edx
movzwl 0x6(%rdi,%r9), %ecx
cmpw $-0x1, %cx
je 0x170fcb
movabsq $-0x61c8864680b583eb, %rsi # imm = 0x9E3779B97F4A7C15
addq %rsi, %rax
movq %rax, %rsi
shrq $0x1e, %rsi
xorq %rax, %rsi
imulq %r11, %rsi
movq %rsi, %r10
shrq $0x1b, %r10
xorq %rsi, %r10
movabsq $-0x6b2fb644ecceee15, %rax # imm = 0x94D049BB133111EB
imulq %rax, %r10
movq %r10, %rax
shrq $0x1f, %rax
xorq %r10, %rax
movq %rax, %rsi
shrq $0xc, %rsi
movabsq $0x3ff0000000000000, %r10 # imm = 0x3FF0000000000000
orq %r10, %rsi
movq %rsi, %xmm0
addsd 0xc0676(%rip), %xmm0    # 0x231638
ucomisd 0x10(%rdi,%r9), %xmm0
ja 0x170fcd
movl %edx, %ecx
movzwl %cx, %ecx
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
addl %edx, %ecx
movabsq $-0x61c8864680b583eb, %rdx # imm = 0x9E3779B97F4A7C15
addq %rdx, %rax
movq %rax, %rdx
shrq $0x1e, %rdx
xorq %rax, %rdx
imulq %r11, %rdx
movq %rdx, %rax
shrq $0x1b, %rax
xorq %rdx, %rax
movabsq $-0x6b2fb644ecceee15, %rdx # imm = 0x94D049BB133111EB
imulq %rdx, %rax
movq %rax, %rsi
shrq $0x1f, %rsi
xorq %rax, %rsi
movq %rsi, (%rbx)
movq 0x60(%rbx), %rax
leaq (%rcx,%rcx,2), %rcx
movq (%rax,%rcx,8), %r10
movq 0x8(%rax,%rcx,8), %r11
movq %rsi, %rax
xorl %edx, %edx
divq %r11
movl %edx, %eax
movl (%r10,%rax,4), %ecx
cmpq $0x2, %r11
jb 0x17105e
cmpl (%rdi,%r9), %ecx
jne 0x17105e
decq %r11
movq %rsi, %rax
xorl %edx, %edx
divq %r11
movl %edx, %eax
cmpl %ecx, (%r10,%rax,4)
cmovneq %rdx, %r11
movl %r11d, %eax
movl (%r10,%rax,4), %ecx
movq %rbp, %rdi
movq %rbx, %rsi
movl %r8d, %edx
callq 0x1726fa
incq %r12
cmpq %r12, %r13
movabsq $-0x40a7b892e31b1a47, %r11 # imm = 0xBF58476D1CE4E5B9
jne 0x170f3c
jmp 0x171259
movq 0x18(%rsp), %rax
movl (%rax), %ecx
testl %ecx, %ecx
je 0x171259
xorl %r13d, %r13d
movq 0x30(%rbp), %rax
movl 0x8(%rbx), %edx
addl %r13d, %edx
movl (%rax,%rdx,8), %r8d
movq (%rbx), %rax
movabsq $-0x61c8864680b583eb, %rdx # imm = 0x9E3779B97F4A7C15
addq %rdx, %rax
movq %rax, %rdx
shrq $0x1e, %rdx
xorq %rax, %rdx
imulq %r11, %rdx
movq %rdx, %rsi
shrq $0x1b, %rsi
xorq %rdx, %rsi
movabsq $-0x6b2fb644ecceee15, %rax # imm = 0x94D049BB133111EB
imulq %rax, %rsi
movq %rsi, %rax
shrq $0x1f, %rax
xorq %rsi, %rax
movq %rax, (%rbx)
movq %rax, %rdx
shrq $0xc, %rdx
movabsq $0x3ff0000000000000, %rsi # imm = 0x3FF0000000000000
orq %rsi, %rdx
movq %rdx, %xmm0
addsd 0xc052d(%rip), %xmm0    # 0x231638
movsd 0x10(%r14), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x17124d
movq 0x50(%rbx), %rdi
movq %r8, %r9
shlq $0x5, %r9
movzwl 0x4(%rdi,%r9), %edx
movzwl 0x6(%rdi,%r9), %ecx
cmpw $-0x1, %cx
je 0x17119f
movabsq $-0x61c8864680b583eb, %rsi # imm = 0x9E3779B97F4A7C15
addq %rsi, %rax
movq %rax, %rsi
shrq $0x1e, %rsi
xorq %rax, %rsi
imulq %r11, %rsi
movq %rsi, %r10
shrq $0x1b, %r10
xorq %rsi, %r10
movabsq $-0x6b2fb644ecceee15, %rax # imm = 0x94D049BB133111EB
imulq %rax, %r10
movq %r10, %rax
shrq $0x1f, %rax
xorq %r10, %rax
movq %rax, %rsi
shrq $0xc, %rsi
movabsq $0x3ff0000000000000, %r10 # imm = 0x3FF0000000000000
orq %r10, %rsi
movq %rsi, %xmm0
addsd 0xc04a2(%rip), %xmm0    # 0x231638
ucomisd 0x10(%rdi,%r9), %xmm0
ja 0x1711a1
movl %edx, %ecx
movzwl %cx, %ecx
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
addl %edx, %ecx
movabsq $-0x61c8864680b583eb, %rdx # imm = 0x9E3779B97F4A7C15
addq %rdx, %rax
movq %rax, %rdx
shrq $0x1e, %rdx
xorq %rax, %rdx
imulq %r11, %rdx
movq %rdx, %rax
shrq $0x1b, %rax
xorq %rdx, %rax
movabsq $-0x6b2fb644ecceee15, %rdx # imm = 0x94D049BB133111EB
imulq %rdx, %rax
movq %rax, %rsi
shrq $0x1f, %rsi
xorq %rax, %rsi
movq %rsi, (%rbx)
movq 0x60(%rbx), %rax
leaq (%rcx,%rcx,2), %rcx
movq (%rax,%rcx,8), %r10
movq 0x8(%rax,%rcx,8), %r11
movq %rsi, %rax
xorl %edx, %edx
divq %r11
movl %edx, %eax
movl (%r10,%rax,4), %ecx
cmpq $0x2, %r11
jb 0x171232
cmpl (%rdi,%r9), %ecx
jne 0x171232
decq %r11
movq %rsi, %rax
xorl %edx, %edx
divq %r11
movl %edx, %eax
cmpl %ecx, (%r10,%rax,4)
cmovneq %rdx, %r11
movl %r11d, %eax
movl (%r10,%rax,4), %ecx
movq %rbp, %rdi
movq %rbx, %rsi
movl %r8d, %edx
callq 0x1726fa
movl 0xc(%rbx), %ecx
movabsq $-0x40a7b892e31b1a47, %r11 # imm = 0xBF58476D1CE4E5B9
incl %r13d
cmpl %ecx, %r13d
jb 0x171099
movq 0x10(%r15), %rsi
movq %r14, %rdi
movq %rbx, %rdx
leaq 0xc(%rsp), %rcx
callq 0x1714ed
movapd %xmm0, %xmm1
movsd (%rsp), %xmm0
ucomisd %xmm0, %xmm1
movl 0xc(%rbx), %eax
jbe 0x1712fd
testl %eax, %eax
je 0x171370
movsd %xmm1, 0x10(%rsp)
xorl %r12d, %r12d
movq 0x28(%rbx), %rax
movq 0x50(%rbx), %rcx
movl (%rax,%r12,4), %esi
movq %rsi, %rax
shlq $0x5, %rax
movq 0x58(%rbx), %rdx
movupd (%rcx,%rax), %xmm0
movupd 0x10(%rcx,%rax), %xmm1
movupd %xmm1, 0x10(%rdx,%rax)
movupd %xmm0, (%rdx,%rax)
movq 0x40(%rbx), %rax
movq 0x48(%rbx), %rdx
movb 0x8(%rax), %cl
shll %cl, %esi
shlq $0x3, %rsi
movq (%rdx), %rdi
addq %rsi, %rdi
movl $0x1, %edx
shll %cl, %edx
addq (%rax), %rsi
movslq %edx, %rdx
shlq $0x3, %rdx
callq 0x2160
incq %r12
movl 0xc(%rbx), %ecx
cmpq %rcx, %r12
jb 0x171290
movsd 0x10(%rsp), %xmm0
jmp 0x17137a
testl %eax, %eax
je 0x171378
xorl %r12d, %r12d
movq 0x28(%rbx), %rax
movq 0x50(%rbx), %rcx
movl (%rax,%r12,4), %esi
movq 0x58(%rbx), %rax
movq %rsi, %rdx
shlq $0x5, %rdx
movupd (%rax,%rdx), %xmm0
movupd 0x10(%rax,%rdx), %xmm1
movupd %xmm1, 0x10(%rcx,%rdx)
movupd %xmm0, (%rcx,%rdx)
movq 0x40(%rbx), %rax
movq 0x48(%rbx), %rdx
movb 0x8(%rax), %cl
shll %cl, %esi
shlq $0x3, %rsi
movq (%rax), %rdi
addq %rsi, %rdi
movl $0x1, %eax
shll %cl, %eax
addq (%rdx), %rsi
movslq %eax, %rdx
shlq $0x3, %rdx
callq 0x2160
incq %r12
movl 0xc(%rbx), %ecx
cmpq %rcx, %r12
jb 0x171304
movsd (%rsp), %xmm0
jmp 0x17137a
xorl %ecx, %ecx
movapd %xmm1, %xmm0
jmp 0x17137a
xorl %ecx, %ecx
movl 0xc(%rsp), %eax
xorl %edx, %edx
divl 0x24(%rsp)
testl %edx, %edx
movabsq $-0x40a7b892e31b1a47, %r11 # imm = 0xBF58476D1CE4E5B9
jne 0x171434
movq 0x10(%r15), %rdi
movq %rbx, %rsi
callq 0x1703e0
movq 0x10(%r15), %rdi
movq %rbx, %rsi
callq 0x1704b0
cmpl $0x0, 0xc(%rbx)
je 0x171428
movsd %xmm0, (%rsp)
xorl %r12d, %r12d
movq 0x28(%rbx), %rax
movq 0x50(%rbx), %rcx
movl (%rax,%r12,4), %esi
movq %rsi, %rax
shlq $0x5, %rax
movq 0x58(%rbx), %rdx
movupd (%rcx,%rax), %xmm0
movupd 0x10(%rcx,%rax), %xmm1
movupd %xmm1, 0x10(%rdx,%rax)
movupd %xmm0, (%rdx,%rax)
movq 0x40(%rbx), %rax
movq 0x48(%rbx), %rdx
movb 0x8(%rax), %cl
shll %cl, %esi
shlq $0x3, %rsi
movq (%rdx), %rdi
addq %rsi, %rdi
movl $0x1, %edx
shll %cl, %edx
addq (%rax), %rsi
movslq %edx, %rdx
shlq $0x3, %rdx
callq 0x2160
incq %r12
movl 0xc(%rbx), %ecx
cmpq %rcx, %r12
jb 0x1713bc
movsd (%rsp), %xmm0
jmp 0x17142a
xorl %ecx, %ecx
movabsq $-0x40a7b892e31b1a47, %r11 # imm = 0xBF58476D1CE4E5B9
movq 0x40(%rsp), %rax
incl %eax
cmpl 0x4(%r14), %eax
jb 0x170dc4
testl %ecx, %ecx
je 0x1714b1
xorl %r14d, %r14d
movq 0x28(%rbx), %rax
movq 0x50(%rbx), %rcx
movl (%rax,%r14,4), %esi
movq 0x58(%rbx), %rax
movq %rsi, %rdx
shlq $0x5, %rdx
movupd (%rax,%rdx), %xmm0
movupd 0x10(%rax,%rdx), %xmm1
movupd %xmm1, 0x10(%rcx,%rdx)
movupd %xmm0, (%rcx,%rdx)
movq 0x40(%rbx), %rax
movq 0x48(%rbx), %rdx
movb 0x8(%rax), %cl
shll %cl, %esi
shlq $0x3, %rsi
movq (%rax), %rdi
addq %rsi, %rdi
movl $0x1, %eax
shll %cl, %eax
addq (%rdx), %rsi
movslq %eax, %rdx
shlq $0x3, %rdx
callq 0x2160
incq %r14
movl 0xc(%rbx), %eax
cmpq %rax, %r14
jb 0x17144c
movq 0x123b28(%rip), %rax    # 0x294fe0
movq (%rax), %r15
movq 0x28(%rsp), %rax
movq 0x10(%rax), %rdi
movq %rbx, %rsi
callq 0x1704b0
leaq 0xcbf57(%rip), %rsi     # 0x23d42a
leaq 0xcbf42(%rip), %rdx     # 0x23d41c
movq %r15, %rdi
movb $0x1, %al
callq 0x22b0
movl 0xc(%rsp), %ebp
jmp 0x170c13