// File: /workspace/github_c_makefile_star2_O1/olcaytaner[P]Isell/instance.c
// Function: distance_between_instances_before_normalize
double distance_between_instances_before_normalize(Instanceptr inst1,Instanceptr inst2, Instance mean, Instance variance)
{
	/*!Last Changed 17.05.2004*/
 int i;
 double res = 0, value1, value2;
 if (!mustrealize)
  {
   for (i=0;i<current_dataset->featurecount;i++)
     switch (current_dataset->features[i].type)
      {
       case INTEGER:value1 = inst1->values[i].intvalue;
								            value2 = inst2->values[i].intvalue;
                    if (variance.values[i].floatvalue != 0)
																				 {
								              value1 = (value1 - mean.values[i].floatvalue) / sqrt(variance.values[i].floatvalue);
								              value2 = (value2 - mean.values[i].floatvalue) / sqrt(variance.values[i].floatvalue);
								              res += (value1 - value2) * (value1 - value2);
																				 }
                    break;
       case    REAL:value1 = inst1->values[i].floatvalue;
								            value2 = inst2->values[i].floatvalue;
                    if (variance.values[i].floatvalue != 0)
																				 {
								              value1 = (value1 - mean.values[i].floatvalue) / sqrt(variance.values[i].floatvalue);
								              value2 = (value2 - mean.values[i].floatvalue) / sqrt(variance.values[i].floatvalue);
								              res += (value1 - value2) * (value1 - value2);
																				 }
                    break;
       case  STRING:if (inst1->values[i].stringindex != inst2->values[i].stringindex)
                      res+=1;
                    break;
      }
  }
 return res;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
leaq 0x37fcaa(%rip), %rax    # 0x3aefa4
xorpd %xmm1, %xmm1
cmpl $0x0, (%rax)
jne 0x2f47f
movq %rsi, %rbx
leaq 0xa355f(%rip), %rsi     # 0xd2870
movq (%rsi), %rax
cmpl $0x0, 0x1bc(%rax)
jle 0x2f47f
movq %rdi, %r14
leaq 0x90(%rsp), %rcx
leaq 0x60(%rsp), %rdx
movq (%rcx), %r12
movq (%rdx), %r13
xorpd %xmm2, %xmm2
movl $0x61e1, %ebp           # imm = 0x61E1
xorl %r15d, %r15d
movl (%rax,%rbp,8), %eax
cmpl $0x2, %eax
je 0x2f3a5
cmpl $0x1, %eax
je 0x2f384
testl %eax, %eax
jne 0x2f465
movsd (%r12,%r15,8), %xmm0
ucomisd %xmm2, %xmm0
jne 0x2f36a
jnp 0x2f465
movq (%rbx), %rax
xorps %xmm4, %xmm4
cvtsi2sdl (%rax,%r15,8), %xmm4
movq (%r14), %rax
xorps %xmm3, %xmm3
cvtsi2sdl (%rax,%r15,8), %xmm3
jmp 0x2f3c9
movq (%r14), %rax
movl (%rax,%r15,8), %eax
movq (%rbx), %rcx
cmpl (%rcx,%r15,8), %eax
je 0x2f465
addsd 0x73180(%rip), %xmm1    # 0xa2520
jmp 0x2f465
movsd (%r12,%r15,8), %xmm0
ucomisd %xmm2, %xmm0
jne 0x2f3b7
jnp 0x2f465
movq (%rbx), %rax
movsd (%rax,%r15,8), %xmm4
movq (%r14), %rax
movsd (%rax,%r15,8), %xmm3
subsd (%r13,%r15,8), %xmm3
movsd %xmm3, 0x20(%rsp)
ucomisd %xmm2, %xmm0
movsd %xmm1, 0x10(%rsp)
jb 0x2f3eb
xorps %xmm3, %xmm3
sqrtsd %xmm0, %xmm3
jmp 0x2f404
movsd %xmm4, 0x8(%rsp)
callq 0x4300
movsd 0x8(%rsp), %xmm4
xorpd %xmm2, %xmm2
movapd %xmm0, %xmm3
subsd (%r13,%r15,8), %xmm4
movsd (%r12,%r15,8), %xmm0
ucomisd %xmm2, %xmm0
jb 0x2f41d
sqrtsd %xmm0, %xmm0
jmp 0x2f43e
movsd %xmm4, 0x8(%rsp)
movsd %xmm3, 0x18(%rsp)
callq 0x4300
movsd 0x18(%rsp), %xmm3
movsd 0x8(%rsp), %xmm4
xorpd %xmm2, %xmm2
leaq 0xa342b(%rip), %rsi     # 0xd2870
movsd 0x10(%rsp), %xmm1
divsd %xmm0, %xmm4
movsd 0x20(%rsp), %xmm0
divsd %xmm3, %xmm0
subsd %xmm4, %xmm0
mulsd %xmm0, %xmm0
addsd %xmm0, %xmm1
incq %r15
movq (%rsi), %rax
movslq 0x1bc(%rax), %rcx
addq $0x68, %rbp
cmpq %rcx, %r15
jl 0x2f343
movapd %xmm1, %xmm0
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq