// File: /workspace/github_cpp_makefile_star2_O2/mertyildiran[P]Plexus/plexus/plexus.cpp
// Function: Network::_ignite(Network*)
void Network::_ignite(Network* network)
{
    unsigned int motor_fire_counter = 0;
    std::vector<Neuron*> ban_list;
    for (;;) {
        if (network->freezer) {
            usleep(10);
            continue;
        }
        if (network->randomly_fire) {
            Neuron* neuron = random_sample(
                network->nonsensory_neurons,
                1
            )[0];
            if (neuron->type == MOTOR_NEURON) {
                if (1 != Random::get(1, network->motor_randomly_fire_rate))
                    continue;
                else
                    motor_fire_counter++;
            }
            neuron->fire();
            if (motor_fire_counter >= network->motor_neurons.size()) {
                if (network->dynamic_output) {
                    network->print_output();
                }
                network->output = network->get_output();
                network->wave_counter++;
                motor_fire_counter = 0;
            }
        } else {
            if (network->next_queue.empty()) {
                for (auto& neuron: network->motor_neurons) {
                    neuron->fire();
                }
                for (auto& neuron: ban_list) {
                    neuron->ban_counter = 0;
                }
                ban_list.clear();
                if (network->dynamic_output) {
                    network->print_output();
                }
                network->output = network->get_output();
                network->wave_counter++;

                if (network->first_queue.empty()) {
                    for (auto const& neuron: network->sensory_neurons) {
                        network->first_queue.insert(
                            neuron->publications.begin(),
                            neuron->publications.end()
                        );
                    }
                }
                network->next_queue = network->first_queue;
            }

            std::unordered_map<Neuron*, double> current_queue
                = network->next_queue;
            network->next_queue.clear();
            for (auto const& neuron: ban_list) {
                if (neuron->ban_counter > network->connectivity_sqrt)
                    current_queue.erase(neuron);
            }
            while (current_queue.size() > 0) {
                auto it = current_queue.begin();
                std::advance(it, rand() % current_queue.size());
                Neuron* neuron = it->first;
                current_queue.erase(neuron);
                if (neuron->ban_counter <= network->connectivity_sqrt) {
                    if (neuron->type == MOTOR_NEURON) {
                        continue;
                    }
                    neuron->fire();
                    ban_list.push_back(neuron);
                    neuron->ban_counter++;
                    network->next_queue.insert(
                        neuron->publications.begin(),
                        neuron->publications.end()
                    );
                }
            }
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rdi, %rbx
movq %fs:0x28, %rax
movq %rax, 0xb0(%rsp)
xorps %xmm0, %xmm0
leaq 0x90(%rsp), %rax
andq $0x0, 0x10(%rax)
movaps %xmm0, (%rax)
leaq 0x50(%rdi), %r15
leaq 0xd8(%rdi), %rax
movq %rax, 0x10(%rsp)
leaq 0x110(%rdi), %rax
movq %rax, 0x18(%rsp)
leaq 0xa0(%rdi), %rax
movq %rax, 0x20(%rsp)
movq $0x0, 0x8(%rsp)
leaq 0x78(%rsp), %r14
leaq 0x40(%rsp), %rbp
pushq $0x1
popq %r12
movq %r15, 0x28(%rsp)
cmpb $0x1, 0x128(%rbx)
jne 0xa2f9
pushq $0xa
popq %rdi
callq 0x9360
jmp 0xa2e6
cmpb $0x1, 0x80(%rbx)
jne 0xa3c7
movq %r14, %rdi
movq %r15, %rsi
callq 0xab3a
movq %rbp, %rdi
movq %r14, %rsi
movl %r12d, %edx
callq 0xaa6a
movq 0x40(%rsp), %rax
movq (%rax), %r13
movq %rbp, %rdi
callq 0xc5aa
movq %r14, %rdi
callq 0xc5aa
cmpl $0x2, 0xa8(%r13)
jne 0xa360
movl 0x84(%rbx), %esi
movl %r12d, %edi
callq 0xacc2
cmpl $0x1, %eax
jne 0xa2e6
movq 0x8(%rsp), %rax
incl %eax
movq %rax, 0x8(%rsp)
movq %r13, %rdi
callq 0x98e8
movl 0x8(%rsp), %eax
movq 0x38(%rbx), %rcx
subq 0x30(%rbx), %rcx
sarq $0x3, %rcx
cmpq %rax, %rcx
ja 0xa2e6
cmpb $0x1, 0x88(%rbx)
jne 0xa392
movq %rbx, %rdi
callq 0xa600
movq %rbp, %rdi
movq %rbx, %rsi
callq 0xa6d2
movq 0x18(%rsp), %rdi
movq %rbp, %rsi
callq 0xcb94
movq %rbp, %rdi
callq 0xca0c
incq 0x178(%rbx)
movq $0x0, 0x8(%rsp)
jmp 0xa2e6
cmpq $0x0, 0xf0(%rbx)
jne 0xa47a
movq 0x30(%rbx), %r15
movq 0x38(%rbx), %r13
cmpq %r13, %r15
je 0xa3f0
movq (%r15), %rdi
callq 0x98e8
addq $0x8, %r15
jmp 0xa3dd
movq 0x90(%rsp), %rax
movq 0x98(%rsp), %rcx
movq %rax, %rdx
cmpq %rcx, %rdx
je 0xa418
movq (%rdx), %rsi
andl $0x0, 0xac(%rsi)
addq $0x8, %rdx
jmp 0xa403
cmpq %rax, %rcx
je 0xa425
movq %rax, 0x98(%rsp)
cmpb $0x0, 0x88(%rbx)
je 0xa436
movq %rbx, %rdi
callq 0xa600
movq %rbp, %rdi
movq %rbx, %rsi
callq 0xa6d2
movq 0x18(%rsp), %rdi
movq %rbp, %rsi
callq 0xcb94
movq %rbp, %rdi
callq 0xca0c
incq 0x178(%rbx)
cmpq $0x0, 0xb8(%rbx)
je 0xa574
movq 0x10(%rsp), %rdi
movq 0x20(%rsp), %rsi
callq 0xaeae
movq %rbp, %rdi
movq 0x10(%rsp), %r15
movq %r15, %rsi
callq 0xb238
movq %r15, %rdi
callq 0xae22
movq 0x90(%rsp), %r13
movq 0x98(%rsp), %r15
cmpq %r15, %r13
je 0xa556
movq (%r13), %rax
movl 0xac(%rax), %eax
cmpl 0x8(%rbx), %eax
jle 0xa4c5
movq %rbp, %rdi
movq %r13, %rsi
callq 0xcd7e
addq $0x8, %r13
jmp 0xa4a2
movq 0x50(%rsp), %rax
movq %rax, 0x38(%rsp)
callq 0x9060
cltq
xorl %edx, %edx
divq 0x58(%rsp)
leaq 0x38(%rsp), %rdi
movq %rdx, %rsi
callq 0xb37e
movq 0x38(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x30(%rsp)
movq %rbp, %rdi
leaq 0x30(%rsp), %rsi
callq 0xcd7e
movq 0x30(%rsp), %rdi
movl 0xac(%rdi), %eax
cmpl 0x8(%rbx), %eax
jg 0xa556
cmpl $0x2, 0xa8(%rdi)
je 0xa556
callq 0x98e8
leaq 0x90(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0xad14
movq 0x30(%rsp), %rax
incl 0xac(%rax)
movq 0x78(%rax), %rsi
movq 0x10(%rsp), %rdi
xorl %edx, %edx
callq 0xcc0a
cmpq $0x0, 0x58(%rsp)
jne 0xa4cb
movq %rbp, %rdi
callq 0xae06
movq 0x28(%rsp), %r15
jmp 0xa2e6
movq 0x10(%rbx), %r15
movq 0x18(%rbx), %r13
cmpq %r13, %r15
je 0xa46b
movq (%r15), %rax
movq 0x78(%rax), %rsi
movq 0x20(%rsp), %rdi
xorl %edx, %edx
callq 0xcc0a
addq $0x8, %r15
jmp 0xa57c
jmp 0xa5c1
jmp 0xa5c1
jmp 0xa5c1
jmp 0xa5c1
jmp 0xa5c1
jmp 0xa5c1
jmp 0xa5c1
jmp 0xa5c6
jmp 0xa5c1
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
callq 0xc5aa
jmp 0xa5d3
jmp 0xa5c1
movq %rax, %rbx
jmp 0xa5d3
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0xae06
leaq 0x90(%rsp), %rdi
callq 0xc5aa
movq %fs:0x28, %rax
cmpq 0xb0(%rsp), %rax
jne 0xa5fb
movq %rbx, %rdi
callq 0x9470
callq 0x92d0