// File: /workspace/github_c_makefile_star2_O3/olcaytaner[P]Isell/decisiontree.c
// Function: prune_tree
void prune_tree(Decisionnodeptr root, Decisionnodeptr toberemoved, Instanceptr cvdata)
{
 /*!Last Changed 24.05.2006 added free_children*/
 /*!Last Changed 10.08.2005 added root in order to remove c45node*/
 /*!Last Changed 28.05.2005 added SVM*/
 /*!Last Changed 22.09.2004 handles also multivariate decision trees*/
 /*!Last Changed 18.03.2004*/
 /*!Last Changed 23.03.2002*/
 int performancebefore, performance, tmp, i;
 if (toberemoved->featureno == LEAF_NODE)
   return;
 performancebefore = test_tree(root, cvdata);
 tmp = toberemoved->featureno;
 toberemoved->featureno = LEAF_NODE;
 performance = test_tree(root, cvdata);
 if (performance >= performancebefore)
  {
   if (in_list(tmp, 2, LINEAR, QUADRATIC))
     matrix_free(toberemoved->w);
   else
     if (tmp == SVMLIN)
       free_svm_split(toberemoved->svmsplit);
   toberemoved->featureno = tmp;
   accumulate_instances_tree(&(toberemoved->instances), toberemoved);
   toberemoved->featureno = LEAF_NODE;
   if (tmp >= 0 && (root->conditiontype != HYBRID_CONDITION) && current_dataset->features[tmp].type == STRING)
    {
     for (i = 0; i < current_dataset->features[tmp].valuecount;i++)
       deallocate_tree(&(toberemoved->string[i]));
     safe_free(toberemoved->string);
     toberemoved->string = NULL;
    }
   else
     free_children(toberemoved);
  }
 else
  {
   toberemoved->featureno = tmp;
   if (toberemoved->featureno >= 0 && (root->conditiontype != HYBRID_CONDITION) && current_dataset->features[toberemoved->featureno].type == STRING)
    {
     for (i = 0;i < current_dataset->features[toberemoved->featureno].valuecount;i++)
       prune_tree(root, &(toberemoved->string[i]), cvdata);
    }
   else
    {
     prune_tree(root, toberemoved->left, cvdata);
     prune_tree(root, toberemoved->right, cvdata);
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
cmpl $-0x1, 0x30(%rsi)
je 0x1da38
movq %rdx, %r15
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x30(%rsi), %r13
movq %r14, %rdi
movq %r15, %rsi
callq 0x1d5ec
movl %eax, %ebp
movl 0x30(%rbx), %r12d
movl $0xffffffff, 0x30(%rbx) # imm = 0xFFFFFFFF
movq %r14, %rdi
movq %r15, %rsi
callq 0x1d5ec
cmpl %ebp, %eax
jge 0x1da4a
movl %r12d, (%r13)
testl %r12d, %r12d
js 0x1da1c
cmpl $0x2, 0x98(%r14)
je 0x1da1c
leaq 0xb7e6c(%rip), %rax     # 0xd5870
movq (%rax), %rax
imulq $0x340, %r12, %rcx      # imm = 0x340
cmpl $0x1, 0x30f08(%rax,%rcx)
je 0x1db47
movq (%rbx), %rsi
movq %r14, %rdi
movq %r15, %rdx
callq 0x1d99b
movq 0x8(%rbx), %rbx
leaq 0x30(%rbx), %r13
cmpl $-0x1, 0x30(%rbx)
jne 0x1d9c3
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %r12d, %edi
movl $0x2, %esi
movl $0xfffffffe, %edx       # imm = 0xFFFFFFFE
movl $0xfffffffd, %ecx       # imm = 0xFFFFFFFD
xorl %eax, %eax
callq 0x3aa8c
testl %eax, %eax
je 0x1da76
movq 0x38(%rbx), %rdi
movq 0x40(%rbx), %rsi
callq 0x3ed51
jmp 0x1da93
cmpl $-0x4, %r12d
jne 0x1da93
leaq 0xa8(%rbx), %rsi
movl $0x11, %ecx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
callq 0x90540
movl %r12d, (%r13)
leaq 0x20(%rbx), %rdi
movq %rbx, %rsi
callq 0x1cef5
movl $0xffffffff, (%r13)     # imm = 0xFFFFFFFF
testl %r12d, %r12d
js 0x1db2e
cmpl $0x2, 0x98(%r14)
je 0x1db2e
leaq 0xb7daf(%rip), %rax     # 0xd5870
movq (%rax), %rax
imulq $0x340, %r12, %r14      # imm = 0x340
cmpl $0x1, 0x30f08(%rax,%r14)
jne 0x1db2e
addq $0x30f08, %rax          # imm = 0x30F08
cmpl $0x0, 0x18(%rax,%r14)
leaq 0xb7d87(%rip), %r13     # 0xd5870
jle 0x1db18
xorl %r15d, %r15d
xorl %r12d, %r12d
movq 0x10(%rbx), %rdi
addq %r15, %rdi
callq 0x1d74c
incq %r12
movq (%r13), %rax
movslq 0x30f20(%rax,%r14), %rax
addq $0x160, %r15            # imm = 0x160
cmpq %rax, %r12
jl 0x1daf1
movq 0x10(%rbx), %rdi
callq 0x3a180
movq $0x0, 0x10(%rbx)
jmp 0x1da38
movq %rbx, %rdi
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1d8e3
addq $0x30f08, %rax          # imm = 0x30F08
cmpl $0x0, 0x18(%rax,%rcx)
jle 0x1da38
xorl %r12d, %r12d
xorl %ebp, %ebp
movq 0x10(%rbx), %rsi
addq %r12, %rsi
movq %r14, %rdi
movq %r15, %rdx
callq 0x1d99b
incq %rbp
leaq 0xb7cf7(%rip), %rax     # 0xd5870
movq (%rax), %rax
movslq (%r13), %rcx
imulq $0x340, %rcx, %rcx      # imm = 0x340
movslq 0x30f20(%rax,%rcx), %rax
addq $0x160, %r12            # imm = 0x160
cmpq %rax, %rbp
jl 0x1db5d
jmp 0x1da38