// File: /workspace/github_c_makefile_star2_O3/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, 0x58(%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)
movl %ecx, 0x3c(%rsp)
movl %ecx, %edi
movl $0x1, %esi
movq %rdx, 0x60(%rsp)
xorl %eax, %eax
callq 0x726c
movsd %xmm0, 0x30(%rsp)
movq (%r12), %r14
testq %r14, %r14
je 0x78bb
xorl %r13d, %r13d
movl $0x0, 0x2c(%rsp)
movq %r14, %rbx
movq 0x30(%r14), %r14
movq %r12, %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x7c89d
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 0x60(%rsp), %rdx
xorl %eax, %eax
callq 0x726c
movsd %xmm0, 0x40(%rsp)
movsd 0x30(%rsp), %xmm1
callq 0x39aee
testl %eax, %eax
je 0x789f
movl $0x1, 0x2c(%rsp)
movsd 0x40(%rsp), %xmm0
movsd %xmm0, 0x30(%rsp)
movq %r13, %r15
movq %rbx, %rbp
movq %r12, %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x7c86e
movq %rbx, %r13
testq %r14, %r14
jne 0x7828
jmp 0x78c3
movl $0x0, 0x2c(%rsp)
movq %rbp, 0x50(%rsp)
movq %r15, 0x48(%rsp)
movq 0x58(%rsp), %r15
movq (%r15), %r14
testq %r14, %r14
je 0x7998
movq 0x8(%r12), %rbp
xorl %ebx, %ebx
movq %r14, %r13
movq 0x30(%r14), %r14
movq %r15, %rdi
movq %rbx, %rsi
movq %r13, %rdx
callq 0x7c89d
movq %r12, %rdi
movq %r13, %rsi
callq 0x7c9c6
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 0x60(%rsp), %rdx
xorl %eax, %eax
callq 0x726c
movsd %xmm0, 0x40(%rsp)
movsd 0x30(%rsp), %xmm1
callq 0x39aee
testl %eax, %eax
je 0x796b
movl $0x2, 0x2c(%rsp)
movsd 0x40(%rsp), %xmm0
movsd %xmm0, 0x30(%rsp)
movq %r13, 0x70(%rsp)
movq %rbx, 0x68(%rsp)
movq %r12, %rdi
movq %rbp, %rsi
movq %r13, %rdx
callq 0x7c89d
movq 0x58(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rsi
movq %r13, %rdx
callq 0x7c86e
movq %r13, %rbx
testq %r14, %r14
jne 0x78e5
movl 0x2c(%rsp), %eax
cmpl $0x1, %eax
je 0x79d4
testl %eax, %eax
movq 0x50(%rsp), %rbp
je 0x79f1
movq %r15, %rdi
movq 0x68(%rsp), %rsi
movq 0x70(%rsp), %rbx
movq %rbx, %rdx
callq 0x7c89d
movq %r12, %rdi
movq %rbx, %rsi
callq 0x7c9c6
movq 0x48(%rsp), %r15
jmp 0x7810
movq %r12, %rdi
movq 0x48(%rsp), %r15
movq %r15, %rsi
movq 0x50(%rsp), %rbp
movq %rbp, %rdx
callq 0x7c89d
jmp 0x7810
movsd 0x30(%rsp), %xmm0
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq