// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %rbx
subq $0x18, %rsp
movq %rcx, %r14
movq %rsi, %r15
orl %r8d, 0x24(%rcx)
movq %rdi, %rbx
movl 0x1c(%rcx), %ebp
movl 0x20(%rcx), %eax
testb $0x4, %al
jne 0x7cb7
movl 0x18(%r14), %eax
addq $0x10, %r14
movq 0x20(%r15), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x20(%r15)
leaq 0x8(%rsp), %rdx
movl %eax, (%rdx)
movq %rcx, 0x8(%rdx)
movq %r15, %rdi
movq %r14, %rsi
callq 0x5004
xorl %eax, %eax
jmp 0x7d34
movl %r8d, %ecx
notl %ecx
andl %ecx, %eax
movl %eax, 0x20(%r14)
testb $0x3, %cl
jne 0x7cf3
leaq 0x38(%r14), %rsi
movl 0x40(%r14), %eax
movq 0x20(%r15), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x20(%r15)
leaq 0x8(%rsp), %rdx
movl %eax, (%rdx)
movq %rcx, 0x8(%rdx)
movq %r15, %rdi
callq 0x5004
movq %r14, %rsi
jmp 0x7cff
leaq 0x28(%r14), %rsi
testb $0x2, %r8b
cmoveq %r14, %rsi
movl 0x18(%rsi), %eax
addq $0x10, %rsi
movq 0x20(%r15), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x20(%r15)
leaq 0x8(%rsp), %rdx
movl %eax, (%rdx)
movq %rcx, 0x8(%rdx)
movq %r15, %rdi
callq 0x5004
movl 0x20(%r14), %ecx
andl $0x3, %ecx
leal 0x8(%rcx), %eax
testl %ecx, %ecx
cmovel %ecx, %eax
movl %ebp, (%rbx)
movl %eax, 0x4(%rbx)
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nop