// File: /workspace/github_c_makefile_star2_O3/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 0x30309
movl %eax, 0x4(%rsp)
movl 0x1bc(%r15), %edx
leaq 0x279c6(%rip), %rsi     # 0xa9cf7
movq %r14, %rdi
movl %ebx, %ecx
callq 0x7ce21
movl %ebx, %ebp
cmpl $0x2, %ebx
movq %rbp, 0x8(%rsp)
jne 0x823bd
leaq 0x2df4f(%rip), %rdi     # 0xb029d
movl $0x6, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x42c0
movl 0x1bc(%r15), %r8d
leaq 0x2f51d(%rip), %rcx     # 0xb188b
leaq 0x32fc33(%rip), %r9     # 0x3b1fa8
movq %r14, %rdi
movl $0x2, %esi
movq %r15, %rdx
callq 0x7e724
movl 0x1bc(%r15), %r8d
leaq 0x24091(%rip), %rcx     # 0xa6424
leaq 0x32fc3e(%rip), %r9     # 0x3b1fd8
movq %r14, %rdi
movl $0x2, %esi
movq %r15, %rdx
callq 0x7e724
movl 0x1407128(%r15), %ecx
leaq 0x2dec7(%rip), %rsi     # 0xb027f
jmp 0x82459
movl 0x1bc(%r15), %r8d
leaq 0x2f4c0(%rip), %rcx     # 0xb188b
leaq 0x32fbd6(%rip), %r9     # 0x3b1fa8
movq %r14, %rdi
movl %ebx, %esi
movq %r15, %rdx
callq 0x7e724
movl 0x1bc(%r15), %r8d
leaq 0x24037(%rip), %rcx     # 0xa6424
leaq 0x32fbe4(%rip), %r9     # 0x3b1fd8
movq %r14, %rdi
movl %ebx, %esi
movq %r15, %rdx
callq 0x7e724
cmpl $0x5, %ebx
ja 0x82426
movl 0x1407128(%r15), %ecx
leaq 0x2dc00(%rip), %rax     # 0xb0014
movslq (%rax,%rbp,4), %rdx
addq %rax, %rdx
jmpq *%rdx
leaq 0x2de55(%rip), %rsi     # 0xb0279
jmp 0x82459
movl 0x1bc(%r15), %r9d
subq $0x8, %rsp
leaq 0x2dd20(%rip), %rcx     # 0xb0158
movq %r14, %rdi
movl %ebx, %esi
movq %r15, %rdx
movl 0xc(%rsp), %r8d
pushq %r13
callq 0x7ebcd
addq $0x10, %rsp
jmp 0x824b2
leaq 0x2de30(%rip), %rsi     # 0xb0289
leaq 0x2e71d(%rip), %rdx     # 0xb0b7d
movq %r14, %rdi
xorl %eax, %eax
callq 0x42e0
movl 0x1bc(%r15), %r9d
subq $0x8, %rsp
leaq 0x2dcdc(%rip), %rcx     # 0xb0158
movq %r14, %rdi
movl %ebx, %esi
movq %r15, %rdx
movl 0xc(%rsp), %r8d
pushq %r13
callq 0x7ebcd
addq $0x10, %rsp
cmpl $0x2, %ebx
jne 0x824b2
leaq 0x2de60(%rip), %rdi     # 0xb0300
movl $0x4, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x42c0
leaq 0x2a613(%rip), %r10     # 0xacacc
leaq 0x2e6c5(%rip), %r11     # 0xb0b85
leaq 0x2e5e3(%rip), %r13     # 0xb0aaa
leaq 0x2e8b4(%rip), %rbp     # 0xb0d82
leaq 0x2e7e4(%rip), %r8      # 0xb0cb9
leaq 0x2e4d8(%rip), %r9      # 0xb09b4
movq %r14, %rdi
movl %ebx, %esi
xorl %edx, %edx
movl $0x6, %ecx
xorl %eax, %eax
pushq %r10
pushq %r11
pushq %r13
pushq %rbp
callq 0x7d617
addq $0x18, %rsp
leaq 0x2e4c7(%rip), %r10     # 0xb09c8
leaq 0x2e7a5(%rip), %r8      # 0xb0cad
leaq 0x2e387(%rip), %r9      # 0xb0896
movq %r14, %rdi
movl %ebx, %esi
movl $0x1, %edx
movl $0x3, %ecx
xorl %eax, %eax
pushq %r10
callq 0x7d617
addq $0x10, %rsp
movl 0x10(%r15), %r10d
movl 0x1bc(%r15), %r11d
subq $0x8, %rsp
leaq 0x2e343(%rip), %rbp     # 0xb0884
leaq 0x23e7d(%rip), %r13     # 0xa63c5
leaq 0x2e376(%rip), %r8      # 0xb08c5
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 0x2e358(%rip), %r11     # 0xb08d5
pushq %r11
pushq %r10
callq 0x7d384
addq $0x50, %rsp
cmpl $0x2, %ebx
jne 0x825a8
leaq 0x2db7a(%rip), %rdi     # 0xb0110
movl $0x6, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x42c0
incl 0x32fc3a(%rip)          # 0x3b21e8
movq %r14, %rdi
movl %ebx, %esi
movq %r15, %rdx
callq 0x80ac7
movl 0x10(%r15), %ecx
leaq 0x23dff(%rip), %rdx     # 0xa63c5
leaq 0x23bdc(%rip), %r8      # 0xa61a9
movq %r14, %rdi
movl %ebx, %esi
callq 0x7ee51
leaq 0x2e2e7(%rip), %rdx     # 0xb08c5
leaq 0x2e62c(%rip), %r8      # 0xb0c11
movq %r14, %rdi
movl %ebx, %esi
movl %r12d, %ecx
callq 0x7ee51
leaq 0x2e2dc(%rip), %rdx     # 0xb08d5
leaq 0x2a07f(%rip), %r8      # 0xac67f
movq %r14, %rdi
movl %ebx, %esi
movl %r12d, %ecx
callq 0x7ee51
movq %r14, %rdi
movl %ebx, %esi
movq %r15, %rdx
movl 0x4(%rsp), %ecx
movl %r12d, %r8d
callq 0x7f0f5
decl %r12d
leaq 0x2e68e(%rip), %rdx     # 0xb0cb9
movq %r14, %rdi
movl %ebx, %esi
xorl %ecx, %ecx
movl %r12d, %r8d
movl $0x1, %r9d
callq 0x7e3dc
cmpl $0x5, %ebx
movq 0x8(%rsp), %r12
ja 0x8266f
leaq 0x5172f(%rip), %rax     # 0xd3d80
movq (%rax,%r12,8), %rsi
leaq 0x2e279(%rip), %rdx     # 0xb08d5
leaq 0x2e656(%rip), %rcx     # 0xb0cb9
leaq 0x10(%rsp), %rdi
xorl %eax, %eax
callq 0x41b0
leaq 0x2e33e(%rip), %rdx     # 0xb09b4
leaq 0x10(%rsp), %rcx
movq %r14, %rdi
movl %ebx, %esi
callq 0x7d316
cmpl $0x5, %ebx
ja 0x826b6
leaq 0x5165f(%rip), %rax     # 0xd3cf0
movq (%rax,%r12,8), %rsi
leaq 0x2dabc(%rip), %rdx     # 0xb0158
leaq 0x2e311(%rip), %rcx     # 0xb09b4
leaq 0x2e4d3(%rip), %r8      # 0xb0b7d
leaq 0x10(%rsp), %rdi
xorl %eax, %eax
callq 0x41b0
leaq 0x2e6c5(%rip), %r12     # 0xb0d82
leaq 0x10(%rsp), %rcx
movq %r14, %rdi
movl %ebx, %esi
movq %r12, %rdx
callq 0x7d316
leaq 0x23cef(%rip), %rbp     # 0xa63c5
movq %r14, %rdi
movl %ebx, %esi
movq %rbp, %rdx
movq %r12, %rcx
callq 0x80495
movq %r14, %rdi
movl %ebx, %esi
callq 0x7e686
movl 0x10(%r15), %ecx
leaq 0x2ea73(%rip), %rax     # 0xb116e
leaq 0x29f7d(%rip), %r8      # 0xac67f
leaq 0x2e47c(%rip), %r9      # 0xb0b85
movq %r14, %rdi
movl %ebx, %esi
movq %rbp, %rdx
pushq %rax
leaq 0x2e391(%rip), %r15     # 0xb0aaa
pushq %r15
callq 0x803e7
addq $0x10, %rsp
leaq 0x275cc(%rip), %rsi     # 0xa9cf7
movq %r14, %rdi
movl %ebx, %edx
movq %r15, %rcx
callq 0x7d912
movq %r14, %rdi
movl %ebx, %esi
callq 0x7db1b
addq $0x7a138, %rsp          # imm = 0x7A138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq