// File: /workspace/github_c_makefile_star2_O3/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, %r13
movq %rdx, %r12
movl %esi, %ebx
movq %rdi, %r14
leaq 0x4(%rsp), %rsi
movq %rdx, %rdi
callq 0x15156
movq %rax, %r15
movl 0x1bc(%r12), %edx
leaq 0x25aed(%rip), %rsi     # 0xa9d7c
movq %r14, %rdi
movl %ebx, %ecx
callq 0x7ce21
cmpl $0x2, %ebx
jne 0x842b7
leaq 0x2bff8(%rip), %rdi     # 0xb029d
movl $0x6, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x42c0
movq %r15, 0x8(%rsp)
movl 0x10(%r12), %ecx
movq 0x10(%r13), %r8
leaq 0x2c7d7(%rip), %rdx     # 0xb0aa3
movq %r14, %rdi
movl %ebx, %esi
movl $0x1, %r9d
callq 0x7e7f5
movl 0x1bc(%r12), %ecx
movq 0x8(%r13), %r8
leaq 0x23c62(%rip), %rdx     # 0xa7f51
movq %r14, %rdi
movl %ebx, %esi
movl $0x1, %r9d
callq 0x7e7f5
movl 0x10(%r12), %ecx
movl 0x1bc(%r12), %r8d
movq (%r13), %r9
leaq 0x2be41(%rip), %rdx     # 0xb0158
movq %r14, %rdi
movl %ebx, %esi
callq 0x7ea43
cmpl $0x2, %ebx
jne 0x843ed
leaq 0x2bfcf(%rip), %rdi     # 0xb0300
movl $0x4, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x42c0
subq $0x8, %rsp
leaq 0x2c67a(%rip), %r10     # 0xb09c8
leaq 0x2c65d(%rip), %r11     # 0xb09b2
leaq 0x2c53a(%rip), %r13     # 0xb0896
leaq 0x2c761(%rip), %rbp     # 0xb0ac4
leaq 0x2c8c0(%rip), %r15     # 0xb0c2a
leaq 0x2c93c(%rip), %r8      # 0xb0cad
leaq 0x2c88f(%rip), %r9      # 0xb0c07
movq %r14, %rdi
movl $0x2, %esi
movl $0x1, %edx
movl $0x7, %ecx
xorl %eax, %eax
pushq %r10
pushq %r11
pushq %r13
pushq %rbp
pushq %r15
callq 0x7d617
addq $0x28, %rsp
leaq 0x2c705(%rip), %r10     # 0xb0aaa
leaq 0x2c90d(%rip), %r8      # 0xb0cb9
leaq 0x2c601(%rip), %r9      # 0xb09b4
movq %r14, %rdi
movl $0x2, %esi
xorl %edx, %edx
movl $0x3, %ecx
xorl %eax, %eax
pushq %r10
callq 0x7d617
addq $0x10, %rsp
leaq 0x2bd3a(%rip), %rdi     # 0xb0110
movl $0x6, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x42c0
jmp 0x84473
subq $0x8, %rsp
leaq 0x2c5d0(%rip), %r10     # 0xb09c8
leaq 0x2c5b3(%rip), %r11     # 0xb09b2
leaq 0x2c490(%rip), %r15     # 0xb0896
leaq 0x2c6b7(%rip), %r13     # 0xb0ac4
leaq 0x2c816(%rip), %rbp     # 0xb0c2a
leaq 0x2c892(%rip), %r8      # 0xb0cad
leaq 0x2c7e5(%rip), %r9      # 0xb0c07
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 0x7d617
addq $0x28, %rsp
leaq 0x2c65e(%rip), %r10     # 0xb0aaa
leaq 0x2c866(%rip), %r8      # 0xb0cb9
leaq 0x2c55a(%rip), %r9      # 0xb09b4
movq %r14, %rdi
movl %ebx, %esi
xorl %edx, %edx
movl $0x3, %ecx
xorl %eax, %eax
pushq %r10
callq 0x7d617
addq $0x10, %rsp
incl 0x32dd6f(%rip)          # 0x3b21e8
leaq 0x2c787(%rip), %rdx     # 0xb0c07
leaq 0x2c789(%rip), %rcx     # 0xb0c10
movq %r14, %rdi
movl %ebx, %esi
callq 0x7d316
movl 0x10(%r12), %r8d
decl %r8d
leaq 0x2c819(%rip), %rdx     # 0xb0cb9
movq %r14, %rdi
movl %ebx, %esi
xorl %ecx, %ecx
movl $0x1, %r9d
callq 0x7e3dc
movl %ebx, %r13d
leaq 0x4f8c4(%rip), %rbp     # 0xd3d80
cmpl $0x5, %ebx
ja 0x844e0
movq (%rbp,%r13,8), %rsi
leaq 0x2c5d6(%rip), %rdx     # 0xb0aa3
leaq 0x2c7e5(%rip), %rcx     # 0xb0cb9
leaq 0x10(%rsp), %rdi
xorl %eax, %eax
callq 0x41b0
leaq 0x2c5dd(%rip), %rdx     # 0xb0ac4
leaq 0x10(%rsp), %rcx
movq %r14, %rdi
movl %ebx, %esi
callq 0x7d316
leaq 0x2c72d(%rip), %rdx     # 0xb0c2a
leaq 0x2c729(%rip), %rcx     # 0xb0c2d
movq %r14, %rdi
movl %ebx, %esi
callq 0x7d316
movl 0x1bc(%r12), %r8d
decl %r8d
leaq 0x2c494(%rip), %rdx     # 0xb09b4
movq %r14, %rdi
movl %ebx, %esi
xorl %ecx, %ecx
movl $0x1, %r9d
callq 0x7e3dc
cmpl $0x5, %ebx
movq 0x8(%rsp), %r15
ja 0x8455b
movq (%rbp,%r13,8), %rsi
leaq 0x23a09(%rip), %rdx     # 0xa7f51
leaq 0x2c465(%rip), %rcx     # 0xb09b4
leaq 0x10(%rsp), %rdi
xorl %eax, %eax
callq 0x41b0
leaq 0x2c450(%rip), %rdx     # 0xb09b2
leaq 0x10(%rsp), %rcx
movq %r14, %rdi
movl %ebx, %esi
callq 0x7d316
cmpl $0x5, %ebx
ja 0x845a2
leaq 0x4f773(%rip), %rax     # 0xd3cf0
movq (%rax,%r13,8), %rsi
leaq 0x2bbd0(%rip), %rdx     # 0xb0158
leaq 0x2c72a(%rip), %rcx     # 0xb0cb9
leaq 0x2c41e(%rip), %r8      # 0xb09b4
leaq 0x10(%rsp), %rdi
xorl %eax, %eax
callq 0x41b0
leaq 0x2c2ed(%rip), %rdx     # 0xb0896
leaq 0x10(%rsp), %rcx
movq %r14, %rdi
movl %ebx, %esi
callq 0x7d316
cmpl $0x5, %ebx
ja 0x845dc
movq (%rbp,%r13,8), %rsi
leaq 0x2c335(%rip), %rdx     # 0xb08fe
leaq 0x2c3e4(%rip), %rcx     # 0xb09b4
leaq 0x10(%rsp), %rdi
xorl %eax, %eax
callq 0x41b0
leaq 0x2c3e5(%rip), %rdx     # 0xb09c8
leaq 0x10(%rsp), %rcx
movq %r14, %rdi
movl %ebx, %esi
callq 0x7d316
leaq 0x2c3bb(%rip), %rdx     # 0xb09b4
movq %r14, %rdi
movl %ebx, %esi
callq 0x7de42
movl 0x4(%rsp), %ecx
movq %r14, %rdi
movl %ebx, %esi
movq %r15, %rdx
callq 0x7dbeb
leaq 0x24910(%rip), %rsi     # 0xa8f2b
leaq 0x2c390(%rip), %rdx     # 0xb09b2
leaq 0x2c5ec(%rip), %rcx     # 0xb0c15
leaq 0x7a130(%rsp), %r12
movl %ebx, %edi
movq %r12, %r8
callq 0x7df46
movq %r14, %rdi
movl %ebx, %esi
movq %r12, %rdx
callq 0x7e093
leaq 0x2c5db(%rip), %rdx     # 0xb0c2a
leaq 0x2c5e0(%rip), %rcx     # 0xb0c36
movq %r14, %rdi
movl %ebx, %esi
callq 0x7d316
movq %r14, %rdi
movl %ebx, %esi
callq 0x7e23a
cmpl $0x3, %ebx
ja 0x8468d
cmpl $0x2, %ebx
je 0x8468d
leaq 0x2bdbe(%rip), %rdi     # 0xb0439
movl $0x7, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x42c0
movq %r14, %rdi
movl %ebx, %esi
callq 0x7deaa
movq %r14, %rdi
movl %ebx, %esi
callq 0x7e686
leaq 0x2cac6(%rip), %rdx     # 0xb116e
leaq 0x2c57b(%rip), %rcx     # 0xb0c2a
leaq 0x2c551(%rip), %r8      # 0xb0c07
leaq 0x2c3ed(%rip), %r12     # 0xb0aaa
movq %r14, %rdi
movl %ebx, %esi
movq %r12, %r9
callq 0x80365
movq %r14, %rdi
movl %ebx, %esi
callq 0x7e686
leaq 0x256a1(%rip), %rsi     # 0xa9d7c
movq %r14, %rdi
movl %ebx, %edx
movq %r12, %rcx
callq 0x7d912
movq %r14, %rdi
movl %ebx, %esi
callq 0x7db1b
movq %r15, %rdi
callq 0x3a180
addq $0xf4258, %rsp          # imm = 0xF4258
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq