// File: /workspace/github_c_makefile_star2_O0/olcaytaner[P]Isell/omnivariaterule.c
// Function: prunerule_with_modelselection
void prunerule_with_modelselection(Decisionruleptr rule, Instanceptr dataset, int modelselectionmethod)
{
 /*!Last Changed 19.02.2005*/
 double bestgen, gen, loglikelihood;
 int complexity, improved = 1, covered;
 Decisionconditionptr best, bestbefore, tmpcondition, tmpbefore;
 complexity = complexity_of_rule(rule);
 loglikelihood = log_likelihood_of_rule(rule, dataset, &covered);
 switch (modelselectionmethod)
  {
   case MODEL_SELECTION_AIC:bestgen = aic_loglikelihood(loglikelihood, complexity);
                            break;
   case MODEL_SELECTION_BIC:bestgen = bic_loglikelihood(loglikelihood, complexity, covered);
                            break;
  }
 while (improved)
  {
   improved = 0;
   tmpbefore = NULL;
   tmpcondition = rule->start;
   while (tmpcondition)
    {
     remove_condition_after(rule, tmpbefore, tmpcondition);
     complexity = complexity_of_rule(rule);
     loglikelihood = log_likelihood_of_rule(rule, dataset, &covered);
     switch (modelselectionmethod)
      {
       case MODEL_SELECTION_AIC:gen = aic_loglikelihood(loglikelihood, complexity);
                                break;
       case MODEL_SELECTION_BIC:gen = bic_loglikelihood(loglikelihood, complexity, covered);
                                break;
      } 
     if (gen < bestgen)
      {
       bestgen = gen;
       bestbefore = tmpbefore;
       best = tmpcondition;
       improved = 1;
      }
     add_condition_after(rule, tmpbefore, tmpcondition);
     tmpbefore = tmpcondition;
     tmpcondition = tmpcondition->next;
    }
   if (improved)
    {
     remove_condition_after(rule, bestbefore, best);
     free_condition(*best);
     safe_free(best);
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl $0x1, -0x38(%rbp)
movq -0x8(%rbp), %rdi
callq 0xabab0
movl %eax, -0x34(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
leaq -0x3c(%rbp), %rdx
callq 0x73bd0
movsd %xmm0, -0x30(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0x64(%rbp)
subl $0x1, %eax
je 0x74bc6
jmp 0x74bbc
movl -0x64(%rbp), %eax
subl $0x2, %eax
je 0x74bdc
jmp 0x74bf3
movsd -0x30(%rbp), %xmm0
cvtsi2sdl -0x34(%rbp), %xmm1
callq 0x66430
movsd %xmm0, -0x20(%rbp)
jmp 0x74bf3
movsd -0x30(%rbp), %xmm0
cvtsi2sdl -0x34(%rbp), %xmm1
movl -0x3c(%rbp), %edi
callq 0x669d0
movsd %xmm0, -0x20(%rbp)
jmp 0x74bf5
cmpl $0x0, -0x38(%rbp)
je 0x74d5e
movl $0x0, -0x38(%rbp)
movq $0x0, -0x60(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
je 0x74cf7
movq -0x8(%rbp), %rdi
movq -0x60(%rbp), %rsi
movq -0x58(%rbp), %rdx
callq 0xae6b0
movq -0x8(%rbp), %rdi
callq 0xabab0
movl %eax, -0x34(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
leaq -0x3c(%rbp), %rdx
callq 0x73bd0
movsd %xmm0, -0x30(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0x68(%rbp)
subl $0x1, %eax
je 0x74c6f
jmp 0x74c65
movl -0x68(%rbp), %eax
subl $0x2, %eax
je 0x74c85
jmp 0x74c9c
movsd -0x30(%rbp), %xmm0
cvtsi2sdl -0x34(%rbp), %xmm1
callq 0x66430
movsd %xmm0, -0x28(%rbp)
jmp 0x74c9c
movsd -0x30(%rbp), %xmm0
cvtsi2sdl -0x34(%rbp), %xmm1
movl -0x3c(%rbp), %edi
callq 0x669d0
movsd %xmm0, -0x28(%rbp)
movsd -0x28(%rbp), %xmm1
movsd -0x20(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x74ccd
movsd -0x28(%rbp), %xmm0
movsd %xmm0, -0x20(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x58(%rbp), %rax
movq %rax, -0x48(%rbp)
movl $0x1, -0x38(%rbp)
movq -0x8(%rbp), %rdi
movq -0x60(%rbp), %rsi
movq -0x58(%rbp), %rdx
callq 0xae5c0
movq -0x58(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x58(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0x58(%rbp)
jmp 0x74c1a
cmpl $0x0, -0x38(%rbp)
je 0x74d59
movq -0x8(%rbp), %rdi
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
callq 0xae6b0
movq -0x48(%rbp), %rcx
movups 0x60(%rcx), %xmm0
movq %rsp, %rax
movups %xmm0, 0x60(%rax)
movups 0x50(%rcx), %xmm0
movups %xmm0, 0x50(%rax)
movups 0x40(%rcx), %xmm0
movups %xmm0, 0x40(%rax)
movups (%rcx), %xmm0
movups 0x10(%rcx), %xmm1
movups 0x20(%rcx), %xmm2
movups 0x30(%rcx), %xmm3
movups %xmm3, 0x30(%rax)
movups %xmm2, 0x20(%rax)
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
callq 0xadc90
movq -0x48(%rbp), %rdi
callq 0x52e80
jmp 0x74bf5
addq $0xe0, %rsp
popq %rbp
retq
nopw (%rax,%rax)