// File: /workspace/github_c_makefile_star2_O3/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
xorl %ebx, %ebx
leaq 0x40(%rsp), %r15
movq %rbx, (%r15)
leaq 0x10(%rsp), %r13
movq %rbx, (%r13)
movq %rdi, 0x60(%rsp)
addq $0x20, %rdi
movq %rdi, 0x58(%rsp)
movq %r15, %rsi
movq %r13, %rdx
movl $0x4, %ecx
callq 0x31019
xorpd %xmm0, %xmm0
movl $0xffffffff, 0xc(%rsp)  # imm = 0xFFFFFFFF
movsd 0x10acc(%rip), %xmm1    # 0xa5518
movsd %xmm1, 0x48(%rsp)
leaq 0x20(%rsp), %r14
movq 0x10(%rsp), %rdi
leaq 0x70(%rsp), %rsi
movsd %xmm0, 0x68(%rsp)
callq 0x9474c
movl %eax, %r12d
movq %rbx, 0x20(%rsp)
movq %rbx, 0x28(%rsp)
movq %rbx, 0x30(%rsp)
movq %rbx, 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 0x30ade
movq %r15, %rdi
leaq 0x28(%rsp), %rsi
movq %r14, %rdx
movl %r12d, %ecx
movsd 0x50(%rsp), %xmm0
callq 0x30ade
movq 0x38(%rsp), %rdi
movq 0x28(%rsp), %rsi
movl %ebp, %edx
callq 0x77900
movsd %xmm0, 0x18(%rsp)
movq 0x30(%rsp), %rdi
movq 0x20(%rsp), %rsi
movl %ebp, %edx
callq 0x77900
addsd 0x18(%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
movq 0x10(%rsp), %rdi
movq 0x38(%rsp), %rsi
callq 0x31345
movq %rax, 0x10(%rsp)
movq 0x30(%rsp), %rsi
movq %r13, %rdi
callq 0x30648
movq 0x40(%rsp), %rdi
movq 0x28(%rsp), %rsi
callq 0x31345
movq %rax, 0x40(%rsp)
movq 0x20(%rsp), %rsi
movq %r15, %rdi
callq 0x30648
movsd 0x18(%rsp), %xmm1
movsd 0x48(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x94b5f
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 0x160db(%rip), %xmm0    # 0xaac48
movsd 0x12f73(%rip), %xmm1    # 0xa7ae8
ucomisd %xmm0, %xmm1
jae 0x94a57
movq 0x58(%rsp), %rbx
movq (%rbx), %rdi
movq 0x10(%rsp), %rsi
callq 0x31345
movq %rax, (%rbx)
movq 0x40(%rsp), %rsi
movq %rbx, %rdi
callq 0x30648
movl 0xc(%rsp), %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq