// File: /workspace/github_c_makefile_star2_O0/olcaytaner[P]Isell/rise.c
// Function: learn_ruleset_rise
Model_riseptr learn_ruleset_rise(Instanceptr instances)
{
 int i, classno, maxcount, ruleexists;
 int ***feature_counts;
 int improvement = YES, bestaccuracy, accuracy;
 Model_riseptr m;
 Decisionruleptr newrule, generalizedrule, rule, rulebefore, nextrule;
 Decisionruleptr* nearestrule;
 Instanceptr tmp;
 m = safemalloc(sizeof(Model_rise), "learn_ruleset_rise", 4);
 m->counts = find_class_counts(instances);
 m->svdm = safemalloc(current_dataset->featurecount * sizeof(matrix), "learn_ruleset_rise", 6);
 nearestrule = safemalloc(data_size(instances) * sizeof(Decisionruleptr), "learn_ruleset_rise", 6);
 feature_counts = find_feature_counts(instances);
 for (i = 0; i < current_dataset->featurecount; i++)
   if (current_dataset->features[i].type == STRING)
     m->svdm[i] = distance_between_discrete_values_of_feature(feature_counts, i);
 free_feature_counts(feature_counts);     
 empty_ruleset(&(m->rules));
 m->rules.defaultclass = find_max_in_list(m->counts, current_dataset->classno);
 classno = all_in_one_class(instances, &maxcount);
 if (!(classno % 10))
   return m;
 tmp = instances;
 while (tmp)
  {
   newrule = create_rule_from_instance(tmp);
   add_rule(&(m->rules), newrule);
   tmp = tmp->next;
  }
 rule = m->rules.start;
 while (rule)
  {
   update_counts(rule, instances, YES);
   rule = rule->next;
  }
 i = 0;
 tmp = instances;
 while (tmp)
  {
   nearestrule[i] = nearest_rule(m, tmp, YES);
   i++;
   tmp = tmp->next;
  }
 bestaccuracy = accuracy_of_ruleset(nearestrule, instances);
 while (improvement)
  {
   improvement = NO;
   rule = m->rules.start;
   rulebefore = NULL;
   while (rule)
    {
     nextrule = rule->next;
     tmp = nearest_example_not_covered(m, rule, instances);
     if (tmp)
      {
       generalizedrule = most_specific_generalization(rule, tmp);
       update_counts(generalizedrule, instances, YES);
       if (rule_exists(m->rules, generalizedrule))
         ruleexists = YES;
       else
         ruleexists = NO;
       remove_rule_after(&(m->rules), rulebefore, rule);
       update_nearest_rule(m, nearestrule, instances, 0, rule);
       add_rule_after(&(m->rules), rulebefore, generalizedrule);
       update_nearest_rule(m, nearestrule, instances, 1, generalizedrule);
       accuracy = accuracy_of_ruleset(nearestrule, instances);
       if (accuracy >= bestaccuracy)
        {
         bestaccuracy = accuracy;
         improvement = YES;
         free_rule(*rule);
         safe_free(rule);
         if (ruleexists)
          {
           remove_rule_after(&(m->rules), rulebefore, generalizedrule);
           update_nearest_rule(m, nearestrule, instances, 0, generalizedrule);
           bestaccuracy = accuracy_of_ruleset(nearestrule, instances);
           free_rule(*generalizedrule);
           safe_free(generalizedrule);
          }
         else
           rulebefore = generalizedrule;
        }
       else
        {
         remove_rule_after(&(m->rules), rulebefore, generalizedrule);
         update_nearest_rule(m, nearestrule, instances, 0, generalizedrule);
         add_rule_after(&(m->rules), rulebefore, rule);
         update_nearest_rule(m, nearestrule, instances, 1, rule);
         rulebefore = rule;
         free_rule(*generalizedrule);
         safe_free(generalizedrule);
        }
      }
     else
       rulebefore = rule;
     rule = nextrule;
    }
  }
 safe_free(nearestrule);
 return m; 
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x10(%rbp)
movl $0x1, -0x2c(%rbp)
movl $0x38, %edi
leaq 0x40e87(%rip), %rsi     # 0xec439
movl $0x4, %edx
callq 0x52d70
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rdi
callq 0x183a0
movq %rax, %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x30(%rax)
leaq 0x5a265(%rip), %rax     # 0x105840
movq (%rax), %rax
movslq 0x1bc(%rax), %rdi
shlq $0x4, %rdi
leaq 0x40e49(%rip), %rsi     # 0xec439
movl $0x6, %edx
callq 0x52d70
movq %rax, %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x10(%rbp), %rdi
callq 0x449f0
movslq %eax, %rdi
shlq $0x3, %rdi
leaq 0x40e1d(%rip), %rsi     # 0xec439
movl $0x6, %edx
callq 0x52d70
movq %rax, -0x70(%rbp)
movq -0x10(%rbp), %rdi
callq 0x187f0
movq %rax, -0x28(%rbp)
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
leaq 0x5a1f8(%rip), %rcx     # 0x105840
movq (%rcx), %rcx
cmpl 0x1bc(%rcx), %eax
jge 0xab6d7
leaq 0x5a1e2(%rip), %rax     # 0x105840
movq (%rax), %rax
addq $0x30f08, %rax          # imm = 0x30F08
movslq -0x14(%rbp), %rcx
imulq $0x340, %rcx, %rcx      # imm = 0x340
addq %rcx, %rax
cmpl $0x1, (%rax)
jne 0xab6c7
movq -0x40(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0x14(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x90(%rbp)
movq -0x28(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0xaaff0
movq %rax, %rcx
movq -0x90(%rbp), %rax
movq %rcx, -0x88(%rbp)
movq %rdx, -0x80(%rbp)
movq -0x88(%rbp), %rcx
movq %rcx, (%rax)
movq -0x80(%rbp), %rcx
movq %rcx, 0x8(%rax)
jmp 0xab6c9
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0xab63e
movq -0x28(%rbp), %rdi
callq 0x18730
movq -0x40(%rbp), %rdi
callq 0xade30
movq -0x40(%rbp), %rax
movq 0x30(%rax), %rdi
leaq 0x5a148(%rip), %rax     # 0x105840
movq (%rax), %rax
movl 0x10(%rax), %esi
callq 0x50070
movl %eax, %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x14(%rax)
movq -0x10(%rbp), %rdi
leaq -0x1c(%rbp), %rsi
callq 0x18420
movl %eax, -0x18(%rbp)
movl -0x18(%rbp), %eax
movl $0xa, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0xab739
movq -0x40(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0xabaa3
movq -0x10(%rbp), %rax
movq %rax, -0x78(%rbp)
cmpq $0x0, -0x78(%rbp)
je 0xab770
movq -0x78(%rbp), %rdi
callq 0xaae50
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0xaea30
movq -0x78(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x78(%rbp)
jmp 0xab741
movq -0x40(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
je 0xab7a2
movq -0x58(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl $0x1, %edx
callq 0xaea90
movq -0x58(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x58(%rbp)
jmp 0xab77b
movl $0x0, -0x14(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x78(%rbp)
cmpq $0x0, -0x78(%rbp)
je 0xab7f0
movq -0x40(%rbp), %rdi
movq -0x78(%rbp), %rsi
movl $0x1, %edx
callq 0xaaca0
movq %rax, %rdx
movq -0x70(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
movq -0x78(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x78(%rbp)
jmp 0xab7b1
movq -0x70(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0xab510
movl %eax, -0x30(%rbp)
cmpl $0x0, -0x2c(%rbp)
je 0xaba92
movl $0x0, -0x2c(%rbp)
movq -0x40(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x58(%rbp)
movq $0x0, -0x60(%rbp)
cmpq $0x0, -0x58(%rbp)
je 0xaba8d
movq -0x58(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x68(%rbp)
movq -0x40(%rbp), %rdi
movq -0x58(%rbp), %rsi
movq -0x10(%rbp), %rdx
callq 0xaa890
movq %rax, -0x78(%rbp)
cmpq $0x0, -0x78(%rbp)
je 0xaba78
movq -0x58(%rbp), %rdi
movq -0x78(%rbp), %rsi
callq 0xaa6a0
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl $0x1, %edx
callq 0xaea90
movq -0x40(%rbp), %rcx
movq -0x50(%rbp), %rdi
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 0xdb870
cmpl $0x0, %eax
je 0xab8b2
movl $0x1, -0x20(%rbp)
jmp 0xab8b9
movl $0x0, -0x20(%rbp)
movq -0x40(%rbp), %rdi
movq -0x60(%rbp), %rsi
movq -0x58(%rbp), %rdx
callq 0xae850
movq -0x40(%rbp), %rdi
movq -0x70(%rbp), %rsi
movq -0x10(%rbp), %rdx
movq -0x58(%rbp), %r8
xorl %ecx, %ecx
callq 0xab250
movq -0x40(%rbp), %rdi
movq -0x60(%rbp), %rsi
movq -0x50(%rbp), %rdx
callq 0xae7d0
movq -0x40(%rbp), %rdi
movq -0x70(%rbp), %rsi
movq -0x10(%rbp), %rdx
movq -0x50(%rbp), %r8
movl $0x1, %ecx
callq 0xab250
movq -0x70(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0xab510
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x30(%rbp), %eax
jl 0xab9e8
movl -0x34(%rbp), %eax
movl %eax, -0x30(%rbp)
movl $0x1, -0x2c(%rbp)
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
cmpl $0x0, -0x20(%rbp)
je 0xab9db
movq -0x40(%rbp), %rdi
movq -0x60(%rbp), %rsi
movq -0x50(%rbp), %rdx
callq 0xae850
movq -0x40(%rbp), %rdi
movq -0x70(%rbp), %rsi
movq -0x10(%rbp), %rdx
movq -0x50(%rbp), %r8
xorl %ecx, %ecx
callq 0xab250
movq -0x70(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0xab510
movl %eax, -0x30(%rbp)
movq -0x50(%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 -0x50(%rbp), %rdi
callq 0x52e80
jmp 0xab9e3
movq -0x50(%rbp), %rax
movq %rax, -0x60(%rbp)
jmp 0xaba76
movq -0x40(%rbp), %rdi
movq -0x60(%rbp), %rsi
movq -0x50(%rbp), %rdx
callq 0xae850
movq -0x40(%rbp), %rdi
movq -0x70(%rbp), %rsi
movq -0x10(%rbp), %rdx
movq -0x50(%rbp), %r8
xorl %ecx, %ecx
callq 0xab250
movq -0x40(%rbp), %rdi
movq -0x60(%rbp), %rsi
movq -0x58(%rbp), %rdx
callq 0xae7d0
movq -0x40(%rbp), %rdi
movq -0x70(%rbp), %rsi
movq -0x10(%rbp), %rdx
movq -0x58(%rbp), %r8
movl $0x1, %ecx
callq 0xab250
movq -0x58(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x50(%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 -0x50(%rbp), %rdi
callq 0x52e80
jmp 0xaba80
movq -0x58(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0x58(%rbp)
jmp 0xab824
jmp 0xab800
movq -0x70(%rbp), %rdi
callq 0x52e80
movq -0x40(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xd0, %rsp
popq %rbp
retq