// File: /workspace/github_c_makefile_star2_O3/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 $0xb8, %rsp
movl %ecx, 0x90(%rsp)
movl %edx, 0x94(%rsp)
xorl %r13d, %r13d
movl %r13d, 0x84(%rsp)
movl %r13d, 0x80(%rsp)
movq %rsi, 0x98(%rsp)
testq %rsi, %rsi
je 0x9f83d
movq %rdi, %r15
xorl %ebp, %ebp
movq 0x98(%rsp), %rbx
xorl %r12d, %r12d
movq $0x0, 0x88(%rsp)
movq %rbx, %rdi
callq 0x2f33a
movl %eax, %r14d
movq 0x30(%r15), %rax
movq %rax, 0x30(%rsp)
movupd (%r15), %xmm0
movupd 0x10(%r15), %xmm1
movupd 0x20(%r15), %xmm2
movupd %xmm2, 0x20(%rsp)
movupd %xmm1, 0x10(%rsp)
movupd %xmm0, (%rsp)
movq %rbx, %rdi
callq 0x7b9ee
cmpl 0x94(%rsp), %r14d
jne 0x9f5f1
incl %r12d
testl %eax, %eax
je 0x9f610
incl %r13d
movl %r13d, 0x84(%rsp)
jmp 0x9f610
movq 0x88(%rsp), %rcx
incl %ecx
movq %rcx, 0x88(%rsp)
testl %eax, %eax
je 0x9f610
incl %ebp
movl %ebp, 0x80(%rsp)
movq 0x10(%rbx), %rbx
testq %rbx, %rbx
jne 0x9f595
testl %r12d, %r12d
je 0x9f83d
cmpl $0x0, 0x90(%rsp)
je 0x9f653
movl %r13d, %eax
addl %ebp, %eax
je 0x9f680
subl %ebp, %r13d
xorps %xmm1, %xmm1
cvtsi2sd %r13d, %xmm1
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
addsd 0x69ef(%rip), %xmm0     # 0xa6040
jmp 0x9f674
movq 0x88(%rsp), %rcx
movl %ecx, %eax
subl %ebp, %eax
addl %r13d, %eax
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
leal (%r12,%rcx), %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
divsd %xmm0, %xmm1
movsd %xmm1, 0x78(%rsp)
jmp 0x9f68a
xorpd %xmm0, %xmm0
movsd %xmm0, 0x78(%rsp)
movq 0x18(%r15), %rax
testq %rax, %rax
je 0x9f83d
addl 0x88(%rsp), %r12d
xorps %xmm0, %xmm0
cvtsi2sd %r12d, %xmm0
movsd %xmm0, 0xa8(%rsp)
xorl %ebx, %ebx
leaq 0x84(%rsp), %rbp
xorl %r14d, %r14d
movq %rax, %r12
movq %r15, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x7c7c4
movq 0x30(%r15), %rax
movq %rax, 0x30(%rsp)
movups (%r15), %xmm0
movupd 0x10(%r15), %xmm1
movupd 0x20(%r15), %xmm2
movupd %xmm2, 0x20(%rsp)
movupd %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq 0x98(%rsp), %rdi
movq %rbp, %rsi
leaq 0x80(%rsp), %rdx
movl 0x94(%rsp), %ecx
callq 0x7c109
movl 0x80(%rsp), %ecx
movl 0x84(%rsp), %eax
cmpl $0x0, 0x90(%rsp)
je 0x9f758
movl %eax, %edx
addl %ecx, %edx
movsd 0x78(%rsp), %xmm0
je 0x9f77c
subl %ecx, %eax
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
xorps %xmm2, %xmm2
cvtsi2sd %edx, %xmm2
addsd 0x68ee(%rip), %xmm2     # 0xa6040
divsd %xmm2, %xmm1
jmp 0x9f780
movq 0x88(%rsp), %rdx
subl %ecx, %edx
addl %eax, %edx
xorps %xmm1, %xmm1
cvtsi2sd %edx, %xmm1
divsd 0xa8(%rsp), %xmm1
movsd 0x78(%rsp), %xmm0
jmp 0x9f780
xorpd %xmm1, %xmm1
movsd %xmm0, 0x78(%rsp)
movsd %xmm1, 0xa0(%rsp)
callq 0x39aee
testl %eax, %eax
jne 0x9f7b6
movsd 0x78(%rsp), %xmm0
movsd 0xa0(%rsp), %xmm1
callq 0x39ab2
movsd 0x78(%rsp), %xmm0
testl %eax, %eax
je 0x9f7d0
movl $0x1, %r14d
movsd 0xa0(%rsp), %xmm0
movq %r12, %r13
movq %rbx, 0xb0(%rsp)
movsd %xmm0, 0x78(%rsp)
movq %r15, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x7c752
movq 0x48(%r12), %rax
movq %r12, %rbx
testq %rax, %rax
jne 0x9f6bd
testl %r14d, %r14d
je 0x9f83d
movq %r15, %rdi
movq 0xb0(%rsp), %rsi
movq %r13, %rdx
callq 0x7c7c4
movl $0xe, %ecx
movq %rsp, %rdi
movq %r13, %rsi
rep  movsq (%rsi), %es:(%rdi)
callq 0x7c1f4
movq %r13, %rdi
callq 0x3a180
movq 0x18(%r15), %rax
xorl %ebx, %ebx
movl $0x0, %r14d
testq %rax, %rax
jne 0x9f6bd
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq