// File: /workspace/github_c_makefile_star2_O0/olcaytaner[P]Isell/omnivariaterule.c
// Function: optimize_ruleset_modelselection
void optimize_ruleset_modelselection(Ruleset* r, int positive, Instanceptr* instances, Ripper_parameterptr param)
{
 /* Last Changed 19.02.2005*/
 Decisionruleptr rule, before = NULL, replacementrule, revisionrule, next, newrule;
 Instanceptr removed = NULL, newsample;
 double error, revisionerror, replacementerror;
 rule = r->start;
 while (rule && rule->classno != positive)
  {
   before = rule;
   rule = rule->next;
  }
 while (rule && class_exists_in_list(*instances, positive))
  {
   error = generalization_error_after_pruning(*r, *instances, positive, param->modelselectionmethod);
   newsample = bootstrap_sample_without_stratification(*instances);
   replacementrule = growrule_omnivariate(&newsample, positive, param);
   remove_rule_after(r, before, rule);
   add_rule_after(r, before, replacementrule);
   if (replacementrule->decisioncount > 0)
     prunerule_with_modelselection(replacementrule, newsample, param->modelselectionmethod);
   deallocate(newsample);
   replacementerror = generalization_error_after_pruning(*r, *instances, positive, param->modelselectionmethod);
   revisionrule = grow_revision_rule_omnivariate(instances, rule, positive, param);
   remove_rule_after(r, before, replacementrule);
   add_rule_after(r, before, revisionrule);
   prunerule_with_modelselection(revisionrule, *instances, param->modelselectionmethod);
   revisionerror = generalization_error_after_pruning(*r, *instances, positive, param->modelselectionmethod);
   if ((revisionerror < error) || (replacementerror < error))
     if (replacementerror <= revisionerror)
      {
       remove_rule_after(r, before, revisionrule);
       add_rule_after(r, before, replacementrule);
       free_rule(*revisionrule);
       safe_free(revisionrule);
       free_rule(*rule);
       safe_free(rule);
       remove_covered(instances, &removed, replacementrule);
       rule = replacementrule;
      }
     else
      {
       free_rule(*replacementrule);
       safe_free(replacementrule);
       free_rule(*rule);
       safe_free(rule);       
       remove_covered(instances, &removed, revisionrule);
       rule = revisionrule;
      }
   else
    {
     remove_rule_after(r, before, revisionrule);
     add_rule_after(r, before, rule);
     free_rule(*revisionrule);
     safe_free(revisionrule);
     free_rule(*replacementrule);
     safe_free(replacementrule);
     remove_covered(instances, &removed, rule);     
    }
   before = rule;
   rule = rule->next;
  }
 if (!rule)
  {
   while (class_exists_in_list(*instances, positive))
    {
     newrule = growrule_omnivariate(instances, positive, param);
     if (newrule->start)
       prunerule_with_modelselection(newrule, *instances, param->modelselectionmethod);
     update_counts(newrule, *instances, 1);
     if (!(newrule->start) || (error_rate_of_rule(*newrule) >= 0.5))
      {
       free_rule(*newrule);
       safe_free(newrule);
       break;
      }
     add_rule(r, newrule);
     remove_covered(instances, &removed, newrule);
    }
  }
 else
  {
   while (rule)
    {
     next = rule->next;
     if (rule->classno == positive)
      {
       if (before)
         before->next = next;
       else
         r->start = next;
       free_rule(*rule);
       safe_free(rule);
       r->rulecount--;
       if (next == NULL)
         r->end = before;
      }
     else
       before = rule;
     rule = next;
    }
   if (before)
     before->next = NULL;
  }
 merge_instancelist(instances, removed);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq $0x0, -0x30(%rbp)
movq $0x0, -0x58(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x28(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x28(%rbp)
movb %al, -0x79(%rbp)
je 0x743b0
movq -0x28(%rbp), %rax
movl (%rax), %eax
cmpl -0xc(%rbp), %eax
setne %al
movb %al, -0x79(%rbp)
movb -0x79(%rbp), %al
testb $0x1, %al
jne 0x743b9
jmp 0x743cf
movq -0x28(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x28(%rbp)
jmp 0x74395
jmp 0x743d1
xorl %eax, %eax
cmpq $0x0, -0x28(%rbp)
movb %al, -0x7a(%rbp)
je 0x743f5
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movl -0xc(%rbp), %esi
callq 0x182a0
cmpl $0x0, %eax
setne %al
movb %al, -0x7a(%rbp)
movb -0x7a(%rbp), %al
testb $0x1, %al
jne 0x74401
jmp 0x74778
movq -0x8(%rbp), %rcx
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movl -0xc(%rbp), %esi
movq -0x20(%rbp), %rax
movl 0x38(%rax), %edx
movq 0x20(%rcx), %r8
movq %rsp, %rax
movq %r8, 0x20(%rax)
movups (%rcx), %xmm0
movups 0x10(%rcx), %xmm1
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
callq 0x741f0
movsd %xmm0, -0x68(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rdi
callq 0x45270
movq %rax, -0x60(%rbp)
movl -0xc(%rbp), %esi
movq -0x20(%rbp), %rdx
leaq -0x60(%rbp), %rdi
callq 0x74970
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x28(%rbp), %rdx
callq 0xae850
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x38(%rbp), %rdx
callq 0xae7d0
movq -0x38(%rbp), %rax
cmpl $0x0, 0x28(%rax)
jle 0x7449d
movq -0x38(%rbp), %rdi
movq -0x60(%rbp), %rsi
movq -0x20(%rbp), %rax
movl 0x38(%rax), %edx
callq 0x74b70
movq -0x60(%rbp), %rdi
callq 0x44510
movq -0x8(%rbp), %rcx
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movl -0xc(%rbp), %esi
movq -0x20(%rbp), %rax
movl 0x38(%rax), %edx
movq 0x20(%rcx), %r8
movq %rsp, %rax
movq %r8, 0x20(%rax)
movups (%rcx), %xmm0
movups 0x10(%rcx), %xmm1
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
callq 0x741f0
movsd %xmm0, -0x78(%rbp)
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rsi
movl -0xc(%rbp), %edx
movq -0x20(%rbp), %rcx
callq 0x74d70
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x38(%rbp), %rdx
callq 0xae850
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x40(%rbp), %rdx
callq 0xae7d0
movq -0x40(%rbp), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rsi
movq -0x20(%rbp), %rax
movl 0x38(%rax), %edx
callq 0x74b70
movq -0x8(%rbp), %rcx
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movl -0xc(%rbp), %esi
movq -0x20(%rbp), %rax
movl 0x38(%rax), %edx
movq 0x20(%rcx), %r8
movq %rsp, %rax
movq %r8, 0x20(%rax)
movups (%rcx), %xmm0
movups 0x10(%rcx), %xmm1
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
callq 0x741f0
movsd %xmm0, -0x70(%rbp)
movsd -0x70(%rbp), %xmm1
movsd -0x68(%rbp), %xmm0
ucomisd %xmm1, %xmm0
ja 0x7458b
movsd -0x78(%rbp), %xmm1
movsd -0x68(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x746c6
movsd -0x78(%rbp), %xmm1
movsd -0x70(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jb 0x74642
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x40(%rbp), %rdx
callq 0xae850
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x38(%rbp), %rdx
callq 0xae7d0
movq -0x40(%rbp), %rcx
movq 0x30(%rcx), %rdx
movq %rsp, %rax
movq %rdx, 0x30(%rax)
movups (%rcx), %xmm0
movups 0x10(%rcx), %xmm1
movups 0x20(%rcx), %xmm2
movups %xmm2, 0x20(%rax)
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
callq 0xadd10
movq -0x40(%rbp), %rdi
callq 0x52e80
movq -0x28(%rbp), %rcx
movq 0x30(%rcx), %rdx
movq %rsp, %rax
movq %rdx, 0x30(%rax)
movups (%rcx), %xmm0
movups 0x10(%rcx), %xmm1
movups 0x20(%rcx), %xmm2
movups %xmm2, 0x20(%rax)
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
callq 0xadd10
movq -0x28(%rbp), %rdi
callq 0x52e80
movq -0x18(%rbp), %rdi
movq -0x38(%rbp), %rdx
leaq -0x58(%rbp), %rsi
callq 0xdb5b0
movq -0x38(%rbp), %rax
movq %rax, -0x28(%rbp)
jmp 0x746c1
movq -0x38(%rbp), %rcx
movq 0x30(%rcx), %rdx
movq %rsp, %rax
movq %rdx, 0x30(%rax)
movups (%rcx), %xmm0
movups 0x10(%rcx), %xmm1
movups 0x20(%rcx), %xmm2
movups %xmm2, 0x20(%rax)
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
callq 0xadd10
movq -0x38(%rbp), %rdi
callq 0x52e80
movq -0x28(%rbp), %rcx
movq 0x30(%rcx), %rdx
movq %rsp, %rax
movq %rdx, 0x30(%rax)
movups (%rcx), %xmm0
movups 0x10(%rcx), %xmm1
movups 0x20(%rcx), %xmm2
movups %xmm2, 0x20(%rax)
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
callq 0xadd10
movq -0x28(%rbp), %rdi
callq 0x52e80
movq -0x18(%rbp), %rdi
movq -0x40(%rbp), %rdx
leaq -0x58(%rbp), %rsi
callq 0xdb5b0
movq -0x40(%rbp), %rax
movq %rax, -0x28(%rbp)
jmp 0x7475f
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x40(%rbp), %rdx
callq 0xae850
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x28(%rbp), %rdx
callq 0xae7d0
movq -0x40(%rbp), %rcx
movq 0x30(%rcx), %rdx
movq %rsp, %rax
movq %rdx, 0x30(%rax)
movups (%rcx), %xmm0
movups 0x10(%rcx), %xmm1
movups 0x20(%rcx), %xmm2
movups %xmm2, 0x20(%rax)
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
callq 0xadd10
movq -0x40(%rbp), %rdi
callq 0x52e80
movq -0x38(%rbp), %rcx
movq 0x30(%rcx), %rdx
movq %rsp, %rax
movq %rdx, 0x30(%rax)
movups (%rcx), %xmm0
movups 0x10(%rcx), %xmm1
movups 0x20(%rcx), %xmm2
movups %xmm2, 0x20(%rax)
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
callq 0xadd10
movq -0x38(%rbp), %rdi
callq 0x52e80
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rdx
leaq -0x58(%rbp), %rsi
callq 0xdb5b0
movq -0x28(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x28(%rbp)
jmp 0x743d1
cmpq $0x0, -0x28(%rbp)
jne 0x74888
jmp 0x74785
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movl -0xc(%rbp), %esi
callq 0x182a0
cmpl $0x0, %eax
je 0x74883
movq -0x18(%rbp), %rdi
movl -0xc(%rbp), %esi
movq -0x20(%rbp), %rdx
callq 0x74970
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x747d3
movq -0x50(%rbp), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rsi
movq -0x20(%rbp), %rax
movl 0x38(%rax), %edx
callq 0x74b70
movq -0x50(%rbp), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rsi
movl $0x1, %edx
callq 0xaea90
movq -0x50(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x7482b
movq -0x50(%rbp), %rcx
movq 0x30(%rcx), %rdx
movq %rsp, %rax
movq %rdx, 0x30(%rax)
movups (%rcx), %xmm0
movups 0x10(%rcx), %xmm1
movups 0x20(%rcx), %xmm2
movups %xmm2, 0x20(%rax)
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
callq 0xaedc0
movsd 0x6e193(%rip), %xmm1    # 0xe29b8
ucomisd %xmm1, %xmm0
jb 0x74860
movq -0x50(%rbp), %rcx
movq 0x30(%rcx), %rdx
movq %rsp, %rax
movq %rdx, 0x30(%rax)
movups (%rcx), %xmm0
movups 0x10(%rcx), %xmm1
movups 0x20(%rcx), %xmm2
movups %xmm2, 0x20(%rax)
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
callq 0xadd10
movq -0x50(%rbp), %rdi
callq 0x52e80
jmp 0x74883
movq -0x8(%rbp), %rdi
movq -0x50(%rbp), %rsi
callq 0xaea30
movq -0x18(%rbp), %rdi
movq -0x50(%rbp), %rdx
leaq -0x58(%rbp), %rsi
callq 0xdb5b0
jmp 0x74785
jmp 0x7494b
jmp 0x7488a
cmpq $0x0, -0x28(%rbp)
je 0x74936
movq -0x28(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x28(%rbp), %rax
movl (%rax), %eax
cmpl -0xc(%rbp), %eax
jne 0x74921
cmpq $0x0, -0x30(%rbp)
je 0x748c1
movq -0x48(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x30(%rax)
jmp 0x748cc
movq -0x48(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, (%rax)
movq -0x28(%rbp), %rcx
movq 0x30(%rcx), %rdx
movq %rsp, %rax
movq %rdx, 0x30(%rax)
movups (%rcx), %xmm0
movups 0x10(%rcx), %xmm1
movups 0x20(%rcx), %xmm2
movups %xmm2, 0x20(%rax)
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
callq 0xadd10
movq -0x28(%rbp), %rdi
callq 0x52e80
movq -0x8(%rbp), %rax
movl 0x10(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x10(%rax)
cmpq $0x0, -0x48(%rbp)
jne 0x7491f
movq -0x30(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x8(%rax)
jmp 0x74929
movq -0x28(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x28(%rbp)
jmp 0x7488a
cmpq $0x0, -0x30(%rbp)
je 0x74949
movq -0x30(%rbp), %rax
movq $0x0, 0x30(%rax)
jmp 0x7494b
movq -0x18(%rbp), %rdi
movq -0x58(%rbp), %rsi
callq 0x44f40
addq $0xc0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)