// File: /workspace/github_c_makefile_star2_O3/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 $0x58, %rsp
movq %r8, 0x38(%rsp)
movq %rdi, %r14
movq %rdx, 0x48(%rsp)
movq (%rdx), %r13
testq %r13, %r13
je 0xad37
movq %rsi, %r12
movq %r14, 0x40(%rsp)
movl 0xc(%rcx), %r15d
movsd 0x9b1ad(%rip), %xmm0    # 0xa5de0
movsd %xmm0, 0x50(%rsp)
movb $0x1, %r14b
xorl %ebx, %ebx
movq 0x30(%r13), %rax
movq %rax, 0x30(%rsp)
movups (%r13), %xmm0
movups 0x10(%r13), %xmm1
movups 0x20(%r13), %xmm2
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq %r12, %rdi
callq 0x7b9ee
testl %eax, %eax
jne 0xac7e
movq 0x30(%r13), %r13
testq %r13, %r13
jne 0xac3e
jmp 0xad2c
movq %r13, %r14
testl %r15d, %r15d
jne 0xade9
movq 0x30(%r14), %rax
movq %rax, 0x30(%rsp)
movupd (%r14), %xmm0
movups 0x10(%r14), %xmm1
movups 0x20(%r14), %xmm2
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movupd %xmm0, (%rsp)
callq 0x7cc0e
movsd 0x50(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jbe 0xacce
movl (%r14), %ebp
movsd %xmm0, 0x50(%rsp)
movq %r14, %rbx
movq %r14, %rdi
callq 0x7cc5f
testq %rax, %rax
je 0xadbb
movq %rax, %r14
movq 0x30(%rax), %rax
movq %rax, 0x30(%rsp)
movups (%r14), %xmm0
movups 0x10(%r14), %xmm1
movups 0x20(%r14), %xmm2
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq %r12, %rdi
callq 0x7b9ee
testl %eax, %eax
jne 0xac81
movq 0x30(%r14), %r13
xorl %r14d, %r14d
testq %r13, %r13
jne 0xac3e
jmp 0xadbb
testb $0x1, %r14b
movq 0x40(%rsp), %r14
je 0xad7c
leaq 0x9b17d(%rip), %rdi     # 0xa5ebb
callq 0x54bec
movq 0x48(%rsp), %rbx
movq 0x18(%rbx), %rdi
leaq 0xcab1d(%rip), %rcx     # 0xd5870
movq (%rcx), %rcx
movl 0x10(%rcx), %edx
cmpl $0x1, %eax
jne 0xad6d
movq 0x38(%rsp), %rsi
callq 0x38636
jmp 0xae4c
movq 0x38(%rsp), %rsi
callq 0x38540
jmp 0xae4c
testl %r15d, %r15d
je 0xadbb
leaq 0x9b133(%rip), %rdi     # 0xa5ebb
callq 0x54bec
movq 0x48(%rsp), %rbx
movq 0x18(%rbx), %rdi
leaq 0xcaad3(%rip), %rcx     # 0xd5870
movq (%rcx), %rcx
movl 0x10(%rcx), %edx
cmpl $0x1, %eax
jne 0xae3d
movq 0x38(%rsp), %rsi
callq 0x38636
jmp 0xae47
leaq 0x9b0f9(%rip), %rdi     # 0xa5ebb
callq 0x54bec
movq 0x10(%rbx), %rdi
leaq 0xcaa9e(%rip), %rcx     # 0xd5870
movq (%rcx), %rcx
movl 0x10(%rcx), %edx
cmpl $0x1, %eax
jne 0xae17
movq 0x38(%rsp), %rsi
callq 0x38636
jmp 0xae21
leaq 0x9b0cb(%rip), %rdi     # 0xa5ebb
callq 0x54bec
movq 0x10(%r13), %rdi
leaq 0xcaa70(%rip), %rcx     # 0xd5870
movq (%rcx), %rcx
movl 0x10(%rcx), %edx
cmpl $0x1, %eax
jne 0xae28
movq 0x38(%rsp), %rsi
callq 0x38636
jmp 0xae32
movq 0x38(%rsp), %rsi
callq 0x38540
movq 0x40(%rsp), %r14
jmp 0xae4f
movq 0x38(%rsp), %rsi
callq 0x38540
movq 0x40(%rsp), %r14
movl (%r13), %ebp
jmp 0xae4f
movq 0x38(%rsp), %rsi
callq 0x38540
movq 0x40(%rsp), %r14
movl 0x14(%rbx), %ebp
movl %ebp, 0x8(%r14)
movq %r14, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq