// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rax
cmpl $-0x1, 0x30(%rax)
jne 0x2a396
jmp 0x2a5e9
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x29e30
movl %eax, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movl 0x30(%rax), %eax
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rax
movl $0xffffffff, 0x30(%rax) # imm = 0xFFFFFFFF
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x29e30
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jl 0x2a50c
movl -0x24(%rbp), %edi
movl $0x2, %esi
movl $0xfffffffe, %edx       # imm = 0xFFFFFFFE
movl $0xfffffffd, %ecx       # imm = 0xFFFFFFFD
movb $0x0, %al
callq 0x53e40
cmpl $0x0, %eax
je 0x2a408
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rdi
movq 0x40(%rax), %rsi
callq 0x59ea0
jmp 0x2a42b
cmpl $-0x4, -0x24(%rbp)
jne 0x2a429
movq -0x10(%rbp), %rsi
addq $0xa8, %rsi
movq %rsp, %rdi
movl $0x11, %ecx
rep  movsq (%rsi), %es:(%rdi)
callq 0xc5dd0
jmp 0x2a42b
movl -0x24(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x30(%rax)
movq -0x10(%rbp), %rdi
addq $0x20, %rdi
movq -0x10(%rbp), %rsi
callq 0x29160
movq -0x10(%rbp), %rax
movl $0xffffffff, 0x30(%rax) # imm = 0xFFFFFFFF
cmpl $0x0, -0x24(%rbp)
jl 0x2a4fe
movq -0x8(%rbp), %rax
cmpl $0x2, 0x98(%rax)
je 0x2a4fe
leaq 0xdb3cd(%rip), %rax     # 0x105840
movq (%rax), %rax
addq $0x30f08, %rax          # imm = 0x30F08
movslq -0x24(%rbp), %rcx
imulq $0x340, %rcx, %rcx      # imm = 0x340
addq %rcx, %rax
cmpl $0x1, (%rax)
jne 0x2a4fe
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
leaq 0xdb3a0(%rip), %rcx     # 0x105840
movq (%rcx), %rcx
addq $0x30f08, %rcx          # imm = 0x30F08
movslq -0x24(%rbp), %rdx
imulq $0x340, %rdx, %rdx      # imm = 0x340
addq %rdx, %rcx
cmpl 0x18(%rcx), %eax
jge 0x2a4e3
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
movslq -0x28(%rbp), %rax
imulq $0x160, %rax, %rax      # imm = 0x160
addq %rax, %rdi
callq 0x2a030
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x2a496
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x52e80
movq -0x10(%rbp), %rax
movq $0x0, 0x10(%rax)
jmp 0x2a507
movq -0x10(%rbp), %rdi
callq 0x2a250
jmp 0x2a5e9
movl -0x24(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x30(%rax)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x30(%rax)
jl 0x2a5be
movq -0x8(%rbp), %rax
cmpl $0x2, 0x98(%rax)
je 0x2a5be
leaq 0xdb304(%rip), %rax     # 0x105840
movq (%rax), %rax
addq $0x30f08, %rax          # imm = 0x30F08
movq -0x10(%rbp), %rcx
movslq 0x30(%rcx), %rcx
imulq $0x340, %rcx, %rcx      # imm = 0x340
addq %rcx, %rax
cmpl $0x1, (%rax)
jne 0x2a5be
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
leaq 0xdb2d3(%rip), %rcx     # 0x105840
movq (%rcx), %rcx
addq $0x30f08, %rcx          # imm = 0x30F08
movq -0x10(%rbp), %rdx
movslq 0x30(%rdx), %rdx
imulq $0x340, %rdx, %rdx      # imm = 0x340
addq %rdx, %rcx
cmpl 0x18(%rcx), %eax
jge 0x2a5bc
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rsi
movslq -0x28(%rbp), %rax
imulq $0x160, %rax, %rax      # imm = 0x160
addq %rax, %rsi
movq -0x18(%rbp), %rdx
callq 0x2a370
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x2a563
jmp 0x2a5e7
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
movq -0x18(%rbp), %rdx
callq 0x2a370
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x18(%rbp), %rdx
callq 0x2a370
jmp 0x2a5e9
addq $0xb0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)