// File: /workspace/github_c_makefile_star2_O2/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 $0x7a138, %rsp          # imm = 0x7A138
movq %rcx, %r15
movq %rdx, %r13
movl %esi, %ebx
movq %rdi, %r14
leaq 0x4(%rsp), %rsi
movq %rdx, %rdi
callq 0x13efa
movq %rax, 0x8(%rsp)
movl 0x1bc(%r13), %edx
leaq 0x21df7(%rip), %rsi     # 0x99ca4
movq %r14, %rdi
movl %ebx, %ecx
callq 0x72674
movq %r14, %rdi
movl %ebx, %esi
callq 0x72b0a
movl 0x10(%r13), %ecx
movq 0x10(%r15), %r8
leaq 0x28b37(%rip), %rdx     # 0xa0a07
pushq $0x1
popq %rbp
movq %r14, %rdi
movl %ebx, %esi
movl %ebp, %r9d
callq 0x73cac
movl 0x1bc(%r13), %ecx
movq 0x8(%r15), %r8
leaq 0x1ffdf(%rip), %rdx     # 0x97ed1
movq %r14, %rdi
movl %ebx, %esi
movl %ebp, %r9d
callq 0x73cac
movl 0x10(%r13), %ecx
movl 0x1bc(%r13), %r8d
movq (%r15), %r9
leaq 0x281a8(%rip), %rdx     # 0xa00bc
movq %r14, %rdi
movl %ebx, %esi
callq 0x73ec6
movq %r14, %rdi
movl %ebx, %esi
callq 0x72fb3
subq $0x8, %rsp
leaq 0x289f9(%rip), %r12     # 0xa092c
leaq 0x289dc(%rip), %r11     # 0xa0916
leaq 0x288b9(%rip), %rbp     # 0xa07fa
leaq 0x28ae0(%rip), %r15     # 0xa0a28
leaq 0x28c3f(%rip), %r10     # 0xa0b8e
leaq 0x28cbb(%rip), %r8      # 0xa0c11
leaq 0x28c0e(%rip), %r9      # 0xa0b6b
pushq $0x7
popq %rcx
movq %r14, %rdi
movl %ebx, %esi
pushq $0x1
popq %rdx
xorl %eax, %eax
pushq %r12
pushq %r11
pushq %rbp
pushq %r15
pushq %r10
callq 0x72de1
addq $0x28, %rsp
leaq 0x28a8b(%rip), %r10     # 0xa0a0e
leaq 0x28c93(%rip), %r12     # 0xa0c1d
leaq 0x28987(%rip), %r9      # 0xa0918
pushq $0x3
popq %rcx
movq %r14, %rdi
movl %ebx, %esi
xorl %edx, %edx
movq %r12, %r8
xorl %eax, %eax
pushq %r10
callq 0x72de1
popq %rax
popq %rcx
movq %r14, %rdi
movl %ebx, %esi
callq 0x726d3
leaq 0x28bba(%rip), %rcx     # 0xa0b74
movq %r14, %rdi
movl %ebx, %esi
leaq 0x28ba5(%rip), %rdx     # 0xa0b6b
callq 0x72b25
movl 0x10(%r13), %r8d
decl %r8d
movq %r14, %rdi
movl %ebx, %esi
movq %r12, %rdx
xorl %ecx, %ecx
pushq $0x1
popq %rbp
movl %ebp, %r9d
callq 0x73938
leaq 0x10(%rsp), %r15
movq %r15, %rdi
movl %ebx, %esi
leaq 0x28a0f(%rip), %rdx     # 0xa0a07
movq %r12, %rcx
callq 0x7327f
movq %r14, %rdi
movl %ebx, %esi
leaq 0x28a1c(%rip), %rdx     # 0xa0a28
movq %r15, %rcx
callq 0x72b25
leaq 0x28b76(%rip), %rcx     # 0xa0b91
movq %r14, %rdi
movl %ebx, %esi
leaq 0x28b67(%rip), %rdx     # 0xa0b8e
callq 0x72b25
movl 0x1bc(%r13), %r8d
decl %r8d
movq %r14, %rdi
movl %ebx, %esi
leaq 0x288d6(%rip), %r12     # 0xa0918
movq %r12, %rdx
xorl %ecx, %ecx
movl %ebp, %r9d
callq 0x73938
movq %r15, %rdi
movl %ebx, %esi
leaq 0x1fe76(%rip), %rdx     # 0x97ed1
movq %r12, %rcx
callq 0x7327f
movq %r14, %rdi
movl %ebx, %esi
leaq 0x288a7(%rip), %r13     # 0xa0916
movq %r13, %rdx
movq %r15, %rcx
callq 0x72b25
movq %r15, %rdi
movl %ebx, %esi
leaq 0x28036(%rip), %rdx     # 0xa00bc
leaq 0x28b90(%rip), %rcx     # 0xa0c1d
movq %r12, %r8
callq 0x7329c
movq %r14, %rdi
movl %ebx, %esi
leaq 0x28759(%rip), %rdx     # 0xa07fa
movq %r15, %rcx
callq 0x72b25
leaq 0x287b2(%rip), %rdx     # 0xa0862
movq %r15, %rdi
movl %ebx, %esi
movq %r12, %rcx
callq 0x7327f
movq %r14, %rdi
movl %ebx, %esi
leaq 0x28863(%rip), %rdx     # 0xa092c
movq %r15, %rcx
callq 0x72b25
movq %r14, %rdi
movl %ebx, %esi
movq %r12, %rdx
callq 0x734bf
leaq 0x4(%rsp), %rax
movl (%rax), %ecx
movq %r14, %rdi
movl %ebx, %esi
movq 0x8(%rsp), %r15
movq %r15, %rdx
callq 0x732d6
leaq 0x20d9d(%rip), %rdx     # 0x98e9b
leaq 0x28a74(%rip), %r8      # 0xa0b79
movq %r14, %rdi
movl %ebx, %esi
movq %r13, %rcx
callq 0x736fc
leaq 0x28a81(%rip), %rcx     # 0xa0b9a
movq %r14, %rdi
movl %ebx, %esi
leaq 0x28a69(%rip), %r12     # 0xa0b8e
movq %r12, %rdx
callq 0x72b25
movq %r14, %rdi
movl %ebx, %esi
callq 0x737fd
movq %r14, %rdi
movl %ebx, %esi
callq 0x7349f
movq %r14, %rdi
movl %ebx, %esi
callq 0x734fe
movq %r14, %rdi
movl %ebx, %esi
callq 0x73b72
leaq 0x28f76(%rip), %rdx     # 0xa10d2
movq %r14, %rdi
movl %ebx, %esi
movq %r12, %rcx
leaq 0x28a00(%rip), %r8      # 0xa0b6b
leaq 0x2889c(%rip), %r12     # 0xa0a0e
movq %r12, %r9
callq 0x752a9
movq %r14, %rdi
movl %ebx, %esi
callq 0x73b72
movq %r14, %rdi
leaq 0x21b16(%rip), %rsi     # 0x99ca4
movl %ebx, %edx
movq %r12, %rcx
callq 0x7308c
movq %r14, %rdi
movl %ebx, %esi
callq 0x7320f
movq %r15, %rdi
callq 0x34ff7
addq $0x7a138, %rsp          # imm = 0x7A138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq