// File: /workspace/github_c_makefile_star2_O1/olcaytaner[P]Isell/cn2.c
// Function: find_best_complex
Decisionruleptr find_best_complex(Instanceptr* instances, int positive, int maxstar, double positive_ratio)
{
 Ruleset star;
 Ruleset newstar;
 Decisionruleptr best_complex = NULL;
 Decisionruleptr rule;
 empty_ruleset(&star);
 rule = empty_rule(positive);
 rule->covered = find_class_count(*instances, positive);
 rule->falsepositives = data_size(*instances) - rule->covered;
 add_rule(&star, rule);
 while (star.rulecount > 0)
  {
   /*Specialize complexes*/
   empty_ruleset(&newstar);
   rule = star.start;
   while (rule)
    {
     if (rule->falsepositives != 0)
       specialize_complex(rule, &newstar, instances, positive, maxstar);
     rule = rule->next;
    }
   /*Check for best complex*/
   rule = newstar.start;
   while (rule)
    {
     if (rule_significantly_better(rule, positive_ratio) && (best_complex == NULL || laplace_estimate_of_rule(*rule) < laplace_estimate_of_rule(*best_complex)))
      {
       if (best_complex != NULL)
        {
         free_rule(*best_complex);
         safe_free(best_complex);
        }
       best_complex = create_copy_of_rule(rule);
      }
     rule = rule->next;
    }
   free_ruleset(star);
   star = newstar;
  }
 safe_free(star.counts);
 return best_complex;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movsd %xmm0, 0x78(%rsp)
movl %edx, %ebx
movl %esi, %ebp
movq %rdi, %r14
leaq 0x40(%rsp), %r15
movq %r15, %rdi
callq 0x7aa63
movl %ebp, %edi
callq 0x7a713
movq %rax, %r12
movq (%r14), %rdi
movl %ebp, %esi
callq 0x11534
movl %eax, 0x4(%r12)
movq (%r14), %rdi
callq 0x2fa14
subl 0x4(%r12), %eax
movl %eax, 0x8(%r12)
movq %r15, %rdi
movq %r12, %rsi
callq 0x7b0fb
cmpl $0x0, 0x10(%r15)
jle 0xdb8f
xorl %r15d, %r15d
leaq 0x80(%rsp), %r12
movq %r12, %rdi
callq 0x7aa63
movq 0x40(%rsp), %r13
testq %r13, %r13
je 0xda5a
cmpl $0x0, 0x8(%r13)
je 0xda54
movq %r13, %rdi
movq %r12, %rsi
movq %r14, %rdx
movl %ebp, %ecx
movl %ebx, %r8d
callq 0xd364
movq 0x30(%r13), %r13
jmp 0xda35
movq 0x80(%rsp), %r13
testq %r13, %r13
je 0xdb37
movq %r13, %rdi
movsd 0x78(%rsp), %xmm0
callq 0xd85f
testl %eax, %eax
je 0xdb2e
testq %r15, %r15
je 0xdb23
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)
callq 0x7b33f
movsd %xmm0, 0x70(%rsp)
movq 0x30(%r15), %rax
movq %rax, 0x30(%rsp)
movupd (%r15), %xmm0
movups 0x10(%r15), %xmm1
movups 0x20(%r15), %xmm2
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movupd %xmm0, (%rsp)
callq 0x7b33f
ucomisd 0x70(%rsp), %xmm0
jbe 0xdb2e
movq 0x30(%r15), %rax
movq %rax, 0x30(%rsp)
movupd (%r15), %xmm0
movups 0x10(%r15), %xmm1
movups 0x20(%r15), %xmm2
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movupd %xmm0, (%rsp)
callq 0x7a989
movq %r15, %rdi
callq 0x39194
movq %r13, %rdi
callq 0x7a54a
movq %rax, %r15
movq 0x30(%r13), %r13
jmp 0xda62
movq 0x60(%rsp), %rax
movq %rax, 0x20(%rsp)
movaps 0x40(%rsp), %xmm0
movaps 0x50(%rsp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
callq 0x7a9dc
movupd 0x80(%rsp), %xmm0
movups 0x90(%rsp), %xmm1
movaps %xmm1, 0x50(%rsp)
movq 0xa0(%rsp), %rax
movq %rax, 0x60(%rsp)
movapd %xmm0, 0x40(%rsp)
cmpl $0x0, 0x50(%rsp)
jg 0xda28
jmp 0xdb92
xorl %r15d, %r15d
movq 0x58(%rsp), %rdi
callq 0x39194
movq %r15, %rax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq