// File: /workspace/github_c_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %r8, 0x70(%rsp)
movq %rcx, 0x78(%rsp)
movq %rdx, %rbp
movl %esi, %r12d
movq $0x0, 0x58(%rsp)
movq %rdi, 0x50(%rsp)
movq (%rdi), %r14
testq %r14, %r14
je 0x4a983
cmpl %r12d, (%r14)
jne 0x4ae21
xorl %ebx, %ebx
testq %r14, %r14
movl %r12d, 0x64(%rsp)
je 0x4acfd
movq %rbp, 0x68(%rsp)
movq (%rbp), %rdi
movl %r12d, %esi
callq 0x11569
testl %eax, %eax
je 0x4ae3b
movq 0x50(%rsp), %r15
movq 0x20(%r15), %rax
movq %rax, 0x20(%rsp)
movups (%r15), %xmm0
movups 0x10(%r15), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq 0x78(%rsp), %rdi
movl %r12d, %esi
callq 0x4a841
movl %eax, 0x84(%rsp)
movq %rbp, %rdi
leaq 0x40(%rsp), %rsi
leaq 0x48(%rsp), %r13
movq %r13, %rdx
movl $0x3, %ecx
callq 0x30746
movq %r13, %rdi
movl %r12d, %esi
movq 0x70(%rsp), %rdx
callq 0x4af27
movq %rax, %r13
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x7afd2
movq %r15, %rdi
movq %rbx, %rsi
movq %r13, %rdx
callq 0x7afad
cmpl $0x0, 0x28(%r13)
jle 0x4aa40
movq 0x40(%rsp), %rsi
movq %r13, %rdi
movl %r12d, %edx
callq 0x9b2c1
movq 0x50(%rsp), %rbp
movq 0x20(%rbp), %rax
movq %rax, 0x20(%rsp)
movups (%rbp), %xmm0
movups 0x10(%rbp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq 0x78(%rsp), %rdi
movl %r12d, %esi
callq 0x4a841
movl %eax, 0x80(%rsp)
leaq 0x48(%rsp), %rdi
movq %r14, %rsi
movl %r12d, %edx
movq 0x70(%rsp), %rcx
callq 0x4b08b
movq %rax, %r15
movq %rbp, %rdi
movq %rbx, %rsi
movq %r13, %rdx
callq 0x7afd2
movq %rbp, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x7afad
movq 0x40(%rsp), %rsi
movq %r15, %rdi
movl %r12d, %edx
callq 0x9b2c1
movq 0x20(%rbp), %rax
movq %rax, 0x20(%rsp)
movups (%rbp), %xmm0
movups 0x10(%rbp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq 0x78(%rsp), %rdi
movl %r12d, %esi
callq 0x4a841
movl 0x80(%rsp), %esi
movl 0x84(%rsp), %edx
cmpl %edx, %eax
setl %cl
cmpl %edx, %esi
setl %dl
orb %cl, %dl
cmpb $0x1, %dl
jne 0x4ab8d
cmpl %eax, %esi
jle 0x4ac2d
movq 0x30(%r13), %rax
movq %rax, 0x30(%rsp)
movups (%r13), %xmm0
movups 0x10(%r13), %xmm1
movups 0x20(%r13), %xmm2
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
callq 0x7a989
movq %r13, %rdi
callq 0x39194
movq 0x30(%r14), %rax
movq %rax, 0x30(%rsp)
movupd (%r14), %xmm0
movups 0x10(%r14), %xmm1
movups 0x20(%r14), %xmm2
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movupd %xmm0, (%rsp)
callq 0x7a989
movq %r14, %rdi
callq 0x39194
movq 0x68(%rsp), %rbp
movq %rbp, %rdi
leaq 0x58(%rsp), %rsi
movq %r15, %rdx
callq 0x9c951
movq %r15, %r13
jmp 0x4acc9
movq %rbp, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x7afd2
movq %rbp, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x7afad
movq 0x30(%r15), %rax
movq %rax, 0x30(%rsp)
movups (%r15), %xmm0
movups 0x10(%r15), %xmm1
movups 0x20(%r15), %xmm2
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
callq 0x7a989
movq %r15, %rdi
callq 0x39194
movq 0x30(%r13), %rax
movq %rax, 0x30(%rsp)
movupd (%r13), %xmm0
movups 0x10(%r13), %xmm1
movups 0x20(%r13), %xmm2
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movupd %xmm0, (%rsp)
callq 0x7a989
movq %r13, %rdi
callq 0x39194
movq 0x68(%rsp), %rbp
movq %rbp, %rdi
leaq 0x58(%rsp), %rsi
movq %r14, %rdx
callq 0x9c951
movq %r14, %r13
jmp 0x4acc9
movq 0x50(%rsp), %r12
movq %r12, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x7afd2
movq %r12, %rdi
movq %rbx, %rsi
movq %r13, %rdx
callq 0x7afad
movq 0x30(%r15), %rax
movq %rax, 0x30(%rsp)
movups (%r15), %xmm0
movups 0x10(%r15), %xmm1
movups 0x20(%r15), %xmm2
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
callq 0x7a989
movq %r15, %rdi
callq 0x39194
movq 0x30(%r14), %rax
movq %rax, 0x30(%rsp)
movupd (%r14), %xmm0
movups 0x10(%r14), %xmm1
movups 0x20(%r14), %xmm2
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movupd %xmm0, (%rsp)
callq 0x7a989
movq %r14, %rdi
callq 0x39194
movq 0x68(%rsp), %rbp
movq %rbp, %rdi
leaq 0x58(%rsp), %rsi
movq %r13, %rdx
callq 0x9c951
movq (%rbp), %rdi
movq 0x48(%rsp), %rsi
callq 0x30ad5
movq %rax, (%rbp)
movq 0x40(%rsp), %rsi
movq %rbp, %rdi
callq 0x2fd59
movq 0x30(%r13), %r14
movq %r13, %rbx
testq %r14, %r14
movl 0x64(%rsp), %r12d
jne 0x4a998
movq (%rbp), %rdi
movl %r12d, %esi
callq 0x11569
testl %eax, %eax
movq 0x50(%rsp), %r14
je 0x4af08
leaq 0x40(%rsp), %rbx
leaq 0x48(%rsp), %r15
movq %rbp, %rdi
movq %rbx, %rsi
movq %r15, %rdx
movl $0x3, %ecx
callq 0x30746
movq %r15, %rdi
movl %r12d, %esi
movq 0x70(%rsp), %rdx
callq 0x4af27
movq %rax, %r13
cmpq $0x0, 0x18(%rax)
je 0x4ad62
movq 0x40(%rsp), %rsi
movq %r13, %rdi
movl %r12d, %edx
movl $0x2, %ecx
callq 0x9c4fc
movq 0x48(%rsp), %rsi
movq %r13, %rdi
movl $0x1, %edx
callq 0x7b122
movq 0x40(%rsp), %rsi
movq %r13, %rdi
xorl %edx, %edx
callq 0x7b122
cmpq $0x0, 0x18(%r13)
je 0x4aeb4
movq 0x30(%r13), %rax
movq %rax, 0x30(%rsp)
movupd (%r13), %xmm0
movups 0x10(%r13), %xmm1
movups 0x20(%r13), %xmm2
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movupd %xmm0, (%rsp)
callq 0x7b300
ucomisd 0x57f55(%rip), %xmm0    # 0xa2d18
jae 0x4aeb4
movq %r14, %rdi
movq %r13, %rsi
callq 0x7b0fb
movq (%rbp), %rdi
movq 0x48(%rsp), %rsi
callq 0x30ad5
movq %rax, (%rbp)
movq 0x40(%rsp), %rsi
movq %rbp, %rdi
callq 0x2fd59
movq %rbp, %rdi
leaq 0x58(%rsp), %rsi
movq %r13, %rdx
callq 0x9c951
movq (%rbp), %rdi
movl 0x64(%rsp), %r12d
movl %r12d, %esi
callq 0x11569
testl %eax, %eax
jne 0x4ad20
jmp 0x4af08
movq %r14, %rbx
movq 0x30(%r14), %r14
testq %r14, %r14
je 0x4a985
cmpl %r12d, (%r14)
jne 0x4ae21
jmp 0x4a985
movq 0x50(%rsp), %r13
movq %r14, %r15
movq 0x30(%r14), %r14
cmpl %r12d, (%r15)
jne 0x4ae9d
leaq 0x30(%rbx), %rax
testq %rbx, %rbx
cmoveq %r13, %rax
movq %r14, (%rax)
movq 0x30(%r15), %rax
movq %rax, 0x30(%rsp)
movupd (%r15), %xmm0
movups 0x10(%r15), %xmm1
movups 0x20(%r15), %xmm2
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movupd %xmm0, (%rsp)
callq 0x7a989
movq %r15, %rdi
callq 0x39194
decl 0x10(%r13)
testq %r14, %r14
jne 0x4aea0
movq %rbx, 0x8(%r13)
jmp 0x4aea0
movq %r15, %rbx
testq %r14, %r14
jne 0x4ae40
testq %rbx, %rbx
je 0x4af08
movq $0x0, 0x30(%rbx)
jmp 0x4af08
movq 0x30(%r13), %rax
movq %rax, 0x30(%rsp)
movupd (%r13), %xmm0
movups 0x10(%r13), %xmm1
movups 0x20(%r13), %xmm2
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movupd %xmm0, (%rsp)
callq 0x7a989
movq %r13, %rdi
callq 0x39194
movq (%rbp), %rdi
movq 0x48(%rsp), %rsi
callq 0x30ad5
movq %rax, (%rbp)
movq 0x40(%rsp), %rsi
movq %rbp, %rdi
callq 0x2fd59
movq 0x58(%rsp), %rsi
movq %rbp, %rdi
callq 0x2fd59
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq