// File: /workspace/github_c_makefile_star2_O1/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 0x30746
xorpd %xmm0, %xmm0
movl $0xffffffff, 0xc(%rsp)  # imm = 0xFFFFFFFF
movsd 0x10518(%rip), %xmm1    # 0xa2518
movsd %xmm1, 0x48(%rsp)
leaq 0x20(%rsp), %r14
movq 0x10(%rsp), %rdi
leaq 0x70(%rsp), %rsi
movsd %xmm0, 0x68(%rsp)
callq 0x91cfc
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 0x301e1
movq %r15, %rdi
leaq 0x28(%rsp), %rsi
movq %r14, %rdx
movl %r12d, %ecx
movsd 0x50(%rsp), %xmm0
callq 0x301e1
movq 0x38(%rsp), %rdi
movq 0x28(%rsp), %rsi
movl %ebp, %edx
callq 0x75f33
movsd %xmm0, 0x18(%rsp)
movq 0x30(%rsp), %rdi
movq 0x20(%rsp), %rsi
movl %ebp, %edx
callq 0x75f33
addsd 0x18(%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
movq 0x10(%rsp), %rdi
movq 0x38(%rsp), %rsi
callq 0x30ad5
movq %rax, 0x10(%rsp)
movq 0x30(%rsp), %rsi
movq %r13, %rdi
callq 0x2fd59
movq 0x40(%rsp), %rdi
movq 0x28(%rsp), %rsi
callq 0x30ad5
movq %rax, 0x40(%rsp)
movq 0x20(%rsp), %rsi
movq %r15, %rdi
callq 0x2fd59
movsd 0x18(%rsp), %xmm1
movsd 0x48(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x92113
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 0x15a77(%rip), %xmm0    # 0xa7b98
movsd 0x12907(%rip), %xmm1    # 0xa4a30
ucomisd %xmm0, %xmm1
jae 0x9200b
movq 0x58(%rsp), %rbx
movq (%rbx), %rdi
movq 0x10(%rsp), %rsi
callq 0x30ad5
movq %rax, (%rbx)
movq 0x40(%rsp), %rsi
movq %rbx, %rdi
callq 0x2fd59
movl 0xc(%rsp), %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq