// File: /workspace/github_c_makefile_star2_O2/olcaytaner[P]Isell/classification.c
// Function: train_nodeboundedtree
void* train_nodeboundedtree(Instanceptr* trdata, Instanceptr *cvdata, void* parameters)
{
 /*!Last Changed 30.09.2007 added postpruning via SRM*/
 /*!Last Changed 31.05.2006*/
 Decisionnodeptr rootnode, besttree = NULL;
 int i, j, k, performance, maxperformance = -1, size = data_size(*trdata);
 double bin;
 Instanceptr data = *trdata;
 Nodeboundedtree_parameterptr p;
 p = (Nodeboundedtree_parameterptr) parameters;
 bin = 4.0 / p->partitioncount;
 if (in_list(p->prunetype, 3, MODELSELECTIONPRUNING, PREPRUNING, VALIDATIONPRUNING))
  {
   k = 0;
   for (i = 0; i < p->partitioncount; i++)
     for (j = 0; j < p->partitioncount; j++)
      {
       rootnode = createnewnode(NULL, 1);
       rootnode->instances = data;
       p->a1 = (i + 1) * bin;
       p->a2 = (j + 1) * bin; 
       create_node_bounded_tree(rootnode, p);
       switch (p->prunetype)
        {
         case     VALIDATIONPRUNING:prune_node_bounded_tree(rootnode, p, size);
                                    break;
         case MODELSELECTIONPRUNING:set_float_parameter("srma1", p->a1);
                                    set_float_parameter("srma2", p->a2);
                                    prune_tree_according_to_model_selection_method(rootnode, MODEL_SELECTION_SRM);
                                    break;
        }
       performance = test_tree(rootnode, *cvdata);
       write_array_variables("aout", k + 1, 3, "d", performance);
       data = NULL;
       accumulate_instances_tree(&data, rootnode);
       if (performance > maxperformance)
        {
         if (maxperformance != -1)
           deallocate_tree(besttree);
         maxperformance = performance;
         besttree = rootnode;       
        }
       else
         deallocate_tree(rootnode);
       k++;
      }
   *trdata = data;
  }
 else
  {
   besttree = createnewnode(NULL, 1);
   besttree->instances = *trdata;  
   create_node_bounded_tree(besttree, p);
  } 
 return besttree;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdx, %rbx
movq %rsi, 0x28(%rsp)
movq %rdi, %r14
movq (%rdi), %rdi
callq 0x2c3cc
movl %eax, 0x14(%rsp)
movq (%r14), %rax
movq %rax, 0x8(%rsp)
cvtsi2sdl 0x4(%rbx), %xmm0
movsd %xmm0, (%rsp)
movl 0x14(%rbx), %edi
pushq $0x3
popq %rsi
pushq $0x2
popq %rdx
pushq $0x1
popq %r8
xorl %ecx, %ecx
xorl %eax, %eax
callq 0x35812
testl %eax, %eax
je 0xb937
movq %r14, 0x20(%rsp)
movsd 0x8a620(%rip), %xmm0    # 0x95df0
divsd (%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
movl 0x4(%rbx), %eax
pushq $-0x1
popq %r15
xorl %r14d, %r14d
xorl %ecx, %ecx
xorl %ebp, %ebp
cmpl %eax, %ecx
jge 0xb928
incl %ecx
movl %ecx, 0x10(%rsp)
cvtsi2sd %ecx, %xmm0
mulsd 0x18(%rsp), %xmm0
movsd %xmm0, 0x30(%rsp)
pushq $0x1
popq %rcx
movl %ecx, %r12d
leal -0x1(%r12), %ecx
cmpl %eax, %ecx
jge 0xb91f
movq %rbp, (%rsp)
xorl %edi, %edi
pushq $0x1
popq %rsi
callq 0x1ac98
movq %rax, %rbp
movq 0x8(%rsp), %rax
movq %rax, 0x20(%rbp)
movsd 0x30(%rsp), %xmm0
movsd %xmm0, 0x18(%rbx)
cvtsi2sd %r12d, %xmm0
mulsd 0x18(%rsp), %xmm0
movsd %xmm0, 0x20(%rbx)
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x48c8b
movl 0x14(%rbx), %eax
cmpl $0x2, %eax
je 0xb878
cmpl $0x1, %eax
jne 0xb8a5
movq %rbp, %rdi
movq %rbx, %rsi
movl 0x14(%rsp), %edx
callq 0x488e1
jmp 0xb8a5
movsd 0x18(%rbx), %xmm0
leaq 0x8a1b8(%rip), %rdi     # 0x95a3c
callq 0x4ce51
movsd 0x20(%rbx), %xmm0
leaq 0x8a1ad(%rip), %rdi     # 0x95a42
callq 0x4ce51
movq %rbp, %rdi
pushq $0x3
popq %rsi
callq 0x4b3a0
movq 0x28(%rsp), %rax
movq (%rax), %rsi
movq %rbp, %rdi
callq 0x1b165
movl %eax, %r13d
incl %r14d
leaq 0x89eee(%rip), %rdi     # 0x957b0
movl %r14d, %esi
pushq $0x3
popq %rdx
leaq 0x9528b(%rip), %rcx     # 0xa0b5a
movl %eax, %r8d
xorl %eax, %eax
callq 0x2f310
andq $0x0, 0x8(%rsp)
leaq 0x8(%rsp), %rdi
movq %rbp, %rsi
callq 0x1aad3
cmpl %r15d, %r13d
jle 0xb902
cmpl $-0x1, %r15d
je 0xb911
movq (%rsp), %rdi
callq 0x1b2aa
jmp 0xb911
movq %rbp, %rdi
callq 0x1b2aa
movl %r15d, %r13d
movq (%rsp), %rbp
movl 0x4(%rbx), %eax
incl %r12d
movl %r13d, %r15d
jmp 0xb80d
movl 0x10(%rsp), %ecx
jmp 0xb7e9
movq 0x8(%rsp), %rax
movq 0x20(%rsp), %rcx
movq %rax, (%rcx)
jmp 0xb956
pushq $0x1
popq %rsi
xorl %edi, %edi
callq 0x1ac98
movq %rax, %rbp
movq (%r14), %rax
movq %rax, 0x20(%rbp)
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x48c8b
movq %rbp, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq