// File: /workspace/github_c_makefile_star2_O3/olcaytaner[P]Isell/savecode.c
// Function: generate_test_code_mlpgeneric
void generate_test_code_mlpgeneric(FILE* testcodefile, PROGRAMMING_LANGUAGE_TYPE language, Datasetptr d, Mlpnetworkptr m)
{
 /*!Last Changed 16.06.2006*/
 int i;
 char st[MAXLENGTH], st2[MAXLENGTH], st3[MAXLENGTH];
 code_function_header(testcodefile, "mlpgeneric", d->featurecount, language);
 code_constant_start(testcodefile, language);
	code_1d_array_constant_instance(testcodefile, language, d, "mean", d->multifeaturecount - 1, &mean);
	code_1d_array_constant_instance(testcodefile, language, d, "variance", d->multifeaturecount - 1, &variance);
 for (i = 0; i <= m->P.layernum; i++)
  {
   sprintf(st, "weights%d", i);
   code_2d_array_constant(testcodefile, language, st, m->weights[i].row, m->weights[i].col, m->weights[i].values); 
  } 
 code_variable_start(testcodefile, language);
 for (i = 0; i < m->P.layernum; i++)
  {
   sprintf(st, "hidden%d", i);
   code_add_array_variable(testcodefile, language, 1, REAL_VARIABLE, st, m->weights[i].row);
  }
 code_add_array_variable(testcodefile, language, 2, REAL_VARIABLE, "output", d->classno, REAL_VARIABLE, "testdataconverted", d->multifeaturecount);
 code_add_variable(testcodefile, language, REAL_VARIABLE, 5, "sum", "weights_ij", "x_j", "sigmoid", "maxvalue");
 code_add_variable(testcodefile, language, INTEGER_VARIABLE, 5, "i", "j", "maxindex", "k", "a");
 code_start(testcodefile, language);
	code_realize(testcodefile, language, d, YES);
 for (i = 0; i < m->P.layernum; i++)
  {
   sprintf(st, "weights%d", i);
   sprintf(st2, "hidden%d", i);
   sprintf(st3, "hidden%d", i - 1);
   if (i == 0)
     code_forward_propagation(testcodefile, language, m->weights[i].row, m->weights[i].col, st, "testdataconverted", st2, YES);
   else
     code_forward_propagation(testcodefile, language, m->weights[i].row, m->weights[i].col, st, st3, st2, YES);
  }
 if (m->P.layernum == 0)
   code_forward_propagation(testcodefile, language, m->weights[m->P.layernum].row, m->weights[m->P.layernum].col, "weights0", "testdataconverted", "output", NO);
 else
  {
   sprintf(st, "weights%d", m->P.layernum);
   sprintf(st2, "hidden%d", m->P.layernum - 1);
   code_forward_propagation(testcodefile, language, m->weights[m->P.layernum].row, m->weights[m->P.layernum].col, st, st2, "output", NO);
  }
 code_find_bound_of_list(testcodefile, language, "output", d->classno, "-10000.0", "maxvalue", "maxindex", ">");
 code_function_return_string(testcodefile, "logistic", language, "maxindex");   
 code_function_end(testcodefile, language);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x16e388, %rsp         # imm = 0x16E388
movq %rcx, %r12
movq %rdx, %rbx
movl %esi, %r14d
movq %rdi, %rbp
movl 0x1bc(%rdx), %edx
leaq 0x241d1(%rip), %rsi     # 0xa9d4b
movl %r14d, %ecx
callq 0x7ce21
cmpl $0x2, %r14d
jne 0x85ba1
leaq 0x2a70e(%rip), %rdi     # 0xb029d
movl $0x6, %esi
movl $0x1, %edx
movq %rbp, %rcx
callq 0x42c0
movl 0x1c0(%rbx), %r8d
decl %r8d
leaq 0x2bcd9(%rip), %rcx     # 0xb188b
leaq 0x32c3ef(%rip), %r9     # 0x3b1fa8
movq %rbp, %rdi
movl %r14d, %esi
movq %rbx, %rdx
callq 0x7e724
movl 0x1c0(%rbx), %r8d
decl %r8d
leaq 0x2084c(%rip), %rcx     # 0xa6424
leaq 0x32c3f9(%rip), %r9     # 0x3b1fd8
movq %rbp, %rdi
movl %r14d, %esi
movq %rbx, 0x10(%rsp)
movq %rbx, %rdx
callq 0x7e724
movl 0x5c(%r12), %eax
testl %eax, %eax
js 0x85c51
movq $-0x1, %rbx
movl $0x8, %r13d
leaq 0x20(%rsp), %r15
incq %rbx
movq %r15, %rdi
leaq 0x2b102(%rip), %rsi     # 0xb0d1c
movl %ebx, %edx
xorl %eax, %eax
callq 0x41b0
movq (%r12), %rax
movl -0x8(%rax,%r13), %ecx
movl -0x4(%rax,%r13), %r8d
movq (%rax,%r13), %r9
movq %rbp, %rdi
movl %r14d, %esi
movq %r15, %rdx
callq 0x7ea43
movslq 0x5c(%r12), %rax
addq $0x10, %r13
cmpq %rax, %rbx
jl 0x85c0d
movl %r14d, %ebx
cmpl $0x2, %r14d
jne 0x85c78
leaq 0x2a69f(%rip), %rdi     # 0xb0300
movl $0x4, %esi
movl $0x1, %edx
movq %rbp, %rcx
callq 0x42c0
movl 0x5c(%r12), %eax
testl %eax, %eax
jle 0x85ccd
leaq 0x20(%rsp), %r14
xorl %r13d, %r13d
xorl %r15d, %r15d
movq %r14, %rdi
leaq 0x2b095(%rip), %rsi     # 0xb0d26
movl %r15d, %edx
xorl %eax, %eax
callq 0x41b0
movq (%r12), %rax
movl (%rax,%r13), %r9d
movq %rbp, %rdi
movl %ebx, %esi
movl $0x1, %edx
movl $0x1, %ecx
movq %r14, %r8
xorl %eax, %eax
callq 0x7d384
incq %r15
movslq 0x5c(%r12), %rax
addq $0x10, %r13
cmpq %rax, %r15
jl 0x85c87
movq 0x10(%rsp), %r13
movl 0x10(%r13), %r9d
movl 0x1c0(%r13), %r10d
subq $0x8, %rsp
leaq 0x2ab9c(%rip), %r11     # 0xb0884
leaq 0x24fe1(%rip), %r8      # 0xaacd0
movq %rbp, %rdi
movl %ebx, %esi
movl $0x2, %edx
movl $0x1, %ecx
xorl %eax, %eax
pushq %r10
pushq %r11
pushq $0x1
callq 0x7d384
addq $0x18, %rsp
leaq 0x2aef1(%rip), %r10     # 0xb0c07
leaq 0x24f67(%rip), %r11     # 0xaac84
leaq 0x2aca4(%rip), %r14     # 0xb09c8
leaq 0x2af82(%rip), %r8      # 0xb0cad
leaq 0x2ac44(%rip), %r9      # 0xb0976
movq %rbp, %rdi
movl %ebx, %esi
movl $0x1, %edx
movl $0x5, %ecx
xorl %eax, %eax
pushq %r10
pushq %r11
pushq %r14
callq 0x7d617
addq $0x18, %rsp
leaq 0x22147(%rip), %r10     # 0xa7ea0
leaq 0x2b022(%rip), %r11     # 0xb0d82
leaq 0x2ad43(%rip), %r14     # 0xb0aaa
leaq 0x2af4b(%rip), %r8      # 0xb0cb9
leaq 0x2ac3f(%rip), %r9      # 0xb09b4
movq %rbp, %rdi
movl %ebx, %esi
xorl %edx, %edx
movl $0x5, %ecx
xorl %eax, %eax
pushq %r10
pushq %r11
pushq %r14
callq 0x7d617
addq $0x20, %rsp
cmpl $0x2, %ebx
movq %rbp, %r15
movl %ebx, %ebp
jne 0x85db5
leaq 0x2a36d(%rip), %rdi     # 0xb0110
movl $0x6, %esi
movl $0x1, %edx
movq %r15, %rcx
callq 0x42c0
incl 0x32c42d(%rip)          # 0x3b21e8
movq %r15, %rdi
movl %ebp, %esi
movq %r13, %rdx
movl $0x1, %ecx
callq 0x8050d
movl 0x5c(%r12), %edx
testl %edx, %edx
jle 0x85e98
movq %r15, 0x18(%rsp)
movl $0x4, %r15d
movl %ebp, 0xc(%rsp)
xorl %ebx, %ebx
leaq 0x20(%rsp), %rdi
leaq 0x2af25(%rip), %rsi     # 0xb0d1c
movl %ebx, %edx
xorl %eax, %eax
callq 0x41b0
movq %r12, %r13
leaq 0x7a140(%rsp), %r12
movq %r12, %rdi
leaq 0x2af11(%rip), %rbp     # 0xb0d26
movq %rbp, %rsi
movl %ebx, %edx
xorl %eax, %eax
callq 0x41b0
movq %rbx, %rdx
subq $0x1, %rdx
leaq 0xf4260(%rsp), %rdi
movq %rdi, %r14
leaq 0x2aa4a(%rip), %rax     # 0xb0884
cmovbq %rax, %r14
movq %rbp, %rsi
xorl %eax, %eax
callq 0x41b0
movq (%r13), %rax
movl -0x4(%rax,%r15), %edx
movl (%rax,%r15), %ecx
movq 0x18(%rsp), %rdi
movl 0xc(%rsp), %esi
leaq 0x20(%rsp), %r8
movq %r14, %r9
pushq $0x1
pushq %r12
movq %r13, %r12
callq 0x80069
addq $0x10, %rsp
incq %rbx
movslq 0x5c(%r13), %rdx
addq $0x10, %r15
cmpq %rdx, %rbx
jl 0x85deb
movl 0xc(%rsp), %ebp
movq 0x18(%rsp), %r15
movq 0x10(%rsp), %r13
testl %edx, %edx
je 0x85ef3
leaq 0x2ae79(%rip), %rsi     # 0xb0d1c
leaq 0x20(%rsp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x41b0
movl 0x5c(%r12), %edx
decl %edx
leaq 0x2ae66(%rip), %rsi     # 0xb0d26
leaq 0x7a140(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x41b0
movq (%r12), %rax
movslq 0x5c(%r12), %rcx
shlq $0x4, %rcx
movl (%rax,%rcx), %edx
movl 0x4(%rax,%rcx), %ecx
movq %r15, %rdi
movl %ebp, %esi
movq %rbx, %r8
movq %r14, %r9
jmp 0x85f0f
movq (%r12), %rax
movl (%rax), %edx
movl 0x4(%rax), %ecx
leaq 0x2ae2c(%rip), %r8      # 0xb0d2f
leaq 0x2a97a(%rip), %r9      # 0xb0884
movq %r15, %rdi
movl %ebp, %esi
pushq $0x0
leaq 0x24db8(%rip), %rax     # 0xaacd0
pushq %rax
callq 0x80069
addq $0x10, %rsp
movl 0x10(%r13), %ecx
leaq 0x2b241(%rip), %rax     # 0xb116e
leaq 0x24d9c(%rip), %rdx     # 0xaacd0
leaq 0x2acd5(%rip), %r8      # 0xb0c10
leaq 0x2acc5(%rip), %r9      # 0xb0c07
movq %r15, %rdi
movl %ebp, %esi
pushq %rax
leaq 0x2ab5b(%rip), %rbx     # 0xb0aaa
pushq %rbx
callq 0x803e7
addq $0x10, %rsp
leaq 0x20075(%rip), %rsi     # 0xa5fd5
movq %r15, %rdi
movl %ebp, %edx
movq %rbx, %rcx
callq 0x7d912
movq %r15, %rdi
movl %ebp, %esi
callq 0x7db1b
addq $0x16e388, %rsp         # imm = 0x16E388
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq