// File: /workspace/github_cpp_makefile_star2_O2/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 $0x568, %rsp            # imm = 0x568
leaq 0x10(%rsp), %rdi
andq $0x0, 0x10(%rdi)
xorps %xmm0, %xmm0
movaps %xmm0, (%rdi)
leaq 0x160(%rsp), %rsi
movl $0x2, (%rsi)
callq 0x4344
leaq 0x160(%rsp), %rsi
movl $0x4, (%rsi)
leaq 0x10(%rsp), %rdi
callq 0x4344
leaq 0x160(%rsp), %rsi
movl $0x1, (%rsi)
leaq 0x10(%rsp), %rdi
callq 0x4344
leaq 0x2159(%rip), %rsi      # 0x5093
leaq 0x128(%rsp), %rdi
leaq 0x368(%rsp), %rdx
callq 0x34ae
leaq 0x160(%rsp), %rdi
leaq 0x128(%rsp), %rsi
callq 0x2502
leaq 0x128(%rsp), %rdi
callq 0x20c0
leaq 0x2134(%rip), %rsi      # 0x50ac
leaq 0x108(%rsp), %rdi
leaq 0x90(%rsp), %rdx
callq 0x34ae
leaq 0x368(%rsp), %rdi
leaq 0x108(%rsp), %rsi
callq 0x246c
leaq 0x108(%rsp), %rdi
callq 0x20c0
leaq 0x90(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x2cf2
leaq 0x50(%rsp), %rax
andq $0x0, 0x10(%rax)
xorps %xmm0, %xmm0
movaps %xmm0, (%rax)
leaq 0x30(%rsp), %rax
movaps %xmm0, (%rax)
andq $0x0, 0x10(%rax)
leaq 0x70(%rsp), %rax
movaps %xmm0, (%rax)
andq $0x0, 0x10(%rax)
pushq $0x1
popq %rax
movq 0x4fe3(%rip), %rbp      # 0x7fd8
leaq 0xe8(%rsp), %r13
leaq 0x148(%rsp), %r14
movq %rax, 0x8(%rsp)
cmpq $0x5, %rax
je 0x323e
pushq $0x1
popq %r12
movq 0x160(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x2, 0x180(%rsp,%rax)
jne 0x3224
leaq 0x160(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x2588
movq 0x10(%rsp), %rcx
cmpl (%rcx), %eax
jne 0x3224
leaq 0x160(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x265a
movq %rbp, %rdi
callq 0x20d0
movq %rax, %rdi
leaq 0x2046(%rip), %rsi      # 0x50bb
callq 0x21a0
movq %rax, %rdi
movq 0x8(%rsp), %rsi
callq 0x2120
movq %rax, %rdi
leaq 0x2032(%rip), %rsi      # 0x50c3
callq 0x21a0
movl %r12d, %esi
movq %rax, %rdi
callq 0x2120
movq %rax, %rdi
callq 0x20d0
movq %rbp, %rdi
leaq 0x201e(%rip), %rsi      # 0x50d1
callq 0x21a0
movq %rax, %r15
leaq 0xd0(%rsp), %rbx
movq %rbx, %rdi
leaq 0x50(%rsp), %rsi
callq 0x34ea
movq %r13, %rdi
movq %rbx, %rsi
callq 0x2e25
movq %r15, %rdi
movq %r13, %rsi
callq 0x2180
movq %rax, %rdi
callq 0x20d0
movq %r13, %rdi
callq 0x20c0
leaq 0xd0(%rsp), %rdi
callq 0x44ba
movq %rbp, %rdi
leaq 0x1fc9(%rip), %rsi      # 0x50d6
callq 0x21a0
movq %rax, %r15
leaq 0xb8(%rsp), %rbx
movq %rbx, %rdi
leaq 0x30(%rsp), %rsi
callq 0x34ea
movq %r13, %rdi
movq %rbx, %rsi
callq 0x2e25
movq %r15, %rdi
movq %r13, %rsi
callq 0x2180
movq %rax, %rdi
callq 0x20d0
movq %r13, %rdi
callq 0x20c0
leaq 0xb8(%rsp), %rdi
callq 0x44ba
leaq 0x90(%rsp), %rbx
movq %rbx, %rdi
leaq 0x50(%rsp), %rsi
callq 0x2ab0
movq %rbx, %rdi
leaq 0x70(%rsp), %rsi
callq 0x2a44
movq %rbp, %rdi
leaq 0x1f53(%rip), %rsi      # 0x50dc
callq 0x21a0
movq %rax, %r15
movq %r14, %rdi
leaq 0x70(%rsp), %rsi
callq 0x34ea
movq %r13, %rdi
movq %r14, %rsi
callq 0x2e25
movq %r15, %rdi
movq %r13, %rsi
callq 0x2180
movq %rax, %rdi
callq 0x20d0
movq %r13, %rdi
callq 0x20c0
movq %r14, %rdi
callq 0x44ba
leaq 0x90(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x2b6a
movq %rbp, %rdi
leaq 0x1efa(%rip), %rsi      # 0x50e2
callq 0x21a0
movsd 0x90(%rsp), %xmm0
movq %rax, %rdi
callq 0x2270
movq %rax, %rdi
callq 0x20d0
movsd 0x90(%rsp), %xmm0
leaq 0x368(%rsp), %rdi
callq 0x24f2
incl %r12d
jmp 0x3018
leaq 0x160(%rsp), %rdi
callq 0x2638
movq 0x8(%rsp), %rax
incq %rax
jmp 0x3005
leaq 0x70(%rsp), %rdi
callq 0x44ba
leaq 0x30(%rsp), %rdi
callq 0x44ba
leaq 0x50(%rsp), %rdi
callq 0x44ba
leaq 0xa0(%rsp), %rdi
callq 0x346a
leaq 0x368(%rsp), %rdi
callq 0x24d8
leaq 0x160(%rsp), %rdi
callq 0x256e
leaq 0x10(%rsp), %rdi
callq 0x3714
xorl %eax, %eax
addq $0x568, %rsp            # imm = 0x568
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x3381
movq %rax, %rbx
leaq 0x108(%rsp), %rdi
callq 0x20c0
jmp 0x338e
movq %rax, %rbx
jmp 0x338e
movq %rax, %rbx
leaq 0x128(%rsp), %rdi
callq 0x20c0
jmp 0x339b
jmp 0x32e1
jmp 0x32e1
jmp 0x32e1
movq %rax, %rbx
jmp 0x339b
jmp 0x3353
jmp 0x3353
movq %rax, %rbx
jmp 0x3310
jmp 0x3353
jmp 0x3353
movq %rax, %rbx
jmp 0x332a
movq %rax, %rbx
jmp 0x3344
movq %rax, %rbx
leaq 0xe8(%rsp), %rdi
callq 0x20c0
leaq 0x148(%rsp), %rdi
jmp 0x334c
movq %rax, %rbx
leaq 0xe8(%rsp), %rdi
callq 0x20c0
leaq 0xd0(%rsp), %rdi
jmp 0x334c
movq %rax, %rbx
leaq 0xe8(%rsp), %rdi
callq 0x20c0
leaq 0xb8(%rsp), %rdi
callq 0x44ba
jmp 0x3356
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x44ba
leaq 0x30(%rsp), %rdi
callq 0x44ba
leaq 0x50(%rsp), %rdi
callq 0x44ba
leaq 0xa0(%rsp), %rdi
callq 0x346a
leaq 0x368(%rsp), %rdi
callq 0x24d8
leaq 0x160(%rsp), %rdi
callq 0x256e
leaq 0x10(%rsp), %rdi
callq 0x3714
movq %rbx, %rdi
callq 0x22d0