// 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>>::process_primary_rearm(dasynq::v2::dprivate::base_bidi_fd_watcher*, dasynq::rearm)
rearm process_primary_rearm(base_bidi_fd_watcher * bdfw, rearm rearm_type) noexcept
    {
        bool emulatedfd = static_cast<base_watcher *>(bdfw)->emulatefd;

        // Called with lock held
        if (rearm_type == rearm::REMOVE) {
            bdfw->read_removed = 1;

            if (backend_traits_t::has_separate_rw_fd_watches) {
                bdfw->watch_flags &= ~IN_EVENTS;
                if (! emulatedfd) {
                    loop_mech.remove_fd_watch_nolock(bdfw->watch_fd, IN_EVENTS);
                }
                return bdfw->write_removed ? rearm::REMOVE : rearm::NOOP;
            }
            else {
                if (! bdfw->write_removed) {
                    if (bdfw->watch_flags & IN_EVENTS) {
                        bdfw->watch_flags &= ~IN_EVENTS;
                        if (! emulatedfd) {
                            set_fd_enabled_nolock(bdfw, bdfw->watch_fd, bdfw->watch_flags,
                                    bdfw->watch_flags != 0);
                        }
                    }
                    return rearm::NOOP;
                }
                else {
                    // both removed: actually remove
                    if (! emulatedfd) {
                        loop_mech.remove_fd_watch_nolock(bdfw->watch_fd, 0 /* not used */);
                    }
                    return rearm::REMOVE;
                }
            }
        }
        else if (rearm_type == rearm::DISARM) {
            bdfw->watch_flags &= ~IN_EVENTS;

            if (! emulatedfd) {
                if (! backend_traits_t::has_separate_rw_fd_watches) {
                    int watch_flags = bdfw->watch_flags  & (IN_EVENTS | OUT_EVENTS);
                    set_fd_enabled_nolock(bdfw, bdfw->watch_fd, watch_flags, watch_flags != 0);
                }
                else {
                    loop_mech.disable_fd_watch_nolock(bdfw->watch_fd, IN_EVENTS);
                }
            }
        }
        else if (rearm_type == rearm::REARM) {
            if (! emulatedfd) {
                bdfw->watch_flags |= IN_EVENTS;
                if (! backend_traits_t::has_separate_rw_fd_watches) {
                    int watch_flags = bdfw->watch_flags;
                    set_fd_enabled_nolock(bdfw, bdfw->watch_fd,
                            watch_flags & (IN_EVENTS | OUT_EVENTS), true);
                }
                else {
                    set_fd_enabled_nolock(bdfw, bdfw->watch_fd, IN_EVENTS, true);
                }
            }
            else {
                bdfw->watch_flags &= ~IN_EVENTS;
                rearm_type = rearm::REQUEUE;
            }
        }
        else if (rearm_type == rearm::NOOP) {
            if (bdfw->emulatefd) {
                if (bdfw->watch_flags & IN_EVENTS) {
                    bdfw->watch_flags &= ~IN_EVENTS;
                    rearm_type = rearm::REQUEUE;
                }
            }
        }
        return rearm_type;
    }

// Assembly:
pushq %rbx
movl %edx, %ebx
cmpl $0x3, %edx
ja 0xc928
movq %rsi, %rax
movb 0xc(%rsi), %dl
movl %ebx, %ecx
leaq 0x267d3(%rip), %rsi     # 0x33020
movslq (%rsi,%rcx,4), %rcx
addq %rsi, %rcx
jmpq *%rcx
movl 0x20(%rax), %ecx
testb $0x4, %dl
jne 0xc896
orl $0x1, %ecx
movl %ecx, 0x20(%rax)
movl 0x1c(%rax), %esi
andl $0x3, %ecx
orl $0x8, %ecx
movq %rax, %rdx
callq 0xc7ec
xorl %ebx, %ebx
jmp 0xc928
movl $0x2, %ebx
testb $0x4, %dl
je 0xc928
movl 0x20(%rax), %ecx
testb $0x1, %cl
je 0xc928
andl $-0x2, %ecx
movl %ecx, 0x20(%rax)
movl $0x5, %ebx
jmp 0xc928
movb 0x48(%rax), %cl
movl %ecx, %esi
orb $0x1, %sil
movb %sil, 0x48(%rax)
testb $0x2, %cl
jne 0xc909
movl 0x20(%rax), %ecx
movl $0x2, %ebx
testb $0x1, %cl
je 0xc928
andl $-0x2, %ecx
movl %ecx, 0x20(%rax)
testb $0x4, %dl
jne 0xc928
movl 0x1c(%rax), %edx
xorl %r8d, %r8d
testl %ecx, %ecx
setne %r8b
jmp 0xc8ff
movl 0x20(%rax), %ecx
movl %ecx, %esi
andl $-0x2, %esi
movl %esi, 0x20(%rax)
movl $0x1, %ebx
testb $0x4, %dl
jne 0xc928
andl $0x2, %ecx
movl 0x1c(%rax), %edx
movl %ecx, %r8d
shrl %r8d
movq %rax, %rsi
callq 0xc47c
jmp 0xc928
movl $0x3, %ebx
testb $0x4, %dl
jne 0xc928
movl 0x1c(%rax), %edx
movl 0xa0(%rdi), %edi
movl $0x2, %esi
xorl %ecx, %ecx
callq 0x8860
movl %ebx, %eax
popq %rbx
retq