// File: /workspace/github_c_makefile_star2_O1/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, %r13
movl %ecx, %r12d
movq %rdx, %r15
movl %esi, %ebx
movq %rdi, %r14
movq %r8, %rdi
callq 0x2fa14
movl %eax, %ebp
movl 0x1bc(%r15), %edx
leaq 0x26afe(%rip), %rsi     # 0xa6c87
movq %r14, %rdi
movl %ebx, %ecx
callq 0x7b551
cmpl $0x2, %ebx
movl %ebp, 0xc(%rsp)
jne 0x8025b
leaq 0x2d05e(%rip), %rdi     # 0xad205
movl $0x6, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x42c0
movl 0x1bc(%r15), %r8d
leaq 0x2e634(%rip), %rcx     # 0xae7fb
leaq 0x32edda(%rip), %r9     # 0x3aefa8
movq %r14, %rdi
movl %ebx, %esi
movq %r15, %rdx
callq 0x7cde7
movl 0x1bc(%r15), %r8d
leaq 0x2323b(%rip), %rcx     # 0xa3424
leaq 0x32ede8(%rip), %r9     # 0x3aefd8
movq %r14, %rdi
movl %ebx, %esi
movq %r15, %rdx
callq 0x7cde7
movl 0x1407128(%r15), %ecx
leaq 0x2d8da(%rip), %rdx     # 0xadae5
movq %r14, %rdi
movl %ebx, %esi
callq 0x7ba0a
movl 0x1bc(%r15), %r9d
subq $0x8, %rsp
leaq 0x2ce99(%rip), %rcx     # 0xad0c0
movq %r14, %rdi
movl %ebx, %esi
movq %r15, %rdx
movl %ebp, %r8d
pushq %r13
callq 0x7d214
addq $0x10, %rsp
leaq 0x2d024(%rip), %rdi     # 0xad268
movl $0x4, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x42c0
jmp 0x802df
movl 0x1bc(%r15), %r8d
leaq 0x2e592(%rip), %rcx     # 0xae7fb
leaq 0x32ed38(%rip), %r9     # 0x3aefa8
movq %r14, %rdi
movl %ebx, %esi
movq %r15, %rdx
callq 0x7cde7
movl 0x1bc(%r15), %r8d
leaq 0x23199(%rip), %rcx     # 0xa3424
leaq 0x32ed46(%rip), %r9     # 0x3aefd8
movq %r14, %rdi
movl %ebx, %esi
movq %r15, %rdx
callq 0x7cde7
movl 0x1407128(%r15), %ecx
leaq 0x2d838(%rip), %rdx     # 0xadae5
movq %r14, %rdi
movl %ebx, %esi
callq 0x7ba0a
movl 0x1bc(%r15), %r9d
subq $0x8, %rsp
leaq 0x2cdf7(%rip), %rcx     # 0xad0c0
movq %r14, %rdi
movl %ebx, %esi
movq %r15, %rdx
movl %ebp, %r8d
pushq %r13
callq 0x7d214
addq $0x10, %rsp
leaq 0x2971a(%rip), %r10     # 0xa9a00
leaq 0x2d800(%rip), %r11     # 0xadaed
leaq 0x2d71e(%rip), %r13     # 0xada12
leaq 0x2d9ef(%rip), %rbp     # 0xadcea
leaq 0x2d91f(%rip), %r8      # 0xadc21
leaq 0x2d613(%rip), %r9      # 0xad91c
movq %r14, %rdi
movl %ebx, %esi
xorl %edx, %edx
movl $0x6, %ecx
xorl %eax, %eax
pushq %r10
pushq %r11
pushq %r13
pushq %rbp
callq 0x7bd1c
addq $0x18, %rsp
leaq 0x2d602(%rip), %r10     # 0xad930
leaq 0x2d8e0(%rip), %r8      # 0xadc15
leaq 0x2d4c2(%rip), %r9      # 0xad7fe
movq %r14, %rdi
movl %ebx, %esi
movl $0x1, %edx
movl $0x3, %ecx
xorl %eax, %eax
pushq %r10
callq 0x7bd1c
addq $0x10, %rsp
movl 0x10(%r15), %r10d
movl 0x1bc(%r15), %r11d
subq $0x8, %rsp
leaq 0x2d47e(%rip), %rbp     # 0xad7ec
leaq 0x23050(%rip), %r13     # 0xa33c5
leaq 0x2d4b1(%rip), %r8      # 0xad82d
movq %r14, %rdi
movl %ebx, %esi
movl $0x4, %edx
movl $0x1, %ecx
movl %r12d, %r9d
movl $0x0, %eax
pushq %r11
pushq %rbp
pushq $0x1
pushq %r10
pushq %r13
xorl %r10d, %r10d
pushq %r10
pushq %r12
leaq 0x2d493(%rip), %r11     # 0xad83d
pushq %r11
pushq %r10
callq 0x7bab4
addq $0x50, %rsp
cmpl $0x2, %ebx
jne 0x803d5
leaq 0x2ccb5(%rip), %rdi     # 0xad078
movl $0x6, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x42c0
incl 0x32ee0d(%rip)          # 0x3af1e8
movq %r14, %rdi
movl %ebx, %esi
movq %r15, %rdx
callq 0x7ec45
movl 0x10(%r15), %ecx
leaq 0x22fd2(%rip), %rdx     # 0xa33c5
leaq 0x22daf(%rip), %r8      # 0xa31a9
movq %r14, %rdi
movl %ebx, %esi
callq 0x7d402
leaq 0x2d422(%rip), %rdx     # 0xad82d
leaq 0x2d767(%rip), %r8      # 0xadb79
movq %r14, %rdi
movl %ebx, %esi
movl %r12d, %ecx
callq 0x7d402
leaq 0x2d417(%rip), %rbp     # 0xad83d
leaq 0x29186(%rip), %r8      # 0xa95b3
movq %r14, %rdi
movl %ebx, %esi
movq %rbp, %rdx
movl %r12d, %ecx
callq 0x7d402
movq %r14, %rdi
movl %ebx, %esi
movq %r15, %rdx
movl 0xc(%rsp), %ecx
movl %r12d, %r8d
callq 0x7d66d
decl %r12d
leaq 0x2d7c6(%rip), %r13     # 0xadc21
movq %r14, %rdi
movl %ebx, %esi
movq %r13, %rdx
xorl %ecx, %ecx
movl %r12d, %r8d
movl $0x1, %r9d
callq 0x7ca9f
leaq 0x10(%rsp), %r12
movq %r12, %rdi
movl %ebx, %esi
movq %rbp, %rdx
movq %r13, %rcx
callq 0x7c24c
leaq 0x2d48d(%rip), %r13     # 0xad91c
movq %r14, %rdi
movl %ebx, %esi
movq %r13, %rdx
movq %r12, %rcx
callq 0x7ba46
leaq 0x2cc1a(%rip), %rdx     # 0xad0c0
leaq 0x2d638(%rip), %r8      # 0xadae5
movq %r12, %rdi
movl %ebx, %esi
movq %r13, %rcx
callq 0x7c269
leaq 0x2d829(%rip), %r13     # 0xadcea
movq %r14, %rdi
movl %ebx, %esi
movq %r13, %rdx
movq %r12, %rcx
callq 0x7ba46
movq %r14, %rdi
movl %ebx, %esi
leaq 0x22ee8(%rip), %r12     # 0xa33c5
movq %r12, %rdx
movq %r13, %rcx
callq 0x7e731
movq %r14, %rdi
movl %ebx, %esi
callq 0x7cd49
movl 0x10(%r15), %ecx
leaq 0x2dbd9(%rip), %rax     # 0xae0d6
leaq 0x2d5e9(%rip), %r9      # 0xadaed
movq %r14, %rdi
movl %ebx, %esi
movq %r12, %rdx
leaq 0x290a0(%rip), %r8      # 0xa95b3
pushq %rax
leaq 0x2d4f7(%rip), %r15     # 0xada12
pushq %r15
callq 0x7e698
addq $0x10, %rsp
leaq 0x2675a(%rip), %rsi     # 0xa6c87
movq %r14, %rdi
movl %ebx, %edx
movq %r15, %rcx
callq 0x7bffb
movq %r14, %rdi
movl %ebx, %esi
callq 0x7c1ca
addq $0x7a138, %rsp          # imm = 0x7A138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq