// File: /workspace/github_cpp_makefile_star2_O3/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 0x50(%rdi), %r15
leaq 0xd8(%rdi), %r12
leaq 0xa0(%rdi), %r13
leaq 0xf8(%rdi), %rax
movq %rax, 0x18(%rsp)
leaq 0x30(%rsp), %r14
movl $0x0, 0xc(%rsp)
movq %r15, 0x10(%rsp)
cmpb $0x1, 0x128(%rbx)
jne 0x75ca
movl $0xa, %edi
callq 0x6330
jmp 0x75b5
cmpb $0x1, 0x80(%rbx)
jne 0x76f5
leaq 0x68(%rsp), %rbp
movq %rbp, %rdi
movq %r15, %rsi
callq 0x80d2
movq %r14, %rdi
movq %rbp, %rsi
movl $0x1, %edx
callq 0x7fb1
movq 0x30(%rsp), %rdi
movq 0x40(%rsp), %rsi
movq (%rdi), %rbp
subq %rdi, %rsi
callq 0x6280
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x7623
movq 0x78(%rsp), %rsi
subq %rdi, %rsi
callq 0x6280
cmpl $0x2, 0xa8(%rbp)
jne 0x7649
movl 0x84(%rbx), %esi
movl $0x1, %edi
callq 0x828a
cmpl $0x1, %eax
jne 0x75b5
incl 0xc(%rsp)
movq %rbp, %rdi
callq 0x69e8
movl 0xc(%rsp), %eax
movq 0x38(%rbx), %rcx
subq 0x30(%rbx), %rcx
sarq $0x3, %rcx
cmpq %rax, %rcx
ja 0x75b5
cmpb $0x1, 0x88(%rbx)
jne 0x767b
movq %rbx, %rdi
callq 0x7a34
movq %r14, %rdi
movq %rbx, %rsi
callq 0x7b3a
movq 0x110(%rbx), %rdi
movq 0x120(%rbx), %rsi
movaps 0x30(%rsp), %xmm0
movups %xmm0, 0x110(%rbx)
movq 0x40(%rsp), %rax
movq %rax, 0x120(%rbx)
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movq $0x0, 0x40(%rsp)
testq %rdi, %rdi
je 0x76e1
subq %rdi, %rsi
callq 0x6280
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x76e1
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x6280
incq 0x178(%rbx)
movl $0x0, 0xc(%rsp)
jmp 0x75b5
movq 0xf0(%rbx), %rax
testq %rax, %rax
jne 0x7838
movq 0x30(%rbx), %r15
movq 0x38(%rbx), %rbp
cmpq %rbp, %r15
je 0x7720
movq (%r15), %rdi
callq 0x69e8
addq $0x8, %r15
jmp 0x770d
movq 0x80(%rsp), %rax
movq 0x88(%rsp), %rcx
movq %rax, %rdx
cmpq %rcx, %rax
je 0x775b
movq (%rdx), %rsi
movl $0x0, 0xac(%rsi)
addq $0x8, %rdx
cmpq %rcx, %rdx
jne 0x7738
cmpq %rcx, %rax
je 0x775b
movq %rax, 0x88(%rsp)
cmpb $0x0, 0x88(%rbx)
je 0x776c
movq %rbx, %rdi
callq 0x7a34
movq %r14, %rdi
movq %rbx, %rsi
callq 0x7b3a
movq 0x110(%rbx), %rdi
movq 0x120(%rbx), %rsi
movaps 0x30(%rsp), %xmm0
movups %xmm0, 0x110(%rbx)
movq 0x40(%rsp), %rax
movq %rax, 0x120(%rbx)
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movq $0x0, 0x40(%rsp)
testq %rdi, %rdi
je 0x77d2
subq %rdi, %rsi
callq 0x6280
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x77d2
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x6280
incq 0x178(%rbx)
cmpq $0x0, 0xb8(%rbx)
jne 0x7826
movq 0x10(%rbx), %rbp
movq 0x18(%rbx), %rax
movq %rax, 0x20(%rsp)
cmpq %rax, %rbp
je 0x7826
movq (%rbp), %rax
movq 0x78(%rax), %r15
movq %r13, 0x30(%rsp)
testq %r15, %r15
je 0x781b
leaq 0x8(%r15), %rsi
movq %r13, %rdi
movq %r14, %rdx
callq 0x9fe2
movq (%r15), %r15
jmp 0x7802
addq $0x8, %rbp
cmpq 0x20(%rsp), %rbp
jne 0x77f5
movq %r12, %rdi
movq %r13, %rsi
callq 0x840c
movq 0xf0(%rbx), %rax
xorl %edx, %edx
movq %rdx, 0x30(%rsp)
movq 0xe0(%rbx), %rcx
movq %rcx, 0x38(%rsp)
movq %rdx, 0x40(%rsp)
movq %rax, 0x48(%rsp)
movq 0x18(%rsp), %rax
movups (%rax), %xmm0
leaq 0x50(%rsp), %rax
movups %xmm0, (%rax)
movq %rdx, 0x60(%rsp)
movq %r14, 0x98(%rsp)
movq %r14, %rdi
movq %r12, %rsi
leaq 0x98(%rsp), %rdx
callq 0x87d8
movq %r12, %rdi
callq 0x83c2
movq 0x80(%rsp), %rbp
movq 0x88(%rsp), %r15
cmpq %r15, %rbp
je 0x78c2
movq (%rbp), %rax
movl 0xac(%rax), %eax
cmpl 0x8(%rbx), %eax
jle 0x78bc
movq %r14, %rdi
movq %rbp, %rsi
callq 0xa098
addq $0x8, %rbp
jmp 0x789d
cmpq $0x0, 0x48(%rsp)
movq 0x10(%rsp), %r15
je 0x79a5
movq 0x40(%rsp), %rbp
callq 0x6060
cltq
xorl %edx, %edx
divq 0x48(%rsp)
testq %rdx, %rdx
je 0x78f4
movq (%rbp), %rbp
decq %rdx
jne 0x78eb
movq 0x8(%rbp), %rax
movq %rax, 0x28(%rsp)
movq %r14, %rdi
leaq 0x28(%rsp), %rsi
callq 0xa098
movq 0x28(%rsp), %rdi
movl 0xac(%rdi), %eax
cmpl 0x8(%rbx), %eax
jg 0x7999
cmpl $0x2, 0xa8(%rdi)
je 0x7999
callq 0x69e8
movq 0x88(%rsp), %rsi
cmpq 0x90(%rsp), %rsi
je 0x794d
movq 0x28(%rsp), %rax
movq %rax, (%rsi)
addq $0x8, 0x88(%rsp)
jmp 0x7964
leaq 0x80(%rsp), %rdi
leaq 0x28(%rsp), %rdx
callq 0xa188
movq 0x28(%rsp), %rax
incl 0xac(%rax)
movq 0x78(%rax), %r15
movq %r12, 0x98(%rsp)
testq %r15, %r15
je 0x7994
leaq 0x8(%r15), %rsi
movq %r12, %rdi
leaq 0x98(%rsp), %rdx
callq 0x9fe2
movq (%r15), %r15
jmp 0x7976
movq 0x10(%rsp), %r15
cmpq $0x0, 0x48(%rsp)
jne 0x78d3
movq %r14, %rdi
callq 0x839c
jmp 0x75b5
jmp 0x79e4
jmp 0x79e4
jmp 0x79e4
jmp 0x79e4
jmp 0x79e4
jmp 0x79e4
jmp 0x79e9
jmp 0x79e9
jmp 0x79e4
movq %rax, %rbx
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x79f6
movq 0x78(%rsp), %rsi
subq %rdi, %rsi
callq 0x6280
jmp 0x79f6
jmp 0x79e4
jmp 0x79e4
movq %rax, %rbx
jmp 0x79f6
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x839c
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x7a13
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x6280
movq %fs:0x28, %rax
cmpq 0xa0(%rsp), %rax
jne 0x7a2e
movq %rbx, %rdi
callq 0x6440
callq 0x62a0
nop