// File: /workspace/github_c_makefile_star2_O2/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, 0x38(%rsp)
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)
pushq $0x1
popq %rbp
movl %ecx, 0x34(%rsp)
movl %ecx, %edi
movl %ebp, %esi
movq %rdx, 0x50(%rsp)
xorl %eax, %eax
callq 0x705c
movsd %xmm0, 0x28(%rsp)
movl %ebp, %r14d
testl %r14d, %r14d
je 0x77b4
movq (%r12), %r13
movq $0x0, 0x40(%rsp)
xorl %ebx, %ebx
testq %r13, %r13
je 0x7690
movq 0x30(%r13), %r14
movq %r12, %rdi
movq %rbx, %rsi
movq %r13, %rdx
callq 0x721ae
movq 0x20(%r12), %rax
movq %rax, 0x20(%rsp)
movups (%r12), %xmm0
movups 0x10(%r12), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movl 0x34(%rsp), %edi
movl %ebp, %esi
movq 0x50(%rsp), %rdx
xorl %eax, %eax
callq 0x705c
movsd %xmm0, 0x48(%rsp)
movsd 0x28(%rsp), %xmm1
callq 0x34c76
testl %eax, %eax
je 0x7677
movsd 0x48(%rsp), %xmm0
movsd %xmm0, 0x28(%rsp)
movl %ebp, %eax
movq %rax, 0x40(%rsp)
movq %rbx, %r15
movq %r13, 0x70(%rsp)
movq %r12, %rdi
movq %rbx, %rsi
movq %r13, %rdx
callq 0x7217f
movq %r13, %rbx
movq %r14, %r13
jmp 0x75fc
movq %r15, 0x58(%rsp)
movl %ebp, %r15d
movq 0x8(%r12), %r13
movq 0x38(%rsp), %rax
movq (%rax), %rbp
xorl %ebx, %ebx
testq %rbp, %rbp
je 0x775c
movq 0x30(%rbp), %r14
movq 0x38(%rsp), %rdi
movq %rbx, %rsi
movq %rbp, %rdx
callq 0x721ae
movq %r12, %rdi
movq %rbp, %rsi
callq 0x7228a
movq 0x20(%r12), %rax
movq %rax, 0x20(%rsp)
movups (%r12), %xmm0
movups 0x10(%r12), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movl 0x34(%rsp), %edi
movl %r15d, %esi
movq 0x50(%rsp), %rdx
xorl %eax, %eax
callq 0x705c
movsd %xmm0, 0x48(%rsp)
movsd 0x28(%rsp), %xmm1
callq 0x34c76
testl %eax, %eax
je 0x7733
movsd 0x48(%rsp), %xmm0
movsd %xmm0, 0x28(%rsp)
pushq $0x2
popq %rax
movq %rax, 0x40(%rsp)
movq %rbp, 0x68(%rsp)
movq %rbx, 0x60(%rsp)
movq %r12, %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0x721ae
movq 0x38(%rsp), %rdi
movq %rbx, %rsi
movq %rbp, %rdx
callq 0x7217f
movq %rbp, %rbx
movq %r14, %rbp
jmp 0x76a7
movq 0x40(%rsp), %r14
testl %r14d, %r14d
movl %r15d, %ebp
movq 0x58(%rsp), %r15
je 0x75e4
cmpl $0x1, %r14d
jne 0x778d
movq %r12, %rdi
movq %r15, %rsi
movq 0x70(%rsp), %rdx
callq 0x721ae
jmp 0x75e4
movq 0x38(%rsp), %rdi
movq 0x60(%rsp), %rsi
movq 0x68(%rsp), %rbx
movq %rbx, %rdx
callq 0x721ae
movq %r12, %rdi
movq %rbx, %rsi
callq 0x7228a
jmp 0x75e4
movsd 0x28(%rsp), %xmm0
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq