// File: /workspace/github_c_makefile_star2_O1/olcaytaner[P]Isell/softtree.c
// Function: find_best_soft_tree_split_K_class
BOOLEAN find_best_soft_tree_split_K_class(Decisionnodeptr rootnode, Decisionnodeptr node, Instanceptr cvdata, Softregtree_parameterptr param)
{
 int i, datasize, performancebefore, performancebest, performancenow;
 double eta, *tmp;
 BOOLEAN result = BOOLEAN_TRUE;
 Decisionnodeptr bestnode;
 tmp = clone_array(node->w0s, current_dataset->classno);
 performancebefore = error_of_soft_tree_K_class(rootnode, cvdata);
 performancebest = performancebefore;
 datasize = data_size(rootnode->instances);
 node->left = createnewnode(node, 1);
 node->left->outputs = safemalloc(current_dataset->classno * sizeof(double), "find_best_soft_tree_split_K_class", 8);
 node->left->leaftype = CONSTANTLEAF;
 node->right = createnewnode(node, 1);
 node->right->outputs = safemalloc(current_dataset->classno * sizeof(double), "find_best_soft_tree_split_K_class", 11);
 node->right->leaftype = CONSTANTLEAF;
 node->featureno = SOFTLIN;
 bestnode = createnewnode(node, 1);
 bestnode->outputs = safemalloc(current_dataset->classno * sizeof(double), "find_best_soft_tree_split_K_class", 15);
 bestnode->left = createnewnode(node, 1);
 bestnode->left->outputs = safemalloc(current_dataset->classno * sizeof(double), "find_best_soft_tree_split_K_class", 17);
 bestnode->right = createnewnode(node, 1);
 bestnode->right->outputs = safemalloc(current_dataset->classno * sizeof(double), "find_best_soft_tree_split_K_class", 19);
 for (i = 0; i <= 10; i++)
  {
   eta = 10.0 / pow(2, i);
   gradient_descent_soft_tree_K_class(rootnode, node, param, eta);
   performancenow = error_of_soft_tree_K_class(rootnode, cvdata);
   if (performancenow < performancebest)
    {
     if (performancebest != performancebefore)
       free_soft_tree_ws_K_class(bestnode);
     performancebest = performancenow;
     copy_soft_tree_ws_K_class(bestnode, node);
    }
   free_soft_tree_ws_K_class(node);
  }
 if (performancebefore <= performancebest)
  {
   result = BOOLEAN_FALSE;
   deallocate_tree_rule(node->left);
   deallocate_tree_rule(node->right);
   safe_free(node->left->outputs);
   safe_free(node->right->outputs);
   safe_free(node->left);
   safe_free(node->right);
   make_leaf_node(node);
   memcpy(node->w0s, tmp, current_dataset->classno * sizeof(double));
  }
 else
  {
   copy_soft_tree_ws_K_class(node, bestnode);
   safe_free(node->w0s);
  }
 if (performancebest != performancebefore)
   free_soft_tree_ws_K_class(bestnode);
 safe_free(tmp);
 deallocate_tree_rule(bestnode->left);
 deallocate_tree_rule(bestnode->right);
 deallocate_tree_rule(bestnode);
 safe_free(bestnode->left->outputs);
 safe_free(bestnode->right->outputs);
 safe_free(bestnode->outputs);
 safe_free(bestnode->left);
 safe_free(bestnode->right);
 safe_free(bestnode);
 return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rcx, 0x18(%rsp)
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
movq 0x50(%rsi), %rdi
leaq 0x48fc9(%rip), %rcx     # 0xd2870
movq (%rcx), %rax
movq %rcx, %r12
movl 0x10(%rax), %esi
callq 0x37088
movq %rax, 0x10(%rsp)
movq %rbx, %rdi
movq %r14, %r13
movq %r14, %rsi
callq 0x88db3
movl %eax, 0x4(%rsp)
movq 0x20(%rbx), %rdi
callq 0x2fa14
movq %r15, %rdi
movl $0x1, %esi
callq 0x1c996
movq %rax, (%r15)
movq (%r12), %rax
movslq 0x10(%rax), %rdi
shlq $0x3, %rdi
leaq 0x24a96(%rip), %r14     # 0xae38e
movq %r14, %rsi
movl $0x8, %edx
callq 0x390f5
movq (%r15), %rcx
movq %rax, 0x70(%rcx)
xorl %ebp, %ebp
movl %ebp, 0x60(%rcx)
movq %r15, %rdi
movl $0x1, %esi
callq 0x1c996
movq %rax, 0x8(%r15)
movq (%r12), %rax
movslq 0x10(%rax), %rdi
shlq $0x3, %rdi
movl $0xb, %r12d
movq %r14, %rsi
movl $0xb, %edx
callq 0x390f5
movq 0x8(%r15), %rcx
movq %rax, 0x70(%rcx)
movl %ebp, 0x60(%rcx)
movl $0xfffffffa, 0x30(%r15) # imm = 0xFFFFFFFA
movq %r15, %rdi
movl $0x1, %esi
callq 0x1c996
movq %rax, %rbp
leaq 0x48f05(%rip), %r14     # 0xd2870
movq (%r14), %rax
movslq 0x10(%rax), %rdi
shlq $0x3, %rdi
leaq 0x24a11(%rip), %rsi     # 0xae38e
movl $0xf, %edx
callq 0x390f5
movq %rax, 0x70(%rbp)
movq %r15, %rdi
movl $0x1, %esi
callq 0x1c996
movq %rax, (%rbp)
movq (%r14), %rax
movslq 0x10(%rax), %rdi
shlq $0x3, %rdi
leaq 0x249e0(%rip), %rsi     # 0xae38e
movl $0x11, %edx
callq 0x390f5
movq (%rbp), %rcx
movq %rax, 0x70(%rcx)
movq %r15, %rdi
movl $0x1, %esi
callq 0x1c996
movq %rax, 0x8(%rbp)
movq (%r14), %rax
movslq 0x10(%rax), %rdi
shlq $0x3, %rdi
leaq 0x249ab(%rip), %rsi     # 0xae38e
movl $0x13, %edx
callq 0x390f5
movq %rbp, 0x8(%rsp)
movq 0x8(%rbp), %rcx
movq %rax, 0x70(%rcx)
xorpd %xmm0, %xmm0
movl 0x4(%rsp), %r14d
movsd %xmm0, 0x20(%rsp)
callq 0x4210
movsd 0x1b31a(%rip), %xmm1    # 0xa4d30
divsd %xmm0, %xmm1
movq %rbx, %rdi
movq %r15, %rsi
movq 0x18(%rsp), %rdx
movapd %xmm1, %xmm0
callq 0x88e93
movq %rbx, %rdi
movq %r13, %rsi
callq 0x88db3
cmpl %r14d, %eax
jge 0x89a61
movl %eax, %ebp
cmpl 0x4(%rsp), %r14d
je 0x89a51
movq 0x8(%rsp), %rdi
callq 0x89730
movq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x89796
movl %ebp, %r14d
movq %r15, %rdi
callq 0x89730
movsd 0x20(%rsp), %xmm0
addsd 0x18aa9(%rip), %xmm0    # 0xa2520
decl %r12d
jne 0x89a03
cmpl %r14d, 0x4(%rsp)
jle 0x89aa5
movq %r15, %rdi
movq 0x8(%rsp), %rsi
callq 0x89796
movq 0x50(%r15), %rdi
callq 0x39194
movl $0x1, %ebx
movq 0x10(%rsp), %r15
jmp 0x89b0d
movq (%r15), %rdi
callq 0x1ced4
movq 0x8(%r15), %rdi
callq 0x1ced4
movq (%r15), %rax
movq 0x70(%rax), %rdi
callq 0x39194
movq 0x8(%r15), %rax
movq 0x70(%rax), %rdi
callq 0x39194
movq (%r15), %rdi
callq 0x39194
movq 0x8(%r15), %rdi
callq 0x39194
movq %r15, %rdi
callq 0x1c39c
movq 0x50(%r15), %rdi
leaq 0x48d7d(%rip), %rax     # 0xd2870
movq (%rax), %rax
movslq 0x10(%rax), %rdx
shlq $0x3, %rdx
movq 0x10(%rsp), %r15
movq %r15, %rsi
callq 0x4310
xorl %ebx, %ebx
cmpl 0x4(%rsp), %r14d
je 0x89b1e
movq 0x8(%rsp), %rdi
callq 0x89730
movq %r15, %rdi
callq 0x39194
movq 0x8(%rsp), %r13
movq (%r13), %rdi
callq 0x1ced4
movq 0x8(%r13), %rdi
callq 0x1ced4
movq %r13, %rdi
callq 0x1ced4
movq (%r13), %rax
movq 0x70(%rax), %rdi
callq 0x39194
movq 0x8(%r13), %rax
movq 0x70(%rax), %rdi
callq 0x39194
movq 0x70(%r13), %rdi
callq 0x39194
movq (%r13), %rdi
callq 0x39194
movq 0x8(%r13), %rdi
callq 0x39194
movq %r13, %rdi
callq 0x39194
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq