// File: /workspace/github_c_makefile_star2_O2/olcaytaner[P]Isell/savecode.c
// Function: generate_test_code_knn
void generate_test_code_knn(FILE* testcodefile, PROGRAMMING_LANGUAGE_TYPE language, Datasetptr d, int nearcount, Instanceptr m)
{
 /*!Last Changed 25.06.2006 added code_increment*/
 /*!Last Changed 13.06.2006*/
 char st[MAXLENGTH];
 int size = data_size(m);
 code_function_header(testcodefile, "knn", d->featurecount, language);
 code_constant_start(testcodefile, language);
	code_1d_array_constant_instance(testcodefile, language, d, "mean", d->featurecount, &mean);
	code_1d_array_constant_instance(testcodefile, language, d, "variance", d->featurecount, &variance);
 code_constant_integer(testcodefile, language, "classno", d->classdefno);
 code_2d_array_constant_instance(testcodefile, language, d, "m", size, d->featurecount, m);
 code_variable_start(testcodefile, language);
 code_add_variable(testcodefile, language, INTEGER_VARIABLE, 6, "i", "j", "k", "maxindex", "maxcount", "count");
 code_add_variable(testcodefile, language, REAL_VARIABLE, 3, "sum", "m_ij", "x_j");
 code_add_array_variable(testcodefile, language, 4, REAL_VARIABLE, "distances", nearcount, INTEGER_VARIABLE, "indexes", nearcount, INTEGER_VARIABLE, "class_counts", d->classno, REAL_VARIABLE, "testdataconverted", d->featurecount);
 code_start(testcodefile, language); 
 code_normalize(testcodefile, language, d);
 code_array_initialize(testcodefile, language, "class_counts", d->classno, "0");
 code_array_initialize(testcodefile, language, "distances", nearcount, "10000.0");
 code_array_initialize(testcodefile, language, "indexes", nearcount, "-1");
 code_sort_according_to_distances(testcodefile, language, d, size, nearcount);
 code_for(testcodefile, language, "i", 0, nearcount - 1, 1);     
 code_array_index_variable(st, language, "indexes", "i");  
 code_set_variable(testcodefile, language, "j", st); 
 code_2d_array_index_variable(st, language, "m", "j", "classno");
 code_set_variable(testcodefile, language, "k", st);
	code_increment(testcodefile, language, "class_counts", "k");
 code_endfor(testcodefile, language, "i");
 code_find_bound_of_list(testcodefile, language, "class_counts", d->classno, "-1", "maxcount", "maxindex", ">");
 code_function_return_string(testcodefile, "knn", language, "maxindex");   
 code_function_end(testcodefile, language);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x7a138, %rsp          # imm = 0x7A138
movq %r8, %r15
movl %ecx, %r13d
movq %rdx, %r12
movl %esi, %ebx
movq %rdi, %r14
movq %r8, %rdi
callq 0x2c3cc
movl %eax, %ebp
movl %eax, 0xc(%rsp)
movl 0x1bc(%r12), %edx
leaq 0x23352(%rip), %rsi     # 0x99c1f
movq %r14, %rdi
movl %ebx, %ecx
callq 0x72674
movq %r14, %rdi
movl %ebx, %esi
callq 0x72b0a
movl 0x1bc(%r12), %r8d
leaq 0x2aefb(%rip), %rcx     # 0xa17eb
leaq 0x3336b1(%rip), %r9     # 0x3a9fa8
movq %r14, %rdi
movl %ebx, %esi
movq %r12, %rdx
callq 0x73bdf
movl 0x1bc(%r12), %r8d
leaq 0x1fb11(%rip), %rcx     # 0x96424
leaq 0x3336be(%rip), %r9     # 0x3a9fd8
movq %r14, %rdi
movl %ebx, %esi
movq %r12, %rdx
callq 0x73bdf
movl 0x1407128(%r12), %ecx
leaq 0x2a1ab(%rip), %rdx     # 0xa0ae1
movq %r14, %rdi
movl %ebx, %esi
callq 0x72aed
movl 0x1bc(%r12), %r9d
subq $0x8, %rsp
leaq 0x29769(%rip), %rcx     # 0xa00bc
movq %r14, %rdi
movl %ebx, %esi
movq %r12, %rdx
movl %ebp, %r8d
pushq %r15
callq 0x74003
popq %rax
popq %rcx
movq %r14, %rdi
movl %ebx, %esi
callq 0x72fb3
leaq 0x26078(%rip), %r10     # 0x9c9f0
leaq 0x2a16a(%rip), %r15     # 0xa0ae9
leaq 0x2a088(%rip), %r11     # 0xa0a0e
leaq 0x2a359(%rip), %rbp     # 0xa0ce6
leaq 0x2a289(%rip), %r8      # 0xa0c1d
leaq 0x29f7d(%rip), %r9      # 0xa0918
pushq $0x6
popq %rcx
movq %r14, %rdi
movl %ebx, %esi
xorl %edx, %edx
xorl %eax, %eax
pushq %r10
pushq %r15
pushq %r11
pushq %rbp
callq 0x72de1
addq $0x18, %rsp
leaq 0x29f6e(%rip), %r10     # 0xa092c
leaq 0x2a24c(%rip), %r8      # 0xa0c11
leaq 0x29e2e(%rip), %r9      # 0xa07fa
pushq $0x1
popq %rbp
pushq $0x3
popq %rcx
movq %r14, %rdi
movl %ebx, %esi
movl %ebp, %edx
xorl %eax, %eax
pushq %r10
callq 0x72de1
popq %rax
popq %rcx
movl 0x10(%r12), %r10d
movl 0x1bc(%r12), %r11d
subq $0x8, %rsp
leaq 0x1f9c9(%rip), %r15     # 0x963c5
leaq 0x29e26(%rip), %r8      # 0xa0829
pushq $0x4
popq %rdx
movq %r14, %rdi
movl %ebx, %esi
movl %ebp, %ecx
movl %r13d, %r9d
movl $0x0, %eax
pushq %r11
leaq 0x29dca(%rip), %r11     # 0xa07e8
pushq %r11
pushq $0x1
pushq %r10
pushq %r15
pushq $0x0
pushq %r13
leaq 0x29e08(%rip), %rbp     # 0xa0839
pushq %rbp
pushq $0x0
callq 0x72b76
addq $0x50, %rsp
movq %r14, %rdi
movl %ebx, %esi
callq 0x726d3
movq %r14, %rdi
movl %ebx, %esi
movq %r12, %rdx
callq 0x75838
movl 0x10(%r12), %ecx
leaq 0x1f751(%rip), %r8      # 0x961b1
movq %r14, %rdi
movl %ebx, %esi
movq %r15, %rdx
callq 0x741f5
leaq 0x2a101(%rip), %r8      # 0xa0b75
movq %r14, %rdi
movl %ebx, %esi
leaq 0x29da9(%rip), %rdx     # 0xa0829
movl %r13d, %ecx
callq 0x741f5
leaq 0x25b14(%rip), %r8      # 0x9c5a3
movq %r14, %rdi
movl %ebx, %esi
movq %rbp, %rdx
movl %r13d, %ecx
callq 0x741f5
movq %r14, %rdi
movl %ebx, %esi
movq %r12, %rdx
movl 0xc(%rsp), %ecx
movl %r13d, %r8d
callq 0x74411
decl %r13d
movq %r14, %rdi
movl %ebx, %esi
leaq 0x2a15b(%rip), %rbp     # 0xa0c1d
movq %rbp, %rdx
xorl %ecx, %ecx
movl %r13d, %r8d
pushq $0x1
popq %r9
callq 0x73938
leaq 0x10(%rsp), %r15
movq %r15, %rdi
movl %ebx, %esi
leaq 0x29d55(%rip), %rdx     # 0xa0839
movq %rbp, %rcx
callq 0x7327f
movq %r14, %rdi
movl %ebx, %esi
leaq 0x29e20(%rip), %r13     # 0xa0918
movq %r13, %rdx
movq %r15, %rcx
callq 0x72b25
movq %r15, %rdi
movl %ebx, %esi
leaq 0x295ad(%rip), %rdx     # 0xa00bc
movq %r13, %rcx
leaq 0x29fc8(%rip), %r8      # 0xa0ae1
callq 0x7329c
movq %r14, %rdi
movl %ebx, %esi
leaq 0x2a1bc(%rip), %r13     # 0xa0ce6
movq %r13, %rdx
movq %r15, %rcx
callq 0x72b25
movq %r14, %rdi
movl %ebx, %esi
leaq 0x1f884(%rip), %r15     # 0x963c5
movq %r15, %rdx
movq %r13, %rcx
callq 0x75391
movq %r14, %rdi
movl %ebx, %esi
callq 0x73b72
movl 0x10(%r12), %ecx
leaq 0x2a570(%rip), %rax     # 0xa10d2
movq %r14, %rdi
movl %ebx, %esi
movq %r15, %rdx
leaq 0x25a32(%rip), %r8      # 0x9c5a3
leaq 0x29f71(%rip), %r9      # 0xa0ae9
pushq %rax
leaq 0x29e8e(%rip), %r15     # 0xa0a0e
pushq %r15
callq 0x752fa
popq %rax
popq %rcx
movq %r14, %rdi
leaq 0x2308c(%rip), %rsi     # 0x99c1f
movl %ebx, %edx
movq %r15, %rcx
callq 0x7308c
movq %r14, %rdi
movl %ebx, %esi
callq 0x7320f
addq $0x7a138, %rsp          # imm = 0x7A138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq