// File: /workspace/github_c_makefile_star2_O0/olcaytaner[P]Isell/multivariaterule.c
// Function: optimize_ruleset_multivariate
void optimize_ruleset_multivariate(Ruleset* r, int positive, Instanceptr* instances, Instanceptr cvdata, Ripper_parameterptr param)
{
 /* Last Changed 14.01.2004*/
 Decisionruleptr rule, before = NULL, replacementrule, revisionrule, next, newrule;
 Instanceptr grow, prune, removed = NULL;
 int 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 = validation_error_after_pruning(*r, cvdata, positive);
   divide_instancelist(instances, &prune, &grow, 3);
   replacementrule = growrule_multivariate(&grow, positive, param);
   remove_rule_after(r, before, rule);
   add_rule_after(r, before, replacementrule);
   if (replacementrule->decisioncount > 0)
     prunerule_in_optimize_phase(replacementrule, prune, positive);
   replacementerror = validation_error_after_pruning(*r, cvdata, positive);
   revisionrule = grow_revision_rule_multivariate(&grow, rule, positive, param);
   remove_rule_after(r, before, replacementrule);
   add_rule_after(r, before, revisionrule);
   prunerule_in_optimize_phase(revisionrule, prune, positive);
   revisionerror = validation_error_after_pruning(*r, cvdata, positive);
   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);     
    }
   *instances = restore_instancelist(*instances, grow);
   merge_instancelist(instances, prune);
   before = rule;
   rule = rule->next;
  }
 if (!rule)
  {
   while (class_exists_in_list(*instances, positive))
    {
     divide_instancelist(instances, &prune, &grow, 3);    
     newrule = growrule_multivariate(&grow, positive, param);
     if (newrule->start)
       prunerule(newrule, prune, positive, 2);
     update_counts(newrule, grow, 1);
     update_counts(newrule, prune, 0);
     if (!(newrule->start) || (error_rate_of_rule(*newrule) >= 0.5))
      {
       free_rule(*newrule);
       safe_free(newrule);
       *instances = restore_instancelist(*instances, grow);
       merge_instancelist(instances, prune);
       break;
      }
     add_rule(r, newrule);
     *instances = restore_instancelist(*instances, grow);
     merge_instancelist(instances, prune);     
     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 %r8, -0x28(%rbp)
movq $0x0, -0x38(%rbp)
movq $0x0, -0x70(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x30(%rbp)
movb %al, -0x7d(%rbp)
je 0x6c804
movq -0x30(%rbp), %rax
movl (%rax), %eax
cmpl -0xc(%rbp), %eax
setne %al
movb %al, -0x7d(%rbp)
movb -0x7d(%rbp), %al
testb $0x1, %al
jne 0x6c80d
jmp 0x6c823
movq -0x30(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x30(%rbp)
jmp 0x6c7e9
jmp 0x6c825
xorl %eax, %eax
cmpq $0x0, -0x30(%rbp)
movb %al, -0x7e(%rbp)
je 0x6c849
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movl -0xc(%rbp), %esi
callq 0x182a0
cmpl $0x0, %eax
setne %al
movb %al, -0x7e(%rbp)
movb -0x7e(%rbp), %al
testb $0x1, %al
jne 0x6c855
jmp 0x6cba9
movq -0x8(%rbp), %rcx
movq -0x20(%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)
callq 0x6c670
movl %eax, -0x74(%rbp)
movq -0x18(%rbp), %rdi
leaq -0x68(%rbp), %rsi
leaq -0x60(%rbp), %rdx
movl $0x3, %ecx
callq 0x45f60
movl -0xc(%rbp), %esi
movq -0x28(%rbp), %rdx
leaq -0x60(%rbp), %rdi
callq 0x6ce00
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x30(%rbp), %rdx
callq 0xae850
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x40(%rbp), %rdx
callq 0xae7d0
movq -0x40(%rbp), %rax
cmpl $0x0, 0x28(%rax)
jle 0x6c8e7
movq -0x40(%rbp), %rdi
movq -0x68(%rbp), %rsi
movl -0xc(%rbp), %edx
callq 0xd9a20
movq -0x8(%rbp), %rcx
movq -0x20(%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)
callq 0x6c670
movl %eax, -0x7c(%rbp)
movq -0x30(%rbp), %rsi
movl -0xc(%rbp), %edx
movq -0x28(%rbp), %rcx
leaq -0x60(%rbp), %rdi
callq 0x6d000
movq %rax, -0x48(%rbp)
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x40(%rbp), %rdx
callq 0xae850
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x48(%rbp), %rdx
callq 0xae7d0
movq -0x48(%rbp), %rdi
movq -0x68(%rbp), %rsi
movl -0xc(%rbp), %edx
callq 0xd9a20
movq -0x8(%rbp), %rcx
movq -0x20(%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)
callq 0x6c670
movl %eax, -0x78(%rbp)
movl -0x78(%rbp), %eax
cmpl -0x74(%rbp), %eax
jl 0x6c99d
movl -0x7c(%rbp), %eax
cmpl -0x74(%rbp), %eax
jge 0x6cad0
movl -0x7c(%rbp), %eax
cmpl -0x78(%rbp), %eax
jg 0x6ca4c
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x48(%rbp), %rdx
callq 0xae850
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x40(%rbp), %rdx
callq 0xae7d0
movq -0x48(%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 -0x48(%rbp), %rdi
callq 0x52e80
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
movq -0x18(%rbp), %rdi
movq -0x40(%rbp), %rdx
leaq -0x70(%rbp), %rsi
callq 0xdb5b0
movq -0x40(%rbp), %rax
movq %rax, -0x30(%rbp)
jmp 0x6cacb
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 -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
movq -0x18(%rbp), %rdi
movq -0x48(%rbp), %rdx
leaq -0x70(%rbp), %rsi
callq 0xdb5b0
movq -0x48(%rbp), %rax
movq %rax, -0x30(%rbp)
jmp 0x6cb69
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x48(%rbp), %rdx
callq 0xae850
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x30(%rbp), %rdx
callq 0xae7d0
movq -0x48(%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 -0x48(%rbp), %rdi
callq 0x52e80
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 -0x18(%rbp), %rdi
movq -0x30(%rbp), %rdx
leaq -0x70(%rbp), %rsi
callq 0xdb5b0
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movq -0x60(%rbp), %rsi
callq 0x464e0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x18(%rbp), %rdi
movq -0x68(%rbp), %rsi
callq 0x44f40
movq -0x30(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x30(%rbp)
jmp 0x6c825
cmpq $0x0, -0x30(%rbp)
jne 0x6cd27
jmp 0x6cbb6
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movl -0xc(%rbp), %esi
callq 0x182a0
cmpl $0x0, %eax
je 0x6cd22
movq -0x18(%rbp), %rdi
leaq -0x68(%rbp), %rsi
leaq -0x60(%rbp), %rdx
movl $0x3, %ecx
callq 0x45f60
movl -0xc(%rbp), %esi
movq -0x28(%rbp), %rdx
leaq -0x60(%rbp), %rdi
callq 0x6ce00
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x6cc18
movq -0x58(%rbp), %rdi
movq -0x68(%rbp), %rsi
movl -0xc(%rbp), %edx
movl $0x2, %ecx
callq 0xdb170
movq -0x58(%rbp), %rdi
movq -0x60(%rbp), %rsi
movl $0x1, %edx
callq 0xaea90
movq -0x58(%rbp), %rdi
movq -0x68(%rbp), %rsi
xorl %edx, %edx
callq 0xaea90
movq -0x58(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x6cc7c
movq -0x58(%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 0x75d42(%rip), %xmm1    # 0xe29b8
ucomisd %xmm1, %xmm0
jb 0x6ccd8
movq -0x58(%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 -0x58(%rbp), %rdi
callq 0x52e80
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movq -0x60(%rbp), %rsi
callq 0x464e0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x18(%rbp), %rdi
movq -0x68(%rbp), %rsi
callq 0x44f40
jmp 0x6cd22
movq -0x8(%rbp), %rdi
movq -0x58(%rbp), %rsi
callq 0xaea30
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movq -0x60(%rbp), %rsi
callq 0x464e0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x18(%rbp), %rdi
movq -0x68(%rbp), %rsi
callq 0x44f40
movq -0x18(%rbp), %rdi
movq -0x58(%rbp), %rdx
leaq -0x70(%rbp), %rsi
callq 0xdb5b0
jmp 0x6cbb6
jmp 0x6cdea
jmp 0x6cd29
cmpq $0x0, -0x30(%rbp)
je 0x6cdd5
movq -0x30(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x30(%rbp), %rax
movl (%rax), %eax
cmpl -0xc(%rbp), %eax
jne 0x6cdc0
cmpq $0x0, -0x38(%rbp)
je 0x6cd60
movq -0x50(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x30(%rax)
jmp 0x6cd6b
movq -0x50(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, (%rax)
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
movq -0x8(%rbp), %rax
movl 0x10(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x10(%rax)
cmpq $0x0, -0x50(%rbp)
jne 0x6cdbe
movq -0x38(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x8(%rax)
jmp 0x6cdc8
movq -0x30(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x30(%rbp)
jmp 0x6cd29
cmpq $0x0, -0x38(%rbp)
je 0x6cde8
movq -0x38(%rbp), %rax
movq $0x0, 0x30(%rax)
jmp 0x6cdea
movq -0x18(%rbp), %rdi
movq -0x70(%rbp), %rsi
callq 0x44f40
addq $0xc0, %rsp
popq %rbp
retq