// File: /workspace/github_c_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rdi, %rbx
leaq 0x33e5f(%rip), %r15     # 0xacc51
movl $0x38, %edi
movq %r15, %rsi
movl $0x4, %edx
callq 0x390f5
movq %rax, %r14
movq %rbx, %rdi
callq 0x115e1
movq %rax, 0x30(%r14)
leaq 0x59a56(%rip), %r12     # 0xd2870
movq (%r12), %rax
movslq 0x1bc(%rax), %rdi
shlq $0x4, %rdi
movq %r15, %rsi
movl $0x6, %edx
callq 0x390f5
movq %rax, 0x28(%r14)
movq %rbx, %rdi
callq 0x2fa14
movslq %eax, %rdi
shlq $0x3, %rdi
movq %r15, %rsi
movl $0x6, %edx
callq 0x390f5
movq %rax, 0x40(%rsp)
movq %rbx, %rdi
callq 0x1189d
movq %rax, %r15
movq (%r12), %rax
cmpl $0x0, 0x1bc(%rax)
movq %rbx, 0x48(%rsp)
jle 0x78ecd
movl $0x8, %r13d
movl $0x30f08, %ebp          # imm = 0x30F08
xorl %r12d, %r12d
cmpl $0x1, (%rax,%rbp)
jne 0x78ea9
movq 0x28(%r14), %rbx
movq %r15, %rdi
movl %r12d, %esi
callq 0x78a31
movq %rax, -0x8(%rbx,%r13)
movq %rdx, (%rbx,%r13)
movq 0x48(%rsp), %rbx
incq %r12
leaq 0x599bd(%rip), %rax     # 0xd2870
movq (%rax), %rax
movslq 0x1bc(%rax), %rcx
addq $0x10, %r13
addq $0x340, %rbp            # imm = 0x340
cmpq %rcx, %r12
jl 0x78e86
movq %r15, %rdi
callq 0x11816
movq %r14, %rdi
callq 0x7aa63
movq 0x30(%r14), %rdi
leaq 0x59988(%rip), %rax     # 0xd2870
movq (%rax), %rax
movl 0x10(%rax), %esi
callq 0x37504
movl %eax, 0x14(%r14)
leaq 0x74(%rsp), %rsi
movq %rbx, %rdi
callq 0x11633
imull $0xcccccccd, %eax, %eax # imm = 0xCCCCCCCD
addl $0x19999998, %eax       # imm = 0x19999998
rorl %eax
cmpl $0x19999999, %eax       # imm = 0x19999999
jb 0x7923e
testq %rbx, %rbx
je 0x78f40
movq %rbx, %r15
movq %r15, %rdi
callq 0x78942
movq %r14, %rdi
movq %rax, %rsi
callq 0x7b0fb
movq 0x10(%r15), %r15
testq %r15, %r15
jne 0x78f24
movq (%r14), %r15
testq %r15, %r15
je 0x78f5e
movq %r15, %rdi
movq %rbx, %rsi
movl $0x1, %edx
callq 0x7b122
movq 0x30(%r15), %r15
jmp 0x78f43
testq %rbx, %rbx
je 0x78f8d
movq 0x40(%rsp), %rbx
movq 0x48(%rsp), %r15
movq %r14, %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0x787fe
movq %rax, (%rbx)
movq 0x10(%r15), %r15
addq $0x8, %rbx
testq %r15, %r15
jne 0x78f6d
movq 0x40(%rsp), %rdi
movq 0x48(%rsp), %rbx
movq %rbx, %rsi
callq 0x78d8e
movl %eax, 0x54(%rsp)
movq (%r14), %r15
testq %r15, %r15
je 0x7922a
movq $0x0, 0x58(%rsp)
xorl %ebp, %ebp
movq %r15, %r13
movq 0x30(%r15), %r15
movq %r14, %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x785ea
testq %rax, %rax
je 0x79118
movq %r15, 0x68(%rsp)
movq %r13, %rdi
movq %rax, %rsi
callq 0x78518
movq %rax, %r12
movq %rax, %rdi
movq %rbx, %rsi
movl $0x1, %edx
callq 0x7b122
movq 0x20(%r14), %rax
movq %rax, 0x20(%rsp)
movups (%r14), %xmm0
movups 0x10(%r14), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq %r12, %rdi
callq 0x9cafc
movl %eax, 0x64(%rsp)
movq %r14, %rdi
movq %rbp, %rsi
movq %r13, %rdx
callq 0x7afd2
testq %rbx, %rbx
je 0x79064
movq 0x40(%rsp), %rbx
movq 0x48(%rsp), %r15
cmpq %r13, (%rbx)
jne 0x79057
movq %r14, %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0x787fe
movq %rax, (%rbx)
movq 0x10(%r15), %r15
addq $0x8, %rbx
testq %r15, %r15
jne 0x7903f
movq %r14, %rdi
movq %rbp, %rsi
movq %r12, %rdx
callq 0x7afad
movq %r14, %rdi
movq 0x40(%rsp), %r15
movq %r15, %rsi
movq 0x48(%rsp), %rbx
movq %rbx, %rdx
movl $0x1, %ecx
movq %r12, %r8
callq 0x78bb7
movq %r15, %rdi
movq %rbx, %rsi
callq 0x78d8e
cmpl 0x54(%rsp), %eax
jge 0x79120
movq %r14, %rdi
movq %rbp, %rsi
movq %r12, %rdx
callq 0x7afd2
testq %rbx, %rbx
je 0x790e5
movq 0x40(%rsp), %rbx
movq 0x48(%rsp), %r15
cmpq %r12, (%rbx)
jne 0x790d8
movq %r14, %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0x787fe
movq %rax, (%rbx)
movq 0x10(%r15), %r15
addq $0x8, %rbx
testq %r15, %r15
jne 0x790c0
movq %r14, %rdi
movq %rbp, %rsi
movq %r13, %rdx
callq 0x7afad
movq %r14, %rdi
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rbx
movq %rbx, %rdx
movl $0x1, %ecx
movq %r13, %r8
callq 0x78bb7
movq %r13, %rbp
jmp 0x791c3
movq %r13, %r12
jmp 0x79201
movl %eax, %r15d
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
cmpl $0x0, 0x64(%rsp)
je 0x7920f
movq %r14, %rdi
movq %rbp, %rsi
movq %r12, %rdx
callq 0x7afd2
testq %rbx, %rbx
je 0x791a3
movq 0x40(%rsp), %rbx
movq 0x48(%rsp), %r15
cmpq %r12, (%rbx)
jne 0x79196
movq %r14, %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0x787fe
movq %rax, (%rbx)
movq 0x10(%r15), %r15
addq $0x8, %rbx
testq %r15, %r15
jne 0x7917e
movq 0x40(%rsp), %rdi
movq 0x48(%rsp), %rbx
movq %rbx, %rsi
callq 0x78d8e
movl %eax, 0x54(%rsp)
movl $0x1, %eax
movq %rax, 0x58(%rsp)
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 0x7a989
movq %r12, %rdi
callq 0x39194
movq %rbp, %r12
movq 0x68(%rsp), %r15
movq %r12, %rbp
testq %r15, %r15
jne 0x78fba
jmp 0x79220
movl $0x1, %eax
movq %rax, 0x58(%rsp)
movl %r15d, 0x54(%rsp)
jmp 0x791fc
cmpl $0x0, 0x58(%rsp)
sete %al
jmp 0x7922c
movb $0x1, %al
testb %al, %al
je 0x78fa3
movq 0x40(%rsp), %rdi
callq 0x39194
movq %r14, %rax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq