// File: /workspace/github_c_makefile_star2_O3/olcaytaner[P]Isell/classification.c
// Function: test_qdaclass
Prediction test_qdaclass(Instanceptr data, void* model, void* parameters, double* posterior)
{
 /*!Last Changed 05.08.2007*/
 Model_qdaclassptr m;
 double max, gi, denom = 0.0;
 int i;
 matrix x, tmp1, tmp2, tmp3, xtranspose;
 Prediction predicted;
 m = (Model_qdaclassptr) model;
 max = -LONG_MAX;
 predicted.classno = -1;
 x = instance_to_matrix(data);
 xtranspose = matrix_transpose(x);
 for (i = 0; i < current_dataset->classno; i++)
  {
   tmp1 = matrix_multiply(x, m->W[i]);
   tmp2 = matrix_multiply(tmp1, xtranspose);
   tmp3 = matrix_multiply(m->w[i], xtranspose);
   gi = tmp2.values[0][0] + tmp3.values[0][0] + m->w0[i];
   if (gi > max)
    {
     max = gi;
     predicted.classno = i;
    }
   posterior[i] = safeexp(gi - log(m->priors[i])) * m->priors[i];
   denom += posterior[i];
   matrix_free(tmp1);
   matrix_free(tmp2);
   matrix_free(tmp3);
  }
 for (i = 0; i < current_dataset->classno; i++)
  	posterior[i] = posterior[i] / denom;
 matrix_free(x);
 matrix_free(xtranspose);
 return predicted;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %r8, %rbx
movq %rdx, %r15
movq %rdi, 0x10(%rsp)
movl $0xffffffff, 0x8(%rdi)  # imm = 0xFFFFFFFF
movq %rsi, %rdi
callq 0x2f0c1
movq %rax, 0x38(%rsp)
movq %rax, %rdi
movq %rdx, 0x30(%rsp)
movq %rdx, %rsi
callq 0x3ed5e
movq %rax, 0x28(%rsp)
movq %rdx, 0x20(%rsp)
leaq 0xcb4f7(%rip), %rax     # 0xd5870
movq (%rax), %rax
cmpl $0x0, 0x10(%rax)
jle 0xa4fb
movq %rbx, 0x18(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x9ba2c(%rip), %xmm0    # 0xa5dc8
movsd %xmm0, 0x40(%rsp)
movl $0x1, %r14d
xorl %ebx, %ebx
movq (%r15), %rax
movq -0x8(%rax,%r14,8), %rdx
movq (%rax,%r14,8), %rcx
movq 0x38(%rsp), %rdi
movq 0x30(%rsp), %rsi
callq 0x3ee2f
movq %rax, 0x60(%rsp)
movq %rax, %rdi
movq %rdx, 0x58(%rsp)
movq %rdx, %rsi
movq 0x28(%rsp), %r13
movq %r13, %rdx
movq %r15, %r12
movq 0x20(%rsp), %r15
movq %r15, %rcx
callq 0x3ee2f
movq %rax, 0x50(%rsp)
movq %rdx, %rbp
movq 0x8(%r12), %rax
movq -0x8(%rax,%r14,8), %rdi
movq (%rax,%r14,8), %rsi
movq %r13, %rdx
movq %r15, %rcx
movq %r12, %r15
callq 0x3ee2f
movq %rax, %r12
movq %rdx, %r13
movq (%rbp), %rax
movsd (%rax), %xmm0
movq (%rdx), %rax
addsd (%rax), %xmm0
movq 0x10(%r15), %rax
addsd (%rax,%rbx,8), %xmm0
ucomisd 0x40(%rsp), %xmm0
jbe 0xa445
movq 0x10(%rsp), %rax
movl %ebx, 0x8(%rax)
movsd %xmm0, 0x40(%rsp)
movq 0x18(%r15), %rax
movsd %xmm0, 0x48(%rsp)
movsd (%rax,%rbx,8), %xmm0
callq 0x4160
movsd 0x48(%rsp), %xmm1
subsd %xmm0, %xmm1
movapd %xmm1, %xmm0
callq 0x39bb5
movq 0x18(%r15), %rax
mulsd (%rax,%rbx,8), %xmm0
movq 0x18(%rsp), %rax
movsd %xmm0, (%rax,%rbx,8)
movsd 0x8(%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, 0x8(%rsp)
movq 0x60(%rsp), %rdi
movq 0x58(%rsp), %rsi
callq 0x3ed51
movq 0x50(%rsp), %rdi
movq %rbp, %rsi
callq 0x3ed51
movq %r12, %rdi
movq %r13, %rsi
callq 0x3ed51
incq %rbx
leaq 0xcb3b0(%rip), %rax     # 0xd5870
movq (%rax), %rax
movslq 0x10(%rax), %rax
addq $0x2, %r14
cmpq %rax, %rbx
jl 0xa3aa
testl %eax, %eax
movq 0x18(%rsp), %rdx
movsd 0x8(%rsp), %xmm1
jle 0xa4fb
xorl %ecx, %ecx
movsd (%rdx,%rcx,8), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, (%rdx,%rcx,8)
incq %rcx
cmpq %rcx, %rax
jne 0xa4e5
movq 0x38(%rsp), %rdi
movq 0x30(%rsp), %rsi
callq 0x3ed51
movq 0x28(%rsp), %rdi
movq 0x20(%rsp), %rsi
callq 0x3ed51
movq 0x10(%rsp), %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq