// File: /workspace/github_c_makefile_star2_O1/olcaytaner[P]Isell/savecode.c
// Function: generate_test_code_naivebayes
void generate_test_code_naivebayes(FILE* testcodefile, PROGRAMMING_LANGUAGE_TYPE language, Datasetptr d, Model_naivebayesptr m)
{
 /*!Last Changed 12.08.2007*/
 char st[MAXLENGTH];
	int* numeric, ncount;
 numeric = numeric_features(d, &ncount);
 code_function_header(testcodefile, "naivebayes", d->featurecount, language);
 code_constant_start(testcodefile, language);
 code_1d_array_constant(testcodefile, language, "priors", d->classno, m->priors, REAL_TYPE);  
 code_1d_array_constant(testcodefile, language, "s", d->featurecount, m->s, REAL_TYPE);  
 code_2d_array_constant(testcodefile, language, "m", d->classno, d->featurecount, m->m);
 code_variable_start(testcodefile, language);
 code_add_variable(testcodefile, language, REAL_VARIABLE, 7, "sum", "maxvalue", "gi", "p_i", "m_ij", "s_j", "x_j");
 code_add_variable(testcodefile, language, INTEGER_VARIABLE, 3, "i", "j", "maxindex");
 code_start(testcodefile, language);
 code_set_variable(testcodefile, language, "maxvalue", "-10000.0");  
 code_for(testcodefile, language, "i", 0, d->classno - 1, 1);     
 code_array_index_variable(st, language, "priors", "i");  
 code_set_variable(testcodefile, language, "p_i", st); 
 code_set_variable(testcodefile, language, "gi", "log(p_i)"); 
 code_for(testcodefile, language, "j", 0, d->featurecount - 1, 1); 
 code_array_index_variable(st, language, "s", "j");
 code_set_variable(testcodefile, language, "s_j", st);
 code_2d_array_index_variable(st, language, "m", "i", "j");
 code_set_variable(testcodefile, language, "m_ij", st);
 code_array_index_variable(st, language, "testdata", "j");
 code_set_variable(testcodefile, language, "x_j", st);
 code_switch(testcodefile, language, "j");
 code_case(testcodefile, language, numeric, ncount);
 code_if(testcodefile, language, "!=", "s_j", "0.0");
 code_set_variable(testcodefile, language, "gi", "gi - 0.5 * ((x_j - m_ij) / s_j) * ((x_j - m_ij) / s_j)");
	code_endif(testcodefile, language);
 code_endcase(testcodefile, language);
 code_endswitch(testcodefile, language);
 code_endfor(testcodefile, language, "j");  
 code_compare_and_set_bound(testcodefile, language, ">", "gi", "maxvalue", "maxindex"); 
 code_endfor(testcodefile, language, "i");
 code_function_return_string(testcodefile, "naivebayes", language, "maxindex");   
 code_function_end(testcodefile, language); 
	safe_free(numeric);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf4258, %rsp          # imm = 0xF4258
movq %rcx, %r15
movq %rdx, %r12
movl %esi, %ebx
movq %rdi, %r14
leaq 0x4(%rsp), %rsi
movq %rdx, %rdi
callq 0x150b9
movq %rax, 0x8(%rsp)
movl 0x1bc(%r12), %edx
leaq 0x24e52(%rip), %rsi     # 0xa6d0c
movq %r14, %rdi
movl %ebx, %ecx
callq 0x7b551
cmpl $0x2, %ebx
jne 0x81ee2
leaq 0x2b335(%rip), %rdi     # 0xad205
movl $0x6, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x42c0
movl 0x10(%r12), %ecx
movq 0x10(%r15), %r8
leaq 0x2bb19(%rip), %rdx     # 0xada0b
movq %r14, %rdi
movl %ebx, %esi
movl $0x1, %r9d
callq 0x7ceb8
movl 0x1bc(%r12), %ecx
movq 0x8(%r15), %r8
leaq 0x22fe4(%rip), %rdx     # 0xa4ef9
movq %r14, %rdi
movl %ebx, %esi
movl $0x1, %r9d
callq 0x7ceb8
movl 0x10(%r12), %ecx
movl 0x1bc(%r12), %r8d
movq (%r15), %r9
leaq 0x2b184(%rip), %rdx     # 0xad0c0
movq %r14, %rdi
movl %ebx, %esi
callq 0x7d0d5
cmpl $0x2, %ebx
jne 0x8200c
leaq 0x2b312(%rip), %rdi     # 0xad268
movl $0x4, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x42c0
subq $0x8, %rsp
leaq 0x2b9bd(%rip), %r10     # 0xad930
leaq 0x2b9a0(%rip), %r11     # 0xad91a
leaq 0x2b87d(%rip), %r15     # 0xad7fe
leaq 0x2baa4(%rip), %r13     # 0xada2c
leaq 0x2bc03(%rip), %rbp     # 0xadb92
leaq 0x2bc7f(%rip), %r8      # 0xadc15
leaq 0x2bbd2(%rip), %r9      # 0xadb6f
movq %r14, %rdi
movl %ebx, %esi
movl $0x1, %edx
movl $0x7, %ecx
xorl %eax, %eax
pushq %r10
pushq %r11
pushq %r15
pushq %r13
pushq %rbp
callq 0x7bd1c
addq $0x28, %rsp
leaq 0x2ba4b(%rip), %r10     # 0xada12
leaq 0x2bc53(%rip), %r8      # 0xadc21
leaq 0x2b947(%rip), %r9      # 0xad91c
movq %r14, %rdi
movl %ebx, %esi
xorl %edx, %edx
movl $0x3, %ecx
xorl %eax, %eax
pushq %r10
callq 0x7bd1c
addq $0x10, %rsp
leaq 0x2b083(%rip), %rdi     # 0xad078
movl $0x6, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x42c0
jmp 0x82092
subq $0x8, %rsp
leaq 0x2b919(%rip), %r10     # 0xad930
leaq 0x2b8fc(%rip), %r11     # 0xad91a
leaq 0x2b7d9(%rip), %r15     # 0xad7fe
leaq 0x2ba00(%rip), %r13     # 0xada2c
leaq 0x2bb5f(%rip), %rbp     # 0xadb92
leaq 0x2bbdb(%rip), %r8      # 0xadc15
leaq 0x2bb2e(%rip), %r9      # 0xadb6f
movq %r14, %rdi
movl %ebx, %esi
movl $0x1, %edx
movl $0x7, %ecx
xorl %eax, %eax
pushq %r10
pushq %r11
pushq %r15
pushq %r13
pushq %rbp
callq 0x7bd1c
addq $0x28, %rsp
leaq 0x2b9a7(%rip), %r10     # 0xada12
leaq 0x2bbaf(%rip), %r8      # 0xadc21
leaq 0x2b8a3(%rip), %r9      # 0xad91c
movq %r14, %rdi
movl %ebx, %esi
xorl %edx, %edx
movl $0x3, %ecx
xorl %eax, %eax
pushq %r10
callq 0x7bd1c
addq $0x10, %rsp
incl 0x32d150(%rip)          # 0x3af1e8
leaq 0x2bad0(%rip), %rdx     # 0xadb6f
leaq 0x2bad2(%rip), %rcx     # 0xadb78
movq %r14, %rdi
movl %ebx, %esi
callq 0x7ba46
movl 0x10(%r12), %r8d
decl %r8d
leaq 0x2bb62(%rip), %r15     # 0xadc21
movq %r14, %rdi
movl %ebx, %esi
movq %r15, %rdx
xorl %ecx, %ecx
movl $0x1, %r9d
callq 0x7ca9f
leaq 0x2b930(%rip), %rdx     # 0xada0b
leaq 0x10(%rsp), %rbp
movq %rbp, %rdi
movl %ebx, %esi
movq %r15, %rcx
callq 0x7c24c
leaq 0x2b938(%rip), %rdx     # 0xada2c
movq %r14, %rdi
movl %ebx, %esi
movq %rbp, %rcx
callq 0x7ba46
leaq 0x2ba8a(%rip), %rdx     # 0xadb92
leaq 0x2ba86(%rip), %rcx     # 0xadb95
movq %r14, %rdi
movl %ebx, %esi
callq 0x7ba46
movl 0x1bc(%r12), %r8d
decl %r8d
leaq 0x2b7f1(%rip), %r12     # 0xad91c
movq %r14, %rdi
movl %ebx, %esi
movq %r12, %rdx
xorl %ecx, %ecx
movl $0x1, %r9d
callq 0x7ca9f
leaq 0x22db2(%rip), %rdx     # 0xa4ef9
movq %rbp, %rdi
movl %ebx, %esi
movq %r12, %rcx
callq 0x7c24c
leaq 0x2b7bf(%rip), %r13     # 0xad91a
movq %r14, %rdi
movl %ebx, %esi
movq %r13, %rdx
movq %rbp, %rcx
callq 0x7ba46
leaq 0x2af4e(%rip), %rdx     # 0xad0c0
movq %rbp, %rdi
movl %ebx, %esi
movq %r15, %rcx
movq %r12, %r8
callq 0x7c269
leaq 0x2b675(%rip), %rdx     # 0xad7fe
movq %r14, %rdi
movl %ebx, %esi
movq %rbp, %rcx
callq 0x7ba46
leaq 0x2b6c9(%rip), %rdx     # 0xad866
movq %rbp, %rdi
movl %ebx, %esi
movq %r12, %rcx
callq 0x7c24c
leaq 0x2b77f(%rip), %rdx     # 0xad930
movq %r14, %rdi
movl %ebx, %esi
movq %rbp, %rcx
callq 0x7ba46
movq %r14, %rdi
movl %ebx, %esi
movq %r12, %rdx
callq 0x7c4fd
movl 0x4(%rsp), %ecx
movq %r14, %rdi
movl %ebx, %esi
movq 0x8(%rsp), %r12
movq %r12, %rdx
callq 0x7c2a3
leaq 0x23d13(%rip), %rsi     # 0xa5efb
leaq 0x2b98e(%rip), %rcx     # 0xadb7d
leaq 0x7a130(%rsp), %r15
movl %ebx, %edi
movq %r13, %rdx
movq %r15, %r8
callq 0x7c601
movq %r14, %rdi
movl %ebx, %esi
movq %r15, %rdx
callq 0x7c75c
leaq 0x2b986(%rip), %rcx     # 0xadb9e
movq %r14, %rdi
movl %ebx, %esi
leaq 0x2b96e(%rip), %rdx     # 0xadb92
callq 0x7ba46
movq %r14, %rdi
movl %ebx, %esi
callq 0x7c903
cmpl $0x3, %ebx
ja 0x82256
cmpl $0x2, %ebx
je 0x82256
leaq 0x2b15d(%rip), %rdi     # 0xad3a1
movl $0x7, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x42c0
movq %r14, %rdi
movl %ebx, %esi
callq 0x7c565
movq %r14, %rdi
movl %ebx, %esi
callq 0x7cd49
leaq 0x2be65(%rip), %rdx     # 0xae0d6
leaq 0x2b91a(%rip), %rcx     # 0xadb92
leaq 0x2b8f0(%rip), %r8      # 0xadb6f
leaq 0x2b78c(%rip), %r15     # 0xada12
movq %r14, %rdi
movl %ebx, %esi
movq %r15, %r9
callq 0x7e616
movq %r14, %rdi
movl %ebx, %esi
callq 0x7cd49
leaq 0x24a68(%rip), %rsi     # 0xa6d0c
movq %r14, %rdi
movl %ebx, %edx
movq %r15, %rcx
callq 0x7bffb
movq %r14, %rdi
movl %ebx, %esi
callq 0x7c1ca
movq %r12, %rdi
callq 0x39194
addq $0xf4258, %rsp          # imm = 0xF4258
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq