// File: /workspace/github_c_makefile_star2_O1/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 0x2e851
movq %rax, 0x38(%rsp)
movq %rax, %rdi
movq %rdx, 0x30(%rsp)
movq %rdx, %rsi
callq 0x3dbba
movq %rax, 0x28(%rsp)
movq %rdx, 0x20(%rsp)
leaq 0xc8517(%rip), %rax     # 0xd2870
movq (%rax), %rax
movl 0x10(%rax), %eax
testl %eax, %eax
jle 0xa4c2
movq %rbx, 0x18(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x98a4b(%rip), %xmm0    # 0xa2dc8
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 0x3dc8b
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 0x3dc8b
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 0x3dc8b
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 0xa426
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 0x38e72
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 0x3dbad
movq 0x50(%rsp), %rdi
movq %rbp, %rsi
callq 0x3dbad
movq %r12, %rdi
movq %r13, %rsi
callq 0x3dbad
incq %rbx
leaq 0xc83cf(%rip), %rax     # 0xd2870
movq (%rax), %rax
movslq 0x10(%rax), %rax
addq $0x2, %r14
cmpq %rax, %rbx
jl 0xa38b
movq 0x18(%rsp), %rbx
movsd 0x8(%rsp), %xmm1
jmp 0xa4c6
xorpd %xmm1, %xmm1
testl %eax, %eax
jle 0xa4e4
movl %eax, %eax
xorl %ecx, %ecx
movsd (%rbx,%rcx,8), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, (%rbx,%rcx,8)
incq %rcx
cmpq %rcx, %rax
jne 0xa4ce
movq 0x38(%rsp), %rdi
movq 0x30(%rsp), %rsi
callq 0x3dbad
movq 0x28(%rsp), %rdi
movq 0x20(%rsp), %rsi
callq 0x3dbad
movq 0x10(%rsp), %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq