// File: /workspace/github_c_makefile_star2_O1/olcaytaner[P]Isell/c45rules.c
// Function: search_best_ruleset
double search_best_ruleset(Ruleset* inlist, Ruleset* outlist, Instanceptr instances, int classno)
{
 /*!Last Changed 31.10.2003*/
 double length, bestlength;
 int found = 1;
 Decisionruleptr inbefore, bestdeleted, bestinserted, outbefore, before, tmp, inlistlast, tmpnext;
 bestlength = description_length_of_all(*inlist, classno, 1, instances);
 while (found)
  {
   found = 0;
   before = NULL;
   tmp = inlist->start;
   while (tmp)
    {
     tmpnext = tmp->next;
     remove_rule_after(inlist, before, tmp);
     length = description_length_of_all(*inlist, classno, 1, instances);
     if (dless(length, bestlength))
      {
       bestlength = length;
       found = 1;
       inbefore = before;
       bestdeleted = tmp;
      }
     add_rule_after(inlist, before, tmp);
     before = tmp;
     tmp = tmpnext;
    }
   before = NULL;
   inlistlast = inlist->end;
   tmp = outlist->start;
   while (tmp)
    {
     tmpnext = tmp->next;
     remove_rule_after(outlist, before, tmp);
     add_rule(inlist, tmp);
     length = description_length_of_all(*inlist, classno, 1, instances);
     if (dless(length, bestlength))
      {
       bestlength = length;
       found = 2;
       outbefore = before;
       bestinserted = tmp;
      }
     remove_rule_after(inlist, inlistlast, tmp);
     add_rule_after(outlist, before, tmp);
     before = tmp;
     tmp = tmpnext;
    }
   if (found)
    {
     if (found == 1)
       remove_rule_after(inlist, inbefore, bestdeleted); 
     else
      {
       remove_rule_after(outlist, outbefore, bestinserted);
       add_rule(inlist, bestinserted);
      }
    }
  }
 return bestlength;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rsi, %rbp
movq %rdi, %r12
movq 0x20(%rdi), %rax
movq %rax, 0x20(%rsp)
movups (%rdi), %xmm0
movups 0x10(%rdi), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movl %ecx, 0x3c(%rsp)
movl %ecx, %edi
movl $0x1, %esi
movq %rdx, 0x58(%rsp)
xorl %eax, %eax
callq 0x7288
movsd %xmm0, 0x30(%rsp)
movq %rbp, 0x40(%rsp)
movq (%r12), %r14
testq %r14, %r14
je 0x78e6
xorl %r13d, %r13d
movl $0x0, 0x2c(%rsp)
movq %r14, %rbx
movq 0x30(%r14), %r14
movq %r12, %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x7afd2
movq 0x20(%r12), %rax
movq %rax, 0x20(%rsp)
movups (%r12), %xmm0
movups 0x10(%r12), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movl 0x3c(%rsp), %edi
movl $0x1, %esi
movq 0x58(%rsp), %rdx
xorl %eax, %eax
callq 0x7288
movsd %xmm0, 0x48(%rsp)
movsd 0x30(%rsp), %xmm1
callq 0x38d8e
testl %eax, %eax
je 0x78ca
movl $0x1, 0x2c(%rsp)
movsd 0x48(%rsp), %xmm0
movsd %xmm0, 0x30(%rsp)
movq %r13, %r15
movq %rbx, 0x60(%rsp)
movq %r12, %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x7afad
movq %rbx, %r13
testq %r14, %r14
jne 0x7851
jmp 0x78ee
movl $0x0, 0x2c(%rsp)
movq %r15, 0x50(%rsp)
movq (%rbp), %r14
testq %r14, %r14
je 0x79bf
movq 0x8(%r12), %rbp
xorl %ebx, %ebx
movq 0x40(%rsp), %r15
movq %r14, %r13
movq 0x30(%r14), %r14
movq %r15, %rdi
movq %rbx, %rsi
movq %r13, %rdx
callq 0x7afd2
movq %r12, %rdi
movq %r13, %rsi
callq 0x7b0fb
movq 0x20(%r12), %rax
movq %rax, 0x20(%rsp)
movups (%r12), %xmm0
movups 0x10(%r12), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movl 0x3c(%rsp), %edi
movl $0x1, %esi
movq 0x58(%rsp), %rdx
xorl %eax, %eax
callq 0x7288
movsd %xmm0, 0x48(%rsp)
movsd 0x30(%rsp), %xmm1
callq 0x38d8e
testl %eax, %eax
je 0x7992
movl $0x2, 0x2c(%rsp)
movsd 0x48(%rsp), %xmm0
movsd %xmm0, 0x30(%rsp)
movq %r13, 0x70(%rsp)
movq %rbx, 0x68(%rsp)
movq %r12, %rdi
movq %rbp, %rsi
movq %r13, %rdx
callq 0x7afd2
movq 0x40(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rsi
movq %r13, %rdx
callq 0x7afad
movq %r13, %rbx
testq %r14, %r14
jne 0x790c
movl 0x2c(%rsp), %r14d
cmpl $0x1, %r14d
je 0x79fb
testl %r14d, %r14d
movq 0x40(%rsp), %rbp
movq 0x50(%rsp), %r15
je 0x7a1e
movq %rbp, %rdi
movq 0x68(%rsp), %rsi
movq 0x70(%rsp), %rbx
movq %rbx, %rdx
callq 0x7afd2
movq %r12, %rdi
movq %rbx, %rsi
callq 0x7b0fb
jmp 0x7a15
movq %r12, %rdi
movq 0x50(%rsp), %r15
movq %r15, %rsi
movq 0x60(%rsp), %rdx
callq 0x7afd2
movq 0x40(%rsp), %rbp
testl %r14d, %r14d
jne 0x7839
movsd 0x30(%rsp), %xmm0
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq