// File: /workspace/github_c_makefile_star2_O1/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 0x58067(%rip), %r14     # 0xa782a
movl $0x4, %esi
movq %r15, %rdi
movq %r14, %rdx
movl $0x5, %ecx
callq 0x39210
movq %rax, %rbx
movl $0x4, %esi
movq %r15, 0x68(%rsp)
movq %r15, %rdi
movq %r14, %rdx
movl $0x6, %ecx
callq 0x39210
movq %rax, 0x60(%rsp)
testq %r13, %r13
je 0x4f8bc
leaq 0xb0(%rsp), %rax
movq (%rax), %r12
movq $0x0, 0x50(%rsp)
movq $0x0, 0x48(%rsp)
movq %r13, %rdi
callq 0x2eaca
movl %eax, %ebp
testq %r12, %r12
je 0x4f877
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 0x7a0fc
testl %eax, %eax
jne 0x4f899
movq 0x30(%r15), %r15
addq $0x4, %r14
testq %r15, %r15
jne 0x4f835
cmpl 0x40(%rsp), %ebp
jne 0x4f88b
movq 0x50(%rsp), %rax
incl %eax
movq %rax, 0x50(%rsp)
jmp 0x4f8ad
movq 0x48(%rsp), %rax
incl %eax
movq %rax, 0x48(%rsp)
jmp 0x4f8ad
cmpl (%r15), %ebp
jne 0x4f8a4
incl (%rbx,%r14)
jmp 0x4f8ad
movq 0x60(%rsp), %rax
incl (%rax,%r14)
movq 0x10(%r13), %r13
testq %r13, %r13
jne 0x4f820
jmp 0x4f8ce
movq $0x0, 0x48(%rsp)
movq $0x0, 0x50(%rsp)
movq 0x70(%rsp), %r12
movl $0x0, (%r12)
xorpd %xmm1, %xmm1
movq 0x68(%rsp), %r13
testl %r13d, %r13d
movq 0x60(%rsp), %r14
jle 0x4f94d
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 0x4f941
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movsd %xmm0, 0x58(%rsp)
movsd %xmm1, 0x40(%rsp)
xorps %xmm1, %xmm1
cvtsi2sd %ecx, %xmm1
divsd %xmm1, %xmm0
callq 0x38e99
movsd 0x40(%rsp), %xmm1
mulsd 0x58(%rsp), %xmm0
addsd %xmm0, %xmm1
incq %r15
cmpq %r15, %r13
jne 0x4f8f1
movq 0x50(%rsp), %rcx
addl %ecx, (%r12)
movq 0x48(%rsp), %rdx
leal (%rcx,%rdx), %eax
imull %ecx, %edx
imull %eax, %edx
testl %edx, %edx
xorpd %xmm0, %xmm0
je 0x4f99b
xorps %xmm0, %xmm0
cvtsi2sd %ecx, %xmm0
movsd %xmm0, 0x58(%rsp)
movsd %xmm1, 0x40(%rsp)
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
callq 0x38e99
movsd 0x40(%rsp), %xmm1
mulsd 0x58(%rsp), %xmm0
addsd %xmm0, %xmm1
movsd %xmm1, 0x40(%rsp)
movq %rbx, %rdi
callq 0x39194
movq %r14, %rdi
callq 0x39194
movsd 0x40(%rsp), %xmm0
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq