// File: /workspace/github_c_makefile_star2_O3/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 0x4981b(%rip), %rcx     # 0xd5870
movq (%rcx), %rax
movq %rcx, %r12
movl 0x10(%rax), %esi
callq 0x37a28
movq %rax, 0x10(%rsp)
movq %rbx, %rdi
movq %r14, %r13
movq %r14, %rsi
callq 0x8b59b
movl %eax, 0x4(%rsp)
movq 0x20(%rbx), %rdi
callq 0x30309
movq %r15, %rdi
movl $0x1, %esi
callq 0x1d107
movq %rax, (%r15)
movq (%r12), %rax
movslq 0x10(%rax), %rdi
shlq $0x3, %rdi
leaq 0x25380(%rip), %r14     # 0xb1426
movq %r14, %rsi
movl $0x8, %edx
callq 0x3a0e1
movq (%r15), %rcx
movq %rax, 0x70(%rcx)
xorl %ebp, %ebp
movl %ebp, 0x60(%rcx)
movq %r15, %rdi
movl $0x1, %esi
callq 0x1d107
movq %rax, 0x8(%r15)
movq (%r12), %rax
movslq 0x10(%rax), %rdi
shlq $0x3, %rdi
movl $0xb, %r12d
movq %r14, %rsi
movl $0xb, %edx
callq 0x3a0e1
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 0x1d107
movq %rax, %rbp
leaq 0x49757(%rip), %r14     # 0xd5870
movq (%r14), %rax
movslq 0x10(%rax), %rdi
shlq $0x3, %rdi
leaq 0x252fb(%rip), %rsi     # 0xb1426
movl $0xf, %edx
callq 0x3a0e1
movq %rax, 0x70(%rbp)
movq %r15, %rdi
movl $0x1, %esi
callq 0x1d107
movq %rax, (%rbp)
movq (%r14), %rax
movslq 0x10(%rax), %rdi
shlq $0x3, %rdi
leaq 0x252ca(%rip), %rsi     # 0xb1426
movl $0x11, %edx
callq 0x3a0e1
movq (%rbp), %rcx
movq %rax, 0x70(%rcx)
movq %r15, %rdi
movl $0x1, %esi
callq 0x1d107
movq %rax, 0x8(%rbp)
movq (%r14), %rax
movslq 0x10(%rax), %rdi
shlq $0x3, %rdi
leaq 0x25295(%rip), %rsi     # 0xb1426
movl $0x13, %edx
callq 0x3a0e1
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 0x1bbf4(%rip), %xmm1    # 0xa7db8
divsd %xmm0, %xmm1
movq %rbx, %rdi
movq %r15, %rsi
movq 0x18(%rsp), %rdx
movapd %xmm1, %xmm0
callq 0x8b67b
movq %rbx, %rdi
movq %r13, %rsi
callq 0x8b59b
cmpl %r14d, %eax
jge 0x8c20f
movl %eax, %ebp
cmpl 0x4(%rsp), %r14d
je 0x8c1ff
movq 0x8(%rsp), %rdi
callq 0x8bede
movq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x8bf44
movl %ebp, %r14d
movq %r15, %rdi
callq 0x8bede
movsd 0x20(%rsp), %xmm0
addsd 0x192fb(%rip), %xmm0    # 0xa5520
decl %r12d
jne 0x8c1b1
cmpl %r14d, 0x4(%rsp)
jle 0x8c253
movq %r15, %rdi
movq 0x8(%rsp), %rsi
callq 0x8bf44
movq 0x50(%r15), %rdi
callq 0x3a180
movl $0x1, %ebx
movq 0x10(%rsp), %r15
jmp 0x8c2bb
movq (%r15), %rdi
callq 0x1d64e
movq 0x8(%r15), %rdi
callq 0x1d64e
movq (%r15), %rax
movq 0x70(%rax), %rdi
callq 0x3a180
movq 0x8(%r15), %rax
movq 0x70(%rax), %rdi
callq 0x3a180
movq (%r15), %rdi
callq 0x3a180
movq 0x8(%r15), %rdi
callq 0x3a180
movq %r15, %rdi
callq 0x1cab0
movq 0x50(%r15), %rdi
leaq 0x495cf(%rip), %rax     # 0xd5870
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 0x8c2cc
movq 0x8(%rsp), %rdi
callq 0x8bede
movq %r15, %rdi
callq 0x3a180
movq 0x8(%rsp), %r13
movq (%r13), %rdi
callq 0x1d64e
movq 0x8(%r13), %rdi
callq 0x1d64e
movq %r13, %rdi
callq 0x1d64e
movq (%r13), %rax
movq 0x70(%rax), %rdi
callq 0x3a180
movq 0x8(%r13), %rax
movq 0x70(%rax), %rdi
callq 0x3a180
movq 0x70(%r13), %rdi
callq 0x3a180
movq (%r13), %rdi
callq 0x3a180
movq 0x8(%r13), %rdi
callq 0x3a180
movq %r13, %rdi
callq 0x3a180
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq