// File: /workspace/github_c_makefile_star2_O1/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 0x23791(%rip), %rsi     # 0xa6cdb
movl %ebp, %ecx
callq 0x7b551
cmpl $0x2, %ebp
jne 0x8356f
leaq 0x29ca8(%rip), %rdi     # 0xad205
movl $0x6, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x42c0
movl 0x1c0(%r14), %r8d
decl %r8d
leaq 0x2b27b(%rip), %rcx     # 0xae7fb
leaq 0x32ba21(%rip), %r9     # 0x3aefa8
movq %rbx, %rdi
movl %ebp, %esi
movq %r14, %rdx
callq 0x7cde7
movl 0x1c0(%r14), %r8d
decl %r8d
leaq 0x1fe7f(%rip), %rcx     # 0xa3424
leaq 0x32ba2c(%rip), %r9     # 0x3aefd8
movq %rbx, %rdi
movl %ebp, %esi
movq %r14, 0x10(%rsp)
movq %r14, %rdx
callq 0x7cde7
cmpl $0x0, 0x5c(%r12)
movq %rbx, %r14
js 0x8361e
movq $-0x1, %rbx
movl $0x8, %r13d
leaq 0x20(%rsp), %r15
incq %rbx
movq %r15, %rdi
leaq 0x2a69c(%rip), %rsi     # 0xadc84
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 %r14, %rdi
movl %ebp, %esi
movq %r15, %rdx
callq 0x7d0d5
movslq 0x5c(%r12), %rax
addq $0x10, %r13
cmpq %rax, %rbx
jl 0x835db
movl %ebp, 0xc(%rsp)
cmpl $0x2, %ebp
jne 0x83640
leaq 0x29c3a(%rip), %rdi     # 0xad268
movl $0x4, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x42c0
cmpl $0x0, 0x5c(%r12)
movq %r14, %rbp
movl 0xc(%rsp), %ebx
jle 0x836a0
leaq 0x20(%rsp), %r14
xorl %r13d, %r13d
xorl %r15d, %r15d
movq %r14, %rdi
leaq 0x2a62a(%rip), %rsi     # 0xadc8e
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 0x7bab4
incq %r15
movslq 0x5c(%r12), %rax
addq $0x10, %r13
cmpq %rax, %r15
jl 0x8365a
movq 0x10(%rsp), %r13
movl 0x10(%r13), %r9d
movl 0x1c0(%r13), %r10d
subq $0x8, %rsp
leaq 0x2a131(%rip), %r11     # 0xad7ec
leaq 0x2455e(%rip), %r8      # 0xa7c20
movq %rbp, %rdi
movl %ebx, %esi
movl $0x2, %edx
movl $0x1, %ecx
xorl %eax, %eax
pushq %r10
pushq %r11
pushq $0x1
callq 0x7bab4
addq $0x18, %rsp
leaq 0x2a486(%rip), %r10     # 0xadb6f
leaq 0x244e4(%rip), %r11     # 0xa7bd4
leaq 0x2a239(%rip), %r14     # 0xad930
leaq 0x2a517(%rip), %r8      # 0xadc15
leaq 0x2a1d9(%rip), %r9      # 0xad8de
movq %rbp, %rdi
movl %ebx, %esi
movl $0x1, %edx
movl $0x5, %ecx
xorl %eax, %eax
pushq %r10
pushq %r11
pushq %r14
callq 0x7bd1c
addq $0x18, %rsp
leaq 0x2171c(%rip), %r10     # 0xa4e48
leaq 0x2a5b7(%rip), %r11     # 0xadcea
leaq 0x2a2d8(%rip), %r14     # 0xada12
leaq 0x2a4e0(%rip), %r8      # 0xadc21
leaq 0x2a1d4(%rip), %r9      # 0xad91c
movq %rbp, %rdi
movl %ebx, %esi
xorl %edx, %edx
movl $0x5, %ecx
xorl %eax, %eax
pushq %r10
pushq %r11
pushq %r14
callq 0x7bd1c
addq $0x20, %rsp
cmpl $0x2, %ebx
movq %rbp, %r15
jne 0x83786
leaq 0x29904(%rip), %rdi     # 0xad078
movl $0x6, %esi
movl $0x1, %edx
movq %r15, %rcx
callq 0x42c0
incl 0x32ba5c(%rip)          # 0x3af1e8
movq %r15, %rdi
movl 0xc(%rsp), %ebp
movl %ebp, %esi
movq %r13, %rdx
movl $0x1, %ecx
callq 0x7e795
movl 0x5c(%r12), %edx
testl %edx, %edx
jle 0x83869
movq %r15, 0x18(%rsp)
movl $0x4, %r15d
xorl %ebx, %ebx
leaq 0x20(%rsp), %rdi
leaq 0x2a4bc(%rip), %rsi     # 0xadc84
movl %ebx, %edx
xorl %eax, %eax
callq 0x41b0
movq %r12, %r13
leaq 0x7a140(%rsp), %r12
movq %r12, %rdi
leaq 0x2a4a8(%rip), %rbp     # 0xadc8e
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 0x29fe1(%rip), %rax     # 0xad7ec
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 0x7e398
addq $0x10, %rsp
incq %rbx
movslq 0x5c(%r13), %rdx
addq $0x10, %r15
cmpq %rdx, %rbx
jl 0x837bc
movl 0xc(%rsp), %ebp
movq 0x18(%rsp), %r15
movq 0x10(%rsp), %r13
testl %edx, %edx
je 0x838c4
leaq 0x2a410(%rip), %rsi     # 0xadc84
leaq 0x20(%rsp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x41b0
movl 0x5c(%r12), %edx
decl %edx
leaq 0x2a3fd(%rip), %rsi     # 0xadc8e
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 0x838e0
movq (%r12), %rax
movl (%rax), %edx
movl 0x4(%rax), %ecx
leaq 0x2a3c3(%rip), %r8      # 0xadc97
leaq 0x29f11(%rip), %r9      # 0xad7ec
movq %r15, %rdi
movl %ebp, %esi
pushq $0x0
leaq 0x24337(%rip), %rax     # 0xa7c20
pushq %rax
callq 0x7e398
addq $0x10, %rsp
movl 0x10(%r13), %ecx
leaq 0x2a7d8(%rip), %rax     # 0xae0d6
leaq 0x2431b(%rip), %rdx     # 0xa7c20
leaq 0x2a26c(%rip), %r8      # 0xadb78
leaq 0x2a25c(%rip), %r9      # 0xadb6f
movq %r15, %rdi
movl %ebp, %esi
pushq %rax
leaq 0x2a0f2(%rip), %rbx     # 0xada12
pushq %rbx
callq 0x7e698
addq $0x10, %rsp
leaq 0x1f6a4(%rip), %rsi     # 0xa2fd5
movq %r15, %rdi
movl %ebp, %edx
movq %rbx, %rcx
callq 0x7bffb
movq %r15, %rdi
movl %ebp, %esi
callq 0x7c1ca
addq $0x16e388, %rsp         # imm = 0x16E388
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq