// File: /workspace/github_c_makefile_star2_O1/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 0x10980
movl (%rbx), %edi
leaq 0xc7f59(%rip), %rax     # 0xd2870
movq (%rax), %rax
movl %edi, 0x1c0(%rax)
movq %r14, 0x8(%rsp)
movl $0xffffffff, 0x8(%r14)  # imm = 0xFFFFFFFF
decl %edi
movl $0x1, %esi
callq 0x3c6e5
movq %rax, 0x18(%rsp)
movq %rdx, %r12
cmpl $0x2, (%rbx)
jl 0xa96a
xorl %r14d, %r14d
movq %rbp, %rdi
movl %r14d, %esi
callq 0x2e4b6
movq (%r12,%r14,8), %rax
movsd %xmm0, (%rax)
incq %r14
movslq (%rbx), %rax
decq %rax
cmpq %rax, %r14
jl 0xa949
movq %r12, 0x10(%rsp)
leaq 0xc7efa(%rip), %rax     # 0xd2870
movq (%rax), %rax
cmpl $0x0, 0x10(%rax)
jle 0xaa42
xorpd %xmm0, %xmm0
movsd %xmm0, (%rsp)
movsd 0x98434(%rip), %xmm0    # 0xa2dc8
movsd %xmm0, 0x20(%rsp)
movl $0x8, %r12d
xorl %r13d, %r13d
movq 0x10(%rbx), %rax
movq -0x8(%rax,%r12), %rdi
movq (%rax,%r12), %rsi
movq 0x18(%rsp), %rdx
movq 0x10(%rsp), %rcx
callq 0x3dc8b
movq %rax, %rbp
movq %rdx, %r14
movq (%rdx), %rax
movsd (%rax), %xmm0
movq 0x8(%rbx), %rax
addsd (%rax,%r13,8), %xmm0
callq 0x38e72
movsd %xmm0, (%r15,%r13,8)
movq (%r14), %rax
movsd (%rax), %xmm1
movq 0x8(%rbx), %rax
addsd (%rax,%r13,8), %xmm1
ucomisd 0x20(%rsp), %xmm1
jbe 0xaa09
movq 0x8(%rsp), %rax
movl %r13d, 0x8(%rax)
movsd %xmm1, 0x20(%rsp)
movsd (%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, (%rsp)
movq %rbp, %rdi
movq %r14, %rsi
callq 0x3dbad
incq %r13
leaq 0xc7e44(%rip), %rax     # 0xd2870
movq (%rax), %rax
movslq 0x10(%rax), %rax
addq $0x10, %r12
cmpq %rax, %r13
jl 0xa9a3
jmp 0xaa4b
xorpd %xmm0, %xmm0
movsd %xmm0, (%rsp)
movq 0x18(%rsp), %rdi
movq 0x10(%rsp), %rsi
callq 0x3dbad
leaq 0xc7e0f(%rip), %rax     # 0xd2870
movq (%rax), %rax
movslq 0x10(%rax), %rcx
testq %rcx, %rcx
movsd (%rsp), %xmm1
jle 0xaa8c
xorl %edx, %edx
movsd (%r15,%rdx,8), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, (%r15,%rdx,8)
incq %rdx
cmpq %rdx, %rcx
jne 0xaa74
movl 0x4(%rbx), %ecx
movl %ecx, 0x1c0(%rax)
movq 0x8(%rsp), %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq