// File: /workspace/github_c_makefile_star2_O2/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:
leaq 0x37e393(%rip), %rax    # 0x3a9fa4
xorpd %xmm1, %xmm1
cmpl $0x0, (%rax)
jne 0x2be8e
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rsi, %rbx
movq %rdi, %r14
leaq 0xf0(%rsp), %rax
leaq 0xc0(%rsp), %rcx
movq (%rax), %r15
movq (%rcx), %rdx
xorpd %xmm2, %xmm2
movl $0x61e1, %r13d          # imm = 0x61E1
xorl %ebp, %ebp
leaq 0xa1c12(%rip), %r12     # 0xcd870
xorpd %xmm1, %xmm1
movq %rdx, 0x8(%rsp)
movq %rsi, 0x58(%rsp)
movq (%r12), %rax
movslq 0x1bc(%rax), %rcx
cmpq %rcx, %rbp
jge 0x2be7d
movl (%rax,%r13,8), %eax
cmpl $0x2, %eax
je 0x2bcfa
cmpl $0x1, %eax
je 0x2bcdb
testl %eax, %eax
jne 0x2be71
movsd (%r15,%rbp,8), %xmm0
ucomisd %xmm2, %xmm0
jne 0x2bca8
jnp 0x2be71
movq (%rbx), %rax
movl (%rax,%rbp,8), %ebx
movq %r14, %r12
movq (%r14), %rax
movl (%rax,%rbp,8), %r14d
movsd (%rdx,%rbp,8), %xmm3
movaps %xmm3, 0x40(%rsp)
ucomisd %xmm2, %xmm0
movapd %xmm1, 0x10(%rsp)
jb 0x2bdd2
sqrtsd %xmm0, %xmm3
jmp 0x2bde4
movq (%r14), %rax
movl (%rax,%rbp,8), %eax
movq (%rbx), %rcx
cmpl (%rcx,%rbp,8), %eax
je 0x2be71
addsd 0x6982b(%rip), %xmm1    # 0x95520
jmp 0x2be71
movsd (%r15,%rbp,8), %xmm0
ucomisd %xmm2, %xmm0
jne 0x2bd0c
jnp 0x2be71
movq (%rbx), %rax
movsd (%rax,%rbp,8), %xmm3
movaps %xmm3, 0x20(%rsp)
movq (%r14), %rax
movsd (%rax,%rbp,8), %xmm3
movaps %xmm3, 0x40(%rsp)
movsd (%rdx,%rbp,8), %xmm3
movaps %xmm3, 0x30(%rsp)
ucomisd %xmm2, %xmm0
movapd %xmm1, 0x10(%rsp)
jb 0x2bd42
sqrtsd %xmm0, %xmm4
jmp 0x2bd54
callq 0x4300
xorpd %xmm2, %xmm2
movq 0x8(%rsp), %rdx
movapd %xmm0, %xmm4
movsd (%rdx,%rbp,8), %xmm5
movsd (%r15,%rbp,8), %xmm0
ucomisd %xmm2, %xmm0
jb 0x2bd6b
sqrtsd %xmm0, %xmm0
jmp 0x2bd91
movapd %xmm4, 0x70(%rsp)
movapd %xmm5, 0x60(%rsp)
callq 0x4300
movapd 0x60(%rsp), %xmm5
movapd 0x70(%rsp), %xmm4
xorpd %xmm2, %xmm2
movq 0x8(%rsp), %rdx
movapd 0x10(%rsp), %xmm1
unpcklpd %xmm0, %xmm4            # xmm4 = xmm4[0],xmm0[0]
movapd 0x40(%rsp), %xmm3
unpcklpd 0x20(%rsp), %xmm3       # xmm3 = xmm3[0],mem[0]
movapd 0x30(%rsp), %xmm0
unpcklpd %xmm5, %xmm0            # xmm0 = xmm0[0],xmm5[0]
subpd %xmm0, %xmm3
divpd %xmm4, %xmm3
movapd %xmm3, %xmm0
unpckhpd %xmm3, %xmm0            # xmm0 = xmm0[1],xmm3[1]
subsd %xmm0, %xmm3
mulsd %xmm3, %xmm3
addsd %xmm3, %xmm1
jmp 0x2be71
callq 0x4300
xorpd %xmm2, %xmm2
movq 0x8(%rsp), %rdx
movapd %xmm0, %xmm3
movsd (%rdx,%rbp,8), %xmm4
movsd (%r15,%rbp,8), %xmm0
ucomisd %xmm2, %xmm0
jb 0x2bdfb
sqrtsd %xmm0, %xmm0
jmp 0x2be21
movapd %xmm3, 0x30(%rsp)
movapd %xmm4, 0x20(%rsp)
callq 0x4300
movapd 0x20(%rsp), %xmm4
movapd 0x30(%rsp), %xmm3
xorpd %xmm2, %xmm2
movq 0x8(%rsp), %rdx
unpcklpd %xmm0, %xmm3            # xmm3 = xmm3[0],xmm0[0]
movd %ebx, %xmm0
movd %r14d, %xmm1
punpckldq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
cvtdq2pd %xmm1, %xmm0
movapd 0x40(%rsp), %xmm1
unpcklpd %xmm4, %xmm1            # xmm1 = xmm1[0],xmm4[0]
subpd %xmm1, %xmm0
divpd %xmm3, %xmm0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
subsd %xmm1, %xmm0
mulsd %xmm0, %xmm0
movapd 0x10(%rsp), %xmm1
addsd %xmm0, %xmm1
movq 0x58(%rsp), %rbx
movq %r12, %r14
leaq 0xa19ff(%rip), %r12     # 0xcd870
incq %rbp
addq $0x68, %r13
jmp 0x2bc6c
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
movapd %xmm1, %xmm0
retq