// File: /workspace/github_c_makefile_star2_O0/olcaytaner[P]Isell/dataset.c
// Function: fisher_discriminant_ratio
double fisher_discriminant_ratio(Datasetptr d)
{
 /* multiclass is handled by one vs one */
 Instanceptr tempinst, traindata, c_means;
 int *c_counts;
 matrix class_mean, class_cov, class_var, fisher_class_feature;
 int i, j, k, f;
 double result = 0, classsum, maxratio; 
 read_from_train_file(d, &traindata);
 realize(traindata);
 exchange_classdefno(d);
 c_counts = find_class_counts(traindata);
 c_means = find_class_means(traindata, c_counts);
 fisher_class_feature = matrix_alloc(d->multifeaturecount - 1, d->classno * d->classno);
 class_mean = matrix_alloc(d->multifeaturecount - 1, d->classno);
 class_var = matrix_alloc(d->multifeaturecount - 1, d->classno);
 tempinst = c_means;
 for (j = 0; j < d->classno; j++)
  {
   class_cov = class_covariance(traindata, j, tempinst);  /*OLCAY DEGISTIRDIM*/
   for (i = 0, f = 0; i < d->multifeaturecount; i++)
    {
     if (i != d->classdefno)
      {
       class_var.values[f][j] = class_cov.values[f][f];
       class_mean.values[f][j] = tempinst->values[f].floatvalue;
       f++;
      }
    }
   tempinst = tempinst->next;
   matrix_free(class_cov);
  }
 maxratio = 0;
 for (i = 0, f = 0;i < d->multifeaturecount; i++)
  {
   if (i != d->classdefno)
    {
     classsum = 0;
     for (j = 0; j < d->classno; j++)
      {
       for (k = j + 1; k < d->classno; k++)
        {
         classsum += (class_mean.values[f][j] - class_mean.values[f][k]) * (class_mean.values[f][j] - class_mean.values[f][k]) / ((class_var.values[f][j] * class_var.values[f][j]) + (class_var.values[f][k] * class_var.values[f][k]));
        }
      }
     if (classsum > maxratio)
      {
       maxratio = classsum;
      }
     f++;
    }
  }
 exchange_classdefno(d);
 matrix_free(fisher_class_feature);
 matrix_free(class_mean);
 matrix_free(class_var);
 safe_free(c_means);
 safe_free(c_counts);
 deallocate(traindata);
 traindata = NULL;
 result = maxratio / (d->classno * (d->classno - 1) / 2);
 return result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x8(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x80(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0x85c60
movq -0x18(%rbp), %rdi
callq 0x17090
movq -0x8(%rbp), %rdi
callq 0x1a880
movq -0x18(%rbp), %rdi
callq 0x183a0
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x188c0
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rax
movl 0x1c0(%rax), %edi
subl $0x1, %edi
movq -0x8(%rbp), %rax
movl 0x10(%rax), %esi
movq -0x8(%rbp), %rax
imull 0x10(%rax), %esi
callq 0x57fc0
movq %rax, -0xa0(%rbp)
movq %rdx, -0x98(%rbp)
movq -0xa0(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x98(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x8(%rbp), %rax
movl 0x1c0(%rax), %edi
subl $0x1, %edi
movq -0x8(%rbp), %rax
movl 0x10(%rax), %esi
callq 0x57fc0
movq %rax, -0xb0(%rbp)
movq %rdx, -0xa8(%rbp)
movq -0xb0(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0xa8(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movl 0x1c0(%rax), %edi
subl $0x1, %edi
movq -0x8(%rbp), %rax
movl 0x10(%rax), %esi
callq 0x57fc0
movq %rax, -0xc0(%rbp)
movq %rdx, -0xb8(%rbp)
movq -0xc0(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0xb8(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x10(%rbp)
movl $0x0, -0x70(%rbp)
movl -0x70(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jge 0x248c1
movq -0x18(%rbp), %rdi
movl -0x70(%rbp), %esi
movq -0x10(%rbp), %rdx
callq 0x17680
movq %rax, -0xd0(%rbp)
movq %rdx, -0xc8(%rbp)
movq -0xd0(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0xc8(%rbp), %rax
movq %rax, -0x40(%rbp)
movl $0x0, -0x6c(%rbp)
movl $0x0, -0x78(%rbp)
movl -0x6c(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x1c0(%rcx), %eax
jge 0x2489a
movl -0x6c(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x1407128(%rcx), %eax
je 0x2488a
movq -0x40(%rbp), %rax
movslq -0x78(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x78(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x50(%rbp), %rax
movslq -0x78(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x70(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movslq -0x78(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x30(%rbp), %rax
movslq -0x78(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x70(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x78(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x78(%rbp)
jmp 0x2488c
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x24814
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x10(%rbp)
movq -0x48(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x59ea0
movl -0x70(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x70(%rbp)
jmp 0x247c2
xorps %xmm0, %xmm0
movsd %xmm0, -0x90(%rbp)
movl $0x0, -0x6c(%rbp)
movl $0x0, -0x78(%rbp)
movl -0x6c(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x1c0(%rcx), %eax
jge 0x24a5c
movl -0x6c(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x1407128(%rcx), %eax
je 0x24a4c
xorps %xmm0, %xmm0
movsd %xmm0, -0x88(%rbp)
movl $0x0, -0x70(%rbp)
movl -0x70(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jge 0x24a21
movl -0x70(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
movl -0x74(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jge 0x24a11
movq -0x30(%rbp), %rax
movslq -0x78(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x70(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x30(%rbp), %rax
movslq -0x78(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x74(%rbp), %rcx
subsd (%rax,%rcx,8), %xmm0
movq -0x30(%rbp), %rax
movslq -0x78(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x70(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
movq -0x30(%rbp), %rax
movslq -0x78(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x74(%rbp), %rcx
subsd (%rax,%rcx,8), %xmm1
mulsd %xmm1, %xmm0
movq -0x50(%rbp), %rax
movslq -0x78(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x70(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
movq -0x50(%rbp), %rax
movslq -0x78(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x70(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm3
movq -0x50(%rbp), %rax
movslq -0x78(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x74(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm2
movq -0x50(%rbp), %rax
movslq -0x78(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x74(%rbp), %rcx
mulsd (%rax,%rcx,8), %xmm2
mulsd %xmm3, %xmm1
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
addsd -0x88(%rbp), %xmm0
movsd %xmm0, -0x88(%rbp)
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0x2492b
jmp 0x24a13
movl -0x70(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x70(%rbp)
jmp 0x24912
movsd -0x88(%rbp), %xmm0
ucomisd -0x90(%rbp), %xmm0
jbe 0x24a43
movsd -0x88(%rbp), %xmm0
movsd %xmm0, -0x90(%rbp)
movl -0x78(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x78(%rbp)
jmp 0x24a4e
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x248da
movq -0x8(%rbp), %rdi
callq 0x1a880
movq -0x68(%rbp), %rdi
movq -0x60(%rbp), %rsi
callq 0x59ea0
movq -0x38(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x59ea0
movq -0x58(%rbp), %rdi
movq -0x50(%rbp), %rsi
callq 0x59ea0
movq -0x20(%rbp), %rdi
callq 0x52e80
movq -0x28(%rbp), %rdi
callq 0x52e80
movq -0x18(%rbp), %rdi
callq 0x44510
movq $0x0, -0x18(%rbp)
movsd -0x90(%rbp), %xmm0
movq -0x8(%rbp), %rax
movl 0x10(%rax), %eax
movq -0x8(%rbp), %rcx
movl 0x10(%rcx), %ecx
subl $0x1, %ecx
imull %ecx, %eax
movl $0x2, %ecx
cltd
idivl %ecx
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x80(%rbp)
movsd -0x80(%rbp), %xmm0
addq $0xd0, %rsp
popq %rbp
retq
nop