// File: /workspace/github_c_makefile_star2_O1/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 $0x48, %rsp
movq %rdx, %r14
movq %rsi, 0x38(%rsp)
movq %rdi, %rbx
movq (%rdi), %rdi
callq 0x2fa14
movl %eax, 0x1c(%rsp)
movq (%rbx), %rax
movq %rax, 0x8(%rsp)
cvtsi2sdl 0x4(%r14), %xmm0
movsd %xmm0, (%rsp)
movl 0x14(%r14), %edi
movl $0x3, %esi
movl $0x2, %edx
xorl %ecx, %ecx
movl $0x1, %r8d
xorl %eax, %eax
callq 0x39a80
testl %eax, %eax
je 0xbf4f
movq %rbx, 0x28(%rsp)
cmpl $0x0, 0x4(%r14)
jle 0xbf73
movsd 0x97020(%rip), %xmm0    # 0xa2de8
divsd (%rsp), %xmm0
movsd %xmm0, 0x20(%rsp)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
xorl %r12d, %r12d
xorl %ecx, %ecx
movq $0x0, 0x10(%rsp)
cmpl $0x0, 0x4(%r14)
jle 0xbf41
movl %eax, (%rsp)
movq %rcx, 0x30(%rsp)
leal 0x1(%rcx), %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x20(%rsp), %xmm0
movsd %xmm0, 0x40(%rsp)
xorl %ebp, %ebp
xorl %edi, %edi
movl $0x1, %esi
callq 0x1c996
movq %rax, %rbx
movq 0x8(%rsp), %rax
movq %rax, 0x20(%rbx)
movsd 0x40(%rsp), %xmm0
movsd %xmm0, 0x18(%r14)
leal 0x1(%rbp), %r15d
xorps %xmm0, %xmm0
cvtsi2sd %r15d, %xmm0
mulsd 0x20(%rsp), %xmm0
movsd %xmm0, 0x20(%r14)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4ed75
movl 0x14(%r14), %eax
cmpl $0x2, %eax
je 0xbe77
cmpl $0x1, %eax
jne 0xbea8
movq %rbx, %rdi
movq %r14, %rsi
movl 0x1c(%rsp), %edx
callq 0x4e9a7
jmp 0xbea8
movsd 0x18(%r14), %xmm0
leaq 0x96bb8(%rip), %rdi     # 0xa2a3c
callq 0x53538
movsd 0x20(%r14), %xmm0
leaq 0x96bac(%rip), %rdi     # 0xa2a42
callq 0x53538
movq %rbx, %rdi
movl $0x3, %esi
callq 0x518e8
movq 0x38(%rsp), %rax
movq (%rax), %rsi
movq %rbx, %rdi
callq 0x1ce72
movl %eax, %r13d
movq 0x10(%rsp), %rax
leal (%rax,%rbp), %esi
incl %esi
leaq 0x968e4(%rip), %rdi     # 0xa27b0
movl $0x3, %edx
leaq 0xa1c86(%rip), %rcx     # 0xadb5e
movl %r13d, %r8d
xorl %eax, %eax
callq 0x32c64
movq $0x0, 0x8(%rsp)
leaq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0x1c787
movl (%rsp), %eax
cmpl %eax, %r13d
jle 0xbf11
movq %r12, %rdi
movq %rbx, %r12
cmpl $-0x1, %eax
movl %r13d, (%rsp)
jne 0xbf17
jmp 0xbf1f
movq %rbx, %rdi
movq %r12, %rbx
callq 0x1cfd1
movq %rbx, %r12
movl %r15d, %ebp
cmpl 0x4(%r14), %r15d
jl 0xbe11
movq 0x10(%rsp), %rax
addl %r15d, %eax
movq %rax, 0x10(%rsp)
movl (%rsp), %eax
movq 0x30(%rsp), %rcx
incl %ecx
cmpl 0x4(%r14), %ecx
jl 0xbde6
jmp 0xbf76
xorl %edi, %edi
movl $0x1, %esi
callq 0x1c996
movq %rax, %r12
movq (%rbx), %rax
movq %rax, 0x20(%r12)
movq %r12, %rdi
movq %r14, %rsi
callq 0x4ed75
jmp 0xbf83
xorl %r12d, %r12d
movq 0x8(%rsp), %rax
movq 0x28(%rsp), %rcx
movq %rax, (%rcx)
movq %r12, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq