// File: /workspace/github_c_makefile_star2_O3/olcaytaner[P]Isell/lerils.c
// Function: order_rulesets
Ruleset order_rulesets(Ruleset* sets, Instanceptr* instances)
{
 int i, j, *included, minexception, bestclass, exception, *counts;
 Ruleset result;
 Instanceptr covered = NULL;
 empty_ruleset(&result);
 included = (int *)safecalloc(current_dataset->classno, sizeof(int), "order_rulesets", 4);
 for (i = 0; i < current_dataset->classno; i++)
  {
   bestclass = -1;
   minexception = +INT_MAX;
   for (j = 0; j < current_dataset->classno; j++)
     if (!included[j])
      {
       exception = exception_count_of_ruleset(sets[j], *instances, j);
       if (exception < minexception)
        {
         minexception = exception;
         bestclass = j;
        }
      }
   remove_covered_by_ruleset(instances, &covered, sets[bestclass], 0);
   merge_ruleset(&result, sets[bestclass]);
   included[bestclass] = YES;
  }
 counts = find_class_counts(*instances);
 result.defaultclass = find_max_in_list(counts, current_dataset->classno);
 merge_instancelist(instances, covered);
 safe_free(counts);
 safe_free(included);
 return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdx, %rbx
movq %rsi, %rbp
movq $0x0, 0x30(%rsp)
movq %rdi, 0x28(%rsp)
callq 0x7c32b
leaq 0x9e0f0(%rip), %r14     # 0xd5870
movq (%r14), %rax
movslq 0x10(%rax), %rdi
leaq 0x72021(%rip), %rdx     # 0xa97af
movl $0x4, %esi
movl $0x4, %ecx
callq 0x3a1fc
movq %rax, %r15
movq (%r14), %rax
movl 0x10(%rax), %ecx
testl %ecx, %ecx
jle 0x378b3
xorl %r13d, %r13d
movq %rbp, 0x38(%rsp)
testl %ecx, %ecx
jle 0x37830
movq %r13, 0x40(%rsp)
movl $0x7fffffff, %r12d      # imm = 0x7FFFFFFF
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
movq %rbp, %r14
xorl %ebp, %ebp
cmpl $0x0, (%r15,%rbp,4)
jne 0x37811
movq (%rbx), %rdi
movq 0x20(%r14), %rax
movq %rax, 0x20(%rsp)
movups (%r14), %xmm0
movups 0x10(%r14), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movl %ebp, %esi
callq 0x9fb34
cmpl %r12d, %eax
cmovll %eax, %r12d
cmovll %ebp, %r13d
leaq 0x9e062(%rip), %rax     # 0xd5870
movq (%rax), %rax
incq %rbp
movslq 0x10(%rax), %rcx
addq $0x28, %r14
cmpq %rcx, %rbp
jl 0x377d0
movslq %r13d, %r14
movq 0x38(%rsp), %rbp
movq 0x40(%rsp), %r13
jmp 0x37837
movq $-0x1, %r14
leaq (%r14,%r14,4), %r12
movq 0x20(%rbp,%r12,8), %rax
movq %rax, 0x20(%rsp)
movups (%rbp,%r12,8), %xmm0
movups 0x10(%rbp,%r12,8), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq %rbx, %rdi
leaq 0x30(%rsp), %rsi
xorl %edx, %edx
callq 0x9f84f
movq 0x20(%rbp,%r12,8), %rax
movq %rax, 0x20(%rsp)
movups (%rbp,%r12,8), %xmm0
movups 0x10(%rbp,%r12,8), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq 0x28(%rsp), %rdi
callq 0x7c38d
movl $0x1, (%r15,%r14,4)
incl %r13d
leaq 0x9dfcc(%rip), %rax     # 0xd5870
movq (%rax), %rax
movl 0x10(%rax), %ecx
cmpl %ecx, %r13d
jl 0x377b6
movq %rbx, %r14
movq (%rbx), %rdi
callq 0x115a6
movq %rax, %r12
leaq 0x9dfa8(%rip), %rax     # 0xd5870
movq (%rax), %rax
movl 0x10(%rax), %esi
movq %r12, %rdi
callq 0x38002
movq 0x28(%rsp), %rbx
movl %eax, 0x14(%rbx)
movq 0x30(%rsp), %rsi
movq %r14, %rdi
callq 0x30648
movq %r12, %rdi
callq 0x3a180
movq %r15, %rdi
callq 0x3a180
movq %rbx, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq