// File: /workspace/github_c_makefile_star2_O2/olcaytaner[P]Isell/cn2.c
// Function: learn_ruleset_cn2
Ruleset learn_ruleset_cn2(Instanceptr* instances, Cn2_parameterptr param)
{
 Decisionruleptr newrule;
 int classno, classcount, *classes, posclass;
 Instanceptr covered = NULL;
 int *counts, maxcount, i;
 double positive_ratio;
 Ruleset result;
 BOOLEAN givenperm;
 if (strlen(param->classpermutation) == 0)
   givenperm = BOOLEAN_FALSE;
 else
   givenperm = BOOLEAN_TRUE; 
 empty_ruleset(&result);
 classno = all_in_one_class(*instances, &maxcount);
 if (!(classno % 10))
   return result; 
 counts = find_class_counts(*instances);
 if (!givenperm)
   classes = find_max_occured(counts, current_dataset->classno, &classcount);
 else
   classcount = current_dataset->classno;
 if (!givenperm)
   result.defaultclass = classes[0];
 else
   result.defaultclass = param->classpermutation[classcount - 1] - '0';
 for (i = classcount - 1; i > 0; i--)
  {
   if (!givenperm)
     posclass = classes[i];
   else
     posclass = param->classpermutation[classcount - i - 1] - '0';
   positive_ratio = find_class_count(*instances, posclass) / (data_size(*instances) + 0.0);
   while (find_class_count(*instances, posclass) > 0)
    {
     newrule = find_best_complex(instances, posclass, param->maxstar, positive_ratio);
     if (newrule)
      {
       remove_covered(instances, &covered, newrule);
       add_rule(&result, newrule);
      }
     else 
       break;
    }
  }
 merge_instancelist(instances, covered);
 safe_free(counts);
 if (!givenperm)
   safe_free(classes);
 return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %rbx
andq $0x0, 0x28(%rsp)
movb 0x10(%rdx), %r12b
callq 0x71c9d
movq (%r14), %rdi
leaq 0x34(%rsp), %rsi
callq 0x10916
pushq $0xa
popq %rcx
cltd
idivl %ecx
testl %edx, %edx
je 0xd43a
movq (%r14), %rdi
callq 0x108c8
movq %rax, %rcx
leaq 0xc0575(%rip), %rax     # 0xcd870
movq (%rax), %rax
movl 0x10(%rax), %esi
testb %r12b, %r12b
movq %rcx, 0x8(%rsp)
je 0xd31d
movslq %esi, %rax
movl %eax, 0x4(%rsp)
movsbl 0xf(%r15,%rax), %eax
addl $-0x30, %eax
jmp 0xd345
movl %r12d, %ebp
leaq 0x4(%rsp), %r12
movq 0x8(%rsp), %rdi
movq %r12, %rdx
callq 0x3372d
movq 0x8(%rsp), %rcx
movq %rax, 0x18(%rsp)
movl (%rax), %eax
movl (%r12), %esi
movl %ebp, %r12d
movl %eax, 0x14(%rbx)
movl %esi, %edx
leaq 0x28(%rsp), %rbp
movb %r12b, 0x3(%rsp)
cmpl $0x2, %edx
jl 0xd413
testb %r12b, %r12b
je 0xd376
movl 0x4(%rsp), %eax
subl %edx, %eax
cltq
movsbl 0x10(%r15,%rax), %r12d
addl $-0x30, %r12d
jmp 0xd380
movq 0x18(%rsp), %rax
movl -0x4(%rax,%rdx,4), %r12d
decq %rdx
movq %rdx, 0x20(%rsp)
movq (%r14), %rdi
movl %r12d, %esi
callq 0x10827
cvtsi2sd %eax, %xmm0
movsd %xmm0, 0x10(%rsp)
movq (%r14), %rdi
callq 0x2c3cc
cvtsi2sd %eax, %xmm0
movsd 0x10(%rsp), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, 0x10(%rsp)
movq (%r14), %rdi
movl %r12d, %esi
callq 0x10827
testl %eax, %eax
jle 0xd3ff
movl (%r15), %edx
movq %r14, %rdi
movl %r12d, %esi
movsd 0x10(%rsp), %xmm0
callq 0xd0ab
testq %rax, %rax
je 0xd3ff
movq %rax, %r13
movq %r14, %rdi
movq %rbp, %rsi
movq %rax, %rdx
callq 0x90582
movq %rbx, %rdi
movq %r13, %rsi
callq 0x7228a
jmp 0xd3b9
movb 0x3(%rsp), %r12b
movq 0x8(%rsp), %rcx
movq 0x20(%rsp), %rdx
jmp 0xd354
movq 0x28(%rsp), %rsi
movq %rcx, %r15
movq %r14, %rdi
callq 0x2c6e4
movq %r15, %rdi
callq 0x34ff7
testb %r12b, %r12b
jne 0xd43a
movq 0x18(%rsp), %rdi
callq 0x34ff7
movq %rbx, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq