// File: /workspace/github_c_makefile_star2_O2/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, 0x68(%rsp)
movq %rcx, 0x70(%rsp)
movq %rdx, %rbp
andq $0x0, 0x60(%rsp)
movl %esi, %r15d
movq %rdi, %r14
xorl %r12d, %r12d
movq %rdi, %rax
movq %rdx, 0x58(%rsp)
movl %esi, 0x44(%rsp)
movq (%rax), %r13
testq %r13, %r13
je 0x45008
cmpl %r15d, (%r13)
je 0x45008
leaq 0x30(%r13), %rax
movq %r13, %r12
jmp 0x44c9e
movq 0x20(%r14), %rax
movq %rax, 0x20(%rsp)
movups (%r14), %xmm0
movups 0x10(%r14), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq 0x70(%rsp), %rdi
movl %r15d, %esi
callq 0x44b86
movl %eax, 0x7c(%rsp)
leaq 0x48(%rsp), %rsi
leaq 0x50(%rsp), %r15
pushq $0x3
popq %rcx
movq %rbp, %rdi
movq %r15, %rdx
callq 0x2cfe5
movq %r15, %rdi
movl 0x44(%rsp), %r15d
movl %r15d, %esi
movq 0x68(%rsp), %rdx
callq 0x45224
movq %rax, %rbx
movq %r14, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x721ae
movq %r14, %rdi
movq %r12, 0x80(%rsp)
movq %r12, %rsi
movq %rbx, %rdx
callq 0x7217f
cmpl $0x0, 0x28(%rbx)
jle 0x44d53
movq 0x48(%rsp), %rsi
movq %rbx, %rdi
movl %r15d, %edx
callq 0x8f09d
movq 0x20(%r14), %rax
movq %rax, 0x20(%rsp)
movups (%r14), %xmm0
movups 0x10(%r14), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq 0x70(%rsp), %rdi
movl %r15d, %esi
callq 0x44b86
movl %eax, 0x78(%rsp)
leaq 0x50(%rsp), %rdi
movq %r13, %rsi
movl %r15d, %edx
movq 0x68(%rsp), %rcx
callq 0x45379
movq %rax, %r12
movq %r14, %rdi
movq 0x80(%rsp), %rbp
movq %rbp, %rsi
movq %rbx, %rdx
callq 0x721ae
movq %r14, %rdi
movq %rbp, %rsi
movq %r12, %rdx
callq 0x7217f
movq 0x48(%rsp), %rsi
movq %r12, %rdi
movl %r15d, %edx
callq 0x8f09d
movq 0x20(%r14), %rax
movq %rax, 0x20(%rsp)
movups (%r14), %xmm0
movups 0x10(%r14), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq 0x70(%rsp), %rdi
movl %r15d, %esi
callq 0x44b86
movl 0x78(%rsp), %esi
movl 0x7c(%rsp), %edx
cmpl %edx, %eax
setl %cl
cmpl %edx, %esi
setl %dl
orb %cl, %dl
cmpb $0x1, %dl
jne 0x44e99
cmpl %eax, %esi
jle 0x44f39
movq 0x30(%rbx), %rax
movq %rax, 0x30(%rsp)
movups (%rbx), %xmm0
movups 0x10(%rbx), %xmm1
movups 0x20(%rbx), %xmm2
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
callq 0x71be8
movq %rbx, %rdi
callq 0x34ff7
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 0x71be8
movq %r13, %rdi
callq 0x34ff7
leaq 0x60(%rsp), %rsi
movq 0x58(%rsp), %rbp
movq %rbp, %rdi
movq %r12, %rdx
callq 0x90582
movq %r12, %rbx
jmp 0x44fdd
movq %r14, %rdi
movq %rbp, %rsi
movq %r12, %rdx
callq 0x721ae
movq %r14, %rdi
movq %rbp, %rsi
movq %r13, %rdx
callq 0x7217f
movq 0x30(%r12), %rax
movq %rax, 0x30(%rsp)
movups (%r12), %xmm0
movups 0x10(%r12), %xmm1
movups 0x20(%r12), %xmm2
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
callq 0x71be8
movq %r12, %rdi
callq 0x34ff7
movq 0x30(%rbx), %rax
movq %rax, 0x30(%rsp)
movupd (%rbx), %xmm0
movups 0x10(%rbx), %xmm1
movups 0x20(%rbx), %xmm2
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movupd %xmm0, (%rsp)
callq 0x71be8
movq %rbx, %rdi
callq 0x34ff7
leaq 0x60(%rsp), %rsi
movq 0x58(%rsp), %rbp
movq %rbp, %rdi
movq %r13, %rdx
callq 0x90582
movq %r13, %rbx
jmp 0x44fdd
movq %r14, %rdi
movq 0x80(%rsp), %r15
movq %r15, %rsi
movq %r12, %rdx
callq 0x721ae
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x7217f
movq 0x30(%r12), %rax
movq %rax, 0x30(%rsp)
movups (%r12), %xmm0
movups 0x10(%r12), %xmm1
movups 0x20(%r12), %xmm2
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
callq 0x71be8
movq %r12, %rdi
callq 0x34ff7
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 0x71be8
movq %r13, %rdi
callq 0x34ff7
leaq 0x60(%rsp), %rsi
movq 0x58(%rsp), %rbp
movq %rbp, %rdi
movq %rbx, %rdx
callq 0x90582
movq (%rbp), %rdi
movq 0x50(%rsp), %rsi
callq 0x2d2da
movq %rax, (%rbp)
movq 0x48(%rsp), %rsi
movq %rbp, %rdi
callq 0x2c6e4
movq 0x30(%rbx), %r13
movq %rbx, %r12
movl 0x44(%rsp), %r15d
testq %r13, %r13
je 0x450a1
movq (%rbp), %rdi
movl %r15d, %esi
callq 0x10855
testl %eax, %eax
jne 0x44cbd
movq %r12, %rax
addq $0x30, %r12
movq %rax, %rbx
testq %rax, %rax
cmoveq %r14, %r12
movq %r13, %r15
testq %r15, %r15
je 0x451a4
movq 0x30(%r15), %r13
movl 0x44(%rsp), %eax
cmpl %eax, (%r15)
jne 0x4509c
movq %r13, (%r12)
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 0x71be8
movq %r15, %rdi
callq 0x34ff7
decl 0x10(%r14)
movq %r13, %r15
testq %r13, %r13
jne 0x45039
movq %rbx, 0x8(%r14)
movq %r13, %r15
jmp 0x45039
movq %r15, %r12
jmp 0x45025
leaq 0x50(%rsp), %r15
pushq $0x1
popq %r13
movl 0x44(%rsp), %r12d
movq (%rbp), %rdi
movl %r12d, %esi
callq 0x10855
testl %eax, %eax
je 0x45205
movq %rbp, %rdi
leaq 0x48(%rsp), %rsi
movq %r15, %rdx
pushq $0x3
popq %rcx
callq 0x2cfe5
movq %r15, %rdi
movl %r12d, %esi
movq 0x68(%rsp), %rdx
callq 0x45224
movq %rax, %rbx
cmpq $0x0, 0x18(%rax)
je 0x45103
movq 0x48(%rsp), %rsi
movq %rbx, %rdi
movl %r12d, %edx
pushq $0x2
popq %rcx
callq 0x90239
movq 0x50(%rsp), %rsi
movq %rbx, %rdi
movl %r13d, %edx
callq 0x722ae
movq 0x48(%rsp), %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x722ae
cmpq $0x0, 0x18(%rbx)
je 0x451b0
movq 0x30(%rbx), %rax
movq %rax, 0x30(%rsp)
movupd (%rbx), %xmm0
movups 0x10(%rbx), %xmm1
movups 0x20(%rbx), %xmm2
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movupd %xmm0, (%rsp)
callq 0x7247e
ucomisd 0x50bc2(%rip), %xmm0    # 0x95d20
jae 0x451b0
movq %r14, %rdi
movq %rbx, %rsi
callq 0x7228a
movq 0x58(%rsp), %rbp
movq (%rbp), %rdi
movq 0x50(%rsp), %rsi
callq 0x2d2da
movq %rax, (%rbp)
movq 0x48(%rsp), %rsi
movq %rbp, %rdi
callq 0x2c6e4
movq %rbp, %rdi
leaq 0x60(%rsp), %rsi
movq %rbx, %rdx
callq 0x90582
jmp 0x450af
testq %rbx, %rbx
je 0x45205
andq $0x0, 0x30(%rbx)
jmp 0x45205
movq 0x30(%rbx), %rax
movq %rax, 0x30(%rsp)
movupd (%rbx), %xmm0
movups 0x10(%rbx), %xmm1
movups 0x20(%rbx), %xmm2
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movupd %xmm0, (%rsp)
callq 0x71be8
movq %rbx, %rdi
callq 0x34ff7
movq 0x58(%rsp), %rbp
movq (%rbp), %rdi
movq 0x50(%rsp), %rsi
callq 0x2d2da
movq %rax, (%rbp)
movq 0x48(%rsp), %rsi
movq %rbp, %rdi
callq 0x2c6e4
movq 0x60(%rsp), %rsi
movq %rbp, %rdi
callq 0x2c6e4
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq