// File: /workspace/github_c_makefile_star2_O3/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 $0x88, %rsp
leaq 0x38245a(%rip), %rax    # 0x3b1fa4
xorpd %xmm1, %xmm1
cmpl $0x0, (%rax)
jne 0x2fdbb
leaq 0xa5d12(%rip), %r13     # 0xd5870
movq (%r13), %rax
cmpl $0x0, 0x1bc(%rax)
jle 0x2fdbb
movq %rsi, %rbx
movq %rdi, %r14
leaq 0xf0(%rsp), %rcx
leaq 0xc0(%rsp), %rdx
movq (%rcx), %r12
movq (%rdx), %rdx
xorpd %xmm2, %xmm2
movl $0x61e1, %ebp           # imm = 0x61E1
xorl %r15d, %r15d
movq %rdx, 0x8(%rsp)
movq %rsi, 0x58(%rsp)
movl (%rax,%rbp,8), %eax
cmpl $0x2, %eax
je 0x2fc21
cmpl $0x1, %eax
je 0x2fc00
testl %eax, %eax
jne 0x2fda0
movsd (%r12,%r15,8), %xmm0
ucomisd %xmm2, %xmm0
jne 0x2fbc8
jnp 0x2fda0
movq (%rbx), %rax
movl (%rax,%r15,8), %ebx
movq %r14, %r13
movq (%r14), %rax
movl (%rax,%r15,8), %r14d
movsd (%rdx,%r15,8), %xmm3
movaps %xmm3, 0x40(%rsp)
ucomisd %xmm2, %xmm0
movapd %xmm1, 0x10(%rsp)
jb 0x2fd00
xorps %xmm3, %xmm3
sqrtsd %xmm0, %xmm3
jmp 0x2fd12
movq (%r14), %rax
movl (%rax,%r15,8), %eax
movq (%rbx), %rcx
cmpl (%rcx,%r15,8), %eax
je 0x2fda0
addsd 0x75904(%rip), %xmm1    # 0xa5520
jmp 0x2fda0
movsd (%r12,%r15,8), %xmm0
ucomisd %xmm2, %xmm0
jne 0x2fc33
jnp 0x2fda0
movq (%rbx), %rax
movsd (%rax,%r15,8), %xmm3
movaps %xmm3, 0x20(%rsp)
movq (%r14), %rax
movsd (%rax,%r15,8), %xmm3
movaps %xmm3, 0x40(%rsp)
movsd (%rdx,%r15,8), %xmm3
movaps %xmm3, 0x30(%rsp)
ucomisd %xmm2, %xmm0
movapd %xmm1, 0x10(%rsp)
jb 0x2fc6f
xorps %xmm4, %xmm4
sqrtsd %xmm0, %xmm4
jmp 0x2fc81
callq 0x4300
xorpd %xmm2, %xmm2
movq 0x8(%rsp), %rdx
movapd %xmm0, %xmm4
movsd (%rdx,%r15,8), %xmm5
movsd (%r12,%r15,8), %xmm0
ucomisd %xmm2, %xmm0
jb 0x2fc99
sqrtsd %xmm0, %xmm0
jmp 0x2fcbf
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 0x2fda0
callq 0x4300
xorpd %xmm2, %xmm2
movq 0x8(%rsp), %rdx
movapd %xmm0, %xmm3
movsd (%rdx,%r15,8), %xmm4
movsd (%r12,%r15,8), %xmm0
ucomisd %xmm2, %xmm0
jb 0x2fd2a
sqrtsd %xmm0, %xmm0
jmp 0x2fd50
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 %r13, %r14
leaq 0xa5ad0(%rip), %r13     # 0xd5870
incq %r15
movq (%r13), %rax
movslq 0x1bc(%rax), %rcx
addq $0x68, %rbp
cmpq %rcx, %r15
jl 0x2fba1
movapd %xmm1, %xmm0
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq