// File: /workspace/github_cpp_makefile_star2_O2/gkosae[P]ArduinoNeuralNet/neuralnet.cpp
// Function: NeuralNet::adjustWeights()
void NeuralNet::adjustWeights() {
    unsigned short count = layers.size();

    for(auto i = 1; i < count; ++i) {
        unsigned short current_layer_size = layers.at(i).size();

        for(auto j = 0; j <  current_layer_size; ++j) {
            unsigned short number_of_weights = layers.at(i).neurons.at(j).getNumberOfWeights();
            double delta = layers.at(i).neurons.at(j).delta;

            for(auto k = 0; k < number_of_weights; ++k) {
                double old_weight = layers.at(i).neurons.at(j).weights.at(k);
                double change_in_weight = (delta * layers.at(i).inputs.at(k)) + lambda*old_weight;
                double new_weight = old_weight - change_in_weight*learning_rate;
                layers.at(i).neurons.at(j).weights.at(k) = new_weight;
            }

            double old_threshold = layers.at(i).neurons.at(j).threshold;
            double change_in_threshold = delta * layers.at(i).neurons.at(j).bias;
            double new_threshold = old_threshold - change_in_threshold*learning_rate;
            layers.at(i).neurons.at(j).threshold = new_threshold;
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
movq 0x20(%rdi), %rax
subq 0x18(%rdi), %rax
leaq 0x18(%rdi), %r14
pushq $0x30
popq %rcx
cqto
idivq %rcx
movzwl %ax, %eax
movq %rax, 0x18(%rsp)
pushq $0x1
popq %r15
cmpq 0x18(%rsp), %r15
jae 0x38f1
movq %r14, %rdi
movq %r15, %rsi
callq 0x47c0
movl 0x20(%rax), %ecx
subl 0x18(%rax), %ecx
shrl $0x6, %ecx
movzwl %cx, %eax
movq %rax, 0x20(%rsp)
xorl %r12d, %r12d
cmpq 0x20(%rsp), %r12
je 0x38e9
movq %r14, %rdi
movq %r15, %rsi
callq 0x47c0
leaq 0x18(%rax), %rdi
movq %r12, %rsi
callq 0x479e
movl 0x28(%rax), %ebp
subl 0x20(%rax), %ebp
shrl $0x3, %ebp
movq %r14, %rdi
movq %r15, %rsi
callq 0x47c0
leaq 0x18(%rax), %rdi
movq %r12, %rsi
callq 0x479e
movsd 0x38(%rax), %xmm0
movsd %xmm0, 0x10(%rsp)
movzwl %bp, %ebp
xorl %r13d, %r13d
movq %r14, %rdi
movq %r15, %rsi
callq 0x47c0
leaq 0x18(%rax), %rdi
movq %r12, %rsi
callq 0x479e
cmpq %r13, %rbp
je 0x387d
addq $0x20, %rax
movq %rax, %rdi
movq %r13, %rsi
callq 0x264c
movsd (%rax), %xmm0
movsd %xmm0, 0x8(%rsp)
movq %r14, %rdi
movq %r15, %rsi
callq 0x47c0
movq %rax, %rdi
movq %r13, %rsi
callq 0x264c
movsd 0x80(%rbx), %xmm0
movsd 0x8(%rsp), %xmm2
mulsd %xmm2, %xmm0
movsd (%rax), %xmm1
mulsd 0x10(%rsp), %xmm1
addsd %xmm0, %xmm1
mulsd 0x8(%rbx), %xmm1
subsd %xmm1, %xmm2
movsd %xmm2, 0x8(%rsp)
movq %r14, %rdi
movq %r15, %rsi
callq 0x47c0
leaq 0x18(%rax), %rdi
movq %r12, %rsi
callq 0x479e
leaq 0x20(%rax), %rdi
movq %r13, %rsi
callq 0x264c
movsd 0x8(%rsp), %xmm0
movsd %xmm0, (%rax)
incq %r13
jmp 0x37ca
movsd 0x18(%rax), %xmm0
movsd %xmm0, 0x8(%rsp)
movq %r14, %rdi
movq %r15, %rsi
callq 0x47c0
leaq 0x18(%rax), %rdi
movq %r12, %rsi
callq 0x479e
movsd 0x10(%rsp), %xmm0
mulsd 0x10(%rax), %xmm0
mulsd 0x8(%rbx), %xmm0
movsd 0x8(%rsp), %xmm1
subsd %xmm0, %xmm1
movsd %xmm1, 0x8(%rsp)
movq %r14, %rdi
movq %r15, %rsi
callq 0x47c0
leaq 0x18(%rax), %rdi
movq %r12, %rsi
callq 0x479e
movsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x18(%rax)
incq %r12
jmp 0x3777
incq %r15
jmp 0x374d
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq