// File: /workspace/github_c_makefile_star2_O2/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, %r14
movl %esi, %ebp
movq %rdi, %rbx
movl 0x1bc(%rdx), %edx
leaq 0x20c21(%rip), %rsi     # 0x99c73
movl %ebp, %ecx
callq 0x72674
movq %rbx, %rdi
movl %ebp, %esi
callq 0x72b0a
movl 0x1c0(%r14), %r8d
decl %r8d
leaq 0x28777(%rip), %rcx     # 0xa17eb
leaq 0x330f2d(%rip), %r9     # 0x3a9fa8
movq %rbx, %rdi
movl %ebp, %esi
movq %r14, %rdx
callq 0x73bdf
movl 0x1c0(%r14), %r8d
decl %r8d
leaq 0x1d38b(%rip), %rcx     # 0x96424
leaq 0x330f38(%rip), %r9     # 0x3a9fd8
movq %rbx, 0x10(%rsp)
movq %rbx, %rdi
movl %ebp, %esi
movq %r14, 0x18(%rsp)
movq %r14, %rdx
callq 0x73bdf
pushq $0x8
popq %r13
leaq 0x27bbe(%rip), %rbx     # 0xa0c80
leaq 0x20(%rsp), %r14
xorl %r15d, %r15d
movslq 0x5c(%r12), %rax
cmpq %rax, %r15
jg 0x7910e
movq %r14, %rdi
movq %rbx, %rsi
movl %r15d, %edx
xorl %eax, %eax
callq 0x41b0
movq (%r12), %rax
movl -0x8(%rax,%r13), %ecx
movl -0x4(%rax,%r13), %r8d
movq (%rax,%r13), %r9
movq 0x10(%rsp), %rdi
movl %ebp, %esi
movq %r14, %rdx
callq 0x73ec6
incq %r15
addq $0x10, %r13
jmp 0x790ca
movq 0x10(%rsp), %rdi
movl %ebp, 0xc(%rsp)
movl %ebp, %esi
callq 0x72fb3
leaq 0x27b65(%rip), %rbx     # 0xa0c8a
leaq 0x20(%rsp), %r14
pushq $0x1
popq %rbp
xorl %r13d, %r13d
xorl %r15d, %r15d
movslq 0x5c(%r12), %rax
cmpq %rax, %r15
jge 0x79175
movq %r14, %rdi
movq %rbx, %rsi
movl %r15d, %edx
xorl %eax, %eax
callq 0x41b0
movq (%r12), %rax
movl (%rax,%r13), %r9d
movq 0x10(%rsp), %rdi
movl 0xc(%rsp), %esi
movl %ebp, %edx
movl %ebp, %ecx
movq %r14, %r8
xorl %eax, %eax
callq 0x72b76
incq %r15
addq $0x10, %r13
jmp 0x79133
movq 0x18(%rsp), %r13
movl 0x10(%r13), %r9d
movl 0x1c0(%r13), %r10d
subq $0x8, %rsp
leaq 0x27658(%rip), %r11     # 0xa07e8
leaq 0x21a69(%rip), %r8      # 0x9ac00
pushq $0x2
popq %rdx
pushq $0x1
popq %r14
movq 0x18(%rsp), %r15
movq %r15, %rdi
movl 0x14(%rsp), %ebp
movl %ebp, %esi
movl %r14d, %ecx
xorl %eax, %eax
pushq %r10
pushq %r11
pushq $0x1
callq 0x72b76
addq $0x18, %rsp
leaq 0x279a4(%rip), %r10     # 0xa0b6b
leaq 0x219e6(%rip), %r11     # 0x9abb4
leaq 0x27a3c(%rip), %r8      # 0xa0c11
leaq 0x276fe(%rip), %r9      # 0xa08da
pushq $0x5
popq %rbx
movq %r15, %rdi
movl %ebp, %esi
movl %r14d, %edx
movl %ebx, %ecx
xorl %eax, %eax
pushq %r10
pushq %r11
leaq 0x27736(%rip), %r10     # 0xa092c
pushq %r10
callq 0x72de1
addq $0x18, %rsp
leaq 0x1ec18(%rip), %r10     # 0x97e20
leaq 0x27ad7(%rip), %r11     # 0xa0ce6
leaq 0x277f8(%rip), %r14     # 0xa0a0e
leaq 0x27a00(%rip), %r8      # 0xa0c1d
leaq 0x276f4(%rip), %r9      # 0xa0918
movq %r15, %rdi
movl %ebp, %esi
xorl %edx, %edx
movl %ebx, %ecx
xorl %eax, %eax
pushq %r10
pushq %r11
pushq %r14
callq 0x72de1
addq $0x20, %rsp
movq %r15, %rdi
movl %ebp, %esi
callq 0x726d3
movq %r15, %rdi
movl %ebp, %esi
movq %r13, %rdx
pushq $0x1
popq %rcx
callq 0x753f5
pushq $0x4
popq %r15
xorl %r14d, %r14d
movslq 0x5c(%r12), %rdx
cmpq %rdx, %r14
jge 0x79304
leaq 0x20(%rsp), %rdi
leaq 0x27a07(%rip), %rsi     # 0xa0c80
movl %r14d, %edx
xorl %eax, %eax
callq 0x41b0
movq %r12, %r13
leaq 0x7a140(%rsp), %r12
movq %r12, %rdi
leaq 0x279f2(%rip), %rbp     # 0xa0c8a
movq %rbp, %rsi
movl %r14d, %edx
xorl %eax, %eax
callq 0x41b0
movq %r14, %rdx
subq $0x1, %rdx
leaq 0xf4260(%rsp), %rdi
movq %rdi, %rbx
leaq 0x2752a(%rip), %rax     # 0xa07e8
cmovbq %rax, %rbx
movq %rbp, %rsi
xorl %eax, %eax
callq 0x41b0
movq (%r13), %rax
movl -0x4(%rax,%r15), %edx
movl (%rax,%r15), %ecx
movq 0x10(%rsp), %rdi
movl 0xc(%rsp), %esi
leaq 0x20(%rsp), %r8
movq %rbx, %r9
pushq $0x1
pushq %r12
movq %r13, %r12
callq 0x75037
popq %rax
popq %rcx
incq %r14
addq $0x10, %r15
jmp 0x7925f
testl %edx, %edx
je 0x79368
leaq 0x27971(%rip), %rsi     # 0xa0c80
leaq 0x20(%rsp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x41b0
movl 0x5c(%r12), %edx
decl %edx
leaq 0x2795e(%rip), %rsi     # 0xa0c8a
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 0x10(%rsp), %r15
movq %r15, %rdi
movl 0xc(%rsp), %ebp
movl %ebp, %esi
movq %rbx, %r8
movq %r14, %r9
jmp 0x7938d
movq (%r12), %rax
movl (%rax), %edx
movl 0x4(%rax), %ecx
leaq 0x2791b(%rip), %r8      # 0xa0c93
leaq 0x27469(%rip), %r9      # 0xa07e8
movq 0x10(%rsp), %r15
movq %r15, %rdi
movl 0xc(%rsp), %ebp
movl %ebp, %esi
pushq $0x0
leaq 0x2186a(%rip), %rax     # 0x9ac00
pushq %rax
callq 0x75037
popq %rax
popq %rcx
movq 0x18(%rsp), %rax
movl 0x10(%rax), %ecx
leaq 0x27d25(%rip), %rax     # 0xa10d2
leaq 0x2184c(%rip), %rdx     # 0x9ac00
leaq 0x277b9(%rip), %r8      # 0xa0b74
leaq 0x277a9(%rip), %r9      # 0xa0b6b
movq %r15, %rdi
movl %ebp, %esi
pushq %rax
leaq 0x2763f(%rip), %rbx     # 0xa0a0e
pushq %rbx
callq 0x752fa
popq %rax
popq %rcx
leaq 0x1cbff(%rip), %rsi     # 0x95fdd
movq %r15, %rdi
movl %ebp, %edx
movq %rbx, %rcx
callq 0x7308c
movq %r15, %rdi
movl %ebp, %esi
callq 0x7320f
addq $0x16e388, %rsp         # imm = 0x16E388
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq