// File: /workspace/github_c_makefile_star2_O0/olcaytaner[P]Isell/omnivariaterule.c
// Function: simplify_ruleset_modelselection
void simplify_ruleset_modelselection(Ruleset* r, int positive, Instanceptr instances, int modelselectionmethod)
{
 /*!Last Changed 19.02.2005*/
 Decisionruleptr firstrule, deleted, tmprule, deletedbefore;
 double minerror, error, loglikelihood;
 int complexity, covered;
 complexity = complexity_of_ruleset(*r, positive);
 loglikelihood = log_likelihood_of_ruleset(*r, instances, positive, &covered);
 switch (modelselectionmethod)
  {
   case MODEL_SELECTION_AIC:minerror = aic_loglikelihood(loglikelihood, complexity);
                            break;
   case MODEL_SELECTION_BIC:minerror = bic_loglikelihood(loglikelihood, complexity, covered);
                            break;
  }
 firstrule = r->start;
 while (firstrule && firstrule->classno != positive)
   firstrule = firstrule->next;
 if (!firstrule)
   return;
 deleted = r->end;
 while (deleted && deleted->next != firstrule)
  {
   tmprule = r->start;
   if (tmprule != deleted)
    {
     while (tmprule->next != deleted)
       tmprule = tmprule->next;
     deletedbefore = tmprule;
    }
   else
     deletedbefore = NULL;
   remove_rule_after(r, deletedbefore, deleted);
   complexity = complexity_of_ruleset(*r, positive);
   loglikelihood = log_likelihood_of_ruleset(*r, instances, positive, &covered);
   switch (modelselectionmethod)
    {
     case MODEL_SELECTION_AIC:error = aic_loglikelihood(loglikelihood, complexity);
                              break;
     case MODEL_SELECTION_BIC:error = bic_loglikelihood(loglikelihood, complexity, covered);
                              break;
    }
   if (error > minerror)
     add_rule_after(r, deletedbefore, deleted);
   else
    {
     free_rule(*deleted);
     safe_free(deleted);
     minerror = error;
    }
   deleted = deletedbefore;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq -0x8(%rbp), %rcx
movl -0xc(%rbp), %edi
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 0xabb00
movl %eax, -0x5c(%rbp)
movq -0x8(%rbp), %rcx
movq -0x18(%rbp), %rdi
movl -0xc(%rbp), %esi
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)
leaq -0x60(%rbp), %rdx
callq 0x73cf0
movsd %xmm0, -0x58(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0x64(%rbp)
subl $0x1, %eax
je 0x74fea
jmp 0x74fe0
movl -0x64(%rbp), %eax
subl $0x2, %eax
je 0x75000
jmp 0x75017
movsd -0x58(%rbp), %xmm0
cvtsi2sdl -0x5c(%rbp), %xmm1
callq 0x66430
movsd %xmm0, -0x48(%rbp)
jmp 0x75017
movsd -0x58(%rbp), %xmm0
cvtsi2sdl -0x5c(%rbp), %xmm1
movl -0x60(%rbp), %edi
callq 0x669d0
movsd %xmm0, -0x48(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x28(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x28(%rbp)
movb %al, -0x65(%rbp)
je 0x7503d
movq -0x28(%rbp), %rax
movl (%rax), %eax
cmpl -0xc(%rbp), %eax
setne %al
movb %al, -0x65(%rbp)
movb -0x65(%rbp), %al
testb $0x1, %al
jne 0x75046
jmp 0x75054
movq -0x28(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x28(%rbp)
jmp 0x75022
cmpq $0x0, -0x28(%rbp)
jne 0x75060
jmp 0x751f3
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x30(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x30(%rbp)
movb %al, -0x66(%rbp)
je 0x7508a
movq -0x30(%rbp), %rax
movq 0x30(%rax), %rax
cmpq -0x28(%rbp), %rax
setne %al
movb %al, -0x66(%rbp)
movb -0x66(%rbp), %al
testb $0x1, %al
jne 0x75096
jmp 0x751f3
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x30(%rbp), %rax
je 0x750d3
jmp 0x750ad
movq -0x38(%rbp), %rax
movq 0x30(%rax), %rax
cmpq -0x30(%rbp), %rax
je 0x750c9
movq -0x38(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x38(%rbp)
jmp 0x750ad
movq -0x38(%rbp), %rax
movq %rax, -0x40(%rbp)
jmp 0x750db
movq $0x0, -0x40(%rbp)
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x30(%rbp), %rdx
callq 0xae850
movq -0x8(%rbp), %rcx
movl -0xc(%rbp), %edi
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 0xabb00
movl %eax, -0x5c(%rbp)
movq -0x8(%rbp), %rcx
movq -0x18(%rbp), %rdi
movl -0xc(%rbp), %esi
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)
leaq -0x60(%rbp), %rdx
callq 0x73cf0
movsd %xmm0, -0x58(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0x6c(%rbp)
subl $0x1, %eax
je 0x7515d
jmp 0x75153
movl -0x6c(%rbp), %eax
subl $0x2, %eax
je 0x75173
jmp 0x7518a
movsd -0x58(%rbp), %xmm0
cvtsi2sdl -0x5c(%rbp), %xmm1
callq 0x66430
movsd %xmm0, -0x50(%rbp)
jmp 0x7518a
movsd -0x58(%rbp), %xmm0
cvtsi2sdl -0x5c(%rbp), %xmm1
movl -0x60(%rbp), %edi
callq 0x669d0
movsd %xmm0, -0x50(%rbp)
movsd -0x50(%rbp), %xmm0
ucomisd -0x48(%rbp), %xmm0
jbe 0x751a9
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x30(%rbp), %rdx
callq 0xae7d0
jmp 0x751e6
movq -0x30(%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 -0x30(%rbp), %rdi
callq 0x52e80
movsd -0x50(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x30(%rbp)
jmp 0x7506c
addq $0xb0, %rsp
popq %rbp
retq
nopl (%rax)