// File: /workspace/github_cpp_makefile_star2_O3/mertyildiran[P]Plexus/plexus/plexus.cpp
// Function: Network::Network(int, int, int, double, int, bool, bool, bool, double)
Network::Network(
    int size,
    int input_dim = 0,
    int output_dim = 0,
    double connectivity = 0.01,
    int precision = 2,
    bool randomly_fire = false,
    bool dynamic_output = false,
    bool visualization = false,
    double decay_factor = 1.0
)
{
    this->precision = precision;
    std::cout << "\nPrecision of the network will be "
        << 1.0 / pow(10, precision) << '\n';
    this->connectivity = static_cast<int>(size * connectivity);
    this->connectivity_sqrt = static_cast<int>(sqrt(this->connectivity));
    std::cout << "Each individual non-sensory neuron will subscribe to "
        << this->connectivity << " different neurons" << '\n';

    this->neurons.reserve(size);
    for (int i = 0; i < size; i++) {
        new Neuron(*this);
    }
    std::cout << size << " neurons created" << '\n';

    this->input_dim = input_dim;
    this->sensory_neurons.reserve(this->input_dim);
    this->pick_neurons_by_type(this->input_dim, SENSORY_NEURON);

    this->output_dim = output_dim;
    this->motor_neurons.reserve(this->output_dim);
    this->pick_neurons_by_type(this->output_dim, MOTOR_NEURON);

    this->get_neurons_by_type(NON_SENSORY_NEURON);
    this->get_neurons_by_type(NON_MOTOR_NEURON);
    this->get_neurons_by_type(INTER_NEURON);
    this->randomly_fire = randomly_fire;
    this->motor_randomly_fire_rate = sqrt(
        this->nonsensory_neurons.size() / this->motor_neurons.size()
    );

    this->dynamic_output = dynamic_output;

    this->decay_factor = decay_factor;

    this->initiated_neurons = 0;
    this->initiate_subscriptions();

    this->fire_counter = 0;
    this->output.reserve(this->output_dim);
    this->wave_counter = 0;

    this->freezer = false;
    this->thread_kill_signal = false;
    this->ignite();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movsd %xmm1, 0x28(%rsp)
movl %r9d, 0x4(%rsp)
movl %r8d, %r13d
movsd %xmm0, 0x30(%rsp)
movl %ecx, %r14d
movl %edx, %r15d
movl %esi, %ebp
movq %rdi, %rbx
movq %fs:0x28, %rax
movq %rax, 0x40(%rsp)
leaq 0x10(%rdi), %rax
movq %rax, 0x18(%rsp)
xorl %eax, %eax
movq %rax, 0x20(%rdi)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x10(%rdi)
leaq 0x30(%rdi), %rcx
movq %rcx, 0x10(%rsp)
movupd %xmm0, 0x30(%rdi)
movq %rax, 0x40(%rdi)
leaq 0xd0(%rdi), %rcx
movupd %xmm0, 0x50(%rdi)
movupd %xmm0, 0x60(%rdi)
movupd %xmm0, 0x70(%rdi)
movq %rcx, 0xa0(%rdi)
movl $0x1, %ecx
movq %rcx, 0xa8(%rdi)
movupd %xmm0, 0xb0(%rdi)
movl $0x3f800000, %edx       # imm = 0x3F800000
movl %edx, 0xc0(%rdi)
movupd %xmm0, 0xc8(%rdi)
leaq 0x108(%rdi), %rsi
movq %rsi, 0xd8(%rdi)
movq %rcx, 0xe0(%rdi)
movupd %xmm0, 0xe8(%rdi)
movl %edx, 0xf8(%rdi)
leaq 0x110(%rdi), %rcx
movq %rcx, 0x8(%rsp)
leaq 0x148(%rdi), %rcx
movq %rcx, 0x20(%rsp)
movupd %xmm0, 0x100(%rdi)
movupd %xmm0, 0x110(%rdi)
movq %rax, 0x120(%rdi)
movupd %xmm0, 0x130(%rdi)
movupd %xmm0, 0x168(%rdi)
movupd %xmm0, 0x158(%rdi)
movupd %xmm0, 0x148(%rdi)
movl %r8d, (%rdi)
movq 0x933d(%rip), %rdi      # 0xffa0
leaq 0x5447(%rip), %rsi      # 0xc0b1
movl $0x22, %edx
callq 0x62d0
cvtsi2sd %r13d, %xmm1
movsd 0x538f(%rip), %xmm0     # 0xc010
callq 0x6410
movsd 0x537a(%rip), %xmm1     # 0xc008
divsd %xmm0, %xmm1
movq 0x9307(%rip), %rdi      # 0xffa0
movapd %xmm1, %xmm0
callq 0x63a0
leaq 0x3d(%rsp), %rsi
movb $0xa, (%rsi)
movl $0x1, %edx
movq %rax, %rdi
callq 0x62d0
xorps %xmm0, %xmm0
cvtsi2sd %ebp, %xmm0
mulsd 0x30(%rsp), %xmm0
cvttsd2si %xmm0, %eax
cvttpd2dq %xmm0, %xmm0
cvtdq2pd %xmm0, %xmm0
movl %eax, 0x4(%rbx)
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x6ce3
sqrtsd %xmm0, %xmm0
jmp 0x6ce8
callq 0x6200
cvttsd2si %xmm0, %eax
movl %eax, 0x8(%rbx)
movq 0x92aa(%rip), %rdi      # 0xffa0
leaq 0x53d7(%rip), %rsi      # 0xc0d4
movl $0x35, %edx
callq 0x62d0
movl 0x4(%rbx), %esi
movq 0x928f(%rip), %rdi      # 0xffa0
callq 0x6400
movq %rax, %r13
leaq 0x53ea(%rip), %rsi      # 0xc10a
movl $0x12, %edx
movq %rax, %rdi
callq 0x62d0
leaq 0x3e(%rsp), %rsi
movb $0xa, (%rsi)
movl $0x1, %edx
movq %r13, %rdi
callq 0x62d0
movslq %ebp, %rsi
movq 0x20(%rsp), %rdi
callq 0x8152
testl %ebp, %ebp
jle 0x6d73
movl %ebp, %r12d
movl $0xb0, %edi
callq 0x6270
movq %rax, %r13
movq %rax, %rdi
movq %rbx, %rsi
callq 0x665c
decl %r12d
jne 0x6d56
movq 0x9226(%rip), %rdi      # 0xffa0
movl %ebp, %esi
callq 0x6400
movq %rax, %r12
leaq 0x5392(%rip), %rsi      # 0xc11d
movl $0x10, %edx
movq %rax, %rdi
callq 0x62d0
leaq 0x3f(%rsp), %rsi
movb $0xa, (%rsi)
movl $0x1, %edx
movq %r12, %rdi
callq 0x62d0
movl %r15d, 0x28(%rbx)
movslq %r15d, %rsi
movq 0x18(%rsp), %rdi
callq 0x8152
movl 0x28(%rbx), %esi
movq %rbx, %rdi
movl $0x1, %edx
callq 0x7020
movl %r14d, 0x48(%rbx)
movslq %r14d, %rsi
movq 0x10(%rsp), %rdi
callq 0x8152
movl 0x48(%rbx), %esi
movq %rbx, %rdi
movl $0x2, %edx
callq 0x7020
movq %rbx, %rdi
movl $0x4, %esi
callq 0x72e0
movq %rbx, %rdi
movl $0x3, %esi
callq 0x72e0
movq %rbx, %rdi
xorl %esi, %esi
callq 0x72e0
movb 0x80(%rsp), %cl
movl 0x4(%rsp), %eax
movb %al, 0x80(%rbx)
movq 0x58(%rbx), %rax
subq 0x50(%rbx), %rax
movq 0x38(%rbx), %rsi
sarq $0x3, %rax
subq 0x30(%rbx), %rsi
sarq $0x3, %rsi
xorl %edx, %edx
divq %rsi
movq %rax, %xmm0
punpckldq 0x51f2(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x51fa(%rip), %xmm0     # 0xc050
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
xorps %xmm0, %xmm0
sqrtsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, 0x84(%rbx)
movb %cl, 0x88(%rbx)
movsd 0x28(%rsp), %xmm0
movsd %xmm0, 0x90(%rbx)
movl $0x0, 0x98(%rbx)
movq %rbx, %rdi
callq 0x7408
movq $0x0, 0x180(%rbx)
movslq 0x48(%rbx), %rsi
movq 0x8(%rsp), %rdi
callq 0x81ee
movq $0x0, 0x178(%rbx)
xorl %eax, %eax
movb %al, 0x128(%rbx)
movb %al, 0x140(%rbx)
movq %rbx, %rdi
callq 0x749e
movq %fs:0x28, %rax
cmpq 0x40(%rsp), %rax
jne 0x701a
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x6f0a
movq %rax, %r14
movl $0xb0, %esi
movq %r13, %rdi
callq 0x6280
jmp 0x6f0d
movq %rax, %r14
movq 0x160(%rbx), %rdi
testq %rdi, %rdi
je 0x6f28
movq 0x170(%rbx), %rsi
subq %rdi, %rsi
callq 0x6280
movq 0x20(%rsp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x6f44
movq 0x158(%rbx), %rsi
subq %rdi, %rsi
callq 0x6280
cmpq $0x0, 0x138(%rbx)
jne 0x7015
leaq 0x130(%rbx), %rax
cmpq $0x0, (%rax)
jne 0x7015
leaq 0xa0(%rbx), %r15
leaq 0xd8(%rbx), %r12
movq 0x8(%rsp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x6f8d
movq 0x120(%rbx), %rsi
subq %rdi, %rsi
callq 0x6280
leaq 0x50(%rbx), %r13
movq %r12, %rdi
callq 0x839c
movq %r15, %rdi
callq 0x839c
movq 0x68(%rbx), %rdi
testq %rdi, %rdi
je 0x6fb6
movq 0x78(%rbx), %rsi
subq %rdi, %rsi
callq 0x6280
movq (%r13), %rdi
testq %rdi, %rdi
je 0x6fcb
movq 0x60(%rbx), %rsi
subq %rdi, %rsi
callq 0x6280
movq 0x10(%rsp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x6fe4
movq 0x40(%rbx), %rsi
subq %rdi, %rsi
callq 0x6280
movq 0x18(%rsp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x6ffd
movq 0x20(%rbx), %rsi
subq %rdi, %rsi
callq 0x6280
movq %fs:0x28, %rax
cmpq 0x40(%rsp), %rax
jne 0x701a
movq %r14, %rdi
callq 0x6440
callq 0x6070
callq 0x62a0
nop