// File: /workspace/github_c_makefile_star2_O3/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
movl %esi, %r15d
movq $0x0, 0x50(%rsp)
movq (%rdi), %r13
testq %r13, %r13
movl %esi, 0x44(%rsp)
movq %rdi, 0x60(%rsp)
je 0x4c19e
movq %rdi, %r12
cmpl %r15d, (%r13)
jne 0x4be09
xorl %r14d, %r14d
jmp 0x4be25
movq %r13, %rax
movq 0x30(%rax), %r13
testq %r13, %r13
je 0x4c19e
movq %rax, %r14
movq %r13, %rax
cmpl %r15d, (%r13)
jne 0x4be0c
leaq 0x48(%rsp), %rbx
movq %rbp, 0x58(%rsp)
movq (%rbp), %rdi
movl %r15d, %esi
callq 0x1152e
testl %eax, %eax
je 0x4c2c2
movq 0x20(%r12), %rax
movq %rax, 0x20(%rsp)
movups (%r12), %xmm0
movups 0x10(%r12), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq 0x70(%rsp), %rdi
movl %r15d, %esi
callq 0x4bcba
movl %eax, 0x7c(%rsp)
movq %rbp, %rdi
leaq 0x38(%rsp), %rsi
movq %rbx, %rdx
movl $0x3, %ecx
callq 0x31019
movq %rbx, %rdi
movl %r15d, %esi
movq 0x68(%rsp), %rdx
callq 0x4c3b3
movq %r14, %rbp
movq %rax, %r14
movq %r12, %rdi
movq %rbp, %rsi
movq %r13, %rdx
callq 0x7c89d
movq %r12, %rdi
movq %rbp, 0x80(%rsp)
movq %rbp, %rsi
movq %r14, %rdx
callq 0x7c86e
cmpl $0x0, 0x28(%r14)
jle 0x4bed8
movq 0x38(%rsp), %rsi
movq %r14, %rdi
movl %r15d, %edx
callq 0x9e2d3
movq 0x20(%r12), %rax
movq %rax, 0x20(%rsp)
movups (%r12), %xmm0
movups 0x10(%r12), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq 0x70(%rsp), %rdi
movl %r15d, %esi
callq 0x4bcba
movl %eax, 0x78(%rsp)
movq %rbx, %rdi
movq %r13, %rsi
movl %r15d, %edx
movq 0x68(%rsp), %rcx
callq 0x4c524
movq %rax, %rbx
movq %r12, %rdi
movq 0x80(%rsp), %rbp
movq %rbp, %rsi
movq %r14, %rdx
callq 0x7c89d
movq %r12, %rdi
movq %rbp, %rsi
movq %rbx, %rdx
callq 0x7c86e
movq 0x38(%rsp), %rsi
movq %rbx, %rdi
movl %r15d, %edx
callq 0x9e2d3
movq 0x20(%r12), %rax
movq %rax, 0x20(%rsp)
movups (%r12), %xmm0
movups 0x10(%r12), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq 0x70(%rsp), %rdi
movl %r15d, %esi
callq 0x4bcba
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 0x4c025
cmpl %eax, %esi
jle 0x4c0c1
movq 0x30(%r14), %rax
movq %rax, 0x30(%rsp)
movups (%r14), %xmm0
movups 0x10(%r14), %xmm1
movups 0x20(%r14), %xmm2
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
callq 0x7c251
movq %r14, %rdi
callq 0x3a180
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 0x7c251
movq %r13, %rdi
callq 0x3a180
movq 0x58(%rsp), %rbp
movq %rbp, %rdi
leaq 0x50(%rsp), %rsi
movq %rbx, %rdx
callq 0x9f94e
movq %rbx, %r14
jmp 0x4c163
movq %r12, %rdi
movq %rbp, %rsi
movq %rbx, %rdx
callq 0x7c89d
movq %r12, %rdi
movq %rbp, %rsi
movq %r13, %rdx
callq 0x7c86e
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 0x7c251
movq %rbx, %rdi
callq 0x3a180
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 0x7c251
movq %r14, %rdi
callq 0x3a180
movq 0x58(%rsp), %rbp
movq %rbp, %rdi
leaq 0x50(%rsp), %rsi
movq %r13, %rdx
callq 0x9f94e
movq %r13, %r14
jmp 0x4c163
movq 0x60(%rsp), %r15
movq %r15, %rdi
movq 0x80(%rsp), %r12
movq %r12, %rsi
movq %rbx, %rdx
callq 0x7c89d
movq %r15, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x7c86e
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 0x7c251
movq %rbx, %rdi
callq 0x3a180
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 0x7c251
movq %r13, %rdi
callq 0x3a180
movq 0x58(%rsp), %rbp
movq %rbp, %rdi
leaq 0x50(%rsp), %rsi
movq %r14, %rdx
callq 0x9f94e
movq (%rbp), %rdi
movq 0x48(%rsp), %rsi
callq 0x31345
movq %rax, (%rbp)
movq 0x38(%rsp), %rsi
movq %rbp, %rdi
callq 0x30648
movq 0x30(%r14), %r13
testq %r13, %r13
movl 0x44(%rsp), %r15d
movq 0x60(%rsp), %r12
leaq 0x48(%rsp), %rbx
jne 0x4be2f
movq (%rbp), %rdi
movl %r15d, %esi
callq 0x1152e
testl %eax, %eax
je 0x4c394
leaq 0x38(%rsp), %rbx
leaq 0x48(%rsp), %r12
leaq 0x50(%rsp), %r14
movq %rbp, %rdi
movq %rbx, %rsi
movq %r12, %rdx
movl $0x3, %ecx
callq 0x31019
movq %r12, %rdi
movl %r15d, %esi
movq 0x68(%rsp), %rdx
callq 0x4c3b3
movq %rax, %r13
cmpq $0x0, 0x18(%rax)
je 0x4c203
movq 0x38(%rsp), %rsi
movq %r13, %rdi
movl %r15d, %edx
movl $0x2, %ecx
callq 0x9f536
movq 0x48(%rsp), %rsi
movq %r13, %rdi
movl $0x1, %edx
callq 0x7c9ed
movq 0x38(%rsp), %rsi
movq %r13, %rdi
xorl %edx, %edx
callq 0x7c9ed
cmpq $0x0, 0x18(%r13)
je 0x4c32c
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 0x7cbcf
ucomisd 0x59ab4(%rip), %xmm0    # 0xa5d18
jae 0x4c32c
movq 0x60(%rsp), %rdi
movq %r13, %rsi
callq 0x7c9c6
movq (%rbp), %rdi
movq 0x48(%rsp), %rsi
callq 0x31345
movq %rax, (%rbp)
movq 0x38(%rsp), %rsi
movq %rbp, %rdi
callq 0x30648
movq %rbp, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x9f94e
movq (%rbp), %rdi
movl 0x44(%rsp), %r15d
movl %r15d, %esi
callq 0x1152e
testl %eax, %eax
jne 0x4c1c1
jmp 0x4c394
movq 0x30(%r13), %r15
movl 0x44(%rsp), %eax
cmpl %eax, (%r13)
jne 0x4c31f
leaq 0x30(%r14), %rax
testq %r14, %r14
cmoveq %r12, %rax
movq %r15, (%rax)
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 0x7c251
movq %r13, %rdi
callq 0x3a180
decl 0x10(%r12)
testq %r15, %r15
jne 0x4c322
jmp 0x4c382
movq %r13, %r14
movq %r15, %r13
testq %r15, %r15
jne 0x4c2c2
jmp 0x4c387
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 0x7c251
movq %r13, %rdi
callq 0x3a180
movq (%rbp), %rdi
movq 0x48(%rsp), %rsi
callq 0x31345
movq %rax, (%rbp)
movq 0x38(%rsp), %rsi
movq %rbp, %rdi
callq 0x30648
jmp 0x4c394
movq %r14, 0x8(%r12)
testq %r14, %r14
je 0x4c394
movq $0x0, 0x30(%r14)
movq 0x50(%rsp), %rsi
movq %rbp, %rdi
callq 0x30648
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq