// File: /workspace/github_c_makefile_star2_O1/olcaytaner[P]Isell/rise.c
// Function: update_nearest_rule
void update_nearest_rule(Model_riseptr m, Decisionruleptr* nearestrule, Instanceptr instances, int operation, Decisionruleptr rule)
{
 int i = 0;
 Instanceptr tmp;
 tmp = instances;
 while (tmp)
  {
   if (operation == 0 && nearestrule[i] == rule)
     nearestrule[i] = nearest_rule(m, tmp, YES);
   else
     if (operation == 1 && rule->falsepositives + rule->covered > 1)
      {
       if (!nearestrule[i])
         nearestrule[i] = rule;
       else
        {
         if (distance_to_rule(m, tmp, rule) < distance_to_rule(m, tmp, nearestrule[i]))
           nearestrule[i] = rule;
         else 
           if (distance_to_rule(m, tmp, rule) == distance_to_rule(m, tmp, nearestrule[i]))
            {
             if (laplace_estimate_of_rule_kclass(*rule) < laplace_estimate_of_rule_kclass(*(nearestrule[i])))
               nearestrule[i] = rule;
             else
               if (laplace_estimate_of_rule_kclass(*rule) == laplace_estimate_of_rule_kclass(*(nearestrule[i])))
                {
                 if (m->counts[rule->classno] > m->counts[nearestrule[i]->classno])
                   nearestrule[i] = rule;
                }
            }
        }
      }
   i++;
   tmp = tmp->next;
  }
}

// Assembly:
testq %rdx, %rdx
je 0x78d8d
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x40, %rsp
movq %r8, %rbx
movl %ecx, %ebp
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %r12
cmpl $0x1, %ebp
je 0x78bf9
testl %ebp, %ebp
jne 0x78d70
cmpq %rbx, (%r15)
je 0x78d5d
cmpl $0x1, %ebp
jne 0x78d70
movl 0x4(%rbx), %eax
addl 0x8(%rbx), %eax
cmpl $0x2, %eax
jl 0x78d70
cmpq $0x0, (%r15)
je 0x78d58
movq %r12, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x7869a
movsd %xmm0, 0x38(%rsp)
movq (%r15), %rdx
movq %r12, %rdi
movq %r14, %rsi
callq 0x7869a
ucomisd 0x38(%rsp), %xmm0
ja 0x78d58
movq %r12, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x7869a
movsd %xmm0, 0x38(%rsp)
movq (%r15), %rdx
movq %r12, %rdi
movq %r14, %rsi
callq 0x7869a
movsd 0x38(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jne 0x78d70
jp 0x78d70
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 0x7b366
movsd %xmm0, 0x38(%rsp)
movq (%r15), %rax
movq 0x30(%rax), %rcx
movq %rcx, 0x30(%rsp)
movupd (%rax), %xmm0
movupd 0x10(%rax), %xmm1
movups 0x20(%rax), %xmm2
movups %xmm2, 0x20(%rsp)
movupd %xmm1, 0x10(%rsp)
movupd %xmm0, (%rsp)
callq 0x7b366
ucomisd 0x38(%rsp), %xmm0
ja 0x78d58
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 0x7b366
movsd %xmm0, 0x38(%rsp)
movq (%r15), %rax
movq 0x30(%rax), %rcx
movq %rcx, 0x30(%rsp)
movupd (%rax), %xmm0
movups 0x10(%rax), %xmm1
movups 0x20(%rax), %xmm2
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movupd %xmm0, (%rsp)
callq 0x7b366
movsd 0x38(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jne 0x78d70
jp 0x78d70
movq 0x30(%r12), %rax
movslq (%rbx), %rcx
movl (%rax,%rcx,4), %ecx
movq (%r15), %rdx
movslq (%rdx), %rdx
cmpl (%rax,%rdx,4), %ecx
jle 0x78d70
movq %rbx, (%r15)
jmp 0x78d70
movq %r12, %rdi
movq %r14, %rsi
movl $0x1, %edx
callq 0x787fe
movq %rax, (%r15)
movq 0x10(%r14), %r14
addq $0x8, %r15
testq %r14, %r14
jne 0x78bda
addq $0x40, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq