// File: /workspace/github_c_makefile_star2_O0/c-zhou[P]oatk/path.c
// Function: estimate_arc_copy_number_siman_impl
static void estimate_arc_copy_number_siman_impl(func_t *funcs, int n_func, var_t **vars, int n_var, int *res)
{
    int i, iter, n_iter;
    double optim_cost, current_cost, new_cost, temp0, temp, p;
    var_t *var;

    current_cost = fvals(funcs, n_func);
    optim_cost = current_cost;
    copy_results(vars, n_var, res);
    
    srand(1234);
    temp0 = SA_TEMPERATURE;
    n_iter = 0;
    for (iter = 0; iter < SA_MAX_ATTEMPTS; ++iter) {
        temp = temp0;
        while (temp > 1e-6) {
            // random select a var to update 
            i = rand() % n_var;
            // record the old var
            var = vars[i];
            // take a random walk to either prev or next
            random_walk_to_neighbour(&vars[i]);
            // calculate new cost
            new_cost = fvals(funcs, n_func);
            // record optim solution
            if (new_cost < optim_cost) {
                optim_cost = new_cost;
                copy_results(vars, n_var, res);
            }
            // acceptance probability
            p = exp(-(new_cost - current_cost) / temp);
            if (new_cost < current_cost || (double) rand() / RAND_MAX < p) {
                // accept update and update cost
                current_cost = new_cost;
            } else {
                // rollback to reject the update
                vars[i] = var;
            }
            // cooling down
            temp *= SA_COOLING_RATE;
            ++n_iter;
        }
        if (optim_cost == 0) break;
        // continue searching from the best solution so far
        temp0 *= SA_RESTART_TEMP;
        set_vars(vars, n_var, res);
#ifdef DEBUG_SIM_ANNEAL_OPTIM
        fprintf(stderr, "[DEBUG_SIM_ANNEAL_OPTIM::%s] optimization after %d iteration [%d attempts] with a minimum fval: %.6f\n",
                __func__, iter, n_iter, optim_cost);
#endif

    }
#ifdef DEBUG_SIM_ANNEAL_OPTIM
    fprintf(stderr, "[DEBUG_SIM_ANNEAL_OPTIM::%s] simulated annealing search finished after %d attempts with a minimum fval: %.6f\n",
            __func__, n_iter, optim_cost);
#endif
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq %r8, -0x28(%rbp)
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0x13780
movsd %xmm0, -0x48(%rbp)
movsd -0x48(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
movq -0x18(%rbp), %rdi
movl -0x1c(%rbp), %esi
movq -0x28(%rbp), %rdx
callq 0x13930
movl $0x4d2, %edi            # imm = 0x4D2
callq 0x2230
movsd 0x1d709(%rip), %xmm0    # 0x234d0
movsd %xmm0, -0x58(%rbp)
movl $0x0, -0x34(%rbp)
movl $0x0, -0x30(%rbp)
cmpl $0x64, -0x30(%rbp)
jge 0x5f4e
movsd -0x58(%rbp), %xmm0
movsd %xmm0, -0x60(%rbp)
movsd -0x60(%rbp), %xmm0
movsd 0x1d6dd(%rip), %xmm1    # 0x234d8
ucomisd %xmm1, %xmm0
jbe 0x5f0c
callq 0x24c0
cltd
idivl -0x1c(%rbp)
movl %edx, -0x2c(%rbp)
movq -0x18(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x70(%rbp)
movq -0x18(%rbp), %rdi
movslq -0x2c(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdi
callq 0x13980
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0x13780
movsd %xmm0, -0x50(%rbp)
movsd -0x50(%rbp), %xmm1
movsd -0x40(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x5e70
movsd -0x50(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
movq -0x18(%rbp), %rdi
movl -0x1c(%rbp), %esi
movq -0x28(%rbp), %rdx
callq 0x13930
movsd -0x50(%rbp), %xmm0
subsd -0x48(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
divsd -0x60(%rbp), %xmm0
callq 0x24b0
movsd %xmm0, -0x68(%rbp)
movsd -0x50(%rbp), %xmm1
movsd -0x48(%rbp), %xmm0
ucomisd %xmm1, %xmm0
ja 0x5ed0
callq 0x24c0
cvtsi2sd %eax, %xmm1
movsd 0x1d627(%rip), %xmm0    # 0x234e8
divsd %xmm0, %xmm1
movsd -0x68(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x5edc
movsd -0x50(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
jmp 0x5eec
movq -0x70(%rbp), %rdx
movq -0x18(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movsd 0x1d5fc(%rip), %xmm0    # 0x234f0
mulsd -0x60(%rbp), %xmm0
movsd %xmm0, -0x60(%rbp)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x5dee
movsd -0x40(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x5f1e
jp 0x5f1e
jmp 0x5f4e
movsd 0x1d5ba(%rip), %xmm0    # 0x234e0
mulsd -0x58(%rbp), %xmm0
movsd %xmm0, -0x58(%rbp)
movq -0x18(%rbp), %rdi
movl -0x1c(%rbp), %esi
movq -0x28(%rbp), %rdx
callq 0x13a20
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x5dda
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)