// File: /workspace/github_cpp_makefile_star2_O1/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 $0xa8, %rsp
movq %rdi, %rbx
movq %fs:0x28, %rax
movq %rax, 0xa0(%rsp)
xorps %xmm0, %xmm0
leaq 0x80(%rsp), %rax
movaps %xmm0, (%rax)
movq $0x0, 0x10(%rax)
leaq 0xd8(%rdi), %r15
leaq 0x110(%rdi), %rax
movq %rax, 0x8(%rsp)
leaq 0xa0(%rdi), %r13
leaq 0xf8(%rdi), %rax
movq %rax, 0x10(%rsp)
leaq 0x50(%rdi), %rax
movq %rax, 0x18(%rsp)
leaq 0x98(%rsp), %rbp
movl $0x0, 0x4(%rsp)
cmpb $0x1, 0x128(%rbx)
jne 0x75f9
movl $0xa, %edi
callq 0x6330
jmp 0x75e4
cmpb $0x1, 0x80(%rbx)
jne 0x76a4
leaq 0x68(%rsp), %r14
movq %r14, %rdi
movq 0x18(%rsp), %rsi
callq 0x8080
leaq 0x30(%rsp), %rdi
movq %r14, %rsi
movl $0x1, %edx
callq 0x7f67
movq 0x30(%rsp), %rdi
movq 0x40(%rsp), %rsi
movq (%rdi), %r12
subq %rdi, %rsi
callq 0x6280
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x7656
movq 0x78(%rsp), %rsi
subq %rdi, %rsi
callq 0x6280
cmpl $0x2, 0xa8(%r12)
jne 0x767e
movl 0x84(%rbx), %esi
movl $0x1, %edi
callq 0x822c
cmpl $0x1, %eax
jne 0x75e4
incl 0x4(%rsp)
movq %r12, %rdi
callq 0x69f6
movl 0x4(%rsp), %eax
movq 0x38(%rbx), %rcx
subq 0x30(%rbx), %rcx
sarq $0x3, %rcx
cmpq %rax, %rcx
ja 0x75e4
jmp 0x791c
cmpq $0x0, 0xf0(%rbx)
jne 0x77ae
movq 0x30(%rbx), %r14
movq 0x38(%rbx), %r12
cmpq %r12, %r14
je 0x76cd
movq (%r14), %rdi
callq 0x69f6
addq $0x8, %r14
jmp 0x76ba
movq 0x80(%rsp), %rax
movq 0x88(%rsp), %rcx
movq %rax, %rdx
cmpq %rcx, %rax
je 0x76fb
movq (%rdx), %rsi
movl $0x0, 0xac(%rsi)
addq $0x8, %rdx
cmpq %rcx, %rdx
jne 0x76e5
cmpq %rax, %rcx
je 0x7708
movq %rax, 0x88(%rsp)
cmpb $0x0, 0x88(%rbx)
je 0x7719
movq %rbx, %rdi
callq 0x79ec
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x7af0
movq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x9fbe
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x774d
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x6280
incq 0x178(%rbx)
cmpq $0x0, 0xb8(%rbx)
jne 0x77a3
movq 0x10(%rbx), %r12
movq 0x18(%rbx), %rax
movq %rax, 0x20(%rsp)
cmpq %rax, %r12
je 0x77a3
movq (%r12), %rax
movq 0x78(%rax), %r14
movq %r13, 0x30(%rsp)
testq %r14, %r14
je 0x7798
leaq 0x8(%r14), %rsi
movq %r13, %rdi
leaq 0x30(%rsp), %rdx
callq 0x9ffe
movq (%r14), %r14
jmp 0x777d
addq $0x8, %r12
cmpq 0x20(%rsp), %r12
jne 0x7770
movq %r15, %rdi
movq %r13, %rsi
callq 0x83be
xorl %ecx, %ecx
movq %rcx, 0x30(%rsp)
movq 0xe0(%rbx), %rax
movq %rax, 0x38(%rsp)
movq %rcx, 0x40(%rsp)
movq 0xf0(%rbx), %rax
movq %rax, 0x48(%rsp)
movq 0x10(%rsp), %rax
movups (%rax), %xmm0
leaq 0x50(%rsp), %rax
movups %xmm0, (%rax)
movq %rcx, 0x60(%rsp)
leaq 0x30(%rsp), %rdi
movq %rdi, 0x98(%rsp)
movq %r15, %rsi
movq %rbp, %rdx
callq 0x877e
movq %r15, %rdi
callq 0x8374
movq 0x80(%rsp), %r12
movq 0x88(%rsp), %r14
cmpq %r14, %r12
je 0x7901
movq (%r12), %rax
movl 0xac(%rax), %eax
cmpl 0x8(%rbx), %eax
jle 0x783c
leaq 0x30(%rsp), %rdi
movq %r12, %rsi
callq 0xa0a4
addq $0x8, %r12
jmp 0x7817
movq 0x40(%rsp), %r12
callq 0x6060
cltq
xorl %edx, %edx
divq 0x48(%rsp)
testq %rdx, %rdx
je 0x7863
movq (%r12), %r12
decq %rdx
jne 0x785a
movq 0x8(%r12), %rax
movq %rax, 0x28(%rsp)
leaq 0x30(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0xa0a4
movq 0x28(%rsp), %rdi
movl 0xac(%rdi), %eax
cmpl 0x8(%rbx), %eax
jg 0x7901
cmpl $0x2, 0xa8(%rdi)
je 0x7901
callq 0x69f6
movq 0x88(%rsp), %rsi
cmpq 0x90(%rsp), %rsi
je 0x78bf
movq 0x28(%rsp), %rax
movq %rax, (%rsi)
addq $0x8, 0x88(%rsp)
jmp 0x78d1
leaq 0x80(%rsp), %rdi
leaq 0x28(%rsp), %rdx
callq 0xa18a
movq 0x28(%rsp), %rax
incl 0xac(%rax)
movq 0x78(%rax), %r14
movq %r15, 0x98(%rsp)
testq %r14, %r14
je 0x7901
leaq 0x8(%r14), %rsi
movq %r15, %rdi
movq %rbp, %rdx
callq 0x9ffe
movq (%r14), %r14
jmp 0x78e8
cmpq $0x0, 0x48(%rsp)
jne 0x7842
leaq 0x30(%rsp), %rdi
callq 0x834e
jmp 0x75e4
cmpb $0x1, 0x88(%rbx)
jne 0x792d
movq %rbx, %rdi
callq 0x79ec
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x7af0
movq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x9fbe
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x7961
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x6280
incq 0x178(%rbx)
jmp 0x75dc
jmp 0x799d
jmp 0x799d
jmp 0x799d
movq %rax, %rbx
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x79af
movq 0x78(%rsp), %rsi
subq %rdi, %rsi
callq 0x6280
jmp 0x79af
jmp 0x799d
jmp 0x799d
jmp 0x799d
jmp 0x799d
jmp 0x79a2
jmp 0x79a2
jmp 0x799d
movq %rax, %rbx
jmp 0x79af
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x834e
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x79cc
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x6280
movq %fs:0x28, %rax
cmpq 0xa0(%rsp), %rax
jne 0x79e7
movq %rbx, %rdi
callq 0x6440
callq 0x62a0