// File: davmac314[P]dinit/src/../dasynq/include/dasynq.h
// Function: std::tuple<int, dasynq::v2::epoll_traits::fd_s> dasynq::v2::dprivate::event_dispatch<dasynq::v2::epoll_traits, dasynq::v2::default_traits<dasynq::null_mutex>>::receive_fd_event<dasynq::v2::epoll_loop<dasynq::interrupt_channel<dasynq::timer_fd_events<dasynq::v2::child_proc_events<dasynq::v2::dprivate::event_dispatch<dasynq::v2::epoll_traits, dasynq::v2::default_traits<dasynq::null_mutex>>>>, dasynq::null_mutex>>>(dasynq::v2::epoll_loop<dasynq::interrupt_channel<dasynq::timer_fd_events<dasynq::v2::child_proc_events<dasynq::v2::dprivate::event_dispatch<dasynq::v2::epoll_traits, dasynq::v2::default_traits<dasynq::null_mutex>>>>, dasynq::null_mutex>>&, dasynq::v2::epoll_traits::fd_r, void*, int)
std::tuple<int, typename Traits::fd_s> receive_fd_event(T &loop_mech, typename Traits::fd_r fd_r,
                void * userdata, int flags) noexcept
        {
            base_fd_watcher * bfdw = static_cast<base_fd_watcher *>(userdata);
            
            bfdw->event_flags |= flags;
            typename Traits::fd_s watch_fd_s {bfdw->watch_fd};
            
            base_watcher * bwatcher = bfdw;
            
            bool is_multi_watch = bfdw->watch_flags & multi_watch;
            if (is_multi_watch) {                
                base_bidi_fd_watcher *bbdw = static_cast<base_bidi_fd_watcher *>(bwatcher);
                bbdw->watch_flags &= ~flags;
                if ((flags & IN_EVENTS) && (flags & OUT_EVENTS)) {
                    // Queue the secondary watcher first:
                    queue_watcher(&bbdw->out_watcher);
                }
                else if (flags & OUT_EVENTS) {                
                    // Use the secondary watcher for queueing:
                    bwatcher = &(bbdw->out_watcher);
                }
            }

            queue_watcher(bwatcher);
            
            if (is_multi_watch && ! traits_t::has_separate_rw_fd_watches) {
                // If this is a bidirectional fd-watch, it has been disabled in *both* directions
                // as the event was delivered. However, the other direction should not be disabled
                // yet, so we need to re-enable:
                int in_out_mask = IN_EVENTS | OUT_EVENTS;
                if ((bfdw->watch_flags & in_out_mask) != 0) {
                    // We need to re-enable the other channel now:
                    return std::make_tuple((bfdw->watch_flags & in_out_mask) | ONE_SHOT, watch_fd_s);
                    // We are the polling thread: don't need to interrupt polling, even if it would
                    // normally be required.
                }
            }

            return std::make_tuple(0, watch_fd_s);
        }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x88(%rbp)
movq %rdi, %rax
movq %rax, -0x80(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movl %r8d, -0x2c(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x38(%rbp)
movl -0x2c(%rbp), %ecx
movq -0x38(%rbp), %rax
orl 0x24(%rax), %ecx
movl %ecx, 0x24(%rax)
movq -0x38(%rbp), %rax
movl 0x1c(%rax), %esi
leaq -0x3c(%rbp), %rdi
callq 0xf620
movq -0x38(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x38(%rbp), %rax
movl 0x20(%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
setne %al
andb $0x1, %al
movb %al, -0x49(%rbp)
testb $0x1, -0x49(%rbp)
je 0xf749
movq -0x48(%rbp), %rax
movq %rax, -0x58(%rbp)
movl -0x2c(%rbp), %ecx
xorl $-0x1, %ecx
movq -0x58(%rbp), %rax
andl 0x20(%rax), %ecx
movl %ecx, 0x20(%rax)
movl -0x2c(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0xf72e
movl -0x2c(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0xf72e
movq -0x78(%rbp), %rdi
movq -0x58(%rbp), %rsi
addq $0x28, %rsi
callq 0x6ba0
jmp 0xf747
movl -0x2c(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0xf745
movq -0x58(%rbp), %rax
addq $0x28, %rax
movq %rax, -0x48(%rbp)
jmp 0xf747
jmp 0xf749
movq -0x78(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0x6ba0
testb $0x1, -0x49(%rbp)
je 0xf7ab
movl $0x3, -0x5c(%rbp)
movq -0x38(%rbp), %rax
movl 0x20(%rax), %eax
andl -0x5c(%rbp), %eax
cmpl $0x0, %eax
je 0xf7a9
movq -0x38(%rbp), %rax
movl 0x20(%rax), %eax
movl -0x5c(%rbp), %ecx
andl %ecx, %eax
orl $0x8, %eax
movl %eax, -0x68(%rbp)
leaq -0x64(%rbp), %rdi
leaq -0x68(%rbp), %rsi
leaq -0x3c(%rbp), %rdx
callq 0x101f0
jmp 0xf797
movq -0x88(%rbp), %rdi
leaq -0x64(%rbp), %rsi
callq 0xf640
jmp 0xf7ca
jmp 0xf7ab
movq -0x88(%rbp), %rdi
movl $0x0, -0x6c(%rbp)
leaq -0x6c(%rbp), %rsi
leaq -0x3c(%rbp), %rdx
callq 0x10230
jmp 0xf7c8
jmp 0xf7ca
movq -0x80(%rbp), %rax
addq $0x90, %rsp
popq %rbp
retq
movq %rax, %rdi
callq 0x52b0
nop