// File: /workspace/github_c_makefile_star2_O3/olcaytaner[P]Isell/omnivariaterule.c
// Function: log_likelihood_of_ruleset
double log_likelihood_of_ruleset(Ruleset set, Instanceptr list, int positive, int* covered)
{
 /*!Last Changed 19.02.2005*/
 int *poscounts, *negcounts, posuncovered = 0, neguncovered = 0, classno, i, iscovered;
 Instanceptr tmp;
 Decisionruleptr rule;
 double result = 0;
 poscounts = safecalloc(set.rulecount, sizeof(int), "log_likelihood_of_ruleset", 5);
 negcounts = safecalloc(set.rulecount, sizeof(int), "log_likelihood_of_ruleset", 6);
 tmp = list;
 while (tmp)
  {
   rule = set.start;
   i = 0;
   classno = give_classno(tmp);
   iscovered = 0;
   while (rule)
    {
     if (rule_cover_instance(tmp, *rule))
      {
       iscovered = 1;
       if (classno == rule->classno)
         poscounts[i]++;
       else
         negcounts[i]++;
       break;
      }
     i++;
     rule = rule->next;
    }
   if (!iscovered)
    {
     if (classno == positive)
       posuncovered++;
     else
       neguncovered++;
    }
   tmp = tmp->next;
  }
 *covered = 0;
 for (i = 0; i < set.rulecount; i++)
  {
   *covered += poscounts[i];
   result += log_likelihood_for_rule_induction(poscounts[i], negcounts[i]);
  }
 *covered += posuncovered;
 result += log_likelihood_for_rule_induction(posuncovered, neguncovered);
 safe_free(poscounts);
 safe_free(negcounts);
 return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rdx, 0x70(%rsp)
movl %esi, 0x40(%rsp)
movq %rdi, %r13
movslq 0xc0(%rsp), %r15
leaq 0x59c0f(%rip), %r14     # 0xaa8ca
movl $0x4, %esi
movq %r15, %rdi
movq %r14, %rdx
movl $0x5, %ecx
callq 0x3a1fc
movq %rax, %rbx
movl $0x4, %esi
movq %r15, 0x68(%rsp)
movq %r15, %rdi
movq %r14, %rdx
movl $0x6, %ecx
callq 0x3a1fc
movq %rax, 0x60(%rsp)
movl $0x0, %eax
movq %rax, 0x48(%rsp)
movl $0x0, %eax
movq %rax, 0x50(%rsp)
testq %r13, %r13
je 0x50dc6
leaq 0xb0(%rsp), %rax
movq (%rax), %r12
movq $0x0, 0x50(%rsp)
movq $0x0, 0x48(%rsp)
movq %r13, %rdi
callq 0x2f33a
movl %eax, %ebp
testq %r12, %r12
je 0x50d83
xorl %r14d, %r14d
movq %r12, %r15
movq 0x30(%r15), %rax
movq %rax, 0x30(%rsp)
movupd (%r15), %xmm0
movupd 0x10(%r15), %xmm1
movups 0x20(%r15), %xmm2
movups %xmm2, 0x20(%rsp)
movupd %xmm1, 0x10(%rsp)
movupd %xmm0, (%rsp)
movq %r13, %rdi
callq 0x7b9ee
testl %eax, %eax
jne 0x50da5
movq 0x30(%r15), %r15
addq $0x4, %r14
testq %r15, %r15
jne 0x50d41
cmpl 0x40(%rsp), %ebp
jne 0x50d97
movq 0x50(%rsp), %rax
incl %eax
movq %rax, 0x50(%rsp)
jmp 0x50db9
movq 0x48(%rsp), %rax
incl %eax
movq %rax, 0x48(%rsp)
jmp 0x50db9
cmpl (%r15), %ebp
jne 0x50db0
incl (%rbx,%r14)
jmp 0x50db9
movq 0x60(%rsp), %rax
incl (%rax,%r14)
movq 0x10(%r13), %r13
testq %r13, %r13
jne 0x50d2c
movq 0x70(%rsp), %r12
movl $0x0, (%r12)
xorpd %xmm0, %xmm0
xorpd %xmm1, %xmm1
movq 0x68(%rsp), %r13
testl %r13d, %r13d
movq 0x60(%rsp), %r14
movl $0x0, %eax
jle 0x50e56
xorl %r15d, %r15d
movl (%rbx,%r15,4), %eax
addl %eax, (%r12)
movl (%rbx,%r15,4), %eax
movl (%r14,%r15,4), %edx
leal (%rdx,%rax), %ecx
imull %eax, %edx
imull %ecx, %edx
xorpd %xmm0, %xmm0
testl %edx, %edx
je 0x50e42
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movsd %xmm0, 0x58(%rsp)
movsd %xmm1, 0x40(%rsp)
xorps %xmm1, %xmm1
cvtsi2sd %ecx, %xmm1
divsd %xmm1, %xmm0
callq 0x39bdc
movsd 0x40(%rsp), %xmm1
mulsd 0x58(%rsp), %xmm0
addsd %xmm0, %xmm1
incq %r15
cmpq %r15, %r13
jne 0x50df2
movl (%r12), %eax
xorpd %xmm0, %xmm0
movq 0x50(%rsp), %rcx
addl %ecx, %eax
movl %eax, (%r12)
movq 0x48(%rsp), %rdx
leal (%rcx,%rdx), %eax
imull %ecx, %edx
imull %eax, %edx
testl %edx, %edx
je 0x50ea2
xorps %xmm0, %xmm0
cvtsi2sd %ecx, %xmm0
movsd %xmm0, 0x58(%rsp)
movsd %xmm1, 0x40(%rsp)
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
callq 0x39bdc
movsd 0x40(%rsp), %xmm1
mulsd 0x58(%rsp), %xmm0
addsd %xmm0, %xmm1
movsd %xmm1, 0x40(%rsp)
movq %rbx, %rdi
callq 0x3a180
movq %r14, %rdi
callq 0x3a180
movsd 0x40(%rsp), %xmm0
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq