// File: /workspace/github_c_makefile_star2_O0/olcaytaner[P]Isell/classification.c
// Function: train_naivebayes
void* train_naivebayes(Instanceptr* trdata, Instanceptr *cvdata, void* parameters)
{
 /*!Last Changed 22.01.2008 changed from variance to standard deviation*/
 /*!Last Changed 11.08.2007*/
 int i, j, k, *counts, size = data_size(*trdata);
 int ***feature_counts;
 Instanceptr tmp, classmeans;
 Model_naivebayesptr m;
 Instance s;
 m = safemalloc(sizeof(Model_naivebayes), "train_naivebayes", 5);
 counts = find_class_counts(*trdata); 
 classmeans = find_class_means(*trdata, counts);
 s = find_variance(*trdata);
 feature_counts = find_feature_counts(*trdata);
 m->s = (double *) safemalloc(current_dataset->featurecount * sizeof(double), "train_naivebayes", 9);
 m->m = (double **) safemalloc_2d(sizeof(double *), sizeof(double), current_dataset->classno, current_dataset->featurecount, "train_naivebayes", 10);
 m->priors = (double *)safemalloc(current_dataset->classno * sizeof(double), "train_naivebayes", 11);
 for (i = 0; i < current_dataset->featurecount; i++)
   m->s[i] = sqrt(s.values[i].floatvalue);
 tmp = classmeans;
 m->p = (double ***) safemalloc(current_dataset->classno * sizeof(double **), "train_naivebayes", 15);
 for (i = 0; i < current_dataset->classno; i++)
  {
   m->p[i] = (double **) safemalloc(current_dataset->featurecount * sizeof(double *), "train_naivebayes", 18);
   m->priors[i] = counts[i] / (size + 0.0);
   for (j = 0; j < current_dataset->featurecount; j++)
    {
     if (current_dataset->features[j].type == STRING)
      {
       m->p[i][j] = (double *) safemalloc(current_dataset->features[j].valuecount * sizeof(double), "train_naivebayes", 24);
       for (k = 0; k < current_dataset->features[j].valuecount; k++)
         m->p[i][j][k] = feature_counts[i][j][k] / (counts[i] + 0.0);
      }
     m->m[i][j] = tmp->values[j].floatvalue;
    }
   tmp = tmp->next;
  }
 free_feature_counts(feature_counts);
 safe_free(s.values);
 safe_free(counts);
 deallocate(classmeans);
 return m;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rdi
callq 0x449f0
movl %eax, -0x34(%rbp)
movl $0x20, %edi
leaq 0xd57d0(%rip), %rsi     # 0xe2b72
movl $0x5, %edx
callq 0x52d70
movq %rax, -0x58(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rdi
callq 0x183a0
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movq -0x30(%rbp), %rsi
callq 0x188c0
movq %rax, -0x50(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rsi
leaq -0xb8(%rbp), %rdi
callq 0x1a0a0
leaq -0x88(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
movl $0x30, %edx
callq 0x42b0
movq -0x8(%rbp), %rax
movq (%rax), %rdi
callq 0x187f0
movq %rax, -0x40(%rbp)
leaq 0xf842a(%rip), %rax     # 0x105840
movq (%rax), %rax
movslq 0x1bc(%rax), %rdi
shlq $0x3, %rdi
leaq 0xd5747(%rip), %rsi     # 0xe2b72
movl $0x9, %edx
callq 0x52d70
movq %rax, %rcx
movq -0x58(%rbp), %rax
movq %rcx, 0x8(%rax)
leaq 0xf83f9(%rip), %rax     # 0x105840
movq (%rax), %rax
movl 0x10(%rax), %edx
leaq 0xf83ec(%rip), %rax     # 0x105840
movq (%rax), %rax
movl 0x1bc(%rax), %ecx
movl $0x8, %esi
leaq 0xd5709(%rip), %r8      # 0xe2b72
movl $0xa, %r9d
movq %rsi, %rdi
callq 0x53120
movq %rax, %rcx
movq -0x58(%rbp), %rax
movq %rcx, (%rax)
leaq 0xf83b8(%rip), %rax     # 0x105840
movq (%rax), %rax
movslq 0x10(%rax), %rdi
shlq $0x3, %rdi
leaq 0xd56d8(%rip), %rsi     # 0xe2b72
movl $0xb, %edx
callq 0x52d70
movq %rax, %rcx
movq -0x58(%rbp), %rax
movq %rcx, 0x10(%rax)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
leaq 0xf8380(%rip), %rcx     # 0x105840
movq (%rcx), %rcx
cmpl 0x1bc(%rcx), %eax
jge 0xd4fc
movq -0x88(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
callq 0x42a0
movq -0x58(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x1c(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xd4b6
movq -0x50(%rbp), %rax
movq %rax, -0x48(%rbp)
leaq 0xf8335(%rip), %rax     # 0x105840
movq (%rax), %rax
movslq 0x10(%rax), %rdi
shlq $0x3, %rdi
leaq 0xd5655(%rip), %rsi     # 0xe2b72
movl $0xf, %edx
callq 0x52d70
movq %rax, %rcx
movq -0x58(%rbp), %rax
movq %rcx, 0x18(%rax)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
leaq 0xf82fd(%rip), %rcx     # 0x105840
movq (%rcx), %rcx
cmpl 0x10(%rcx), %eax
jge 0xd733
leaq 0xf82ea(%rip), %rax     # 0x105840
movq (%rax), %rax
movslq 0x1bc(%rax), %rdi
shlq $0x3, %rdi
leaq 0xd5607(%rip), %rsi     # 0xe2b72
movl $0x12, %edx
callq 0x52d70
movq %rax, %rdx
movq -0x58(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x1c(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x30(%rbp), %rax
movslq -0x1c(%rbp), %rcx
cvtsi2sdl (%rax,%rcx,4), %xmm0
cvtsi2sdl -0x34(%rbp), %xmm1
xorps %xmm2, %xmm2
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movq -0x58(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x1c(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
leaq 0xf8279(%rip), %rcx     # 0x105840
movq (%rcx), %rcx
cmpl 0x1bc(%rcx), %eax
jge 0xd719
leaq 0xf8263(%rip), %rax     # 0x105840
movq (%rax), %rax
addq $0x30f08, %rax          # imm = 0x30F08
movslq -0x20(%rbp), %rcx
imulq $0x340, %rcx, %rcx      # imm = 0x340
addq %rcx, %rax
cmpl $0x1, (%rax)
jne 0xd6e3
leaq 0xf823c(%rip), %rax     # 0x105840
movq (%rax), %rax
addq $0x30f08, %rax          # imm = 0x30F08
movslq -0x20(%rbp), %rcx
imulq $0x340, %rcx, %rcx      # imm = 0x340
addq %rcx, %rax
movslq 0x18(%rax), %rdi
shlq $0x3, %rdi
leaq 0xd5548(%rip), %rsi     # 0xe2b72
movl $0x18, %edx
callq 0x52d70
movq %rax, %rdx
movq -0x58(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x20(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
leaq 0xf81e0(%rip), %rcx     # 0x105840
movq (%rcx), %rcx
addq $0x30f08, %rcx          # imm = 0x30F08
movslq -0x20(%rbp), %rdx
imulq $0x340, %rdx, %rdx      # imm = 0x340
addq %rdx, %rcx
cmpl 0x18(%rcx), %eax
jge 0xd6e1
movq -0x40(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x20(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x24(%rbp), %rcx
cvtsi2sdl (%rax,%rcx,4), %xmm0
movq -0x30(%rbp), %rax
movslq -0x1c(%rbp), %rcx
cvtsi2sdl (%rax,%rcx,4), %xmm1
xorps %xmm2, %xmm2
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movq -0x58(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x20(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x24(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0xd656
jmp 0xd6e3
movq -0x48(%rbp), %rax
movq (%rax), %rax
movslq -0x20(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x58(%rbp), %rax
movq (%rax), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x20(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0xd5bd
movq -0x48(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x48(%rbp)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xd539
movq -0x40(%rbp), %rdi
callq 0x18730
movq -0x88(%rbp), %rdi
callq 0x52e80
movq -0x30(%rbp), %rdi
callq 0x52e80
movq -0x50(%rbp), %rdi
callq 0x44510
movq -0x58(%rbp), %rax
addq $0xc0, %rsp
popq %rbp
retq
nopw (%rax,%rax)