// File: /workspace/github_c_makefile_star2_O2/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), %r12
movq %r12, %rdi
callq 0x71c9d
movl %ebp, %edi
callq 0x719a4
movq %rax, %r15
movq (%r14), %rdi
movl %ebp, %esi
callq 0x10827
movl %eax, 0x4(%r15)
movq (%r14), %rdi
callq 0x2c3cc
subl 0x4(%r15), %eax
movl %eax, 0x8(%r15)
movq %r12, %rdi
movq %r15, %rsi
callq 0x7228a
xorl %r12d, %r12d
leaq 0x80(%rsp), %r15
cmpl $0x0, 0x50(%rsp)
jle 0xd289
movq %r15, %rdi
callq 0x71c9d
leaq 0x40(%rsp), %r13
movq (%r13), %r13
testq %r13, %r13
je 0xd155
cmpl $0x0, 0x8(%r13)
je 0xd14f
movq %r13, %rdi
movq %r15, %rsi
movq %r14, %rdx
movl %ebp, %ecx
movl %ebx, %r8d
callq 0xca7c
addq $0x30, %r13
jmp 0xd12c
movq %r15, %r13
movq (%r13), %r13
testq %r13, %r13
je 0xd239
movq %r13, %rdi
movsd 0x78(%rsp), %xmm0
callq 0xcf60
testl %eax, %eax
je 0xd230
testq %r12, %r12
je 0xd225
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 0x724bd
movsd %xmm0, 0x70(%rsp)
movq 0x30(%r12), %rax
movq %rax, 0x30(%rsp)
movupd (%r12), %xmm0
movups 0x10(%r12), %xmm1
movups 0x20(%r12), %xmm2
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movupd %xmm0, (%rsp)
callq 0x724bd
ucomisd 0x70(%rsp), %xmm0
jbe 0xd230
movq 0x30(%r12), %rax
movq %rax, 0x30(%rsp)
movupd (%r12), %xmm0
movups 0x10(%r12), %xmm1
movups 0x20(%r12), %xmm2
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movupd %xmm0, (%rsp)
callq 0x71be8
movq %r12, %rdi
callq 0x34ff7
movq %r13, %rdi
callq 0x717f9
movq %rax, %r12
addq $0x30, %r13
jmp 0xd158
movq 0x60(%rsp), %rax
movq %rax, 0x20(%rsp)
movaps 0x40(%rsp), %xmm0
movaps 0x50(%rsp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
callq 0x71c3d
movq 0xa0(%rsp), %rax
movq %rax, 0x60(%rsp)
movupd 0x80(%rsp), %xmm0
movups 0x90(%rsp), %xmm1
movaps %xmm1, 0x50(%rsp)
movapd %xmm0, 0x40(%rsp)
jmp 0xd114
movq 0x58(%rsp), %rdi
callq 0x34ff7
movq %r12, %rax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq