// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/../dasynq/include/dasynq.h
// Function: dasynq::v2::event_loop<dasynq::null_mutex, dasynq::v2::default_traits<dasynq::null_mutex>>::register_fd(dasynq::v2::dprivate::base_bidi_fd_watcher*, int, int, bool)
void register_fd(base_bidi_fd_watcher *callback, int fd, int eventmask, bool emulate = false)
    {
        std::lock_guard<mutex_t> guard(loop_mech.lock);

        loop_mech.prepare_watcher(callback);
        try {
            loop_mech.prepare_watcher(&callback->out_watcher);
            try {
                bool do_interrupt = false;
                if (backend_traits_t::has_separate_rw_fd_watches) {
                    int r = loop_mech.add_bidi_fd_watch(fd, callback, eventmask | ONE_SHOT, emulate);
                    if (r & IN_EVENTS) {
                        callback->emulatefd = true;
                        if (eventmask & IN_EVENTS) {
                            callback->watch_flags &= ~IN_EVENTS;
                            requeue_watcher(callback);
                        }
                    }
                    else if ((eventmask & IN_EVENTS) && backend_traits_t::interrupt_after_fd_add) {
                        do_interrupt = true;
                    }

                    if (r & OUT_EVENTS) {
                        callback->out_watcher.emulatefd = true;
                        if (eventmask & OUT_EVENTS) {
                            callback->watch_flags &= ~OUT_EVENTS;
                            requeue_watcher(&callback->out_watcher);
                        }
                    }
                    else if ((eventmask & OUT_EVENTS) && backend_traits_t::interrupt_after_fd_add) {
                        do_interrupt = true;
                    }
                }
                else {
                    if (! loop_mech.add_fd_watch(fd, callback, eventmask | ONE_SHOT, true, emulate)) {
                        callback->emulatefd = true;
                        callback->out_watcher.emulatefd = true;
                        if (eventmask & IN_EVENTS) {
                            callback->watch_flags &= ~IN_EVENTS;
                            requeue_watcher(callback);
                        }
                        if (eventmask & OUT_EVENTS) {
                            callback->watch_flags &= ~OUT_EVENTS;
                            requeue_watcher(&callback->out_watcher);
                        }
                    }
                    else if (backend_traits_t::interrupt_after_fd_add) {
                        do_interrupt = true;
                    }
                }

                if (do_interrupt) {
                    interrupt_if_necessary();
                }
            }
            catch (...) {
                loop_mech.release_watcher(&callback->out_watcher);
                throw;
            }
        }
        catch (...) {
            loop_mech.release_watcher(callback);
            throw;
        }
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %r8d, %r14d
movl %ecx, %ebp
movl %edx, %r13d
movq %rsi, %r12
movq %rdi, %rbx
addq $0x10, %rsi
movq %rsi, (%rsp)
callq 0xccbe
leaq 0x38(%r12), %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0xccbe
movl %ebp, %ecx
orl $0x8, %ecx
movzbl %r14b, %r9d
movq %rbx, %rdi
movl %r13d, %esi
movq %r12, %rdx
movl $0x1, %r8d
callq 0xcbf6
testb %al, %al
jne 0xcb8f
orb $0x4, 0xc(%r12)
orb $0x4, 0x34(%r12)
testb $0x1, %bpl
je 0xcb5c
andb $-0x2, 0x20(%r12)
movl 0x18(%r12), %eax
movq 0x20(%rbx), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x20(%rbx)
leaq 0x8(%rsp), %rdx
movl %eax, (%rdx)
movq %rcx, 0x8(%rdx)
movq %rbx, %rdi
movq (%rsp), %rsi
callq 0xc4be
testb $0x2, %bpl
je 0xcb8f
andb $-0x3, 0x20(%r12)
movl 0x40(%r12), %eax
movq 0x20(%rbx), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x20(%rbx)
leaq 0x8(%rsp), %rdx
movl %eax, (%rdx)
movq %rcx, 0x8(%rdx)
movq %rbx, %rdi
movq %r15, %rsi
callq 0xc4be
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rdi
callq 0x8210
movq %rbx, %rdi
movq %r15, %rsi
callq 0xc92c
callq 0x8920
jmp 0xcbde
movq %rax, %r14
callq 0x8a50
jmp 0xcbc5
movq %rax, %r14
movq %r14, %rdi
callq 0x8210
movq %rbx, %rdi
movq (%rsp), %rsi
callq 0xc92c
callq 0x8920
movq %rax, %rbx
callq 0x8a50
movq %rbx, %rdi
callq 0x8ab0
movq %rax, %rdi
callq 0xb8be