// File: /workspace/github_c_makefile_star2_O2/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 %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
addq $0x18, %rbx
xorpd %xmm0, %xmm0
movsd %xmm0, (%rsp)
leaq 0x5dd08(%rip), %r12     # 0xcd870
movq (%rbx), %rbx
testq %rbx, %rbx
je 0x6fc7f
movq %r14, %rdi
movq %rbx, %rsi
callq 0x7099c
testl %eax, %eax
jne 0x6fc76
movslq (%rbx), %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 0x6fc03
cmpl $0x2, %edx
je 0x6fbe4
cmpl $0x1, %edx
jne 0x6fc76
movq 0x28(%r15), %rax
movq %rcx, %rdx
shlq $0x4, %rdx
movq 0x8(%rax,%rdx), %rax
movq (%r14), %rdx
movslq (%rdx,%rcx,8), %rcx
cvttsd2si 0x8(%rbx), %edx
movq (%rax,%rcx,8), %rax
movslq %edx, %rcx
movsd (%rsp), %xmm0
addsd (%rax,%rcx,8), %xmm0
jmp 0x6fc71
movq (%r14), %rdx
movsd (%rdx,%rcx,8), %xmm0
movsd 0x10(%rbx), %xmm1
ucomisd %xmm1, %xmm0
jbe 0x6fc3c
movsd 0x10(%rax), %xmm2
subsd 0x8(%rax), %xmm2
jmp 0x6fc20
movq (%r14), %rdx
cvtsi2sdl (%rdx,%rcx,8), %xmm0
movsd 0x10(%rbx), %xmm1
ucomisd %xmm1, %xmm0
jbe 0x6fc4d
movl 0x10(%rax), %ecx
subl 0x8(%rax), %ecx
cvtsi2sd %ecx, %xmm2
subsd %xmm1, %xmm0
divsd %xmm2, %xmm0
mulsd %xmm0, %xmm0
movsd (%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, (%rsp)
jmp 0x6fc76
movsd 0x18(%rbx), %xmm1
movsd 0x10(%rax), %xmm2
subsd 0x8(%rax), %xmm2
jmp 0x6fc5c
movsd 0x18(%rbx), %xmm1
movl 0x10(%rax), %ecx
subl 0x8(%rax), %ecx
cvtsi2sd %ecx, %xmm2
subsd %xmm0, %xmm1
divsd %xmm2, %xmm1
mulsd %xmm1, %xmm1
movsd (%rsp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rsp)
addq $0x48, %rbx
jmp 0x6fb68
movsd (%rsp), %xmm0
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq