// File: /workspace/github_c_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r8, %r15
movq %rdx, %rbx
movq %rsi, %rbp
movq %rdi, %r14
movl (%rdx), %esi
decl %esi
movq 0x18(%rdx), %rdx
movq 0x20(%rbx), %rcx
movq %rbp, %rdi
callq 0xfc9a
movl (%rbx), %edi
leaq 0xc3453(%rip), %rax     # 0xcd870
movq (%rax), %rax
movl %edi, 0x1c0(%rax)
movq %r14, 0x10(%rsp)
orl $-0x1, 0x8(%r14)
decl %edi
pushq $0x1
popq %rsi
callq 0x380d3
movq %rax, 0x18(%rsp)
movq %rdx, 0x8(%rsp)
xorl %r14d, %r14d
movslq (%rbx), %rax
decq %rax
cmpq %rax, %r14
jge 0xa46f
movq %rbp, %rdi
movl %r14d, %esi
callq 0x2aea2
movq 0x8(%rsp), %rax
movq (%rax,%r14,8), %rax
movsd %xmm0, (%rax)
incq %r14
jmp 0xa447
movsd 0x8b959(%rip), %xmm0    # 0x95dd0
movsd %xmm0, 0x20(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, (%rsp)
pushq $0x8
popq %r13
xorl %r12d, %r12d
leaq 0xc33dd(%rip), %rax     # 0xcd870
movq (%rax), %rax
movslq 0x10(%rax), %rax
cmpq %rax, %r12
jge 0xa52e
movq 0x10(%rbx), %rax
movq -0x8(%rax,%r13), %rdi
movq (%rax,%r13), %rsi
movq 0x18(%rsp), %rdx
movq 0x8(%rsp), %rcx
callq 0x3933d
movq %rax, %rbp
movq %rdx, %r14
movq (%rdx), %rax
movsd (%rax), %xmm0
movq 0x8(%rbx), %rax
addsd (%rax,%r12,8), %xmm0
callq 0x34d50
movsd %xmm0, (%r15,%r12,8)
movq (%r14), %rax
movsd (%rax), %xmm1
movq 0x8(%rbx), %rax
addsd (%rax,%r12,8), %xmm1
ucomisd 0x20(%rsp), %xmm1
jbe 0xa509
movq 0x10(%rsp), %rax
movl %r12d, 0x8(%rax)
movsd %xmm1, 0x20(%rsp)
movsd (%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, (%rsp)
movq %rbp, %rdi
movq %r14, %rsi
callq 0x3929f
incq %r12
addq $0x10, %r13
jmp 0xa48c
movq 0x18(%rsp), %rdi
movq 0x8(%rsp), %rsi
callq 0x3929f
leaq 0xc332c(%rip), %rax     # 0xcd870
movq (%rax), %rax
movl 0x10(%rax), %ecx
xorl %edx, %edx
testl %ecx, %ecx
cmovlel %edx, %ecx
movsd (%rsp), %xmm1
cmpq %rdx, %rcx
je 0xa570
movsd (%r15,%rdx,8), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, (%r15,%rdx,8)
incq %rdx
jmp 0xa556
movl 0x4(%rbx), %ecx
movl %ecx, 0x1c0(%rax)
movq 0x10(%rsp), %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq