// File: /workspace/github_c_makefile_star2_O0/olcaytaner[P]Isell/classification.c
// Function: train_qdaclass
void* train_qdaclass(Instanceptr* trdata, Instanceptr *cvdata, void* parameters)
{
 /*!Last Changed 05.08.2007*/
 Model_qdaclassptr m;
 matrix Si, mi, mitranspose, tmpmat;
 int i, *counts, size = data_size(*trdata);
 Instanceptr classmeans, tmp;
 double det;
 m = safemalloc(sizeof(Model_qdaclass), "train_qdaclass", 2);
 m->w0 = (double *)safemalloc(current_dataset->classno * sizeof(double), "qdaclass", 3);
 m->priors = (double *)safemalloc(current_dataset->classno * sizeof(double), "qdaclass", 4);
 m->w = (matrix *)safemalloc(current_dataset->classno * sizeof(matrix), "qdaclass", 5);
 m->W = (matrix *)safemalloc(current_dataset->classno * sizeof(matrix), "qdaclass", 6);
 counts = find_class_counts(*trdata);
 for (i = 0; i < current_dataset->classno; i++)
   m->priors[i] = counts[i] / (size + 0.0);
 classmeans = find_class_means(*trdata, counts);
 tmp = classmeans;
 for (i = 0; i < current_dataset->classno; i++)
  {
   mi = instance_to_matrix(tmp);
   mitranspose = matrix_transpose(mi);
   Si = class_covariance(*trdata, i, tmp);
   while (matrix_determinant(Si) < DBL_DELTA)
     matrix_perturbate(Si);
   det = matrix_determinant(Si);
   matrix_inverse(&Si);
   m->W[i] = matrix_copy(Si);
   matrix_multiply_constant(&(m->W[i]), -0.5);
   m->w[i] = matrix_multiply(mi, Si);
   tmpmat = matrix_multiply(m->w[i], mitranspose);
   m->w0[i] = -0.5 * (tmpmat.values[0][0] + log(det)) + log((counts[i] + 0.0) / size);
   tmp = tmp->next;
   matrix_free(mi);
   matrix_free(Si);
   matrix_free(mitranspose);
   matrix_free(tmpmat);
  }
 safe_free(counts);
 deallocate(classmeans);
 return m;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rdi
callq 0x449f0
movl %eax, -0x74(%rbp)
movl $0x20, %edi
leaq 0xd5061(%rip), %rsi     # 0xe2b83
movl $0x2, %edx
callq 0x52d70
movq %rax, -0x20(%rbp)
leaq 0xf7d09(%rip), %rax     # 0x105840
movq (%rax), %rax
movslq 0x10(%rax), %rdi
shlq $0x3, %rdi
leaq 0xd8d91(%rip), %rsi     # 0xe68da
movl $0x3, %edx
callq 0x52d70
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x10(%rax)
leaq 0xf7cdb(%rip), %rax     # 0x105840
movq (%rax), %rax
movslq 0x10(%rax), %rdi
shlq $0x3, %rdi
leaq 0xd8d63(%rip), %rsi     # 0xe68da
movl $0x4, %edx
callq 0x52d70
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x18(%rax)
leaq 0xf7cad(%rip), %rax     # 0x105840
movq (%rax), %rax
movslq 0x10(%rax), %rdi
shlq $0x4, %rdi
leaq 0xd8d35(%rip), %rsi     # 0xe68da
movl $0x5, %edx
callq 0x52d70
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x8(%rax)
leaq 0xf7c7f(%rip), %rax     # 0x105840
movq (%rax), %rax
movslq 0x10(%rax), %rdi
shlq $0x4, %rdi
leaq 0xd8d07(%rip), %rsi     # 0xe68da
movl $0x6, %edx
callq 0x52d70
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x8(%rbp), %rax
movq (%rax), %rdi
callq 0x183a0
movq %rax, -0x70(%rbp)
movl $0x0, -0x64(%rbp)
movl -0x64(%rbp), %eax
leaq 0xf7c38(%rip), %rcx     # 0x105840
movq (%rcx), %rcx
cmpl 0x10(%rcx), %eax
jge 0xdc49
movq -0x70(%rbp), %rax
movslq -0x64(%rbp), %rcx
cvtsi2sdl (%rax,%rcx,4), %xmm0
cvtsi2sdl -0x74(%rbp), %xmm1
xorps %xmm2, %xmm2
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x64(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0xdbfe
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movq -0x70(%rbp), %rsi
callq 0x188c0
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rax
movq %rax, -0x88(%rbp)
movl $0x0, -0x64(%rbp)
movl -0x64(%rbp), %eax
leaq 0xf7bc7(%rip), %rcx     # 0x105840
movq (%rcx), %rcx
cmpl 0x10(%rcx), %eax
jge 0xdf5d
movq -0x88(%rbp), %rdi
callq 0x43160
movq %rax, -0xa0(%rbp)
movq %rdx, -0x98(%rbp)
movq -0xa0(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x98(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x40(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x59ed0
movq %rax, -0xb0(%rbp)
movq %rdx, -0xa8(%rbp)
movq -0xb0(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0xa8(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movl -0x64(%rbp), %esi
movq -0x88(%rbp), %rdx
callq 0x17680
movq %rax, -0xc0(%rbp)
movq %rdx, -0xb8(%rbp)
movq -0xc0(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0xb8(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x30(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x5c130
movaps %xmm0, %xmm1
movsd 0xd4d38(%rip), %xmm0    # 0xe2a70
ucomisd %xmm1, %xmm0
jbe 0xdd4d
movq -0x30(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x5c0d0
jmp 0xdd20
movq -0x30(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x5c130
movsd %xmm0, -0x90(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x5c470
movq -0x20(%rbp), %rax
movq (%rax), %rax
movslq -0x64(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x110(%rbp)
movq -0x30(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x58550
movq %rax, %rcx
movq -0x110(%rbp), %rax
movq %rcx, -0xd0(%rbp)
movq %rdx, -0xc8(%rbp)
movq -0xd0(%rbp), %rcx
movq %rcx, (%rax)
movq -0xc8(%rbp), %rcx
movq %rcx, 0x8(%rax)
movq -0x20(%rbp), %rax
movq (%rax), %rdi
movslq -0x64(%rbp), %rax
shlq $0x4, %rax
addq %rax, %rdi
movsd 0xd4c90(%rip), %xmm0    # 0xe2a68
callq 0x5a9d0
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x64(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x108(%rbp)
movq -0x40(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x30(%rbp), %rdx
movq -0x28(%rbp), %rcx
callq 0x59fe0
movq %rax, %rcx
movq -0x108(%rbp), %rax
movq %rcx, -0xe0(%rbp)
movq %rdx, -0xd8(%rbp)
movq -0xe0(%rbp), %rcx
movq %rcx, (%rax)
movq -0xd8(%rbp), %rcx
movq %rcx, 0x8(%rax)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x64(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rdi
movq 0x8(%rax), %rsi
movq -0x50(%rbp), %rdx
movq -0x48(%rbp), %rcx
callq 0x59fe0
movq %rax, -0xf0(%rbp)
movq %rdx, -0xe8(%rbp)
movq -0xf0(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0xe8(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
movq (%rax), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x100(%rbp)
movsd -0x90(%rbp), %xmm0
callq 0x4120
movaps %xmm0, %xmm1
movsd -0x100(%rbp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0xf8(%rbp)
movq -0x70(%rbp), %rax
movslq -0x64(%rbp), %rcx
cvtsi2sdl (%rax,%rcx,4), %xmm0
xorps %xmm1, %xmm1
addsd %xmm1, %xmm0
cvtsi2sdl -0x74(%rbp), %xmm1
divsd %xmm1, %xmm0
callq 0x4120
movaps %xmm0, %xmm1
movsd -0xf8(%rbp), %xmm0
movsd 0xd4b78(%rip), %xmm2    # 0xe2a68
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x64(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq -0x88(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x88(%rbp)
movq -0x40(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x59ea0
movq -0x30(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x59ea0
movq -0x50(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0x59ea0
movq -0x60(%rbp), %rdi
movq -0x58(%rbp), %rsi
callq 0x59ea0
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0xdc6f
movq -0x70(%rbp), %rdi
callq 0x52e80
movq -0x80(%rbp), %rdi
callq 0x44510
movq -0x20(%rbp), %rax
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
nopl (%rax)