// File: /workspace/github_c_makefile_star2_O2/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, %r12
movq %rsi, %rbx
movq %rdi, %r14
cmpl $-0x1, 0x30(%rbx)
je 0x1b682
movq %r14, %rdi
movq %r12, %rsi
callq 0x1b165
movl %eax, %ebp
movl 0x30(%rbx), %r15d
orl $-0x1, 0x30(%rbx)
movq %r14, %rdi
movq %r12, %rsi
callq 0x1b165
cmpl %ebp, %eax
jge 0x1b562
movl %r15d, 0x30(%rbx)
testl %r15d, %r15d
js 0x1b54e
cmpl $0x2, 0x98(%r14)
je 0x1b54e
leaq 0xb233a(%rip), %rax     # 0xcd870
movq (%rax), %rax
imulq $0x340, %r15, %rcx      # imm = 0x340
cmpl $0x1, 0x30f08(%rax,%rcx)
je 0x1b630
movq (%rbx), %rsi
movq %r14, %rdi
movq %r12, %rdx
callq 0x1b4d4
movq 0x8(%rbx), %rbx
jmp 0x1b4ee
pushq $0x2
popq %rsi
pushq $-0x2
popq %rdx
pushq $-0x3
popq %rcx
movl %r15d, %edi
xorl %eax, %eax
callq 0x35812
testl %eax, %eax
je 0x1b588
movq 0x38(%rbx), %rdi
movq 0x40(%rbx), %rsi
callq 0x3929f
jmp 0x1b5a3
cmpl $-0x4, %r15d
jne 0x1b5a3
leaq 0xa8(%rbx), %rsi
pushq $0x11
popq %rcx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
callq 0x828bc
movl %r15d, 0x30(%rbx)
leaq 0x20(%rbx), %rdi
movq %rbx, %rsi
callq 0x1aad3
orl $-0x1, 0x30(%rbx)
testl %r15d, %r15d
js 0x1b617
cmpl $0x2, 0x98(%r14)
je 0x1b617
leaq 0xb22a3(%rip), %rax     # 0xcd870
movq (%rax), %rax
imulq $0x340, %r15, %r14      # imm = 0x340
cmpl $0x1, 0x30f08(%rax,%r14)
jne 0x1b617
xorl %r15d, %r15d
xorl %r12d, %r12d
movslq 0x30f20(%rax,%r14), %rax
movq 0x10(%rbx), %rdi
cmpq %rax, %r12
jge 0x1b678
addq %r15, %rdi
callq 0x1b2aa
incq %r12
leaq 0xb2265(%rip), %rax     # 0xcd870
movq (%rax), %rax
addq $0x160, %r15            # imm = 0x160
jmp 0x1b5e8
movq %rbx, %rdi
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1b42e
xorl %ebp, %ebp
xorl %r13d, %r13d
movslq %r15d, %rcx
imulq $0x340, %rcx, %rcx      # imm = 0x340
movslq 0x30f20(%rax,%rcx), %rax
cmpq %rax, %r13
jge 0x1b682
movq 0x10(%rbx), %rsi
addq %rbp, %rsi
movq %r14, %rdi
movq %r12, %rdx
callq 0x1b4d4
incq %r13
leaq 0xb2208(%rip), %rax     # 0xcd870
movq (%rax), %rax
movl 0x30(%rbx), %r15d
addq $0x160, %rbp            # imm = 0x160
jmp 0x1b635
callq 0x34ff7
andq $0x0, 0x10(%rbx)
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq