// File: /workspace/github_c_makefile_star2_O0/olcaytaner[P]Isell/c45rules.c
// Function: rank_classes
void rank_classes(Ruleset* r, Instanceptr traindata)
{
 /*!Last Changed 02.02.2004 added safecalloc*/
 /*!Last Changed 05.11.2003*/
 Decisionruleptr* classstarts = (Decisionruleptr*) safecalloc(current_dataset->classno, sizeof(Decisionruleptr), "rank_classes", 1);
 Decisionruleptr* classends = (Decisionruleptr*) safecalloc(current_dataset->classno, sizeof(Decisionruleptr), "rank_classes", 2);
 int* rulecounts = safecalloc(current_dataset->classno, sizeof(int), "rank_classes", 3);
 int* classdone = safecalloc(current_dataset->classno, sizeof(int), "rank_classes", 4);
 int classcount = 0, classno = -1, i, j, minfpc, minindex, fpc;
 Decisionruleptr tmp;
 Decisionruleptr tmpbefore;
 tmpbefore = NULL;
 tmp = r->start;
 while (tmp)
  {
   classdone[tmp->classno] = 1;
   if (tmp->classno != classno)
    {
     if (classno != -1)
       classends[classno] = tmpbefore;
     classstarts[tmp->classno] = tmp;
     classcount++;
     classno = tmp->classno;
    }
   rulecounts[classno]++;
   tmpbefore = tmp;
   tmp = tmp->next;
  }
 classends[classno] = tmpbefore;
 for (i = 0; i < current_dataset->classno; i++)
   if (classends[i])
     classends[i]->next = NULL;
 safe_free(r->counts);
 empty_ruleset(r);
 for (i = 0; i < classcount; i++)
  {
   minfpc = +INT_MAX;
   minindex = -1;
   tmp = r->end;
   for (j = 0; j < current_dataset->classno; j++)
     if (classdone[j])
      {
       if (r->rulecount == 0)
         r->start = classstarts[j];
       if (r->end)
         r->end->next = classstarts[j];
       r->end = classends[j];
       r->rulecount += rulecounts[j];
       fpc = false_positive_count(*r, traindata);
       if (fpc < minfpc)
        {
         minfpc = fpc;
         minindex = j;
        }
       r->rulecount -= rulecounts[j];
       if (r->rulecount == 0)
         r->start = NULL;
       r->end = tmp;
       if (tmp)
         tmp->next = NULL;
      }
   if (minindex != -1)
    {
     if (r->rulecount == 0)
       r->start = classstarts[minindex];
     if (r->end)
       r->end->next = classstarts[minindex];
     r->end = classends[minindex];
     r->rulecount += rulecounts[minindex];     
     classdone[minindex] = 0;
    }
   else
    {
     printf("Minimum description length larger than INT_MAX\n");
     break;
    }
  }
 safe_free(classstarts);
 safe_free(classends);
 safe_free(rulecounts);
 safe_free(classdone);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq 0xfac56(%rip), %rax     # 0x105840
movq (%rax), %rax
movslq 0x10(%rax), %rdi
movl $0x8, %esi
leaq 0xd7e05(%rip), %rdx     # 0xe2a02
movl $0x1, %ecx
callq 0x52f40
movq %rax, -0x18(%rbp)
leaq 0xfac2e(%rip), %rax     # 0x105840
movq (%rax), %rax
movslq 0x10(%rax), %rdi
movl $0x8, %esi
leaq 0xd7ddd(%rip), %rdx     # 0xe2a02
movl $0x2, %ecx
callq 0x52f40
movq %rax, -0x20(%rbp)
leaq 0xfac06(%rip), %rax     # 0x105840
movq (%rax), %rax
movslq 0x10(%rax), %rdi
movl $0x4, %esi
leaq 0xd7db5(%rip), %rdx     # 0xe2a02
movl $0x3, %ecx
callq 0x52f40
movq %rax, -0x28(%rbp)
leaq 0xfabde(%rip), %rax     # 0x105840
movq (%rax), %rax
movslq 0x10(%rax), %rdi
movl $0x4, %esi
leaq 0xd7d8d(%rip), %rdx     # 0xe2a02
movl $0x4, %ecx
callq 0x52f40
movq %rax, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movl $0xffffffff, -0x38(%rbp) # imm = 0xFFFFFFFF
movq $0x0, -0x60(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
je 0xad31
movq -0x30(%rbp), %rax
movq -0x58(%rbp), %rcx
movslq (%rcx), %rcx
movl $0x1, (%rax,%rcx,4)
movq -0x58(%rbp), %rax
movl (%rax), %eax
cmpl -0x38(%rbp), %eax
je 0xad07
cmpl $-0x1, -0x38(%rbp)
je 0xace2
movq -0x60(%rbp), %rdx
movq -0x20(%rbp), %rax
movslq -0x38(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x58(%rbp), %rdx
movq -0x18(%rbp), %rax
movq -0x58(%rbp), %rcx
movslq (%rcx), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
movq -0x58(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x38(%rbp)
movq -0x28(%rbp), %rax
movslq -0x38(%rbp), %rcx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
movq -0x58(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x58(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x58(%rbp)
jmp 0xaca4
movq -0x60(%rbp), %rdx
movq -0x20(%rbp), %rax
movslq -0x38(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
leaq 0xfaaee(%rip), %rcx     # 0x105840
movq (%rcx), %rcx
cmpl 0x10(%rcx), %eax
jge 0xad8a
movq -0x20(%rbp), %rax
movslq -0x3c(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
je 0xad7d
movq -0x20(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq $0x0, 0x30(%rax)
jmp 0xad7f
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0xad48
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x52e80
movq -0x8(%rbp), %rdi
callq 0xade30
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x34(%rbp), %eax
jge 0xaf9f
movl $0x7fffffff, -0x44(%rbp) # imm = 0x7FFFFFFF
movl $0xffffffff, -0x48(%rbp) # imm = 0xFFFFFFFF
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x58(%rbp)
movl $0x0, -0x40(%rbp)
movl -0x40(%rbp), %eax
leaq 0xfaa62(%rip), %rcx     # 0x105840
movq (%rcx), %rcx
cmpl 0x10(%rcx), %eax
jge 0xaeff
movq -0x30(%rbp), %rax
movslq -0x40(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
je 0xaeef
movq -0x8(%rbp), %rax
cmpl $0x0, 0x10(%rax)
jne 0xae19
movq -0x18(%rbp), %rax
movslq -0x40(%rbp), %rcx
movq (%rax,%rcx,8), %rcx
movq -0x8(%rbp), %rax
movq %rcx, (%rax)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0xae3c
movq -0x18(%rbp), %rax
movslq -0x40(%rbp), %rcx
movq (%rax,%rcx,8), %rcx
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rcx, 0x30(%rax)
movq -0x20(%rbp), %rax
movslq -0x40(%rbp), %rcx
movq (%rax,%rcx,8), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x28(%rbp), %rax
movslq -0x40(%rbp), %rcx
movl (%rax,%rcx,4), %ecx
movq -0x8(%rbp), %rax
addl 0x10(%rax), %ecx
movl %ecx, 0x10(%rax)
movq -0x8(%rbp), %rcx
movq -0x10(%rbp), %rdi
movq 0x20(%rcx), %rdx
movq %rsp, %rax
movq %rdx, 0x20(%rax)
movups (%rcx), %xmm0
movups 0x10(%rcx), %xmm1
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
callq 0xae400
movl %eax, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
cmpl -0x44(%rbp), %eax
jge 0xaea2
movl -0x4c(%rbp), %eax
movl %eax, -0x44(%rbp)
movl -0x40(%rbp), %eax
movl %eax, -0x48(%rbp)
movq -0x28(%rbp), %rax
movslq -0x40(%rbp), %rcx
movl (%rax,%rcx,4), %edx
movq -0x8(%rbp), %rax
movl 0x10(%rax), %ecx
subl %edx, %ecx
movl %ecx, 0x10(%rax)
movq -0x8(%rbp), %rax
cmpl $0x0, 0x10(%rax)
jne 0xaece
movq -0x8(%rbp), %rax
movq $0x0, (%rax)
movq -0x58(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x8(%rax)
cmpq $0x0, -0x58(%rbp)
je 0xaeed
movq -0x58(%rbp), %rax
movq $0x0, 0x30(%rax)
jmp 0xaeef
jmp 0xaef1
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0xadd4
cmpl $-0x1, -0x48(%rbp)
je 0xaf7f
movq -0x8(%rbp), %rax
cmpl $0x0, 0x10(%rax)
jne 0xaf22
movq -0x18(%rbp), %rax
movslq -0x48(%rbp), %rcx
movq (%rax,%rcx,8), %rcx
movq -0x8(%rbp), %rax
movq %rcx, (%rax)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0xaf45
movq -0x18(%rbp), %rax
movslq -0x48(%rbp), %rcx
movq (%rax,%rcx,8), %rcx
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rcx, 0x30(%rax)
movq -0x20(%rbp), %rax
movslq -0x48(%rbp), %rcx
movq (%rax,%rcx,8), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x28(%rbp), %rax
movslq -0x48(%rbp), %rcx
movl (%rax,%rcx,4), %ecx
movq -0x8(%rbp), %rax
addl 0x10(%rax), %ecx
movl %ecx, 0x10(%rax)
movq -0x30(%rbp), %rax
movslq -0x48(%rbp), %rcx
movl $0x0, (%rax,%rcx,4)
jmp 0xaf8f
leaq 0xd7a89(%rip), %rdi     # 0xe2a0f
movb $0x0, %al
callq 0x4030
jmp 0xaf9f
jmp 0xaf91
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0xada7
movq -0x18(%rbp), %rdi
callq 0x52e80
movq -0x20(%rbp), %rdi
callq 0x52e80
movq -0x28(%rbp), %rdi
callq 0x52e80
movq -0x30(%rbp), %rdi
callq 0x52e80
addq $0x90, %rsp
popq %rbp
retq
nopl (%rax)