// File: /workspace/github_c_makefile_star2_O3/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 0x7c32b
movl %ebp, %edi
callq 0x7bfd8
movq %rax, %r12
movq (%r14), %rdi
movl %ebp, %esi
callq 0x114f9
movl %eax, 0x4(%r12)
movq (%r14), %rdi
callq 0x30309
subl 0x4(%r12), %eax
movl %eax, 0x8(%r12)
movq %r15, %rdi
movq %r12, %rsi
callq 0x7c9c6
cmpl $0x0, 0x10(%r15)
jle 0xdc16
xorl %r15d, %r15d
leaq 0x80(%rsp), %r12
movq %r12, %rdi
callq 0x7c32b
movq 0x40(%rsp), %r13
testq %r13, %r13
je 0xdae1
cmpl $0x0, 0x8(%r13)
je 0xdadb
movq %r13, %rdi
movq %r12, %rsi
movq %r14, %rdx
movl %ebp, %ecx
movl %ebx, %r8d
callq 0xd3fc
movq 0x30(%r13), %r13
jmp 0xdabc
movq 0x80(%rsp), %r13
testq %r13, %r13
je 0xdbbe
movq %r13, %rdi
movsd 0x78(%rsp), %xmm0
callq 0xd8e5
testl %eax, %eax
je 0xdbb5
testq %r15, %r15
je 0xdbaa
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 0x7cc0e
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 0x7cc0e
ucomisd 0x70(%rsp), %xmm0
jbe 0xdbb5
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 0x7c251
movq %r15, %rdi
callq 0x3a180
movq %r13, %rdi
callq 0x7be1e
movq %rax, %r15
movq 0x30(%r13), %r13
jmp 0xdae9
movq 0x60(%rsp), %rax
movq %rax, 0x20(%rsp)
movaps 0x40(%rsp), %xmm0
movaps 0x50(%rsp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
callq 0x7c2a4
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 0xdaaf
jmp 0xdc19
xorl %r15d, %r15d
movq 0x58(%rsp), %rdi
callq 0x3a180
movq %r15, %rax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq