// File: /workspace/github_cpp_makefile_star2_O1/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, 0x8(%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, 0x20(%rsp)
xorl %eax, %eax
movq %rax, 0x20(%rdi)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x10(%rdi)
leaq 0x30(%rdi), %rcx
movq %rcx, 0x18(%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, 0x10(%rsp)
leaq 0x148(%rdi), %rcx
movq %rcx, 0x28(%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 0x932d(%rip), %rdi      # 0xffa0
leaq 0x53f7(%rip), %rsi      # 0xc071
movl $0x22, %edx
callq 0x62d0
cvtsi2sd %r13d, %xmm1
movsd 0x537f(%rip), %xmm0     # 0xc010
callq 0x6410
movsd 0x536a(%rip), %xmm1     # 0xc008
divsd %xmm0, %xmm1
movq 0x92f7(%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 0x6cf3
sqrtsd %xmm0, %xmm0
jmp 0x6cf8
callq 0x6200
cvttsd2si %xmm0, %eax
movl %eax, 0x8(%rbx)
movq 0x929a(%rip), %rdi      # 0xffa0
leaq 0x5387(%rip), %rsi      # 0xc094
movl $0x35, %edx
callq 0x62d0
movl 0x4(%rbx), %esi
movq 0x927f(%rip), %rdi      # 0xffa0
callq 0x6400
movq %rax, %r13
leaq 0x539a(%rip), %rsi      # 0xc0ca
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 0x28(%rsp), %rdi
callq 0x8100
testl %ebp, %ebp
jle 0x6d83
movl %ebp, %r12d
movl $0xb0, %edi
callq 0x6270
movq %rax, %r13
movq %rax, %rdi
movq %rbx, %rsi
callq 0x665c
decl %r12d
jne 0x6d66
movq 0x9216(%rip), %rdi      # 0xffa0
movl %ebp, %esi
callq 0x6400
movq %rax, %r12
leaq 0x5342(%rip), %rsi      # 0xc0dd
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 0x20(%rsp), %rdi
callq 0x8100
movl 0x28(%rbx), %esi
movq %rbx, %rdi
movl $0x1, %edx
callq 0x7040
movl %r14d, 0x48(%rbx)
movslq %r14d, %rsi
movq 0x18(%rsp), %rdi
callq 0x8100
movl 0x48(%rbx), %esi
movq %rbx, %rdi
movl $0x2, %edx
callq 0x7040
movq %rbx, %rdi
movl $0x4, %esi
callq 0x7300
movq %rbx, %rdi
movl $0x3, %esi
callq 0x7300
movq %rbx, %rdi
xorl %esi, %esi
callq 0x7300
movb 0x80(%rsp), %r14b
movl 0x4(%rsp), %eax
movb %al, 0x80(%rbx)
movq 0x58(%rbx), %rax
subq 0x50(%rbx), %rax
movq 0x38(%rbx), %rcx
sarq $0x3, %rax
subq 0x30(%rbx), %rcx
sarq $0x3, %rcx
xorl %edx, %edx
divq %rcx
movq %rax, %xmm1
punpckldq 0x51e1(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x51e9(%rip), %xmm1     # 0xc050
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x6e83
sqrtsd %xmm0, %xmm0
jmp 0x6e88
callq 0x6200
movsd 0x8(%rsp), %xmm1
cvttsd2si %xmm0, %eax
movl %eax, 0x84(%rbx)
movb %r14b, 0x88(%rbx)
movsd %xmm1, 0x90(%rbx)
movl $0x0, 0x98(%rbx)
movq %rbx, %rdi
callq 0x7428
movq $0x0, 0x180(%rbx)
movslq 0x48(%rbx), %rsi
movq 0x10(%rsp), %rdi
callq 0x8196
movq $0x0, 0x178(%rbx)
xorl %eax, %eax
movb %al, 0x128(%rbx)
movb %al, 0x140(%rbx)
movq %rbx, %rdi
callq 0x74be
movq %fs:0x28, %rax
cmpq 0x40(%rsp), %rax
jne 0x703a
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x6f2a
movq %rax, %r14
movl $0xb0, %esi
movq %r13, %rdi
callq 0x6280
jmp 0x6f2d
movq %rax, %r14
movq 0x160(%rbx), %rdi
testq %rdi, %rdi
je 0x6f48
movq 0x170(%rbx), %rsi
subq %rdi, %rsi
callq 0x6280
movq 0x28(%rsp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x6f64
movq 0x158(%rbx), %rsi
subq %rdi, %rsi
callq 0x6280
cmpq $0x0, 0x138(%rbx)
jne 0x7035
leaq 0x130(%rbx), %rax
cmpq $0x0, (%rax)
jne 0x7035
leaq 0xa0(%rbx), %r15
leaq 0xd8(%rbx), %r12
movq 0x10(%rsp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x6fad
movq 0x120(%rbx), %rsi
subq %rdi, %rsi
callq 0x6280
leaq 0x50(%rbx), %r13
movq %r12, %rdi
callq 0x834e
movq %r15, %rdi
callq 0x834e
movq 0x68(%rbx), %rdi
testq %rdi, %rdi
je 0x6fd6
movq 0x78(%rbx), %rsi
subq %rdi, %rsi
callq 0x6280
movq (%r13), %rdi
testq %rdi, %rdi
je 0x6feb
movq 0x60(%rbx), %rsi
subq %rdi, %rsi
callq 0x6280
movq 0x18(%rsp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x7004
movq 0x40(%rbx), %rsi
subq %rdi, %rsi
callq 0x6280
movq 0x20(%rsp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x701d
movq 0x20(%rbx), %rsi
subq %rdi, %rsi
callq 0x6280
movq %fs:0x28, %rax
cmpq 0x40(%rsp), %rax
jne 0x703a
movq %r14, %rdi
callq 0x6440
callq 0x6070
callq 0x62a0
nop