// File: /workspace/github_c_makefile_star2_O2/olcaytaner[P]Isell/univariaterule.c
// Function: prunerule
void prunerule(Decisionruleptr rule, Instanceptr pruneset, int positive, int reptype)
{
 /*!Last Changed 02.12.2004 added free_condition and safe_free*/
 /*!Last Changed 16.06.2003 added if (P == 0) return;*/
 /*!Last Changed 10.05.2003*/
 int P = 0, N = 0, p = 0, n = 0, improved = 1;
 double v, bestv;
 Instanceptr tmp;
 Decisionconditionptr best, bestbefore, tmpcondition, tmpbefore;
 tmp = pruneset;
 while (tmp)
  {
   if (give_classno(tmp) == positive)
    {
     P++;
     if (rule_cover_instance(tmp, *rule))
       p++;
    }
   else
    {
     N++;
     if (rule_cover_instance(tmp, *rule))
       n++;
    }
   tmp = tmp->next;
  }
 if (P == 0)
   return;
 bestv = rule_value_metric(n, p, N, P, reptype);
 while (improved)
  {
   improved = 0;
   tmpbefore = NULL;
   tmpcondition = rule->start;
   while (tmpcondition)
    {
     remove_condition_after(rule, tmpbefore, tmpcondition);
     calculate_performance_for_prune(pruneset, *rule, &p, &n, positive);
     v = rule_value_metric(n, p, N, P, reptype);
     if (dless(bestv, v) || dequal(bestv, v))
      {
       bestv = v;
       bestbefore = tmpbefore;
       best = tmpcondition;
       improved = 1;
      }
     add_condition_after(rule, tmpbefore, tmpcondition);
     tmpbefore = tmpcondition;
     tmpcondition = tmpcondition->next;
    }
   if (improved)
    {
     remove_condition_after(rule, bestbefore, best);
     free_condition(*best);
     safe_free(best);
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movl %ecx, 0x80(%rsp)
movl %edx, 0x84(%rsp)
movq %rsi, %rbp
movq %rdi, %r15
andl $0x0, 0x7c(%rsp)
andl $0x0, 0x78(%rsp)
xorl %ebx, %ebx
xorl %r14d, %r14d
movl $0x0, 0x74(%rsp)
movl $0x0, 0x70(%rsp)
movq %rsi, 0xa0(%rsp)
testq %rbp, %rbp
je 0x902f2
movq %rbp, %rdi
callq 0x2b47e
movl %eax, %r12d
movq 0x30(%r15), %rax
movq %rax, 0x30(%rsp)
movups (%r15), %xmm0
movups 0x10(%r15), %xmm1
movups 0x20(%r15), %xmm2
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq %rbp, %rdi
callq 0x71406
cmpl 0x84(%rsp), %r12d
jne 0x902dc
incl 0x70(%rsp)
testl %eax, %eax
je 0x902ec
incl %ebx
movl %ebx, 0x7c(%rsp)
jmp 0x902ec
incl 0x74(%rsp)
testl %eax, %eax
je 0x902ec
incl %r14d
movl %r14d, 0x78(%rsp)
movq 0x10(%rbp), %rbp
jmp 0x90285
cmpl $0x0, 0x70(%rsp)
je 0x90471
movl %r14d, %edi
movl %ebx, %esi
movl 0x74(%rsp), %edx
movl 0x70(%rsp), %ecx
movl 0x80(%rsp), %r8d
callq 0x90062
movsd %xmm0, 0x88(%rsp)
leaq 0x18(%r15), %rax
movq %rax, 0x98(%rsp)
xorl %ebx, %ebx
testb $0x1, %bl
jne 0x90471
xorl %r13d, %r13d
movq 0x98(%rsp), %rax
xorl %r14d, %r14d
movq (%rax), %rbx
testq %rbx, %rbx
je 0x90439
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x720e4
movq 0x30(%r15), %rax
movq %rax, 0x30(%rsp)
movups (%r15), %xmm0
movups 0x10(%r15), %xmm1
movups 0x20(%r15), %xmm2
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq 0xa0(%rsp), %rdi
leaq 0x7c(%rsp), %rsi
leaq 0x78(%rsp), %rdx
movl 0x84(%rsp), %ecx
callq 0x71ab8
movl 0x78(%rsp), %edi
movl 0x7c(%rsp), %esi
movl 0x74(%rsp), %edx
movl 0x70(%rsp), %ecx
movl 0x80(%rsp), %r8d
callq 0x90062
movaps %xmm0, %xmm1
movsd 0x88(%rsp), %xmm0
movsd %xmm1, 0x90(%rsp)
callq 0x34c76
testl %eax, %eax
jne 0x90401
movsd 0x88(%rsp), %xmm0
movsd 0x90(%rsp), %xmm1
callq 0x34c3a
movsd 0x88(%rsp), %xmm0
testl %eax, %eax
je 0x90416
pushq $0x1
popq %rax
movl %eax, %r13d
movsd 0x90(%rsp), %xmm0
movq %rbx, %rbp
movq %r14, %r12
movsd %xmm0, 0x88(%rsp)
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x7208c
leaq 0x48(%rbx), %rax
movq %rbx, %r14
jmp 0x90345
testl %r13d, %r13d
sete %bl
je 0x9032e
movq %r15, %rdi
movq %r12, %rsi
movq %rbp, %rdx
callq 0x720e4
pushq $0xe
popq %rcx
movq %rsp, %rdi
movq %rbp, %rsi
rep  movsq (%rsi), %es:(%rdi)
callq 0x71b91
movq %rbp, %rdi
callq 0x34ff7
jmp 0x9032e
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq