// File: /workspace/github_cpp_makefile_star2_O3/wkohlenberg[P]simple_NN/src/main.cpp
// Function: main
int main()
{
  // Topology
  vector<unsigned> topology;
  topology.push_back(INPUT);
  topology.push_back(HIDDEN);
  topology.push_back(OUTPUT);

  // Read training data file
  TrainData trainData("input/xor_train_data.txt");

  // Open log file
  LogData log("output/log.txt");

  // Create the neural net
  Net NN(topology);

  vector<double> inputVals;   // Input values
  vector<double> targetVals;  // Target values
  vector<double> outputVals;  // Output values

  unsigned int train_num = 1;
  for (unsigned int epoch_num = 1; epoch_num <= EPOCH; epoch_num++)
  {
    // Train the neural net by training data
    while (!trainData.isEof())
    {
      // Last row of file is empty
      if (trainData.readInput(inputVals) != topology[0])
      {
        break;
      }

      trainData.readTarget(targetVals);
      cout << endl << "Epoch: " << epoch_num << "; Train num: " << train_num << endl;
      cout << "in: " << showVectorValues(inputVals) << endl;
      cout << "out: " << showVectorValues(targetVals) << endl;

      // Feed forward
      NN.feedForward(inputVals);
      NN.getOutputValLayer(outputVals);
      cout << "res: " << showVectorValues(outputVals) << endl;

      // Backpropogation
      NN.backPropagation(targetVals);
      cout << "Total error is " << NN.getAvgError() << endl;
      log.write(NN.getAvgError());

      train_num++;
    }

    train_num = 1;
    trainData.toBeginOfFile();
  }

  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x558, %rsp            # imm = 0x558
xorps %xmm0, %xmm0
leaq 0x20(%rsp), %rdi
movaps %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
leaq 0x150(%rsp), %rdx
movl $0x2, (%rdx)
xorl %esi, %esi
callq 0x493a
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rax
movl $0x4, 0x150(%rsp)
cmpq %rax, %rsi
je 0x33d9
movl $0x4, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x28(%rsp)
jmp 0x33f5
leaq 0x20(%rsp), %rdi
leaq 0x150(%rsp), %rdx
callq 0x493a
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rax
movl $0x1, 0x150(%rsp)
cmpq %rax, %rsi
je 0x3416
movl $0x1, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x28(%rsp)
jmp 0x3428
leaq 0x20(%rsp), %rdi
leaq 0x150(%rsp), %rdx
callq 0x493a
leaq 0xd0(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x2c90(%rip), %rsi      # 0x60cb
leaq 0x2ca1(%rip), %rdx      # 0x60e3
leaq 0xc0(%rsp), %rdi
callq 0x3e4e
leaq 0x150(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
callq 0x267e
movq 0xc0(%rsp), %rdi
cmpq %r14, %rdi
je 0x3481
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x21f0
leaq 0xb0(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x2c50(%rip), %rsi      # 0x60e4
leaq 0x2c57(%rip), %rdx      # 0x60f2
leaq 0xa0(%rsp), %rdi
callq 0x3e4e
leaq 0x358(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
callq 0x253c
movq 0xa0(%rsp), %rdi
cmpq %r14, %rdi
je 0x34da
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x21f0
leaq 0x128(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x30f4
xorps %xmm0, %xmm0
leaq 0x60(%rsp), %rcx
movaps %xmm0, (%rcx)
xorl %eax, %eax
movq %rax, 0x10(%rcx)
leaq 0x40(%rsp), %rcx
movq %rax, 0x10(%rcx)
movaps %xmm0, (%rcx)
leaq 0x80(%rsp), %rcx
movq %rax, 0x10(%rcx)
movaps %xmm0, (%rcx)
movl $0x1, %r12d
movq 0x5ab3(%rip), %rbp      # 0x8fd8
movq %rsp, %r15
leaq 0x128(%rsp), %r13
movq 0x150(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x2, 0x170(%rsp,%rax)
jne 0x38c6
movl $0x1, %ebx
leaq 0x150(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x2764
movq 0x20(%rsp), %rcx
cmpl (%rcx), %eax
jne 0x38ba
leaq 0x150(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x289e
movq (%rbp), %rax
movq -0x18(%rax), %rdi
addq %rbp, %rdi
movl $0xa, %esi
callq 0x21d0
movsbl %al, %esi
movq %rbp, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2150
movq %rax, %r14
movl $0x7, %edx
movq %rax, %rdi
leaq 0x2b39(%rip), %rsi      # 0x60f3
callq 0x2210
movq %r14, %rdi
movq %r12, %rsi
callq 0x2140
movq %rax, %r14
movl $0xd, %edx
movq %rax, %rdi
leaq 0x2b1f(%rip), %rsi      # 0x60fb
callq 0x2210
movl %ebx, %esi
movq %r14, %rdi
callq 0x2140
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x21d0
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2150
movl $0x4, %edx
movq %rbp, %rdi
leaq 0x2ae5(%rip), %rsi      # 0x6109
callq 0x2210
leaq 0x110(%rsp), %r14
movq %r14, %rdi
leaq 0x60(%rsp), %rsi
callq 0x3c86
movq %r15, %rdi
movq %r14, %rsi
callq 0x325a
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq %rbp, %rdi
callq 0x2210
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x21d0
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2150
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x369f
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x21f0
movq 0x110(%rsp), %rdi
testq %rdi, %rdi
je 0x36bc
movq 0x120(%rsp), %rsi
subq %rdi, %rsi
callq 0x21f0
movl $0x5, %edx
movq %rbp, %rdi
leaq 0x2a43(%rip), %rsi      # 0x610e
callq 0x2210
leaq 0xf8(%rsp), %r14
movq %r14, %rdi
leaq 0x40(%rsp), %rsi
callq 0x3c86
movq %r15, %rdi
movq %r14, %rsi
callq 0x325a
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq %rbp, %rdi
callq 0x2210
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x21d0
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2150
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x3746
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x21f0
movq 0xf8(%rsp), %rdi
testq %rdi, %rdi
je 0x3763
movq 0x108(%rsp), %rsi
subq %rdi, %rsi
callq 0x21f0
movq %r13, %rdi
leaq 0x60(%rsp), %rsi
callq 0x2e12
movq %r13, %rdi
leaq 0x80(%rsp), %rsi
callq 0x2d7e
movl $0x5, %edx
movq %rbp, %rdi
leaq 0x2985(%rip), %rsi      # 0x6114
callq 0x2210
leaq 0xe0(%rsp), %r14
movq %r14, %rdi
leaq 0x80(%rsp), %rsi
callq 0x3c86
movq %r15, %rdi
movq %r14, %rsi
callq 0x325a
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq %rbp, %rdi
callq 0x2210
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x21d0
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2150
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x380d
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x21f0
movq 0xe0(%rsp), %rdi
testq %rdi, %rdi
je 0x382a
movq 0xf0(%rsp), %rsi
subq %rdi, %rsi
callq 0x21f0
movq %r13, %rdi
leaq 0x40(%rsp), %rsi
callq 0x2f10
movl $0xf, %edx
movq %rbp, %rdi
leaq 0x28d4(%rip), %rsi      # 0x611a
callq 0x2210
movsd 0x128(%rsp), %xmm0
movq %rbp, %rdi
callq 0x22b0
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x21d0
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2150
movsd 0x128(%rsp), %xmm0
leaq 0x358(%rsp), %rdi
callq 0x264c
incl %ebx
movq 0x150(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x2, 0x170(%rsp,%rax)
je 0x354f
jmp 0x38c6
movq 0x150(%rsp), %rax
movq -0x18(%rax), %rax
leaq (%rsp,%rax), %rdi
addq $0x150, %rdi            # imm = 0x150
xorl %esi, %esi
callq 0x22f0
leaq 0x150(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2240
incq %r12
cmpq $0x5, %r12
jne 0x3530
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x3913
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x21f0
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x392a
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x21f0
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x3941
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x21f0
leaq 0x138(%rsp), %rdi
callq 0x3c3e
leaq 0x358(%rsp), %rdi
callq 0x2608
leaq 0x150(%rsp), %rdi
callq 0x274a
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x397f
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x21f0
xorl %eax, %eax
addq $0x558, %rsp            # imm = 0x558
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x39fb
jmp 0x39fb
movq %rax, %rbx
jmp 0x3b2b
movq %rax, %rbx
movq 0xa0(%rsp), %rdi
cmpq %r14, %rdi
je 0x3b38
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x21f0
jmp 0x3b38
movq %rax, %rbx
jmp 0x3b38
movq %rax, %rbx
movq 0xc0(%rsp), %rdi
cmpq %r14, %rdi
je 0x3b45
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x21f0
jmp 0x3b45
jmp 0x39fb
movq %rax, %rbx
jmp 0x3b45
jmp 0x3ad0
movq %rax, %rbx
jmp 0x3a47
jmp 0x3ad0
jmp 0x3ad0
movq %rax, %rbx
jmp 0x3a7c
jmp 0x3ad0
movq %rax, %rbx
jmp 0x3ab1
movq %rax, %rbx
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x3a47
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x21f0
movq 0xe0(%rsp), %rdi
testq %rdi, %rdi
je 0x3ad3
movq 0xf0(%rsp), %rsi
jmp 0x3ac6
movq %rax, %rbx
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x3a7c
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x21f0
movq 0xf8(%rsp), %rdi
testq %rdi, %rdi
je 0x3ad3
movq 0x108(%rsp), %rsi
jmp 0x3ac6
movq %rax, %rbx
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x3ab1
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x21f0
movq 0x110(%rsp), %rdi
testq %rdi, %rdi
je 0x3ad3
movq 0x120(%rsp), %rsi
subq %rdi, %rsi
callq 0x21f0
jmp 0x3ad3
movq %rax, %rbx
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x3af0
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x21f0
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x3b07
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x21f0
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x3b1e
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x21f0
leaq 0x138(%rsp), %rdi
callq 0x3c3e
leaq 0x358(%rsp), %rdi
callq 0x2608
leaq 0x150(%rsp), %rdi
callq 0x274a
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x3b5c
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x21f0
movq %rbx, %rdi
callq 0x2310