// File: /workspace/github_c_makefile_star2_O1/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 $0x58, %rsp
movq %rdx, 0x30(%rsp)
movq %rsi, %rbp
movq $0x0, 0x40(%rsp)
movq %rdi, 0x38(%rsp)
callq 0x7aa63
leaq 0x9ba88(%rip), %r13     # 0xd2870
movq (%r13), %rax
movslq 0x10(%rax), %rdi
leaq 0x6f98a(%rip), %rdx     # 0xa6781
movl $0x4, %esi
movl $0x4, %ecx
callq 0x39210
movq %rax, %r15
movq (%r13), %rax
cmpl $0x0, 0x10(%rax)
jle 0x36f19
xorl %r12d, %r12d
movq %rbp, 0x48(%rsp)
movq (%r13), %rax
cmpl $0x0, 0x10(%rax)
jle 0x36e9c
movq %r12, 0x50(%rsp)
movl $0x7fffffff, %r14d      # imm = 0x7FFFFFFF
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
movq %rbp, %rbx
xorl %ebp, %ebp
cmpl $0x0, (%r15,%rbp,4)
jne 0x36e79
movq 0x30(%rsp), %rax
movq (%rax), %rdi
movq 0x20(%rbx), %rax
movq %rax, 0x20(%rsp)
movups (%rbx), %xmm0
movups 0x10(%rbx), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movl %ebp, %esi
callq 0x9cb37
cmpl %r14d, %eax
cmovll %eax, %r14d
cmovll %ebp, %r12d
incq %rbp
movq (%r13), %rax
movslq 0x10(%rax), %rax
addq $0x28, %rbx
cmpq %rax, %rbp
jl 0x36e3f
movslq %r12d, %rbx
movq 0x48(%rsp), %rbp
movq 0x50(%rsp), %r12
jmp 0x36ea3
movq $-0x1, %rbx
leaq (%rbx,%rbx,4), %r14
movq 0x20(%rbp,%r14,8), %rax
movq %rax, 0x20(%rsp)
movups (%rbp,%r14,8), %xmm0
movups 0x10(%rbp,%r14,8), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rsi
xorl %edx, %edx
callq 0x9c7df
movq 0x20(%rbp,%r14,8), %rax
movq %rax, 0x20(%rsp)
movups (%rbp,%r14,8), %xmm0
movups 0x10(%rbp,%r14,8), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq 0x38(%rsp), %rdi
callq 0x7aac5
movl $0x1, (%r15,%rbx,4)
incl %r12d
movq (%r13), %rax
cmpl 0x10(%rax), %r12d
jl 0x36e1f
movq 0x30(%rsp), %r14
movq (%r14), %rdi
callq 0x115e1
movq %rax, %r12
movq (%r13), %rax
movl 0x10(%rax), %esi
movq %r12, %rdi
callq 0x37504
movq 0x38(%rsp), %rbx
movl %eax, 0x14(%rbx)
movq 0x40(%rsp), %rsi
movq %r14, %rdi
callq 0x2fd59
movq %r12, %rdi
callq 0x39194
movq %r15, %rdi
callq 0x39194
movq %rbx, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq