// File: /workspace/github_cpp_makefile_star2_O3/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
subq $0x10, %rsp
movl %edx, %ebx
cmpl $0x3, %edx
ja 0xc753
movb 0xc(%rsi), %al
movl %ebx, %ecx
leaq 0x269ac(%rip), %rdx     # 0x33004
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
movl 0x20(%rsi), %r8d
testb $0x4, %al
jne 0xc746
movl %r8d, %eax
orl $0x1, %eax
movl %eax, 0x20(%rsi)
movl 0x1c(%rsi), %edx
leaq 0x4(%rsp), %rcx
movq %rsi, 0x4(%rcx)
andl $0x2, %r8d
leal 0x40000001(,%r8,2), %eax
movl %eax, (%rcx)
movl 0xa0(%rdi), %edi
movl $0x3, %esi
callq 0x8860
xorl %ebx, %ebx
jmp 0xc753
movl $0x2, %ebx
testb $0x4, %al
je 0xc753
movl 0x20(%rsi), %eax
testb $0x1, %al
je 0xc753
andl $-0x2, %eax
movl %eax, 0x20(%rsi)
jmp 0xc74e
movb 0x48(%rsi), %cl
movl %ecx, %edx
orb $0x1, %dl
movb %dl, 0x48(%rsi)
testb $0x2, %cl
jne 0xc726
movl 0x20(%rsi), %ecx
movl $0x2, %ebx
testb $0x1, %cl
je 0xc753
andl $-0x2, %ecx
movl %ecx, 0x20(%rsi)
testb $0x4, %al
jne 0xc753
movl 0x1c(%rsi), %edx
xorl %r8d, %r8d
testl %ecx, %ecx
setne %r8b
jmp 0xc71f
movl 0x20(%rsi), %ecx
movl %ecx, %edx
andl $-0x2, %edx
movl %edx, 0x20(%rsi)
movl $0x1, %ebx
testb $0x4, %al
jne 0xc753
andl $0x2, %ecx
movl 0x1c(%rsi), %edx
movl %ecx, %r8d
shrl %r8d
callq 0xc2c4
jmp 0xc753
movl $0x3, %ebx
testb $0x4, %al
jne 0xc753
movl 0x1c(%rsi), %edx
movl 0xa0(%rdi), %edi
movl $0x2, %esi
xorl %ecx, %ecx
callq 0x8860
jmp 0xc753
andl $-0x2, %r8d
movl %r8d, 0x20(%rsi)
movl $0x5, %ebx
movl %ebx, %eax
addq $0x10, %rsp
popq %rbx
retq
nop