// File: /workspace/github_c_makefile_star2_O2/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, 0x40(%rsp)
movq %rdx, %r15
movq %rdi, 0x10(%rsp)
orl $-0x1, 0x8(%rdi)
movq %rsi, %rdi
callq 0x2b20d
movq %rax, 0x30(%rsp)
movq %rax, %rdi
movq %rdx, 0x28(%rsp)
movq %rdx, %rsi
callq 0x392ac
movq %rax, 0x20(%rsp)
movq %rdx, 0x18(%rsp)
movsd 0x8bf20(%rip), %xmm0    # 0x95dd0
movsd %xmm0, 0x38(%rsp)
xorpd %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
pushq $0x1
popq %r14
xorl %ebx, %ebx
leaq 0xc39a3(%rip), %rax     # 0xcd870
movq (%rax), %rax
movslq 0x10(%rax), %rax
cmpq %rax, %rbx
jge 0x9ff5
movq (%r15), %rax
movq -0x8(%rax,%r14,8), %rdx
movq (%rax,%r14,8), %rcx
movq 0x30(%rsp), %rdi
movq 0x28(%rsp), %rsi
callq 0x3933d
movq %rax, 0x60(%rsp)
movq %rax, %rdi
movq %rdx, 0x58(%rsp)
movq %rdx, %rsi
movq 0x20(%rsp), %r13
movq %r13, %rdx
movq %r15, %r12
movq 0x18(%rsp), %r15
movq %r15, %rcx
callq 0x3933d
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 0x3933d
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 0x38(%rsp), %xmm0
jbe 0x9f78
movq 0x10(%rsp), %rax
movl %ebx, 0x8(%rax)
movsd %xmm0, 0x38(%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 0x34d50
movq 0x18(%r15), %rax
mulsd (%rax,%rbx,8), %xmm0
movq 0x40(%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 0x3929f
movq 0x50(%rsp), %rdi
movq %rbp, %rsi
callq 0x3929f
movq %r12, %rdi
movq %r13, %rsi
callq 0x3929f
incq %rbx
addq $0x2, %r14
jmp 0x9ec6
xorl %ecx, %ecx
testl %eax, %eax
cmovlel %ecx, %eax
movq 0x40(%rsp), %rdx
cmpq %rcx, %rax
je 0xa01b
movsd (%rdx,%rcx,8), %xmm0
divsd 0x8(%rsp), %xmm0
movsd %xmm0, (%rdx,%rcx,8)
incq %rcx
jmp 0xa001
movq 0x30(%rsp), %rdi
movq 0x28(%rsp), %rsi
callq 0x3929f
movq 0x20(%rsp), %rdi
movq 0x18(%rsp), %rsi
callq 0x3929f
movq 0x10(%rsp), %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq