// File: /workspace/github_c_makefile_star2_O3/olcaytaner[P]Isell/rise.c
// Function: distance_to_rule
double distance_to_rule(Model_riseptr m, Instanceptr inst, Decisionruleptr rule)
{
 Decisionconditionptr condition;
 int fno;
 double distance = 0.0;
 condition = rule->start;
 while (condition)
  {
   if (!condition_cover_instance(inst, condition))
    {
     fno = condition->featureindex;
     switch (current_dataset->features[fno].type)
      {
       case  STRING:distance += m->svdm[fno].values[inst->values[fno].stringindex][(int)condition->value];
                    break;
       case INTEGER:if (inst->values[fno].intvalue > condition->upperlimit)
                      distance += pow((inst->values[fno].intvalue - condition->upperlimit) / (current_dataset->features[fno].max.intvalue - current_dataset->features[fno].min.intvalue), 2);
                    else
                      distance += pow((condition->lowerlimit - inst->values[fno].intvalue) / (current_dataset->features[fno].max.intvalue - current_dataset->features[fno].min.intvalue), 2);
                    break;
       case    REAL:if (inst->values[fno].floatvalue > condition->upperlimit)
                      distance += pow((inst->values[fno].floatvalue - condition->upperlimit) / (current_dataset->features[fno].max.floatvalue - current_dataset->features[fno].min.floatvalue), 2);
                    else
                      distance += pow((condition->lowerlimit - inst->values[fno].floatvalue) / (current_dataset->features[fno].max.floatvalue - current_dataset->features[fno].min.floatvalue), 2);
                    break;
      }
    }
   condition = condition->next;
  }
 return distance;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq 0x18(%rdx), %r15
testq %r15, %r15
je 0x7a124
movq %rsi, %rbx
movq %rdi, %r14
xorpd %xmm0, %xmm0
movsd %xmm0, (%rsp)
leaq 0x5b86b(%rip), %r12     # 0xd5870
movq %rbx, %rdi
movq %r15, %rsi
callq 0x7af32
testl %eax, %eax
jne 0x7a115
movslq (%r15), %rcx
movq (%r12), %rax
imulq $0x340, %rcx, %rdx      # imm = 0x340
addq %rdx, %rax
addq $0x30f08, %rax          # imm = 0x30F08
movl (%rax), %edx
testl %edx, %edx
je 0x7a096
cmpl $0x2, %edx
je 0x7a076
cmpl $0x1, %edx
jne 0x7a115
movq 0x28(%r14), %rax
movq %rcx, %rdx
shlq $0x4, %rdx
movq 0x8(%rax,%rdx), %rax
movq (%rbx), %rdx
movslq (%rdx,%rcx,8), %rcx
cvttsd2si 0x8(%r15), %edx
movq (%rax,%rcx,8), %rax
movslq %edx, %rcx
movsd (%rsp), %xmm0
addsd (%rax,%rcx,8), %xmm0
jmp 0x7a110
movq (%rbx), %rdx
movsd (%rdx,%rcx,8), %xmm0
movsd 0x10(%r15), %xmm1
ucomisd %xmm1, %xmm0
jbe 0x7a0d6
movsd 0x10(%rax), %xmm2
subsd 0x8(%rax), %xmm2
jmp 0x7a0ba
movq (%rbx), %rdx
xorps %xmm0, %xmm0
cvtsi2sdl (%rdx,%rcx,8), %xmm0
movsd 0x10(%r15), %xmm1
ucomisd %xmm1, %xmm0
jbe 0x7a0e8
movl 0x10(%rax), %ecx
subl 0x8(%rax), %ecx
xorps %xmm2, %xmm2
cvtsi2sd %ecx, %xmm2
subsd %xmm1, %xmm0
divsd %xmm2, %xmm0
mulsd %xmm0, %xmm0
movsd (%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, (%rsp)
jmp 0x7a115
movsd 0x18(%r15), %xmm1
movsd 0x10(%rax), %xmm2
subsd 0x8(%rax), %xmm2
jmp 0x7a0fb
movsd 0x18(%r15), %xmm1
movl 0x10(%rax), %ecx
subl 0x8(%rax), %ecx
xorps %xmm2, %xmm2
cvtsi2sd %ecx, %xmm2
subsd %xmm0, %xmm1
divsd %xmm2, %xmm1
mulsd %xmm1, %xmm1
movsd (%rsp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rsp)
movq 0x48(%r15), %r15
testq %r15, %r15
jne 0x7a005
jmp 0x7a12d
xorpd %xmm0, %xmm0
movsd %xmm0, (%rsp)
movsd (%rsp), %xmm0
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq