// File: /workspace/github_cpp_makefile_star2_O3/gkosae[P]ArduinoNeuralNet/neuralnet.cpp
// Function: NeuralNet::writeBody(std::__cxx11::basic_stringstream<char, std::char_traits<char>, std::allocator<char>>&)
void NeuralNet::writeBody(stringstream& ss) {
    ss << "NeuralNet network{};\n\n";

    ss << "// Function to populate neural network\n";
    ss << "void populateNetwork() {\n";
    ss << "\tvector<Neuron> temp{};\n\n";

    std::string input_neuron_prefix = "in_";
    std::string output_neuron_prefix = "out_";
    std::string hidden_layer_prefix = "hi_";

    ss << "\t// Input layer\n";
    unsigned short number_of_inputs = layers.front().size();
    for(auto i = 0; i < number_of_inputs; i++) {
      ss << "\tNeuron " << input_neuron_prefix << i+1 << "{};";
      ss << "\ttemp.push_back(" << input_neuron_prefix << i+1 << ");\n";
    }

    ss << "\tLayer input_layer{temp};\n";
    ss << "\tnetwork.addLayer(input_layer);\n";
    ss << "\ttemp.clear();\n\n";

    // Create hidden layers
    unsigned short number_of_hidden_layers = layers.size() - 2;
    for(auto i = 0; i < number_of_hidden_layers; i++) {

        ss << "\t// Hidden layer " << i+1 << '\n';
        unsigned int current_layer_size = layers.at(i+1).size();
        for(auto j = 0; j < current_layer_size; j++) {
            ss << "\tNeuron " << hidden_layer_prefix << i+1 << "_" << j+1 << "{vector<double>{";
            unsigned short number_of_weights = layers.at(i+1).neurons.at(j).weights.size();

            for(auto k = 0; k <  number_of_weights; k++) {
              ss << layers.at(i+1).neurons.at(j).weights.at(k);
              if(k != number_of_weights - 1) ss << ", ";
            }

            ss << "}, " << layers.at(i+1).neurons.at(j).threshold << "};";
            ss << "\ttemp.push_back(" << hidden_layer_prefix << i+1 << "_" << j+1 << ");\n";
        }

        ss << "\tLayer " << hidden_layer_prefix << i+1 << "{temp};\n";
        ss << "\tnetwork.addLayer(" << hidden_layer_prefix << i+1 << ");\n";
        ss << "\ttemp.clear();\n\n";
    }


    ss << "\t// Output layer\n";
    unsigned short number_of_outputs = layers.back().size();
    for(auto i = 0; i < number_of_outputs; i++) {
      ss << "\tNeuron " << output_neuron_prefix << i+1 << "{vector<double>{";

      unsigned short number_of_weights = layers.back().neurons.at(i).weights.size();

      for(auto j = 0; j < number_of_weights; j++) {
        ss << layers.back().neurons.at(i).weights.at(j);
        if(j != number_of_weights - 1)ss << ", ";
      }

      ss << "}, " << layers.back().neurons.at(i).threshold << "};";
      ss << "\ttemp.push_back(" << output_neuron_prefix << i+1 << ");\n";
    }

    ss << "\tLayer output_layer{temp};\n";
    ss << "\tnetwork.addLayer(output_layer);\n";
    ss << "\ttemp.clear();\n\n";

    ss << "}\n\n";

    ss << "// Arduino boilerplate\n";
    ss << "void setup() {\n";
    ss << "\t populateNetwork();\n";
    ss << "}\n\n";
    ss << "void loop() {\n \n}\n\n";
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rsi, %rbx
movq %rdi, 0x8(%rsp)
addq $0x10, %rbx
leaq 0x2b85(%rip), %rsi      # 0x72e9
movl $0x16, %edx
movq %rbx, %rdi
callq 0x2190
leaq 0x2b88(%rip), %rsi      # 0x7300
movl $0x27, %edx
movq %rbx, %rdi
callq 0x2190
leaq 0x2b9c(%rip), %rsi      # 0x7328
movl $0x19, %edx
movq %rbx, %rdi
callq 0x2190
leaq 0x2ba2(%rip), %rsi      # 0x7342
movl $0x19, %edx
movq %rbx, %rdi
callq 0x2190
leaq 0x78(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x2b9f(%rip), %rsi      # 0x735c
leaq 0x2b9b(%rip), %rdx      # 0x735f
leaq 0x68(%rsp), %rdi
callq 0x28b2
leaq 0x58(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x2b82(%rip), %rsi      # 0x7360
leaq 0x2b7f(%rip), %rdx      # 0x7364
leaq 0x48(%rsp), %rdi
callq 0x28b2
leaq 0x30(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x2b66(%rip), %rsi      # 0x7365
leaq 0x2b62(%rip), %rdx      # 0x7368
leaq 0x20(%rsp), %rdi
callq 0x28b2
leaq 0x2b52(%rip), %rsi      # 0x7369
movl $0x10, %edx
movq %rbx, %rdi
callq 0x2190
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rax
movl 0x20(%rax), %ecx
subl 0x18(%rax), %ecx
shrl $0x6, %ecx
movzwl %cx, %r13d
negl %r13d
movl $0x1, %r15d
leaq 0x2b30(%rip), %r14      # 0x737a
leaq 0x2b36(%rip), %rbp      # 0x7387
leaq 0x2c59(%rip), %r12      # 0x74b1
leal (%r15,%r13), %eax
cmpl $0x1, %eax
je 0x48eb
movl $0x8, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2190
movq 0x68(%rsp), %rsi
movq 0x70(%rsp), %rdx
movq %rbx, %rdi
callq 0x2190
movq %rax, %rdi
movl %r15d, %esi
callq 0x2250
movl $0x3, %edx
movq %rax, %rdi
leaq 0x2ae2(%rip), %rsi      # 0x7383
callq 0x2190
movl $0x10, %edx
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x2190
movq 0x68(%rsp), %rsi
movq 0x70(%rsp), %rdx
movq %rbx, %rdi
callq 0x2190
movq %rax, %rdi
movl %r15d, %esi
callq 0x2250
incl %r15d
movl $0x3, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x2190
jmp 0x4858
leaq 0x2aa6(%rip), %rsi      # 0x7398
movl $0x1a, %edx
movq %rbx, %rdi
callq 0x2190
leaq 0x2aad(%rip), %rsi      # 0x73b3
movl $0x20, %edx
movq %rbx, %rdi
callq 0x2190
leaq 0x2aba(%rip), %rsi      # 0x73d4
movl $0x10, %edx
movq %rbx, %rdi
callq 0x2190
movq 0x8(%rsp), %rcx
movl 0x20(%rcx), %eax
subl 0x18(%rcx), %eax
shrl $0x4, %eax
imull $0xaaaaaaab, %eax, %eax # imm = 0xAAAAAAAB
addl $0xfffe, %eax           # imm = 0xFFFE
movzwl %ax, %eax
movq %rax, 0x88(%rsp)
xorl %ebp, %ebp
leaq 0x2a13(%rip), %r15      # 0x7367
movq %rbx, 0x18(%rsp)
cmpq 0x88(%rsp), %rbp
je 0x4d26
movl $0x11, %edx
movq %rbx, %rdi
leaq 0x2a6f(%rip), %rsi      # 0x73e5
callq 0x2190
incq %rbp
movq %rbx, %rdi
movl %ebp, %esi
callq 0x2250
movb $0xa, 0x7(%rsp)
movl $0x1, %edx
movq %rax, %rdi
leaq 0x7(%rsp), %rsi
callq 0x2190
movq 0x8(%rsp), %rcx
movq 0x18(%rcx), %rax
movq 0x20(%rcx), %rdx
subq %rax, %rdx
sarq $0x4, %rdx
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rdx
cmpq %rbp, %rdx
jbe 0x5074
leaq (,%rbp,2), %r12
addq %rbp, %r12
shlq $0x4, %r12
movl 0x20(%rax,%r12), %ecx
subl 0x18(%rax,%r12), %ecx
shrl $0x6, %ecx
movzwl %cx, %eax
movq %rax, 0x90(%rsp)
movq $0x0, 0x10(%rsp)
movq 0x10(%rsp), %rax
cmpq 0x90(%rsp), %rax
je 0x4c85
movl $0x8, %edx
movq %rbx, %rdi
leaq 0x295e(%rip), %rsi      # 0x737a
callq 0x2190
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
movq %rbx, %rdi
callq 0x2190
movq %rax, %rdi
movl %ebp, %esi
callq 0x2250
movq %rax, %r13
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2190
movq 0x10(%rsp), %rax
leaq 0x1(%rax), %rsi
movq %r13, %rdi
movq %rsi, 0x40(%rsp)
callq 0x2250
movl $0x10, %edx
movq %rax, %rdi
leaq 0x2982(%rip), %rsi      # 0x73f7
callq 0x2190
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rcx
movq 0x20(%rax), %rdx
subq %rcx, %rdx
sarq $0x4, %rdx
movabsq $-0x5555555555555555, %rax # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %rdx
cmpq %rbp, %rdx
jbe 0x503e
movq 0x18(%rcx,%r12), %rax
movq 0x20(%rcx,%r12), %rdx
subq %rax, %rdx
sarq $0x6, %rdx
movq 0x10(%rsp), %rsi
cmpq %rsi, %rdx
jbe 0x5041
movq %rsi, %r13
shlq $0x6, %r13
movl 0x28(%rax,%r13), %ecx
subl 0x20(%rax,%r13), %ecx
shrl $0x3, %ecx
andl $0xffff, %ecx           # imm = 0xFFFF
je 0x4b85
leal -0x1(%rcx), %ebx
movl %ecx, %r14d
xorl %r15d, %r15d
movq 0x8(%rsp), %rcx
movq 0x18(%rcx), %rax
movq 0x20(%rcx), %rdx
subq %rax, %rdx
sarq $0x4, %rdx
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rdx
cmpq %rbp, %rdx
jbe 0x502d
movq 0x18(%rax,%r12), %rcx
movq 0x20(%rax,%r12), %rdx
subq %rcx, %rdx
sarq $0x6, %rdx
cmpq 0x10(%rsp), %rdx
jbe 0x5021
movq 0x20(%rcx,%r13), %rax
movq 0x28(%rcx,%r13), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq %r15, %rdx
jbe 0x5028
movsd (%rax,%r15,8), %xmm0
movq 0x18(%rsp), %rdi
callq 0x2200
cmpq %r15, %rbx
je 0x4b79
movl $0x2, %edx
movq 0x18(%rsp), %rdi
leaq 0x2895(%rip), %rsi      # 0x7409
callq 0x2190
incq %r15
cmpq %r15, %r14
jne 0x4aed
movl $0x3, %edx
movq 0x18(%rsp), %rbx
movq %rbx, %rdi
leaq 0x286f(%rip), %rsi      # 0x7408
callq 0x2190
leaq 0x27c2(%rip), %r15      # 0x7367
movq 0x8(%rsp), %rcx
movq 0x18(%rcx), %rax
movq 0x20(%rcx), %rdx
subq %rax, %rdx
sarq $0x4, %rdx
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rdx
cmpq %rbp, %rdx
jbe 0x503e
movq 0x18(%rax,%r12), %rcx
movq 0x20(%rax,%r12), %rdx
subq %rcx, %rdx
sarq $0x6, %rdx
movq 0x10(%rsp), %rsi
cmpq %rsi, %rdx
jbe 0x5041
movsd 0x18(%rcx,%r13), %xmm0
movq %rbx, %rdi
callq 0x2200
movl $0x2, %edx
movq %rax, %rdi
leaq 0x2777(%rip), %rsi      # 0x7384
callq 0x2190
movl $0x10, %edx
movq %rbx, %rdi
leaq 0x2766(%rip), %rsi      # 0x7387
callq 0x2190
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
movq %rbx, %rdi
callq 0x2190
movq %rax, %rdi
movl %ebp, %esi
callq 0x2250
movq %rax, %r13
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2190
movq %r13, %rdi
movq 0x40(%rsp), %rsi
callq 0x2250
movl $0x3, %edx
movq %rax, %rdi
leaq 0x2840(%rip), %rsi      # 0x74b1
callq 0x2190
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsp)
jmp 0x49fa
movl $0x7, %edx
movq %rbx, %rdi
leaq 0x2778(%rip), %rsi      # 0x740c
callq 0x2190
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
movq %rbx, %rdi
callq 0x2190
movq %rax, %rdi
movl %ebp, %esi
callq 0x2250
movl $0x8, %edx
movq %rax, %rdi
leaq 0x26e6(%rip), %rsi      # 0x73aa
callq 0x2190
movl $0x12, %edx
movq %rbx, %rdi
leaq 0x273c(%rip), %rsi      # 0x7414
callq 0x2190
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
movq %rbx, %rdi
callq 0x2190
movq %rax, %rdi
movl %ebp, %esi
callq 0x2250
movl $0x3, %edx
movq %rax, %rdi
leaq 0x27a9(%rip), %rsi      # 0x74b1
callq 0x2190
movl $0x10, %edx
movq %rbx, %rdi
leaq 0x26b8(%rip), %rsi      # 0x73d4
callq 0x2190
jmp 0x4959
leaq 0x26fa(%rip), %rsi      # 0x7427
movl $0x11, %edx
movq %rbx, %rdi
callq 0x2190
movq 0x8(%rsp), %rax
movq 0x20(%rax), %rax
movl -0x10(%rax), %ecx
subl -0x18(%rax), %ecx
shrl $0x6, %ecx
movzwl %cx, %eax
movq %rax, 0x10(%rsp)
xorl %r12d, %r12d
cmpq 0x10(%rsp), %r12
je 0x4f07
movl $0x8, %edx
movq %rbx, %rdi
leaq 0x2609(%rip), %rsi      # 0x737a
callq 0x2190
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %rdx
movq %rbx, %rdi
callq 0x2190
leaq 0x1(%r12), %r13
movq %rax, %rdi
movl %r13d, %esi
callq 0x2250
movl $0x10, %edx
movq %rax, %rdi
leaq 0x2650(%rip), %rsi      # 0x73f7
callq 0x2190
movq 0x8(%rsp), %rax
movq 0x20(%rax), %rcx
movq -0x18(%rcx), %rax
movq -0x10(%rcx), %rdx
subq %rax, %rdx
sarq $0x6, %rdx
cmpq %r12, %rdx
jbe 0x5063
movq %r12, %rbp
shlq $0x6, %rbp
movl 0x28(%rax,%rbp), %ecx
subl 0x20(%rax,%rbp), %ecx
shrl $0x3, %ecx
andl $0xffff, %ecx           # imm = 0xFFFF
je 0x4e5e
leal -0x1(%rcx), %ebx
movl %ecx, %r14d
xorl %r15d, %r15d
movq 0x8(%rsp), %rax
movq 0x20(%rax), %rcx
movq -0x18(%rcx), %rax
movq -0x10(%rcx), %rdx
subq %rax, %rdx
sarq $0x6, %rdx
cmpq %r12, %rdx
jbe 0x5052
movq 0x20(%rax,%rbp), %rcx
movq 0x28(%rax,%rbp), %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
cmpq %r15, %rdx
jbe 0x504f
movsd (%rcx,%r15,8), %xmm0
movq 0x18(%rsp), %rdi
callq 0x2200
cmpq %r15, %rbx
je 0x4e56
movl $0x2, %edx
movq 0x18(%rsp), %rdi
leaq 0x25b8(%rip), %rsi      # 0x7409
callq 0x2190
incq %r15
cmpq %r15, %r14
jne 0x4df0
movl $0x3, %edx
movq 0x18(%rsp), %rbx
movq %rbx, %rdi
leaq 0x2596(%rip), %rsi      # 0x7408
callq 0x2190
movq 0x8(%rsp), %rax
movq 0x20(%rax), %rcx
movq -0x18(%rcx), %rax
movq -0x10(%rcx), %rdx
subq %rax, %rdx
sarq $0x6, %rdx
cmpq %r12, %rdx
jbe 0x5063
movsd 0x18(%rax,%rbp), %xmm0
movq %rbx, %rdi
callq 0x2200
movl $0x2, %edx
movq %rax, %rdi
leaq 0x24cf(%rip), %rsi      # 0x7384
callq 0x2190
movl $0x10, %edx
movq %rbx, %rdi
leaq 0x24be(%rip), %rsi      # 0x7387
callq 0x2190
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %rdx
movq %rbx, %rdi
callq 0x2190
movq %rax, %rdi
movl %r13d, %esi
callq 0x2250
movl $0x3, %edx
movq %rax, %rdi
leaq 0x25b7(%rip), %rsi      # 0x74b1
callq 0x2190
movq %r13, %r12
jmp 0x4d57
leaq 0x252b(%rip), %rsi      # 0x7439
movl $0x1b, %edx
movq %rbx, %rdi
callq 0x2190
leaq 0x2533(%rip), %rsi      # 0x7455
movl $0x21, %edx
movq %rbx, %rdi
callq 0x2190
leaq 0x249e(%rip), %rsi      # 0x73d4
movl $0x10, %edx
movq %rbx, %rdi
callq 0x2190
leaq 0x257b(%rip), %rsi      # 0x74c5
movl $0x3, %edx
movq %rbx, %rdi
callq 0x2190
leaq 0x2519(%rip), %rsi      # 0x7477
movl $0x17, %edx
movq %rbx, %rdi
callq 0x2190
leaq 0x251d(%rip), %rsi      # 0x748f
movl $0xf, %edx
movq %rbx, %rdi
callq 0x2190
leaq 0x2519(%rip), %rsi      # 0x749f
movl $0x15, %edx
movq %rbx, %rdi
callq 0x2190
leaq 0x252b(%rip), %rsi      # 0x74c5
movl $0x3, %edx
movq %rbx, %rdi
callq 0x2190
leaq 0x2507(%rip), %rsi      # 0x74b5
movl $0x13, %edx
movq %rbx, %rdi
callq 0x2190
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x4fd7
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x2180
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x4ff3
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x2180
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0x500f
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x2180
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x10(%rsp), %rsi
jmp 0x5030
movq %r15, %rsi
jmp 0x5030
movq %rbp, %rsi
leaq 0x20ac(%rip), %rdi      # 0x70e3
xorl %eax, %eax
callq 0x21d0
movq %rbp, %rsi
leaq 0x209b(%rip), %rdi      # 0x70e3
xorl %eax, %eax
callq 0x21d0
movq %r15, %r12
leaq 0x208a(%rip), %rdi      # 0x70e3
movq %r12, %rsi
xorl %eax, %eax
callq 0x21d0
leaq 0x2079(%rip), %rdi      # 0x70e3
movq %r12, %rsi
xorl %eax, %eax
callq 0x21d0
leaq 0x2068(%rip), %rdi      # 0x70e3
movq %rbp, %rsi
xorl %eax, %eax
callq 0x21d0
jmp 0x50b1
jmp 0x50b1
movq %rax, %rbx
jmp 0x50d0
movq %rax, %rbx
jmp 0x50ec
jmp 0x50b1
jmp 0x50b1
jmp 0x50b1
jmp 0x50b1
jmp 0x50b1
jmp 0x50b1
jmp 0x50b1
jmp 0x50b1
jmp 0x50b1
jmp 0x50b1
jmp 0x50b1
jmp 0x50b1
jmp 0x50b1
jmp 0x50b1
jmp 0x50b1
movq %rax, %rbx
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x50d0
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x2180
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x50ec
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x2180
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0x5108
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x2180
movq %rbx, %rdi
callq 0x2260