// File: /workspace/github_c_makefile_star2_O1/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 0x2fa14
movl %eax, %ebp
movq %rsp, %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x12519
movq (%r14), %r14
leaq 0x39c703(%rip), %rax    # 0x3aefa4
cmpl $0x0, (%rax)
leaq 0xbffc5(%rip), %r12     # 0xd2870
movq (%r12), %rax
je 0x129aa
movslq 0x1c0(%rax), %rdi
shlq $0x3, %rdi
leaq 0x90b58(%rip), %rsi     # 0xa341f
movl $0x8, %edx
callq 0x390f5
movq %rax, (%rbx)
movq (%r12), %rdx
cmpl $0x0, 0x1c0(%rdx)
jle 0x12958
xorl %ecx, %ecx
movl 0x1407128(%rdx), %edx
cmpq %rdx, %rcx
je 0x128f6
movq $0x0, (%rax,%rcx,8)
incq %rcx
movq (%r12), %rdx
movslq 0x1c0(%rdx), %rsi
cmpq %rsi, %rcx
jl 0x128e3
jmp 0x12958
movq (%r12), %rdx
cmpl $0x0, 0x1c0(%rdx)
jle 0x12954
xorl %ecx, %ecx
movl 0x1407128(%rdx), %edx
cmpq %rdx, %rcx
je 0x12941
movq (%r15), %rdx
movsd (%rdx,%rcx,8), %xmm0
subsd (%r14,%rcx,8), %xmm0
mulsd %xmm0, %xmm0
addsd (%rax,%rcx,8), %xmm0
movsd %xmm0, (%rax,%rcx,8)
incq %rcx
movq (%r12), %rdx
movslq 0x1c0(%rdx), %rsi
cmpq %rsi, %rcx
jl 0x1291a
movq 0x10(%r15), %r15
testq %r15, %r15
jne 0x1290b
movq (%r12), %rdx
cmpl $0x0, 0x1c0(%rdx)
jle 0x12abf
decl %ebp
xorps %xmm0, %xmm0
cvtsi2sd %ebp, %xmm0
xorl %ecx, %ecx
movl 0x1407128(%rdx), %edx
cmpq %rdx, %rcx
je 0x12992
movsd (%rax,%rcx,8), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, (%rax,%rcx,8)
incq %rcx
movq (%r12), %rdx
movslq 0x1c0(%rdx), %rsi
cmpq %rsi, %rcx
jl 0x12979
jmp 0x12abf
movslq 0x1bc(%rax), %rdi
shlq $0x3, %rdi
leaq 0x90a63(%rip), %rsi     # 0xa341f
movl $0x19, %edx
callq 0x390f5
movq %rax, (%rbx)
movq (%r12), %rsi
cmpl $0x0, 0x1bc(%rsi)
jle 0x12a6f
movl $0x61e1, %ecx           # imm = 0x61E1
xorl %edx, %edx
testl $0xfffffffd, (%rsi,%rcx,8) # imm = 0xFFFFFFFD
jne 0x129f2
movq $0x0, (%rax,%rdx,8)
incq %rdx
movq (%r12), %rsi
movslq 0x1bc(%rsi), %rdi
addq $0x68, %rcx
cmpq %rdi, %rdx
jl 0x129e1
jmp 0x12a6f
movq (%r12), %rsi
cmpl $0x0, 0x1bc(%rsi)
jle 0x12a6b
movl $0x61e1, %ecx           # imm = 0x61E1
xorl %edx, %edx
movl (%rsi,%rcx,8), %esi
cmpl $0x2, %esi
je 0x12a38
testl %esi, %esi
jne 0x12a54
movq (%r15), %rsi
xorps %xmm0, %xmm0
cvtsi2sdl (%rsi,%rdx,8), %xmm0
jmp 0x12a40
movq (%r15), %rsi
movsd (%rsi,%rdx,8), %xmm0
subsd (%r14,%rdx,8), %xmm0
mulsd %xmm0, %xmm0
addsd (%rax,%rdx,8), %xmm0
movsd %xmm0, (%rax,%rdx,8)
incq %rdx
movq (%r12), %rsi
movslq 0x1bc(%rsi), %rdi
addq $0x68, %rcx
cmpq %rdi, %rdx
jl 0x12a1f
movq 0x10(%r15), %r15
testq %r15, %r15
jne 0x12a0b
movq (%r12), %rsi
cmpl $0x0, 0x1bc(%rsi)
jle 0x12abf
decl %ebp
xorps %xmm0, %xmm0
cvtsi2sd %ebp, %xmm0
movl $0x61e1, %ecx           # imm = 0x61E1
xorl %edx, %edx
testl $0xfffffffd, (%rsi,%rcx,8) # imm = 0xFFFFFFFD
jne 0x12aa8
movsd (%rax,%rdx,8), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, (%rax,%rdx,8)
incq %rdx
movq (%r12), %rsi
movslq 0x1bc(%rsi), %rdi
addq $0x68, %rcx
cmpq %rdi, %rdx
jl 0x12a91
movq %r14, %rdi
callq 0x39194
movq %rbx, %rax
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq