// File: /workspace/github_c_makefile_star2_O2/olcaytaner[P]Isell/data.c
// Function: find_variance
Instance find_variance(Instanceptr myptr)
{
 /*!Last Changed 02.02.2004 added safemalloc and safecalloc*/
 /*!Last Changed 18.03.2002*/
 int i, count = data_size(myptr);
 Instanceptr temp = myptr;
 Instance mean;
 Instance result;
 mean=find_mean(myptr);
 if (mustrealize)
  {
   result.values = (union value *)safemalloc(current_dataset->multifeaturecount * sizeof(union value), "find_variance", 8);
   for (i = 0; i < current_dataset->multifeaturecount; i++)
     if (i != current_dataset->classdefno)
       result.values[i].floatvalue = 0;
   while (temp)
    {
     for (i = 0; i < current_dataset->multifeaturecount; i++)
       if (i != current_dataset->classdefno)
         result.values[i].floatvalue += (temp->values[i].floatvalue - mean.values[i].floatvalue) * (temp->values[i].floatvalue-mean.values[i].floatvalue);
     temp = temp->next;
    }
   for (i =0 ; i < current_dataset->multifeaturecount; i++)
     if (i != current_dataset->classdefno)
       result.values[i].floatvalue /= (count - 1);
  }
 else
  {
   result.values = (union value *)safemalloc(current_dataset->featurecount * sizeof(union value), "find_variance", 25);
   for (i = 0; i < current_dataset->featurecount; i++)
     switch (current_dataset->features[i].type)
      {
       case INTEGER:result.values[i].floatvalue = 0;
                    break;
       case    REAL:result.values[i].floatvalue = 0;
                    break;
      }
   while (temp)
    {
     for (i = 0; i < current_dataset->featurecount; i++)
       switch (current_dataset->features[i].type)
        {
         case INTEGER:result.values[i].floatvalue += (temp->values[i].intvalue-mean.values[i].floatvalue) * (temp->values[i].intvalue - mean.values[i].floatvalue);
                      break;
         case    REAL:result.values[i].floatvalue += (temp->values[i].floatvalue-mean.values[i].floatvalue) * (temp->values[i].floatvalue - mean.values[i].floatvalue);
                      break;
        }
     temp=temp->next;
    }
   for (i = 0; i < current_dataset->featurecount; i++)
     switch (current_dataset->features[i].type)
      {
       case INTEGER:result.values[i].floatvalue /= (count - 1);
                    break;
       case    REAL:result.values[i].floatvalue /= (count - 1);
                    break;
      }
  }
 safe_free(mean.values);
 return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x30, %rsp
movq %rsi, %r15
movq %rdi, %rbx
movq %rsi, %rdi
callq 0x2c3cc
movl %eax, %ebp
movq %rsp, %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x116b6
movq (%r14), %r14
leaq 0x3985f2(%rip), %rax    # 0x3a9fa4
cmpl $0x0, (%rax)
leaq 0xbbeb4(%rip), %r12     # 0xcd870
movq (%r12), %rax
je 0x11a8f
movslq 0x1c0(%rax), %rdi
shlq $0x3, %rdi
leaq 0x84a47(%rip), %rsi     # 0x9641f
pushq $0x8
popq %rdx
callq 0x34f59
movq %rax, (%rbx)
movq (%r12), %rcx
xorl %edx, %edx
movslq 0x1c0(%rcx), %rsi
cmpq %rsi, %rdx
jge 0x11a50
movl 0x1407128(%rcx), %esi
cmpq %rsi, %rdx
je 0x11a09
andq $0x0, (%rax,%rdx,8)
movq (%r12), %rcx
incq %rdx
jmp 0x119e9
xorl %edx, %edx
movslq 0x1c0(%rcx), %rsi
cmpq %rsi, %rdx
jge 0x11a4c
movl 0x1407128(%rcx), %esi
cmpq %rsi, %rdx
je 0x11a47
movq (%r15), %rcx
movsd (%rcx,%rdx,8), %xmm0
subsd (%r14,%rdx,8), %xmm0
mulsd %xmm0, %xmm0
addsd (%rax,%rdx,8), %xmm0
movsd %xmm0, (%rax,%rdx,8)
movq (%r12), %rcx
incq %rdx
jmp 0x11a10
movq 0x10(%r15), %r15
testq %r15, %r15
jne 0x11a0e
decl %ebp
cvtsi2sd %ebp, %xmm0
xorl %edx, %edx
movslq 0x1c0(%rcx), %rsi
cmpq %rsi, %rdx
jge 0x11b72
movl 0x1407128(%rcx), %esi
cmpq %rsi, %rdx
je 0x11a8a
movsd (%rax,%rdx,8), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, (%rax,%rdx,8)
movq (%r12), %rcx
incq %rdx
jmp 0x11a5d
movslq 0x1bc(%rax), %rdi
shlq $0x3, %rdi
leaq 0x8497e(%rip), %rsi     # 0x9641f
pushq $0x19
popq %rdx
callq 0x34f59
movq %rax, (%rbx)
movl $0x61e1, %edx           # imm = 0x61E1
xorl %esi, %esi
movq (%r12), %rcx
movslq 0x1bc(%rcx), %rdi
cmpq %rdi, %rsi
jge 0x11b30
testl $0xfffffffd, (%rcx,%rdx,8) # imm = 0xFFFFFFFD
jne 0x11ad1
andq $0x0, (%rax,%rsi,8)
incq %rsi
addq $0x68, %rdx
jmp 0x11ab3
movl $0x61e1, %edx           # imm = 0x61E1
xorl %esi, %esi
movslq 0x1bc(%rcx), %rdi
cmpq %rdi, %rsi
jge 0x11b2c
movl (%rcx,%rdx,8), %ecx
cmpl $0x2, %ecx
je 0x11b03
testl %ecx, %ecx
jne 0x11b1f
movq (%r15), %rcx
cvtsi2sdl (%rcx,%rsi,8), %xmm0
jmp 0x11b0b
movq (%r15), %rcx
movsd (%rcx,%rsi,8), %xmm0
subsd (%r14,%rsi,8), %xmm0
mulsd %xmm0, %xmm0
addsd (%rax,%rsi,8), %xmm0
movsd %xmm0, (%rax,%rsi,8)
incq %rsi
movq (%r12), %rcx
addq $0x68, %rdx
jmp 0x11ae1
movq 0x10(%r15), %r15
testq %r15, %r15
jne 0x11ada
decl %ebp
cvtsi2sd %ebp, %xmm0
movl $0x61e1, %edx           # imm = 0x61E1
xorl %esi, %esi
movslq 0x1bc(%rcx), %rdi
cmpq %rdi, %rsi
jge 0x11b72
testl $0xfffffffd, (%rcx,%rdx,8) # imm = 0xFFFFFFFD
jne 0x11b65
movsd (%rax,%rsi,8), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, (%rax,%rsi,8)
incq %rsi
movq (%r12), %rcx
addq $0x68, %rdx
jmp 0x11b42
movq %r14, %rdi
callq 0x34ff7
movq %rbx, %rax
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq