// File: /workspace/github_c_makefile_star2_O3/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 0x30309
movl %eax, %ebp
movq %rsp, %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x1247b
movq (%r14), %r14
leaq 0x39f7b3(%rip), %rax    # 0x3b1fa4
cmpl $0x0, (%rax)
leaq 0xc3075(%rip), %r12     # 0xd5870
movq (%r12), %rax
je 0x128f2
movslq 0x1c0(%rax), %rdi
shlq $0x3, %rdi
leaq 0x93c08(%rip), %rsi     # 0xa641f
movl $0x8, %edx
callq 0x3a0e1
movq %rax, (%rbx)
movq (%r12), %rcx
cmpl $0x0, 0x1c0(%rcx)
jle 0x128a4
xorl %edx, %edx
movl 0x1407128(%rcx), %esi
cmpq %rsi, %rdx
je 0x1284a
movq $0x0, (%rax,%rdx,8)
movq (%r12), %rcx
incq %rdx
movslq 0x1c0(%rcx), %rsi
cmpq %rsi, %rdx
jl 0x12833
jmp 0x128a4
cmpl $0x0, 0x1c0(%rcx)
jle 0x128a0
xorl %edx, %edx
movl 0x1407128(%rcx), %esi
cmpq %rsi, %rdx
je 0x12891
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
movslq 0x1c0(%rcx), %rsi
cmpq %rsi, %rdx
jl 0x12866
movq 0x10(%r15), %r15
testq %r15, %r15
jne 0x1285b
cmpl $0x0, 0x1c0(%rcx)
jle 0x129ff
decl %ebp
xorps %xmm0, %xmm0
cvtsi2sd %ebp, %xmm0
xorl %edx, %edx
movl 0x1407128(%rcx), %esi
cmpq %rsi, %rdx
je 0x128de
movsd (%rax,%rdx,8), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, (%rax,%rdx,8)
movq (%r12), %rcx
incq %rdx
movslq 0x1c0(%rcx), %rsi
cmpq %rsi, %rdx
jl 0x128c1
jmp 0x129ff
movslq 0x1bc(%rax), %rdi
shlq $0x3, %rdi
leaq 0x93b1b(%rip), %rsi     # 0xa641f
movl $0x19, %edx
callq 0x3a0e1
movq %rax, (%rbx)
movq (%r12), %rcx
cmpl $0x0, 0x1bc(%rcx)
jle 0x129b3
movl $0x61e1, %edx           # imm = 0x61E1
xorl %esi, %esi
testl $0xfffffffd, (%rcx,%rdx,8) # imm = 0xFFFFFFFD
jne 0x1293a
movq $0x0, (%rax,%rsi,8)
incq %rsi
movq (%r12), %rcx
movslq 0x1bc(%rcx), %rdi
addq $0x68, %rdx
cmpq %rdi, %rsi
jl 0x12929
jmp 0x129b3
cmpl $0x0, 0x1bc(%rcx)
jle 0x129af
movl $0x61e1, %edx           # imm = 0x61E1
xorl %esi, %esi
movl (%rcx,%rdx,8), %ecx
cmpl $0x2, %ecx
je 0x1297c
testl %ecx, %ecx
jne 0x12998
movq (%r15), %rcx
xorps %xmm0, %xmm0
cvtsi2sdl (%rcx,%rsi,8), %xmm0
jmp 0x12984
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
movslq 0x1bc(%rcx), %rdi
addq $0x68, %rdx
cmpq %rdi, %rsi
jl 0x12963
movq 0x10(%r15), %r15
testq %r15, %r15
jne 0x12953
cmpl $0x0, 0x1bc(%rcx)
jle 0x129ff
decl %ebp
xorps %xmm0, %xmm0
cvtsi2sd %ebp, %xmm0
movl $0x61e1, %edx           # imm = 0x61E1
xorl %esi, %esi
testl $0xfffffffd, (%rcx,%rdx,8) # imm = 0xFFFFFFFD
jne 0x129e8
movsd (%rax,%rsi,8), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, (%rax,%rsi,8)
incq %rsi
movq (%r12), %rcx
movslq 0x1bc(%rcx), %rdi
addq $0x68, %rdx
cmpq %rdi, %rsi
jl 0x129d1
movq %r14, %rdi
callq 0x3a180
movq %rbx, %rax
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq