// File: /workspace/github_c_makefile_star2_O2/olcaytaner[P]Isell/svmregtree.c
// Function: optimize_C_for_svmregtreenode
int optimize_C_for_svmregtreenode(Regressionnodeptr node, LEAF_TYPE leaftype)
{
 /*!Last Changed 01.11.2009*/
 int bestfeature = -1, currentfeature;
 double C, currenterror, besterror = +INT_MAX, currentsplit;
 Instanceptr validate = NULL, learn = NULL, leftinstances, rightinstances, testleft, testright;
 divide_instancelist(&(node->instances), &validate, &learn, 4);
 for (C = 0.0; C <= 3.0; C+= 0.1)
  {
   currentfeature = find_best_svmregtree_feature(learn, &currentsplit, C, leaftype);
   leftinstances = rightinstances = testleft = testright = NULL;
   divide_instancelist_according_to_split(&learn, &leftinstances, &rightinstances, currentfeature, currentsplit);
   divide_instancelist_according_to_split(&validate, &testleft, &testright, currentfeature, currentsplit);
   currenterror = constant_or_linear_model_mse(leftinstances, testleft, leaftype) + constant_or_linear_model_mse(rightinstances, testright, leaftype);
   learn = restore_instancelist(learn, leftinstances);
   merge_instancelist(&learn, rightinstances); 
   validate = restore_instancelist(validate, testleft);
   merge_instancelist(&validate, testright); 
   if (currenterror < besterror)
    {
     besterror = currenterror;
     bestfeature = currentfeature;
     node->split = currentsplit;
    }
  }
 node->instances = restore_instancelist(node->instances, learn);
 merge_instancelist(&(node->instances), validate);
 return bestfeature;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movl %esi, %ebp
leaq 0x40(%rsp), %r15
andq $0x0, (%r15)
leaq 0x10(%rsp), %r13
andq $0x0, (%r13)
movq %rdi, 0x60(%rsp)
addq $0x20, %rdi
pushq $0x4
popq %rcx
movq %rdi, 0x58(%rsp)
movq %r15, %rsi
movq %r13, %rdx
callq 0x2cfe5
movsd 0xef9a(%rip), %xmm0     # 0x95518
movsd %xmm0, 0x48(%rsp)
pushq $-0x1
popq %rax
movl %eax, 0xc(%rsp)
xorpd %xmm0, %xmm0
leaq 0x28(%rsp), %rbx
leaq 0x20(%rsp), %r14
movsd 0x114c7(%rip), %xmm1    # 0x97a68
ucomisd %xmm0, %xmm1
jb 0x866c8
movq 0x10(%rsp), %rdi
leaq 0x70(%rsp), %rsi
movsd %xmm0, 0x68(%rsp)
callq 0x862b8
andq $0x0, 0x20(%rsp)
andq $0x0, 0x28(%rsp)
movl %eax, %r12d
andq $0x0, 0x30(%rsp)
andq $0x0, 0x38(%rsp)
movsd 0x70(%rsp), %xmm0
movsd %xmm0, 0x50(%rsp)
movq %r13, %rdi
leaq 0x38(%rsp), %rsi
leaq 0x30(%rsp), %rdx
movl %eax, %ecx
callq 0x2caf4
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rdx
movl %r12d, %ecx
movsd 0x50(%rsp), %xmm0
callq 0x2caf4
movq 0x38(%rsp), %rdi
movq 0x28(%rsp), %rsi
movl %ebp, %edx
callq 0x6d63d
movsd %xmm0, 0x18(%rsp)
movq 0x30(%rsp), %rdi
movq 0x20(%rsp), %rsi
movl %ebp, %edx
callq 0x6d63d
addsd 0x18(%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
movq 0x10(%rsp), %rdi
movq 0x38(%rsp), %rsi
callq 0x2d2da
movq %rax, 0x10(%rsp)
movq 0x30(%rsp), %rsi
movq %r13, %rdi
callq 0x2c6e4
movq 0x40(%rsp), %rdi
movq 0x28(%rsp), %rsi
callq 0x2d2da
movq %rax, 0x40(%rsp)
movq 0x20(%rsp), %rsi
movq %r15, %rdi
callq 0x2c6e4
movsd 0x18(%rsp), %xmm1
movsd 0x48(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x866b5
movq 0x60(%rsp), %rax
movsd 0x50(%rsp), %xmm0
movsd %xmm0, 0x50(%rax)
movl %r12d, 0xc(%rsp)
movsd %xmm1, 0x48(%rsp)
movsd 0x68(%rsp), %xmm0
addsd 0x144b5(%rip), %xmm0    # 0x9ab78
jmp 0x86599
movq 0x58(%rsp), %rbx
movq (%rbx), %rdi
movq 0x10(%rsp), %rsi
callq 0x2d2da
movq %rax, (%rbx)
movq 0x40(%rsp), %rsi
movq %rbx, %rdi
callq 0x2c6e4
movl 0xc(%rsp), %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq