// File: /workspace/github_c_makefile_star2_O0/olcaytaner[P]Isell/svmsimplex.c
// Function: solve_svm_regression
Svm_regression_modelptr solve_svm_regression(Instanceptr data, Svm_simplex_parameterptr parameters)
{
 Quadraticprogramptr program;
 Convexsolutionptr solution;
 Svm_regression_modelptr model;
 int i, j, k, correct, size;
 double sum, lower_bound = +INT_MAX, upper_bound = -INT_MAX;
 Instanceptr tmp;
 size = data_size(data);
 model = safemalloc(sizeof(Svm_regression_model), "solve_svm_regression", 4);
 program = prepare_qp_for_epsilon_svm(data, parameters);
 solution = solve_qp_wolfe_method(program);
 model->support_vector_count = 0;
 for (i = 0; i < size; i++)
   if (solution->variables[i] - solution->variables[i + size] > DBL_DELTA)
     model->support_vector_count++;
 model->alpha = safemalloc(model->support_vector_count * sizeof(double), "solve_svm_regression", 10);
 model->support_vectors = safemalloc(model->support_vector_count * sizeof(Instanceptr), "solve_svm_regression", 11);
 j = 0;
 model->b = 0;
 correct = 0;
 for (i = 0, tmp = data; i < size; i++, tmp = tmp->next)
  {
   if (solution->variables[i] - solution->variables[i + size] > DBL_DELTA)
    {
     model->alpha[j] = solution->variables[i] - solution->variables[i + size];
     model->support_vectors[j] = tmp;
     j++;
    }
   sum = program->c[i];
   for (k = 0; k < solution->variablecount; k++)
     sum += program->Q.values[i][k] * solution->variables[k];
   if (solution->variables[i] > DBL_DELTA && solution->variables[i] < parameters->C - DBL_DELTA)
    {
     model->b += sum;
     correct++;
    }
   else
     if (solution->variables[i] < DBL_DELTA && sum < lower_bound)
       lower_bound = sum;
     else
       if (solution->variables[i] > parameters->C - DBL_DELTA && sum > upper_bound)
         upper_bound = sum;
   sum = program->c[i + size];
   for (k = 0; k < solution->variablecount; k++)
     sum += program->Q.values[i + size][k] * solution->variables[k];
   sum *= -1;
   if (solution->variables[i + size] > DBL_DELTA && solution->variables[i + size] < parameters->C - DBL_DELTA)
    {
     model->b += sum;
     correct++;
    }
   else
     if (solution->variables[i] < DBL_DELTA && sum > upper_bound)
       upper_bound = sum;
     else
       if (solution->variables[i] > parameters->C - DBL_DELTA && sum < lower_bound)
         lower_bound = sum;
  }
 if (correct > 0)
   model->b /= correct;
 else
   model->b = (upper_bound + lower_bound) / 2;
 model->b *= -1;
 free_convex_solution(solution);
 free_quadratic_program(program);
 return model;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movsd 0x15528(%rip), %xmm0    # 0xe2010
movsd %xmm0, -0x50(%rbp)
movsd 0x15513(%rip), %xmm0    # 0xe2008
movsd %xmm0, -0x58(%rbp)
movq -0x8(%rbp), %rdi
callq 0x449f0
movl %eax, -0x3c(%rbp)
movl $0x20, %edi
leaq 0x2171a(%rip), %rsi     # 0xee22c
movl $0x4, %edx
callq 0x52d70
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0xcc560
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
callq 0x16000
movq %rax, -0x20(%rbp)
movq -0x28(%rbp), %rax
movl $0x0, (%rax)
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jge 0xccba4
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x2c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x2c(%rbp), %ecx
addl -0x3c(%rbp), %ecx
movslq %ecx, %rcx
subsd (%rax,%rcx,8), %xmm0
movsd 0x15eea(%rip), %xmm1    # 0xe2a70
ucomisd %xmm1, %xmm0
jbe 0xccb97
movq -0x28(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
jmp 0xccb99
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0xccb4f
movq -0x28(%rbp), %rax
movslq (%rax), %rdi
shlq $0x3, %rdi
leaq 0x21676(%rip), %rsi     # 0xee22c
movl $0xa, %edx
callq 0x52d70
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x28(%rbp), %rax
movslq (%rax), %rdi
shlq $0x3, %rdi
leaq 0x2164f(%rip), %rsi     # 0xee22c
movl $0xb, %edx
callq 0x52d70
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x8(%rax)
movl $0x0, -0x30(%rbp)
movq -0x28(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, 0x18(%rax)
movl $0x0, -0x38(%rbp)
movl $0x0, -0x2c(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x60(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jge 0xccf9f
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x2c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x2c(%rbp), %ecx
addl -0x3c(%rbp), %ecx
movslq %ecx, %rcx
subsd (%rax,%rcx,8), %xmm0
movsd 0x15e1a(%rip), %xmm1    # 0xe2a70
ucomisd %xmm1, %xmm0
jbe 0xcccb1
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x2c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x2c(%rbp), %ecx
addl -0x3c(%rbp), %ecx
movslq %ecx, %rcx
subsd (%rax,%rcx,8), %xmm0
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x30(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq -0x60(%rbp), %rdx
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x30(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rax
movslq -0x2c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x48(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0x18(%rcx), %eax
jge 0xccd21
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x34(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x34(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm2
movsd -0x48(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x48(%rbp)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0xcccce
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x2c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd 0x15d36(%rip), %xmm1    # 0xe2a70
ucomisd %xmm1, %xmm0
jbe 0xccd8a
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x2c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
movq -0x10(%rbp), %rax
movsd 0x20(%rax), %xmm0
movsd 0x15d0e(%rip), %xmm2    # 0xe2a70
subsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jbe 0xccd8a
movsd -0x48(%rbp), %xmm0
movq -0x28(%rbp), %rax
addsd 0x18(%rax), %xmm0
movsd %xmm0, 0x18(%rax)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0xcce07
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x2c(%rbp), %rcx
movsd 0x15cd2(%rip), %xmm0    # 0xe2a70
ucomisd (%rax,%rcx,8), %xmm0
jbe 0xccdc1
movsd -0x48(%rbp), %xmm1
movsd -0x50(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0xccdc1
movsd -0x48(%rbp), %xmm0
movsd %xmm0, -0x50(%rbp)
jmp 0xcce05
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x2c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x10(%rbp), %rax
movsd 0x20(%rax), %xmm1
movsd 0x15c8d(%rip), %xmm2    # 0xe2a70
subsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jbe 0xcce03
movsd -0x48(%rbp), %xmm0
ucomisd -0x58(%rbp), %xmm0
jbe 0xcce03
movsd -0x48(%rbp), %xmm0
movsd %xmm0, -0x58(%rbp)
jmp 0xcce05
jmp 0xcce07
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rax
movl -0x2c(%rbp), %ecx
addl -0x3c(%rbp), %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x48(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0x18(%rcx), %eax
jge 0xcce81
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rax
movl -0x2c(%rbp), %ecx
addl -0x3c(%rbp), %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movslq -0x34(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x34(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm2
movsd -0x48(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x48(%rbp)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0xcce29
movsd 0x15bbf(%rip), %xmm0    # 0xe2a48
mulsd -0x48(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x2c(%rbp), %ecx
addl -0x3c(%rbp), %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movsd 0x15bbf(%rip), %xmm1    # 0xe2a70
ucomisd %xmm1, %xmm0
jbe 0xccf06
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x2c(%rbp), %ecx
addl -0x3c(%rbp), %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm1
movq -0x10(%rbp), %rax
movsd 0x20(%rax), %xmm0
movsd 0x15b92(%rip), %xmm2    # 0xe2a70
subsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jbe 0xccf06
movsd -0x48(%rbp), %xmm0
movq -0x28(%rbp), %rax
addsd 0x18(%rax), %xmm0
movsd %xmm0, 0x18(%rax)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0xccf83
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x2c(%rbp), %rcx
movsd 0x15b56(%rip), %xmm0    # 0xe2a70
ucomisd (%rax,%rcx,8), %xmm0
jbe 0xccf39
movsd -0x48(%rbp), %xmm0
ucomisd -0x58(%rbp), %xmm0
jbe 0xccf39
movsd -0x48(%rbp), %xmm0
movsd %xmm0, -0x58(%rbp)
jmp 0xccf81
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x2c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x10(%rbp), %rax
movsd 0x20(%rax), %xmm1
movsd 0x15b15(%rip), %xmm2    # 0xe2a70
subsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jbe 0xccf7f
movsd -0x48(%rbp), %xmm1
movsd -0x50(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0xccf7f
movsd -0x48(%rbp), %xmm0
movsd %xmm0, -0x50(%rbp)
jmp 0xccf81
jmp 0xccf83
jmp 0xccf85
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
movq -0x60(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x60(%rbp)
jmp 0xccc1b
cmpl $0x0, -0x38(%rbp)
jle 0xccfbe
cvtsi2sdl -0x38(%rbp), %xmm1
movq -0x28(%rbp), %rax
movsd 0x18(%rax), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, 0x18(%rax)
jmp 0xccfdd
movsd -0x58(%rbp), %xmm0
addsd -0x50(%rbp), %xmm0
movsd 0x15cd0(%rip), %xmm1    # 0xe2ca0
divsd %xmm1, %xmm0
movq -0x28(%rbp), %rax
movsd %xmm0, 0x18(%rax)
movq -0x28(%rbp), %rax
movsd 0x15a5f(%rip), %xmm0    # 0xe2a48
mulsd 0x18(%rax), %xmm0
movsd %xmm0, 0x18(%rax)
movq -0x20(%rbp), %rdi
callq 0x14f00
movq -0x18(%rbp), %rdi
callq 0x14ea0
movq -0x28(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
nop