// File: /workspace/github_c_makefile_star2_O2/olcaytaner[P]Isell/nodeboundedtree.c
// Function: create_node_bounded_tree
int create_node_bounded_tree(Decisionnodeptr node, Nodeboundedtree_parameterptr param)
{
 /*!Last Changed 01.10.2006 added second vc calculation type*/
 /*!Last Changed 24.09.2006 discrete type is also added*/
 /*!Last Changed 01.07.2006 added nodeindex with MODEL_SELECTION_FIX*/
 /*!Last Changed 31.05.2006 added a1 and a2 to parameters*/
 /*!Last Changed 24.05.2006 added free_children and continue*/
 /*!Last Changed 19.03.2006*/
 Node_expandedptr header = NULL, nextexpanded;
 BOOLEAN isexpanded;
 int *countsleft, *countsright, expandedcount = 0, numinstances = data_size(node->instances);
 int i, error = 0, h, parenterror, lefterror, righterror, level, len, nodeindex = 0, childrenproduced;
 double bestupperbound, upperbound;
 Decisionnodeptr expanded_node;
 if (param->prunetype == PREPRUNING)
  {
   error = find_error_as_leaf(node->instances);
   bestupperbound = srm_classification((error + 0.0) / numinstances, 1, numinstances, param->a1, param->a2);
  }
 if (param->model != MODEL_SELECTION_FIX)
   add_node_to_expanded_list(node, &header, -1, param->usediscrete);
 else
  {
   add_node_to_expanded_list(node, &header, nodeindex, param->usediscrete);
   nodeindex++;
  }
 while (header && expandedcount < param->nodecount)
  {
   if (param->prunetype == PREPRUNING)     
     parenterror = find_error_as_leaf(header->node->instances);
   nextexpanded = header->next;
   expanded_node = header->node;
   safe_free(header);
   header = nextexpanded;
   switch (param->model)
    {
     case MODEL_SELECTION_UNI:if (param->usediscrete)
                               {
                                expanded_node->featureno = find_best_ldt_feature(expanded_node->instances, &(expanded_node->split));
                                if (expanded_node->featureno == -1)
                                  isexpanded = BOOLEAN_FALSE;
                                else
                                  isexpanded = BOOLEAN_TRUE;
                               }
                              else
                                isexpanded = find_best_hybrid_ldt_split_single_model(expanded_node, UNIVARIATE, param->variance_explained);
                              break;
     case MODEL_SELECTION_LIN:isexpanded = find_best_hybrid_ldt_split_single_model(expanded_node, LINEAR, param->variance_explained);
                              break;
     case MODEL_SELECTION_QUA:isexpanded = find_best_hybrid_ldt_split_single_model(expanded_node, QUADRATIC, param->variance_explained);
                              break;
     case MODEL_SELECTION_LEV:level = level_of_node(expanded_node);
                              len = strlen(param->modelstring);
                              if (level >= len)
                                level = len - 1;
                              find_best_hybrid_ldt_split_according_char(expanded_node, param->modelstring[level], param->variance_explained);
                              break;
     case MODEL_SELECTION_FIX:isexpanded = find_best_hybrid_ldt_split_according_char(expanded_node, param->modelstring[2 * expandedcount], param->variance_explained);
                              break;
     default                 :printf(m1325);
                              isexpanded = BOOLEAN_FALSE;
                              break;
    }
   if (param->usediscrete)
     childrenproduced = make_children(expanded_node);
   else
     childrenproduced = make_multivariate_children(expanded_node);
   if (isexpanded && childrenproduced)
    {     
     if (param->prunetype == PREPRUNING)     
      {
       switch (param->vccalculationtype)
        {
         case VC_GENERAL:h = decisiontree_vc_dimension_wrt_nodetype(current_dataset, expandedcount + 1, param->model - 5);
                         break;
        }
       lefterror = find_error_as_leaf(expanded_node->left->instances);
       righterror = find_error_as_leaf(expanded_node->right->instances);
       error += lefterror + righterror - parenterror;
       upperbound = srm_classification((error + 0.0) / numinstances, h, numinstances, param->a1, param->a2);
       if (upperbound < bestupperbound)
         bestupperbound = upperbound;
       else
        {
         expanded_node->instances = expanded_node->left->instances;
         merge_instancelist(&(expanded_node->instances), expanded_node->right->instances);
         expanded_node->left->instances = NULL;
         expanded_node->right->instances = NULL;
         free_children(expanded_node);
         make_leaf_node(expanded_node);
         continue;
        }
      }
     if (param->model == MODEL_SELECTION_FIX)
      {
       switch (param->modelstring[2 * expandedcount + 1]){
         case '1':countsleft = find_class_counts(expanded_node->left->instances);
                  countsright = find_class_counts(expanded_node->right->instances);
                  if (log_likelihood_for_classification(countsleft) < log_likelihood_for_classification(countsright))
                   {
                    can_be_divided(expanded_node->right, NULL);
                    make_leaf_node(expanded_node->right);
                    if (!add_node_to_expanded_list(expanded_node->left, &header, nodeindex, param->usediscrete))
                     {
                      empty_heap(header);
                      safe_free(countsleft);
                      safe_free(countsright);                      
                      return 0;
                     }
                    nodeindex++;
                   }
                  else
                   {
                    can_be_divided(expanded_node->left, NULL);
                    make_leaf_node(expanded_node->left);
                    if (!add_node_to_expanded_list(expanded_node->right, &header, nodeindex, param->usediscrete))
                     { 
                      empty_heap(header);
                      safe_free(countsleft);
                      safe_free(countsright);                      
                      return 0;
                     }
                    nodeindex++;
                   }
                  safe_free(countsleft);
                  safe_free(countsright);
                  break;
         case '2':if (!add_node_to_expanded_list(expanded_node->left, &header, nodeindex, param->usediscrete))
                   {
                    can_be_divided(expanded_node->right, NULL);
                    make_leaf_node(expanded_node->right);
                    empty_heap(header);
                    return 0;
                   }
                  nodeindex++;
                  if (!add_node_to_expanded_list(expanded_node->right, &header, nodeindex, param->usediscrete))
                   {
                    empty_heap(header);
                    return 0;
                   }
                  nodeindex++;
                  break;
         case '0':can_be_divided(expanded_node->left, NULL);
                  make_leaf_node(expanded_node->left);
                  can_be_divided(expanded_node->right, NULL);
                  make_leaf_node(expanded_node->right);
                  break;
       }
      }
     else
      {
       if (param->usediscrete && current_dataset->features[expanded_node->featureno].type == STRING)
        {
         for (i = 0; i < current_dataset->features[expanded_node->featureno].valuecount; i++)
           add_node_to_expanded_list(&(expanded_node->string[i]), &header, -1, BOOLEAN_TRUE); 
        }
       else
        {
         add_node_to_expanded_list(expanded_node->left, &header, -1, param->usediscrete);
         add_node_to_expanded_list(expanded_node->right, &header, -1, param->usediscrete);
        }
      }
     expandedcount++;      
    }
   else
    {
     make_leaf_node(expanded_node);
     if (param->model == MODEL_SELECTION_FIX)
      {
       empty_heap(header);
       return 0;
      }
    }
  }
 empty_heap(header);
 return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rsi, %rbx
movq %rdi, %r15
andq $0x0, 0x10(%rsp)
movq 0x20(%rdi), %rdi
callq 0x2c3cc
cmpl $0x0, 0x14(%rbx)
movl %eax, 0x34(%rsp)
cvtsi2sd %eax, %xmm0
movsd %xmm0, 0x58(%rsp)
movl $0x0, %r14d
jne 0x48cfa
movq 0x20(%r15), %rdi
callq 0x10881
movl %eax, %r14d
cvtsi2sd %eax, %xmm0
divsd 0x58(%rsp), %xmm0
movsd 0x18(%rbx), %xmm1
movsd 0x20(%rbx), %xmm2
pushq $0x1
popq %rdi
movl 0x34(%rsp), %esi
callq 0x41c3e
movsd %xmm0, 0x50(%rsp)
xorl %eax, %eax
xorl %edx, %edx
cmpl $0x9, 0x8(%rbx)
movl 0xc(%rbx), %ecx
sete %al
movq %rax, 0x28(%rsp)
setne %dl
negl %edx
leaq 0x10(%rsp), %rsi
movq %r15, %rdi
callq 0x48af1
leaq 0x30(%rbx), %rax
movq %rax, 0x48(%rsp)
pushq $0x1
popq %rax
movq %rax, 0x20(%rsp)
xorl %r15d, %r15d
movslq %r15d, %rax
leaq (%rax,%rax), %rcx
movq %rcx, 0x38(%rsp)
incl %eax
movq %rax, 0x18(%rsp)
movq 0x10(%rsp), %r13
movl %r12d, 0xc(%rsp)
movq %r13, %r12
movq %r13, 0x60(%rsp)
testq %r12, %r12
je 0x491a8
cmpl (%rbx), %r15d
jge 0x491a8
cmpl $0x0, 0x14(%rbx)
jne 0x48d81
movq (%r12), %rax
movq 0x20(%rax), %rdi
callq 0x10881
movl %eax, 0x44(%rsp)
movq (%r12), %rbp
movq 0x10(%r12), %r13
movq %r12, %rdi
callq 0x34ff7
movl 0x8(%rbx), %eax
addl $-0x5, %eax
cmpl $0x4, %eax
ja 0x48e4f
leaq 0x51970(%rip), %rcx     # 0x9a718
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpl $0x0, 0xc(%rbx)
je 0x48f57
movq 0x20(%rbp), %rdi
leaq 0x28(%rbp), %rsi
callq 0x92f52
movl %eax, 0x30(%rbp)
xorl %r12d, %r12d
cmpl $-0x1, %eax
setne %r12b
jmp 0x48e5e
movq 0x38(%rsp), %rax
movsbl 0x30(%rbx,%rax), %esi
movsd 0x28(%rbx), %xmm0
movq %rbp, %rdi
callq 0x4c565
jmp 0x48e4a
movsd 0x28(%rbx), %xmm0
movq %rbp, %rdi
pushq $-0x3
jmp 0x48e44
movq %rbp, %rdi
callq 0x1c028
movl %eax, %r12d
movq 0x48(%rsp), %rdi
callq 0x4190
leal -0x1(%rax), %ecx
cmpl %eax, %r12d
cmovll %r12d, %ecx
movslq %ecx, %rax
movsbl 0x30(%rbx,%rax), %esi
movsd 0x28(%rbx), %xmm0
movq %rbp, %rdi
callq 0x4c565
movl 0xc(%rsp), %r12d
jmp 0x48e5e
movsd 0x28(%rbx), %xmm0
movq %rbp, %rdi
pushq $-0x2
popq %rsi
callq 0x4ba38
movl %eax, %r12d
jmp 0x48e5e
leaq 0x51908(%rip), %rdi     # 0x9a75e
callq 0x4090
xorl %r12d, %r12d
cmpl $0x0, 0xc(%rbx)
je 0x48e6e
movq %rbp, %rdi
callq 0x91657
jmp 0x48e76
movq %rbp, %rdi
callq 0x4692e
testl %r12d, %r12d
je 0x48f66
testl %eax, %eax
je 0x48f66
cmpl $0x0, 0x14(%rbx)
movl %r12d, 0xc(%rsp)
jne 0x48f88
cmpl $0x0, 0x10(%rbx)
jne 0x48eba
leaq 0x849cd(%rip), %rax     # 0xcd870
movq (%rax), %rdi
movl 0x8(%rbx), %edx
addl $-0x5, %edx
movq 0x18(%rsp), %rsi
callq 0x93ba7
movl %eax, 0x40(%rsp)
movq (%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x10881
movl %eax, %r12d
movq 0x8(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x10881
subl 0x44(%rsp), %r14d
addl %r12d, %r14d
addl %eax, %r14d
cvtsi2sd %r14d, %xmm0
divsd 0x58(%rsp), %xmm0
movsd 0x18(%rbx), %xmm1
movsd 0x20(%rbx), %xmm2
movl 0x40(%rsp), %edi
movl 0x34(%rsp), %esi
callq 0x41c3e
movsd 0x50(%rsp), %xmm1
ucomisd %xmm0, %xmm1
ja 0x48f7d
movq (%rbp), %rax
movq 0x8(%rbp), %rcx
movq 0x20(%rax), %rax
leaq 0x20(%rbp), %rdi
movq %rax, 0x20(%rbp)
movq 0x20(%rcx), %rsi
callq 0x2c6e4
movq (%rbp), %rax
andq $0x0, 0x20(%rax)
movq 0x8(%rbp), %rax
andq $0x0, 0x20(%rax)
movq %rbp, %rdi
callq 0x1b42e
movq %rbp, %rdi
callq 0x1a6ac
movq %r13, %r12
jmp 0x48d58
movsd 0x28(%rbx), %xmm0
movq %rbp, %rdi
xorl %esi, %esi
jmp 0x48e45
movq %rbp, %rdi
callq 0x1a6ac
cmpl $0x9, 0x8(%rbx)
jne 0x48d4b
jmp 0x491ce
movsd %xmm0, 0x50(%rsp)
movl 0xc(%rsp), %r12d
movq %r13, 0x10(%rsp)
cmpl $0x9, 0x8(%rbx)
jne 0x49028
movslq 0x38(%rsp), %rax
movq 0x48(%rsp), %rcx
movzbl 0x1(%rcx,%rax), %eax
cmpl $0x30, %eax
je 0x490d7
cmpl $0x32, %eax
movq 0x18(%rsp), %rcx
je 0x4910c
movl %ecx, %r15d
cmpl $0x31, %eax
jne 0x48d33
movq (%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x108c8
movq %rax, %r12
movq 0x8(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x108c8
movq %rax, %r15
movq %r12, %rdi
callq 0x1b961
movsd %xmm0, 0x38(%rsp)
movq %r15, %rdi
callq 0x1b961
ucomisd 0x38(%rsp), %xmm0
jbe 0x4915a
movq 0x8(%rbp), %rdi
xorl %esi, %esi
callq 0x1abee
movq 0x8(%rbp), %rdi
callq 0x1a6ac
movq (%rbp), %rdi
jmp 0x49172
movl 0xc(%rbx), %ecx
testl %ecx, %ecx
je 0x4909b
leaq 0x8483a(%rip), %rax     # 0xcd870
movq (%rax), %rax
movslq 0x30(%rbp), %rdx
imulq $0x340, %rdx, %rsi      # imm = 0x340
cmpl $0x1, 0x30f08(%rax,%rsi)
jne 0x4909b
xorl %r12d, %r12d
xorl %r13d, %r13d
movslq %edx, %rcx
imulq $0x340, %rcx, %rcx      # imm = 0x340
movslq 0x30f20(%rax,%rcx), %rax
cmpq %rax, %r13
jge 0x490c5
movq 0x10(%rbp), %rdi
addq %r12, %rdi
leaq 0x10(%rsp), %rsi
pushq $-0x1
popq %rdx
pushq $0x1
popq %rcx
callq 0x48af1
incq %r13
leaq 0x847e4(%rip), %rax     # 0xcd870
movq (%rax), %rax
movl 0x30(%rbp), %edx
addq $0x160, %r12            # imm = 0x160
jmp 0x49054
movq (%rbp), %rdi
leaq 0x10(%rsp), %r12
movq %r12, %rsi
pushq $-0x1
popq %r13
movl %r13d, %edx
callq 0x48af1
movq 0x8(%rbp), %rdi
movl 0xc(%rbx), %ecx
movq %r12, %rsi
movl %r13d, %edx
callq 0x48af1
movq 0x18(%rsp), %rax
movl %eax, %r15d
movl 0xc(%rsp), %r12d
jmp 0x48d33
movq (%rbp), %rdi
xorl %esi, %esi
callq 0x1abee
movq (%rbp), %rdi
callq 0x1a6ac
movq 0x8(%rbp), %rdi
xorl %esi, %esi
callq 0x1abee
movq 0x8(%rbp), %rdi
callq 0x1a6ac
movq 0x18(%rsp), %rax
movl %eax, %r15d
jmp 0x48d33
movq (%rbp), %rdi
movl 0xc(%rbx), %ecx
leaq 0x10(%rsp), %r13
movq %r13, %rsi
movq 0x28(%rsp), %r12
movl %r12d, %edx
callq 0x48af1
testl %eax, %eax
je 0x491e6
leal 0x1(%r12), %edx
movq 0x8(%rbp), %rdi
movl 0xc(%rbx), %ecx
movq %r13, %rsi
callq 0x48af1
testl %eax, %eax
je 0x49226
addl $0x2, %r12d
movq %r12, 0x28(%rsp)
jmp 0x490c5
movq (%rbp), %rdi
xorl %esi, %esi
callq 0x1abee
movq (%rbp), %rdi
callq 0x1a6ac
movq 0x8(%rbp), %rdi
movl 0xc(%rbx), %ecx
leaq 0x10(%rsp), %rsi
movq 0x28(%rsp), %r13
movl %r13d, %edx
callq 0x48af1
testl %eax, %eax
je 0x4920a
incl %r13d
movq %r13, 0x28(%rsp)
movq %r12, %rdi
callq 0x34ff7
movq %r15, %rdi
callq 0x34ff7
jmp 0x490c5
movq 0x60(%rsp), %rax
movq %rax, 0x10(%rsp)
movq %r12, %rdi
callq 0x48b45
movq 0x20(%rsp), %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r13, 0x10(%rsp)
movq %r13, %rdi
callq 0x48b45
movq $0x0, 0x20(%rsp)
jmp 0x491ba
movq 0x8(%rbp), %rdi
movq $0x0, 0x20(%rsp)
xorl %esi, %esi
callq 0x1abee
movq 0x8(%rbp), %rdi
callq 0x1a6ac
movq 0x10(%rsp), %rdi
jmp 0x491b5
movq 0x10(%rsp), %rdi
callq 0x48b45
movq %r12, %rdi
callq 0x34ff7
movq %r15, %rdi
callq 0x34ff7
jmp 0x491db
movq 0x10(%rsp), %rdi
jmp 0x491d6
nopl (%rax)