// File: /workspace/github_c_makefile_star2_O2/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, %rbp
movq 0x50(%rsi), %rdi
leaq 0x4f018(%rip), %rcx     # 0xcd870
movq (%rcx), %rax
movq %rcx, %r13
movl 0x10(%rax), %esi
callq 0x3325d
movq %rax, 0x10(%rsp)
movq %rbp, %rdi
movq %r14, %rbx
movq %r14, %rsi
callq 0x7de33
movl %eax, 0x4(%rsp)
movq 0x20(%rbp), %rdi
callq 0x2c3cc
pushq $0x1
popq %r14
movq %r15, %rdi
movl %r14d, %esi
callq 0x1ac98
movq %rax, (%r15)
movq (%r13), %rax
movslq 0x10(%rax), %rdi
shlq $0x3, %rdi
leaq 0x22adb(%rip), %r12     # 0xa1386
pushq $0x8
popq %rdx
movq %r12, %rsi
callq 0x34f59
movq (%r15), %rcx
movq %rax, 0x70(%rcx)
andl $0x0, 0x60(%rcx)
movq %r15, %rdi
movl %r14d, %esi
callq 0x1ac98
movq %rax, 0x8(%r15)
movq (%r13), %rax
movslq 0x10(%rax), %rdi
shlq $0x3, %rdi
pushq $0xb
popq %r14
movq %r12, %rsi
movl %r14d, %edx
callq 0x34f59
movq 0x8(%r15), %rcx
movq %rax, 0x70(%rcx)
andl $0x0, 0x60(%rcx)
movl $0xfffffffa, 0x30(%r15) # imm = 0xFFFFFFFA
movq %r15, %rdi
pushq $0x1
popq %rsi
callq 0x1ac98
movq %rax, %r13
leaq 0x4ef5c(%rip), %r12     # 0xcd870
movq (%r12), %rax
movslq 0x10(%rax), %rdi
shlq $0x3, %rdi
pushq $0xf
popq %rdx
leaq 0x22a5c(%rip), %rsi     # 0xa1386
callq 0x34f59
movq %rax, 0x70(%r13)
movq %r15, %rdi
pushq $0x1
popq %rsi
callq 0x1ac98
movq %rax, (%r13)
movq (%r12), %rax
movslq 0x10(%rax), %rdi
shlq $0x3, %rdi
pushq $0x11
popq %rdx
leaq 0x22a2e(%rip), %rsi     # 0xa1386
callq 0x34f59
movq (%r13), %rcx
movq %rax, 0x70(%rcx)
movq %r15, %rdi
pushq $0x1
popq %rsi
callq 0x1ac98
movq %rax, 0x8(%r13)
movq (%r12), %rax
movslq 0x10(%rax), %rdi
shlq $0x3, %rdi
pushq $0x13
popq %rdx
leaq 0x229fc(%rip), %rsi     # 0xa1386
callq 0x34f59
movq %r13, 0x8(%rsp)
movq 0x8(%r13), %rcx
movq %rax, 0x70(%rcx)
xorpd %xmm0, %xmm0
movl 0x4(%rsp), %r12d
subl $0x1, %r14d
jb 0x7ea22
movsd %xmm0, 0x20(%rsp)
callq 0x4210
movsd 0x1937a(%rip), %xmm1    # 0x97d38
divsd %xmm0, %xmm1
movq %rbp, %rdi
movq %r15, %rsi
movq 0x18(%rsp), %rdx
movapd %xmm1, %xmm0
callq 0x7df05
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x7de33
cmpl %r12d, %eax
jge 0x7ea0a
movl %eax, %r13d
cmpl 0x4(%rsp), %r12d
je 0x7e9fa
movq 0x8(%rsp), %rdi
callq 0x7e6e1
movq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x7e747
movl %r13d, %r12d
movq %r15, %rdi
callq 0x7e6e1
movsd 0x20(%rsp), %xmm0
addsd 0x16b00(%rip), %xmm0    # 0x95520
jmp 0x7e9a5
cmpl %r12d, 0x4(%rsp)
jle 0x7ea49
movq %r15, %rdi
movq 0x8(%rsp), %rsi
callq 0x7e747
movq 0x50(%r15), %rdi
callq 0x34ff7
movq 0x10(%rsp), %r14
pushq $0x1
popq %rbp
jmp 0x7eab1
movq (%r15), %rdi
callq 0x1b1b9
movq 0x8(%r15), %rdi
callq 0x1b1b9
movq (%r15), %rax
movq 0x70(%rax), %rdi
callq 0x34ff7
movq 0x8(%r15), %rax
movq 0x70(%rax), %rdi
callq 0x34ff7
movq (%r15), %rdi
callq 0x34ff7
movq 0x8(%r15), %rdi
callq 0x34ff7
movq %r15, %rdi
callq 0x1a6ac
movq 0x50(%r15), %rdi
leaq 0x4edd9(%rip), %rax     # 0xcd870
movq (%rax), %rax
movslq 0x10(%rax), %rdx
shlq $0x3, %rdx
movq 0x10(%rsp), %r14
movq %r14, %rsi
callq 0x4310
xorl %ebp, %ebp
cmpl 0x4(%rsp), %r12d
je 0x7eac2
movq 0x8(%rsp), %rdi
callq 0x7e6e1
movq %r14, %rdi
callq 0x34ff7
movq 0x8(%rsp), %rbx
movq (%rbx), %rdi
callq 0x1b1b9
movq 0x8(%rbx), %rdi
callq 0x1b1b9
movq %rbx, %rdi
callq 0x1b1b9
movq (%rbx), %rax
movq 0x70(%rax), %rdi
callq 0x34ff7
movq 0x8(%rbx), %rax
movq 0x70(%rax), %rdi
callq 0x34ff7
movq 0x70(%rbx), %rdi
callq 0x34ff7
movq (%rbx), %rdi
callq 0x34ff7
movq 0x8(%rbx), %rdi
callq 0x34ff7
movq %rbx, %rdi
callq 0x34ff7
movl %ebp, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq