// File: /workspace/github_c_makefile_star2_O1/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 %rdi, %r15
xorl %r13d, %r13d
movl %r13d, 0x7c(%rsp)
movl %r13d, 0x78(%rsp)
movl $0x0, %r12d
movq %rsi, 0x90(%rsp)
testq %rsi, %rsi
je 0x9c5b5
xorl %r12d, %r12d
movq 0x90(%rsp), %rbx
xorl %r13d, %r13d
movq %rbx, %rdi
callq 0x2eaca
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 0x7a0fc
cmpl 0x84(%rsp), %r14d
jne 0x9c5a1
incl %r12d
testl %eax, %eax
je 0x9c5ac
incl 0x7c(%rsp)
jmp 0x9c5ac
incl %r13d
testl %eax, %eax
je 0x9c5ac
incl 0x78(%rsp)
movq 0x10(%rbx), %rbx
testq %rbx, %rbx
jne 0x9c54c
movq %r13, 0x88(%rsp)
testl %r12d, %r12d
je 0x9c7cd
movl 0x78(%rsp), %ecx
movl 0x7c(%rsp), %eax
cmpl $0x0, 0x80(%rsp)
je 0x9c600
movl %eax, %edx
addl %ecx, %edx
movq 0x88(%rsp), %rsi
je 0x9c626
subl %ecx, %eax
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
xorps %xmm0, %xmm0
cvtsi2sd %edx, %xmm0
addsd 0x6a42(%rip), %xmm0     # 0xa3040
jmp 0x9c620
movq 0x88(%rsp), %rsi
movl %esi, %edx
subl %ecx, %edx
addl %eax, %edx
xorps %xmm1, %xmm1
cvtsi2sd %edx, %xmm1
leal (%r12,%rsi), %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
divsd %xmm0, %xmm1
jmp 0x9c62a
xorpd %xmm1, %xmm1
addl %esi, %r12d
xorps %xmm0, %xmm0
cvtsi2sd %r12d, %xmm0
movsd %xmm0, 0xa0(%rsp)
movq 0x18(%r15), %rax
testq %rax, %rax
je 0x9c78d
movsd %xmm1, 0x70(%rsp)
xorl %ebx, %ebx
xorl %ebp, %ebp
movq %rax, %r12
movq %r15, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x7af03
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 0x90(%rsp), %rdi
leaq 0x7c(%rsp), %rsi
leaq 0x78(%rsp), %rdx
movl 0x84(%rsp), %ecx
callq 0x7a84a
movl 0x78(%rsp), %ecx
movl 0x7c(%rsp), %eax
cmpl $0x0, 0x80(%rsp)
je 0x9c6e9
movl %eax, %edx
addl %ecx, %edx
movsd 0x70(%rsp), %xmm0
je 0x9c70d
subl %ecx, %eax
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
xorps %xmm2, %xmm2
cvtsi2sd %edx, %xmm2
addsd 0x695d(%rip), %xmm2     # 0xa3040
divsd %xmm2, %xmm1
jmp 0x9c711
movq 0x88(%rsp), %rdx
subl %ecx, %edx
addl %eax, %edx
xorps %xmm1, %xmm1
cvtsi2sd %edx, %xmm1
divsd 0xa0(%rsp), %xmm1
movsd 0x70(%rsp), %xmm0
jmp 0x9c711
xorpd %xmm1, %xmm1
movsd %xmm0, 0x70(%rsp)
movsd %xmm1, 0x98(%rsp)
callq 0x38d8e
testl %eax, %eax
jne 0x9c747
movsd 0x70(%rsp), %xmm0
movsd 0x98(%rsp), %xmm1
callq 0x38d52
movsd 0x70(%rsp), %xmm0
testl %eax, %eax
je 0x9c75b
movl $0x1, %ebp
movsd 0x98(%rsp), %xmm0
movq %r12, %r13
movq %rbx, %r14
movsd %xmm0, 0x70(%rsp)
movq %r15, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x7ae99
movq 0x48(%r12), %rax
movq %r12, %rbx
testq %rax, %rax
jne 0x9c655
testl %ebp, %ebp
sete %al
movsd 0x70(%rsp), %xmm1
jmp 0x9c78f
movb $0x1, %al
testb %al, %al
jne 0x9c7cd
movq %r15, %rdi
movq %r14, %rsi
movq %r13, %rdx
movsd %xmm1, 0x70(%rsp)
callq 0x7af03
movl $0xe, %ecx
movq %rsp, %rdi
movq %r13, %rsi
rep  movsq (%rsi), %es:(%rdi)
callq 0x7a935
movq %r13, %rdi
callq 0x39194
movsd 0x70(%rsp), %xmm1
jmp 0x9c63e
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq