// File: /workspace/github_c_makefile_star2_O3/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 0x355f1(%rip), %r15     # 0xafd29
movl $0x38, %edi
movq %r15, %rsi
movl $0x4, %edx
callq 0x3a0e1
movq %rax, %r14
movq %rbx, %rdi
callq 0x115a6
movq %rax, 0x30(%r14)
leaq 0x5b110(%rip), %r12     # 0xd5870
movq (%r12), %rax
movslq 0x1bc(%rax), %rdi
shlq $0x4, %rdi
movq %r15, %rsi
movl $0x6, %edx
callq 0x3a0e1
movq %rax, 0x28(%r14)
movq %rbx, %rdi
callq 0x30309
movslq %eax, %rdi
shlq $0x3, %rdi
movq %r15, %rsi
movl $0x6, %edx
callq 0x3a0e1
movq %rax, 0x40(%rsp)
movq %rbx, %rdi
callq 0x1185c
movq %rax, %r15
movq (%r12), %rax
cmpl $0x0, 0x1bc(%rax)
movq %rbx, 0x48(%rsp)
jle 0x7a813
movl $0x8, %r13d
movl $0x30f08, %ebp          # imm = 0x30F08
xorl %r12d, %r12d
cmpl $0x1, (%rax,%rbp)
jne 0x7a7f9
movq 0x28(%r14), %rbx
movq %r15, %rdi
movl %r12d, %esi
callq 0x7a367
movq %rax, -0x8(%rbx,%r13)
movq %rdx, (%rbx,%r13)
movq 0x48(%rsp), %rbx
leaq 0x5b07a(%rip), %rax     # 0xd5870
movq (%rax), %rax
incq %r12
movslq 0x1bc(%rax), %rcx
addq $0x10, %r13
addq $0x340, %rbp            # imm = 0x340
cmpq %rcx, %r12
jl 0x7a7cc
movq %r15, %rdi
callq 0x117d8
movq %r14, %rdi
callq 0x7c32b
movq 0x30(%r14), %rdi
leaq 0x5b042(%rip), %rax     # 0xd5870
movq (%rax), %rax
movl 0x10(%rax), %esi
callq 0x38002
movl %eax, 0x14(%r14)
leaq 0x74(%rsp), %rsi
movq %rbx, %rdi
callq 0x115f8
imull $0xcccccccd, %eax, %eax # imm = 0xCCCCCCCD
addl $0x19999998, %eax       # imm = 0x19999998
rorl %eax
cmpl $0x19999999, %eax       # imm = 0x19999999
jb 0x7ab7b
testq %rbx, %rbx
je 0x7a886
movq %rbx, %r15
movq %r15, %rdi
callq 0x7a282
movq %r14, %rdi
movq %rax, %rsi
callq 0x7c9c6
movq 0x10(%r15), %r15
testq %r15, %r15
jne 0x7a86a
movq (%r14), %r15
testq %r15, %r15
je 0x7a8a4
movq %r15, %rdi
movq %rbx, %rsi
movl $0x1, %edx
callq 0x7c9ed
movq 0x30(%r15), %r15
jmp 0x7a889
testq %rbx, %rbx
je 0x7a8d3
movq 0x40(%rsp), %rbx
movq 0x48(%rsp), %r15
movq %r14, %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0x7a13e
movq %rax, (%rbx)
movq 0x10(%r15), %r15
addq $0x8, %rbx
testq %r15, %r15
jne 0x7a8b3
movq 0x40(%rsp), %rdi
movq 0x48(%rsp), %rbx
movq %rbx, %rsi
callq 0x7a6d4
movl %eax, 0x54(%rsp)
movq (%r14), %r15
testq %r15, %r15
je 0x7ab71
movq $0x0, 0x58(%rsp)
xorl %ebp, %ebp
movq %r15, %r13
movq 0x30(%r15), %r15
movq %r14, %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x79f2a
testq %rax, %rax
je 0x7aa5e
movq %r15, 0x68(%rsp)
movq %r13, %rdi
movq %rax, %rsi
callq 0x79e54
movq %rax, %r12
movq %rax, %rdi
movq %rbx, %rsi
movl $0x1, %edx
callq 0x7c9ed
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 0x9faf9
movl %eax, 0x64(%rsp)
movq %r14, %rdi
movq %rbp, %rsi
movq %r13, %rdx
callq 0x7c89d
testq %rbx, %rbx
je 0x7a9aa
movq 0x40(%rsp), %rbx
movq 0x48(%rsp), %r15
cmpq %r13, (%rbx)
jne 0x7a99d
movq %r14, %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0x7a13e
movq %rax, (%rbx)
movq 0x10(%r15), %r15
addq $0x8, %rbx
testq %r15, %r15
jne 0x7a985
movq %r14, %rdi
movq %rbp, %rsi
movq %r12, %rdx
callq 0x7c86e
movq %r14, %rdi
movq 0x40(%rsp), %r15
movq %r15, %rsi
movq 0x48(%rsp), %rbx
movq %rbx, %rdx
movl $0x1, %ecx
movq %r12, %r8
callq 0x7a503
movq %r15, %rdi
movq %rbx, %rsi
callq 0x7a6d4
cmpl 0x54(%rsp), %eax
jge 0x7aa66
movq %r14, %rdi
movq %rbp, %rsi
movq %r12, %rdx
callq 0x7c89d
testq %rbx, %rbx
je 0x7aa2b
movq 0x40(%rsp), %rbx
movq 0x48(%rsp), %r15
cmpq %r12, (%rbx)
jne 0x7aa1e
movq %r14, %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0x7a13e
movq %rax, (%rbx)
movq 0x10(%r15), %r15
addq $0x8, %rbx
testq %r15, %r15
jne 0x7aa06
movq %r14, %rdi
movq %rbp, %rsi
movq %r13, %rdx
callq 0x7c86e
movq %r14, %rdi
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rbx
movq %rbx, %rdx
movl $0x1, %ecx
movq %r13, %r8
callq 0x7a503
movq %r13, %rbp
jmp 0x7ab09
movq %r13, %r12
jmp 0x7ab47
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 0x7c251
movq %r13, %rdi
callq 0x3a180
cmpl $0x0, 0x64(%rsp)
je 0x7ab55
movq %r14, %rdi
movq %rbp, %rsi
movq %r12, %rdx
callq 0x7c89d
testq %rbx, %rbx
je 0x7aae9
movq 0x40(%rsp), %rbx
movq 0x48(%rsp), %r15
cmpq %r12, (%rbx)
jne 0x7aadc
movq %r14, %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0x7a13e
movq %rax, (%rbx)
movq 0x10(%r15), %r15
addq $0x8, %rbx
testq %r15, %r15
jne 0x7aac4
movq 0x40(%rsp), %rdi
movq 0x48(%rsp), %rbx
movq %rbx, %rsi
callq 0x7a6d4
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 0x7c251
movq %r12, %rdi
callq 0x3a180
movq %rbp, %r12
movq 0x68(%rsp), %r15
movq %r12, %rbp
testq %r15, %r15
jne 0x7a900
jmp 0x7ab66
movl $0x1, %eax
movq %rax, 0x58(%rsp)
movl %r15d, 0x54(%rsp)
jmp 0x7ab42
cmpl $0x0, 0x58(%rsp)
jne 0x7a8e9
movq 0x40(%rsp), %rdi
callq 0x3a180
movq %r14, %rax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)