// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x7a198, %rsp          # imm = 0x7A198
movq %rdi, -0x20(%rbp)
movl %esi, -0x24(%rbp)
movq %rdx, -0x30(%rbp)
movl %ecx, -0x34(%rbp)
movq %r8, -0x40(%rbp)
movq -0x40(%rbp), %rdi
callq 0x449f0
movl %eax, -0x7a164(%rbp)
movq -0x20(%rbp), %rdi
movq -0x30(%rbp), %rax
movl 0x1bc(%rax), %edx
movl -0x24(%rbp), %ecx
leaq 0x31966(%rip), %rsi     # 0xe683f
callq 0xaf1e0
movq -0x20(%rbp), %rdi
movl -0x24(%rbp), %esi
callq 0xaf9c0
movq -0x20(%rbp), %rdi
movl -0x24(%rbp), %esi
movq -0x30(%rbp), %rdx
movq -0x30(%rbp), %rax
movl 0x1bc(%rax), %r8d
leaq 0x2e193(%rip), %rcx     # 0xe309a
leaq 0x32d06a(%rip), %r9     # 0x3e1f78
callq 0xb14a0
movq -0x20(%rbp), %rdi
movl -0x24(%rbp), %esi
movq -0x30(%rbp), %rdx
movq -0x30(%rbp), %rax
movl 0x1bc(%rax), %r8d
leaq 0x2e174(%rip), %rcx     # 0xe30a4
leaq 0x32d071(%rip), %r9     # 0x3e1fa8
callq 0xb14a0
movq -0x20(%rbp), %rdi
movl -0x24(%rbp), %esi
movq -0x30(%rbp), %rax
movl 0x1407128(%rax), %ecx
leaq 0x38299(%rip), %rdx     # 0xed1ed
callq 0xaf920
movq -0x20(%rbp), %rdi
movl -0x24(%rbp), %esi
movq -0x30(%rbp), %rdx
movl -0x7a164(%rbp), %r8d
movq -0x30(%rbp), %rax
movl 0x1bc(%rax), %r9d
movq -0x40(%rbp), %rax
leaq 0x37847(%rip), %rcx     # 0xec7c8
movq %rax, (%rsp)
callq 0xb1b30
movq -0x20(%rbp), %rdi
movl -0x24(%rbp), %esi
callq 0xb00e0
movq -0x20(%rbp), %rdi
movl -0x24(%rbp), %esi
xorl %edx, %edx
movl $0x6, %ecx
leaq 0x3837e(%rip), %r8      # 0xed329
leaq 0x38072(%rip), %r9      # 0xed024
leaq 0x38439(%rip), %rbx     # 0xed3f2
leaq 0x3815a(%rip), %r11     # 0xed11a
leaq 0x3822e(%rip), %r10     # 0xed1f5
leaq 0x34687(%rip), %rax     # 0xe9655
movq %rbx, (%rsp)
movq %r11, 0x8(%rsp)
movq %r10, 0x10(%rsp)
movq %rax, 0x18(%rsp)
movb $0x0, %al
callq 0xafe40
movq -0x20(%rbp), %rdi
movl -0x24(%rbp), %esi
movl $0x1, %edx
movl $0x3, %ecx
leaq 0x3831d(%rip), %r8      # 0xed31d
leaq 0x37eff(%rip), %r9      # 0xecf06
leaq 0x3802a(%rip), %rax     # 0xed038
movq %rax, (%rsp)
movb $0x0, %al
callq 0xafe40
movq -0x20(%rbp), %rdi
movl -0x24(%rbp), %esi
movl -0x34(%rbp), %r9d
movl -0x34(%rbp), %r14d
movq -0x30(%rbp), %rax
movl 0x10(%rax), %r11d
movq -0x30(%rbp), %rax
movl 0x1bc(%rax), %eax
movl $0x4, %edx
movl $0x1, %ecx
leaq 0x37eea(%rip), %r8      # 0xecf35
xorl %r10d, %r10d
leaq 0x37ef0(%rip), %r15     # 0xecf45
leaq 0x2dfe9(%rip), %rbx     # 0xe3045
leaq 0x37e91(%rip), %r10     # 0xecef4
movl $0x0, (%rsp)
movq %r15, 0x8(%rsp)
movl %r14d, 0x10(%rsp)
movl $0x0, 0x18(%rsp)
movq %rbx, 0x20(%rsp)
movl %r11d, 0x28(%rsp)
movl $0x1, 0x30(%rsp)
movq %r10, 0x38(%rsp)
movl %eax, 0x40(%rsp)
movb $0x0, %al
callq 0xafab0
movq -0x20(%rbp), %rdi
movl -0x24(%rbp), %esi
callq 0xaf2c0
movq -0x20(%rbp), %rdi
movl -0x24(%rbp), %esi
movq -0x30(%rbp), %rdx
callq 0xb3a50
movq -0x20(%rbp), %rdi
movl -0x24(%rbp), %esi
movq -0x30(%rbp), %rax
movl 0x10(%rax), %ecx
leaq 0x2df76(%rip), %rdx     # 0xe3045
leaq 0x381b1(%rip), %r8      # 0xed287
callq 0xb1e60
movq -0x20(%rbp), %rdi
movl -0x24(%rbp), %esi
movl -0x34(%rbp), %ecx
leaq 0x37e49(%rip), %rdx     # 0xecf35
leaq 0x3818e(%rip), %r8      # 0xed281
callq 0xb1e60
movq -0x20(%rbp), %rdi
movl -0x24(%rbp), %esi
movl -0x34(%rbp), %ecx
leaq 0x37e3c(%rip), %rdx     # 0xecf45
leaq 0x340f8(%rip), %r8      # 0xe9208
callq 0xb1e60
movq -0x20(%rbp), %rdi
movl -0x24(%rbp), %esi
movq -0x30(%rbp), %rdx
movl -0x7a164(%rbp), %ecx
movl -0x34(%rbp), %r8d
callq 0xb2100
movq -0x20(%rbp), %rdi
movl -0x24(%rbp), %esi
movl -0x34(%rbp), %r8d
subl $0x1, %r8d
leaq 0x381e4(%rip), %rdx     # 0xed329
xorl %ecx, %ecx
movl $0x1, %r9d
callq 0xb10b0
leaq -0x7a160(%rbp), %rdi
movl -0x24(%rbp), %esi
leaq 0x37de2(%rip), %rdx     # 0xecf45
leaq 0x381bf(%rip), %rcx     # 0xed329
callq 0xb04c0
movq -0x20(%rbp), %rdi
movl -0x24(%rbp), %esi
leaq -0x7a160(%rbp), %rcx
leaq 0x37ea0(%rip), %rdx     # 0xed024
callq 0xafa00
leaq -0x7a160(%rbp), %rdi
movl -0x24(%rbp), %esi
leaq 0x3762e(%rip), %rdx     # 0xec7c8
leaq 0x37e83(%rip), %rcx     # 0xed024
leaq 0x38045(%rip), %r8      # 0xed1ed
callq 0xb0560
movq -0x20(%rbp), %rdi
movl -0x24(%rbp), %esi
leaq -0x7a160(%rbp), %rcx
leaq 0x38230(%rip), %rdx     # 0xed3f2
callq 0xafa00
movq -0x20(%rbp), %rdi
movl -0x24(%rbp), %esi
leaq 0x2de70(%rip), %rdx     # 0xe3045
leaq 0x38216(%rip), %rcx     # 0xed3f2
callq 0xb3500
movq -0x20(%rbp), %rdi
movl -0x24(%rbp), %esi
leaq 0x3813a(%rip), %rdx     # 0xed329
callq 0xb13f0
movq -0x20(%rbp), %rdi
movl -0x24(%rbp), %esi
movq -0x30(%rbp), %rax
movl 0x10(%rax), %ecx
leaq 0x2de3c(%rip), %rdx     # 0xe3045
leaq 0x33ff8(%rip), %r8      # 0xe9208
leaq 0x37fde(%rip), %r9      # 0xed1f5
leaq 0x37efc(%rip), %r10     # 0xed11a
leaq 0x385b9(%rip), %rax     # 0xed7de
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
callq 0xb3440
movq -0x20(%rbp), %rdi
movl -0x24(%rbp), %edx
leaq 0x315fe(%rip), %rsi     # 0xe683f
leaq 0x37ed2(%rip), %rcx     # 0xed11a
callq 0xb01f0
movq -0x20(%rbp), %rdi
movl -0x24(%rbp), %esi
callq 0xb03a0
addq $0x7a198, %rsp          # imm = 0x7A198
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nopw (%rax,%rax)