// File: davmac314[P]dinit/src/../dasynq/include/dasynq.h
// Function: dasynq::v2::event_loop<dasynq::null_mutex, dasynq::v2::default_traits<dasynq::null_mutex>>::process_events(int)
bool process_events(int limit) noexcept
    {
        loop_mech.lock.lock();
        
        if (limit == 0) {
            return false;
        }
        
        // limit processing to the number of events currently queued, to avoid prolonged processing
        // of watchers which requeueu themselves immediately (including file watchers which are using
        // emulation for watching regular files)
        //
        // If limit is -1 (no limit) we rely on this being always larger than/equal to the number of
        // queued events when cast to size_t (which is unsigned).
        limit = std::min(size_t(limit), loop_mech.num_queued_events());

        base_watcher * pqueue = loop_mech.pull_queued_event();
        bool active = false;
        
        while (pqueue != nullptr) {
        
            pqueue->active = true;
            active = true;
            
            base_bidi_fd_watcher *bbfw = nullptr;
            
            // (Above variables are initialised only to silence compiler warnings).
            
            if (pqueue->watchType == watch_type_t::SECONDARYFD) {
                // construct a pointer to the main watcher, using integer arithmetic to avoid undefined
                // pointer arithmetic:
                uintptr_t rp = (uintptr_t)pqueue;

                // Here we take the offset of a member from a non-standard-layout class, which is
                // specified to have undefined result by the C++ language standard, but which
                // in practice works fine:
                _Pragma ("GCC diagnostic push")
                _Pragma ("GCC diagnostic ignored \"-Winvalid-offsetof\"")
                rp -= offsetof(base_bidi_fd_watcher, out_watcher);
                _Pragma ("GCC diagnostic pop")
                bbfw = (base_bidi_fd_watcher *)rp;

                // issue a secondary dispatch:
                bbfw->dispatch_second(this);
            }
            else {
                pqueue->dispatch(this);
            }

            if (limit > 0) {
                limit--;
                if (limit == 0) break;
            }
            pqueue = loop_mech.pull_queued_event();
        }
        
        loop_mech.lock.unlock();
        return active;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0x50(%rbp)
addq $0x28, %rdi
callq 0x6030
cmpl $0x0, -0x14(%rbp)
jne 0xea1f
movb $0x0, -0x1(%rbp)
jmp 0xeb02
movq -0x50(%rbp), %rdi
movslq -0x14(%rbp), %rax
movq %rax, -0x20(%rbp)
callq 0x104a0
movq %rax, -0x28(%rbp)
leaq -0x20(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x8110
movq -0x50(%rbp), %rdi
movq (%rax), %rax
movl %eax, -0x14(%rbp)
callq 0x104c0
movq %rax, -0x30(%rbp)
movb $0x0, -0x31(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0xeaed
movq -0x30(%rbp), %rax
movb 0xc(%rax), %cl
andb $-0x2, %cl
orb $0x1, %cl
movb %cl, 0xc(%rax)
movb $0x1, -0x31(%rbp)
movq $0x0, -0x40(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x3, 0x8(%rax)
jne 0xeab5
movq -0x50(%rbp), %rsi
movq -0x30(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
subq $0x28, %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
jmp 0xeac2
movq -0x50(%rbp), %rsi
movq -0x30(%rbp), %rdi
movq (%rdi), %rax
callq *(%rax)
cmpl $0x0, -0x14(%rbp)
jle 0xeadb
movl -0x14(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
jne 0xead9
jmp 0xeaed
jmp 0xeadb
movq -0x50(%rbp), %rdi
callq 0x104c0
movq %rax, -0x30(%rbp)
jmp 0xea58
movq -0x50(%rbp), %rdi
addq $0x28, %rdi
callq 0x5fe0
movb -0x31(%rbp), %al
andb $0x1, %al
movb %al, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)