// File: /workspace/github_c_makefile_star2_O0/olcaytaner[P]Isell/classification.c
// Function: test_ldaclass
Prediction test_ldaclass(Instanceptr data, void* model, void* parameters, double* posterior)
{
 /*!Last Changed 02.02.2004 added safemalloc*/
 int i, j;
 matrix temp, res;
 double max, denom = 0.0;
 Model_ldaclassptr m;
 Prediction predicted;
 m = (Model_ldaclassptr) model;
 dimension_reduce_with_pca(data, m->newfeaturecount - 1, m->eigenvectors);
 current_dataset->multifeaturecount = m->newfeaturecount; 
 max = -LONG_MAX;
 predicted.classno = -1;
 temp = matrix_alloc(m->newfeaturecount - 1, 1);
 for (j = 0; j < m->newfeaturecount - 1;j++)
   temp.values[j][0] = real_feature(data, j);
 for (i = 0;i < current_dataset->classno;i++)
  {
   res = matrix_multiply(m->w[i], temp);
   posterior[i] = safeexp(res.values[0][0] + m->w0[i]);
   denom += posterior[i];
   if (res.values[0][0] + m->w0[i] > max)
    {
     max = res.values[0][0] + m->w0[i];
     predicted.classno = i;
    }
   matrix_free(res);
  }
 matrix_free(temp);
 for (i = 0; i < current_dataset->classno; i++)
   posterior[i] = posterior[i] / denom;
 current_dataset->multifeaturecount = m->oldfeaturecount;
 return predicted;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x88(%rbp)
movq %rdi, -0x90(%rbp)
movq %rsi, -0x8(%rbp)
movq %rdx, -0x10(%rbp)
movq %rcx, -0x18(%rbp)
movq %r8, -0x20(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x58(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x8(%rbp), %rdi
movq -0x60(%rbp), %rax
movl (%rax), %esi
subl $0x1, %esi
movq -0x60(%rbp), %rax
movq 0x18(%rax), %rdx
movq 0x20(%rax), %rcx
callq 0x170d0
movq -0x88(%rbp), %rdi
movq -0x60(%rbp), %rax
movl (%rax), %ecx
leaq 0xf6fa5(%rip), %rax     # 0x105840
movq (%rax), %rax
movl %ecx, 0x1c0(%rax)
movsd 0xd41b4(%rip), %xmm0    # 0xe2a60
movsd %xmm0, -0x50(%rbp)
movl $0xffffffff, 0x8(%rdi)  # imm = 0xFFFFFFFF
movq -0x60(%rbp), %rax
movl (%rax), %edi
subl $0x1, %edi
movl $0x1, %esi
callq 0x57fc0
movq %rax, -0x70(%rbp)
movq %rdx, -0x68(%rbp)
movq -0x70(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0x30(%rbp)
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
movq -0x60(%rbp), %rcx
movl (%rcx), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0xe921
movq -0x8(%rbp), %rdi
movl -0x28(%rbp), %esi
callq 0x42c40
movq -0x30(%rbp), %rax
movslq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsd %xmm0, (%rax)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0xe8ea
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
leaq 0xf6f0e(%rip), %rcx     # 0x105840
movq (%rcx), %rcx
cmpl 0x10(%rcx), %eax
jge 0xea2e
movq -0x60(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x24(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rdi
movq 0x8(%rax), %rsi
movq -0x38(%rbp), %rdx
movq -0x30(%rbp), %rcx
callq 0x59fe0
movq %rax, -0x80(%rbp)
movq %rdx, -0x78(%rbp)
movq -0x80(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x78(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq (%rax), %rax
movsd (%rax), %xmm0
movq -0x60(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x24(%rbp), %rcx
addsd (%rax,%rcx,8), %xmm0
callq 0x52a40
movq -0x20(%rbp), %rax
movslq -0x24(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq -0x20(%rbp), %rax
movslq -0x24(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
addsd -0x58(%rbp), %xmm0
movsd %xmm0, -0x58(%rbp)
movq -0x40(%rbp), %rax
movq (%rax), %rax
movsd (%rax), %xmm0
movq -0x60(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x24(%rbp), %rcx
addsd (%rax,%rcx,8), %xmm0
ucomisd -0x50(%rbp), %xmm0
jbe 0xea13
movq -0x88(%rbp), %rax
movq -0x40(%rbp), %rcx
movq (%rcx), %rcx
movsd (%rcx), %xmm0
movq -0x60(%rbp), %rcx
movq 0x8(%rcx), %rcx
movslq -0x24(%rbp), %rdx
addsd (%rcx,%rdx,8), %xmm0
movsd %xmm0, -0x50(%rbp)
movl -0x24(%rbp), %ecx
movl %ecx, 0x8(%rax)
movq -0x48(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x59ea0
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0xe928
movq -0x38(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x59ea0
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
leaq 0xf6df4(%rip), %rcx     # 0x105840
movq (%rcx), %rcx
cmpl 0x10(%rcx), %eax
jge 0xea7e
movq -0x20(%rbp), %rax
movslq -0x24(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
divsd -0x58(%rbp), %xmm0
movq -0x20(%rbp), %rax
movslq -0x24(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0xea42
movq -0x90(%rbp), %rax
movq -0x60(%rbp), %rcx
movl 0x4(%rcx), %edx
leaq 0xf6dad(%rip), %rcx     # 0x105840
movq (%rcx), %rcx
movl %edx, 0x1c0(%rcx)
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)