// File: /workspace/github_cpp_makefile_star2_O1/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
movaps %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
movl $0x2, 0x150(%rsp)
movq 0x8(%rsp), %rsi
testq %rsi, %rsi
je 0x33a8
movl $0x2, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rsp)
jmp 0x33b8
movq %rsp, %rdi
leaq 0x150(%rsp), %rdx
callq 0x4932
movl $0x4, 0x150(%rsp)
movq 0x8(%rsp), %rsi
cmpq 0x10(%rsp), %rsi
je 0x33e0
movl $0x4, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rsp)
jmp 0x33f0
movq %rsp, %rdi
leaq 0x150(%rsp), %rdx
callq 0x4932
movl $0x1, 0x150(%rsp)
movq 0x8(%rsp), %rsi
cmpq 0x10(%rsp), %rsi
je 0x3418
movl $0x1, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rsp)
jmp 0x3428
movq %rsp, %rdi
leaq 0x150(%rsp), %rdx
callq 0x4932
leaq 0xd0(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x2c60(%rip), %rsi      # 0x609b
leaq 0x2c71(%rip), %rdx      # 0x60b3
leaq 0xc0(%rsp), %rdi
callq 0x3e42
leaq 0x150(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
callq 0x266e
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 0x2c20(%rip), %rsi      # 0x60b4
leaq 0x2c27(%rip), %rdx      # 0x60c2
leaq 0xa0(%rsp), %rdi
callq 0x3e42
leaq 0x358(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
callq 0x252c
movq 0xa0(%rsp), %rdi
cmpq %r14, %rdi
je 0x34da
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x21f0
leaq 0x128(%rsp), %rdi
movq %rsp, %rsi
callq 0x30e0
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, %r13d
movq 0x5ab5(%rip), %rbp      # 0x8fd8
leaq 0x20(%rsp), %rbx
leaq 0x128(%rsp), %r12
movq 0x150(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x2, 0x170(%rsp,%rax)
jne 0x38c0
movl $0x1, %r14d
leaq 0x150(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x2754
movq (%rsp), %rcx
cmpl (%rcx), %eax
jne 0x38c0
leaq 0x150(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x288e
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, %r15
movl $0x7, %edx
movq %rax, %rdi
leaq 0x2b09(%rip), %rsi      # 0x60c3
callq 0x2210
movq %r15, %rdi
movq %r13, %rsi
callq 0x2140
movq %rax, %r15
movl $0xd, %edx
movq %rax, %rdi
leaq 0x2aef(%rip), %rsi      # 0x60cb
callq 0x2210
movl %r14d, %esi
movq %r15, %rdi
callq 0x2140
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x21d0
movsbl %al, %esi
movq %r15, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2150
movl $0x4, %edx
movq %rbp, %rdi
leaq 0x2ab4(%rip), %rsi      # 0x60d9
callq 0x2210
leaq 0x110(%rsp), %r15
movq %r15, %rdi
leaq 0x60(%rsp), %rsi
callq 0x3c80
movq %rbx, %rdi
movq %r15, %rsi
callq 0x3246
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
movq %rbp, %rdi
callq 0x2210
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x21d0
movsbl %al, %esi
movq %r15, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2150
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x36a2
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x21f0
movq 0x110(%rsp), %rdi
testq %rdi, %rdi
je 0x36bf
movq 0x120(%rsp), %rsi
subq %rdi, %rsi
callq 0x21f0
movl $0x5, %edx
movq %rbp, %rdi
leaq 0x2a10(%rip), %rsi      # 0x60de
callq 0x2210
leaq 0xf8(%rsp), %r15
movq %r15, %rdi
leaq 0x40(%rsp), %rsi
callq 0x3c80
movq %rbx, %rdi
movq %r15, %rsi
callq 0x3246
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
movq %rbp, %rdi
callq 0x2210
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x21d0
movsbl %al, %esi
movq %r15, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2150
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x374b
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x21f0
movq 0xf8(%rsp), %rdi
testq %rdi, %rdi
je 0x3768
movq 0x108(%rsp), %rsi
subq %rdi, %rsi
callq 0x21f0
movq %r12, %rdi
leaq 0x60(%rsp), %rsi
callq 0x2dfa
movq %r12, %rdi
leaq 0x80(%rsp), %rsi
callq 0x2d6e
movl $0x5, %edx
movq %rbp, %rdi
leaq 0x2950(%rip), %rsi      # 0x60e4
callq 0x2210
leaq 0xe0(%rsp), %r15
movq %r15, %rdi
leaq 0x80(%rsp), %rsi
callq 0x3c80
movq %rbx, %rdi
movq %r15, %rsi
callq 0x3246
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
movq %rbp, %rdi
callq 0x2210
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x21d0
movsbl %al, %esi
movq %r15, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2150
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x3814
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x21f0
movq 0xe0(%rsp), %rdi
testq %rdi, %rdi
je 0x3831
movq 0xf0(%rsp), %rsi
subq %rdi, %rsi
callq 0x21f0
movq %r12, %rdi
leaq 0x40(%rsp), %rsi
callq 0x2efc
movl $0xf, %edx
movq %rbp, %rdi
leaq 0x289d(%rip), %rsi      # 0x60ea
callq 0x2210
movsd 0x128(%rsp), %xmm0
movq %rbp, %rdi
callq 0x22b0
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x21d0
movsbl %al, %esi
movq %r15, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2150
movsd 0x128(%rsp), %xmm0
leaq 0x358(%rsp), %rdi
callq 0x263c
incl %r14d
movq 0x150(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x2, 0x170(%rsp,%rax)
je 0x3550
movq 0x150(%rsp), %rax
movq -0x18(%rax), %rdi
leaq 0x150(%rsp), %r14
addq %r14, %rdi
xorl %esi, %esi
callq 0x22f0
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2240
incq %r13
cmpq $0x5, %r13
jne 0x3530
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x3914
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x21f0
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x392b
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x21f0
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x3942
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x21f0
leaq 0x138(%rsp), %rdi
callq 0x3c3e
leaq 0x358(%rsp), %rdi
callq 0x25f8
leaq 0x150(%rsp), %rdi
callq 0x273a
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x397f
movq 0x10(%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
jmp 0x39fb
movq %rax, %rbx
jmp 0x3b32
movq %rax, %rbx
movq 0xa0(%rsp), %rdi
cmpq %r14, %rdi
je 0x3b3f
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x21f0
jmp 0x3b3f
movq %rax, %rbx
jmp 0x3b3f
movq %rax, %rbx
movq 0xc0(%rsp), %rdi
cmpq %r14, %rdi
je 0x3b4c
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x21f0
jmp 0x3b4c
movq %rax, %rbx
jmp 0x3b4c
jmp 0x3ad7
movq %rax, %rbx
jmp 0x3a82
movq %rax, %rbx
jmp 0x3a48
jmp 0x3ad7
jmp 0x3ad7
jmp 0x3ad7
movq %rax, %rbx
jmp 0x3ab8
movq %rax, %rbx
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x3a48
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x21f0
movq 0xe0(%rsp), %rdi
testq %rdi, %rdi
je 0x3ada
movq 0xf0(%rsp), %rsi
jmp 0x3acd
movq %rax, %rbx
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x3a82
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x21f0
movq 0xf8(%rsp), %rdi
testq %rdi, %rdi
je 0x3ada
movq 0x108(%rsp), %rsi
jmp 0x3acd
movq %rax, %rbx
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x3ab8
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x21f0
movq 0x110(%rsp), %rdi
testq %rdi, %rdi
je 0x3ada
movq 0x120(%rsp), %rsi
subq %rdi, %rsi
callq 0x21f0
jmp 0x3ada
movq %rax, %rbx
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x3af7
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x21f0
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x3b0e
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x21f0
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x3b25
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x21f0
leaq 0x138(%rsp), %rdi
callq 0x3c3e
leaq 0x358(%rsp), %rdi
callq 0x25f8
leaq 0x150(%rsp), %rdi
callq 0x273a
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x3b62
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x21f0
movq %rbx, %rdi
callq 0x2310