// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %rax
movl %r8d, %r14d
movl %ecx, %ebp
movl %edx, %r13d
movq %rsi, %r15
movq %rdi, %rbx
addq $0x10, %rsi
movq %rsi, (%rsp)
callq 0xc232
leaq 0x38(%r15), %r12
movq %rbx, %rdi
movq %r12, %rsi
callq 0xc232
movl %ebp, %ecx
orl $0x8, %ecx
movzbl %r14b, %r9d
pushq $0x1
popq %r8
movq %rbx, %rdi
movl %r13d, %esi
movq %r15, %rdx
callq 0xc170
testb %al, %al
jne 0xc0e6
orb $0x4, 0xc(%r15)
orb $0x4, 0x34(%r15)
testb $0x1, %bpl
je 0xc0e0
andb $-0x2, 0x20(%r15)
movq %rbx, %rdi
movq %r15, %rsi
callq 0xbaa8
testb $0x2, %bpl
jne 0xc0f5
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
andb $-0x3, 0x20(%r15)
addq $0x28, %r15
movq %rbx, %rdi
movq %r15, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xbaa8
movq %rax, %rdi
callq 0x8200
movq %rbx, %rdi
movq %r12, %rsi
callq 0xbf34
callq 0x8910
jmp 0xc157
movq %rax, %r14
callq 0x8a40
jmp 0xc13e
movq %rax, %r14
movq %r14, %rdi
callq 0x8200
movq %rbx, %rdi
movq (%rsp), %rsi
callq 0xbf34
callq 0x8910
movq %rax, %rbx
callq 0x8a40
movq %rbx, %rdi
callq 0x8a90
movq %rax, %rdi
callq 0xaebb
nop