// File: /workspace/github_c_makefile_star2_O1/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
movq %rdx, %r15
movq %rsi, %rbx
movq %rdi, %r14
leaq 0xb5625(%rip), %r13     # 0xd2870
cmpl $-0x1, 0x30(%rbx)
je 0x1d3ff
movq %r14, %rdi
movq %r15, %rsi
callq 0x1ce72
movl %eax, %ebp
movl 0x30(%rbx), %r12d
movl $0xffffffff, 0x30(%rbx) # imm = 0xFFFFFFFF
movq %r14, %rdi
movq %r15, %rsi
callq 0x1ce72
cmpl %ebp, %eax
jge 0x1d2bc
movl %r12d, 0x30(%rbx)
testl %r12d, %r12d
js 0x1d2a8
cmpl $0x2, 0x98(%r14)
je 0x1d2a8
movq (%r13), %rax
imulq $0x340, %r12, %rcx      # imm = 0x340
cmpl $0x1, 0x30f08(%rax,%rcx)
je 0x1d3a9
movq (%rbx), %rsi
movq %r14, %rdi
movq %r15, %rdx
callq 0x1d22a
movq 0x8(%rbx), %rbx
jmp 0x1d24b
movl %r12d, %edi
movl $0x2, %esi
movl $0xfffffffe, %edx       # imm = 0xFFFFFFFE
movl $0xfffffffd, %ecx       # imm = 0xFFFFFFFD
xorl %eax, %eax
callq 0x39a80
testl %eax, %eax
je 0x1d2e8
movq 0x38(%rbx), %rdi
movq 0x40(%rbx), %rsi
callq 0x3dbad
jmp 0x1d305
cmpl $-0x4, %r12d
jne 0x1d305
leaq 0xa8(%rbx), %rsi
movl $0x11, %ecx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
callq 0x8dd6c
movl %r12d, 0x30(%rbx)
leaq 0x20(%rbx), %rdi
movq %rbx, %rsi
callq 0x1c787
movl $0xffffffff, 0x30(%rbx) # imm = 0xFFFFFFFF
testl %r12d, %r12d
js 0x1d390
cmpl $0x2, 0x98(%r14)
je 0x1d390
movq (%r13), %rax
imulq $0x340, %r12, %r14      # imm = 0x340
cmpl $0x1, 0x30f08(%rax,%r14)
jne 0x1d390
movq (%r13), %rax
cmpl $0x0, 0x30f20(%rax,%r14)
jle 0x1d37d
xorl %r15d, %r15d
xorl %r12d, %r12d
movq 0x10(%rbx), %rdi
addq %r15, %rdi
callq 0x1cfd1
incq %r12
movq (%r13), %rax
movslq 0x30f20(%rax,%r14), %rax
addq $0x160, %r15            # imm = 0x160
cmpq %rax, %r12
jl 0x1d356
movq 0x10(%rbx), %rdi
callq 0x39194
movq $0x0, 0x10(%rbx)
jmp 0x1d3ff
movq %rbx, %rdi
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1d173
movq (%r13), %rax
movslq 0x30(%rbx), %rcx
imulq $0x340, %rcx, %rcx      # imm = 0x340
cmpl $0x0, 0x30f20(%rax,%rcx)
jle 0x1d3ff
xorl %r12d, %r12d
xorl %ebp, %ebp
movq 0x10(%rbx), %rsi
addq %r12, %rsi
movq %r14, %rdi
movq %r15, %rdx
callq 0x1d22a
incq %rbp
movq (%r13), %rax
movslq 0x30(%rbx), %rcx
imulq $0x340, %rcx, %rcx      # imm = 0x340
movslq 0x30f20(%rax,%rcx), %rax
addq $0x160, %r12            # imm = 0x160
cmpq %rax, %rbp
jl 0x1d3c7
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq