// File: /workspace/github_c_makefile_star2_O2/olcaytaner[P]Isell/classification.c
// Function: test_irep
Prediction test_irep(Instanceptr data, void* model, void* parameters, double* posterior)
{
 /*!Last Changed 10.11.2003 Rulecount, decisioncount and mdl added*/
 /*!Last Changed 21.05.2003 free_ruleset function is added*/
 /*!Last Changed 13.05.2003*/
 int bestclass, rulesordered;
 BOOLEAN covered = BOOLEAN_FALSE;
 double besterror = 1.5, error; 
 Ruleset* r;
 Decisionruleptr tmp, bestrule = NULL;
 Prediction predicted;
 r = (Ruleset*) model;
 tmp = r->start;
 rulesordered = ((Ripper_parameterptr) parameters)->rulesordered;
 while (tmp)
  {
   if (rule_cover_instance(data, *tmp))
    {
     covered = BOOLEAN_TRUE;
     if (rulesordered)
      {
       if (get_parameter_o("laplaceestimate") == ON)
         normalize_array_laplace(tmp->counts, posterior, current_dataset->classno);
       else
         normalize_array(tmp->counts, posterior, current_dataset->classno);
       predicted.classno = tmp->classno;
       return predicted;
      }
     else
      {
       error = laplace_estimate_of_rule(*tmp);
       if (error < besterror)
        {
         besterror = error;
         bestclass = tmp->classno;
         bestrule = tmp;
        }
       tmp = get_next_class_rule(tmp);
       if (tmp)
         continue;
       else
         break;
      }
    }
   tmp = tmp->next;
  }
 if (!covered)
  {
   if (get_parameter_o("laplaceestimate") == ON)
     normalize_array_laplace(r->counts, posterior, current_dataset->classno);
			else
     normalize_array(r->counts, posterior, current_dataset->classno);
   predicted.classno = r->defaultclass;
   return predicted;
  }
 else
   if (!rulesordered)
    {
  			if (get_parameter_o("laplaceestimate") == ON)
       normalize_array_laplace(bestrule->counts, posterior, current_dataset->classno);
			  else
       normalize_array(bestrule->counts, posterior, current_dataset->classno);
     predicted.classno = bestclass;
     return predicted;
    }
   else
    {
  			if (get_parameter_o("laplaceestimate") == ON)
       normalize_array_laplace(r->counts, posterior, current_dataset->classno);
			  else
       normalize_array(r->counts, posterior, current_dataset->classno);
     predicted.classno = r->defaultclass;
     return predicted;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %r8, 0x38(%rsp)
movq %rdx, %r13
movq %rsi, %r12
movq %rdi, 0x40(%rsp)
movl 0xc(%rcx), %ebx
xorl %r14d, %r14d
movsd 0x8b70d(%rip), %xmm0    # 0x95de8
movsd %xmm0, 0x58(%rsp)
pushq $0x1
popq %rbp
movq %rdx, 0x50(%rsp)
xorl %r15d, %r15d
movq (%r13), %r13
testq %r13, %r13
je 0xa7f1
movq %r13, 0x60(%rsp)
movq 0x30(%r13), %rax
movq %rax, 0x30(%rsp)
movupd (%r13), %xmm0
movupd 0x10(%r13), %xmm1
movups 0x20(%r13), %xmm2
movups %xmm2, 0x20(%rsp)
movupd %xmm1, 0x10(%rsp)
movupd %xmm0, (%rsp)
movq %r12, %rdi
callq 0x71406
testl %eax, %eax
je 0xa79e
testl %ebx, %ebx
jne 0xa7a7
movq 0x30(%r13), %rax
movq %rax, 0x30(%rsp)
movupd (%r13), %xmm0
movups 0x10(%r13), %xmm1
movups 0x20(%r13), %xmm2
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movupd %xmm0, (%rsp)
callq 0x724bd
movsd 0x58(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jbe 0xa782
movl (%r13), %eax
movl %eax, 0x4c(%rsp)
movsd %xmm0, 0x58(%rsp)
movq %r13, %r15
movq %r13, %rdi
callq 0x7250e
movq %rax, %r13
movl %ebp, %r14d
testq %rax, %rax
jne 0xa6fe
jmp 0xa838
addq $0x30, %r13
jmp 0xa6ec
leaq 0x8b715(%rip), %rdi     # 0x95ec3
callq 0x4cff1
movq 0x60(%rsp), %r14
movq 0x10(%r14), %rdi
leaq 0xc30ad(%rip), %rcx     # 0xcd870
movq (%rcx), %rcx
movl 0x10(%rcx), %edx
cmpl $0x1, %eax
jne 0xa7da
movq 0x38(%rsp), %rsi
callq 0x33bf9
jmp 0xa7e4
movq 0x38(%rsp), %rsi
callq 0x33b8f
movq 0x40(%rsp), %rbx
movl (%r14), %eax
jmp 0xa879
testl %r14d, %r14d
je 0xa88e
testl %ebx, %ebx
je 0xa838
leaq 0x8b6be(%rip), %rdi     # 0x95ec3
callq 0x4cff1
movq 0x50(%rsp), %r14
movq 0x18(%r14), %rdi
leaq 0xc3056(%rip), %rcx     # 0xcd870
movq (%rcx), %rcx
movl 0x10(%rcx), %edx
cmpl $0x1, %eax
jne 0xa8c6
movq 0x38(%rsp), %rsi
callq 0x33bf9
jmp 0xa8d0
leaq 0x8b684(%rip), %rdi     # 0x95ec3
callq 0x4cff1
movq 0x10(%r15), %rdi
leaq 0xc3021(%rip), %rcx     # 0xcd870
movq (%rcx), %rcx
movl 0x10(%rcx), %edx
cmpl $0x1, %eax
jne 0xa866
movq 0x38(%rsp), %rsi
callq 0x33bf9
jmp 0xa870
movq 0x38(%rsp), %rsi
callq 0x33b8f
movq 0x40(%rsp), %rbx
movl 0x4c(%rsp), %eax
movl %eax, 0x8(%rbx)
movq %rbx, %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x8b62e(%rip), %rdi     # 0x95ec3
callq 0x4cff1
movq 0x50(%rsp), %r14
movq 0x18(%r14), %rdi
leaq 0xc2fc6(%rip), %rcx     # 0xcd870
movq (%rcx), %rcx
movl 0x10(%rcx), %edx
cmpl $0x1, %eax
movq 0x40(%rsp), %rbx
jne 0xa8d7
movq 0x38(%rsp), %rsi
callq 0x33bf9
jmp 0xa8e1
movq 0x38(%rsp), %rsi
callq 0x33b8f
movq 0x40(%rsp), %rbx
jmp 0xa8e1
movq 0x38(%rsp), %rsi
callq 0x33b8f
movl 0x14(%r14), %eax
jmp 0xa879