// File: /workspace/github_c_makefile_star2_O0/janet-lang[P]janet/src/core/vm.c
// Function: janet_check_can_resume
static JanetSignal janet_check_can_resume(JanetFiber *fiber, Janet *out, int is_cancel) {
    /* Check conditions */
    JanetFiberStatus old_status = janet_fiber_status(fiber);
    if (janet_vm.stackn >= JANET_RECURSION_GUARD) {
        janet_fiber_set_status(fiber, JANET_STATUS_ERROR);
        *out = janet_cstringv("C stack recursed too deeply");
        return JANET_SIGNAL_ERROR;
    }
    /* If a "task" fiber is trying to be used as a normal fiber, detect that. See bug #920.
     * Fibers must be marked as root fibers manually, or by the ev scheduler. */
    if (janet_vm.fiber != NULL && (fiber->gc.flags & JANET_FIBER_FLAG_ROOT)) {
#ifdef JANET_EV
        *out = janet_cstringv(is_cancel
                              ? "cannot cancel root fiber, use ev/cancel"
                              : "cannot resume root fiber, use ev/go");
#else
        *out = janet_cstringv(is_cancel
                              ? "cannot cancel root fiber"
                              : "cannot resume root fiber");
#endif
        return JANET_SIGNAL_ERROR;
    }
    if (old_status == JANET_STATUS_ALIVE ||
            old_status == JANET_STATUS_DEAD ||
            (old_status >= JANET_STATUS_USER0 && old_status <= JANET_STATUS_USER4) ||
            old_status == JANET_STATUS_ERROR) {
        const uint8_t *str = janet_formatc("cannot resume fiber with status :%s",
                                           janet_status_names[old_status]);
        *out = janet_wrap_string(str);
        return JANET_SIGNAL_ERROR;
    }
    return JANET_SIGNAL_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq -0x10(%rbp), %rdi
callq 0x36a40
movl %eax, -0x20(%rbp)
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
cmpl $0x400, 0x18(%rax)      # imm = 0x400
jl 0x79dce
jmp 0x79d6a
movq -0x10(%rbp), %rax
movl 0x10(%rax), %ecx
andl $0xffc0ffff, %ecx       # imm = 0xFFC0FFFF
movl %ecx, 0x10(%rax)
movq -0x10(%rbp), %rax
movl 0x10(%rax), %ecx
orl $0x10000, %ecx          # imm = 0x10000
movl %ecx, 0x10(%rax)
movq -0x18(%rbp), %rax
movq %rax, -0x48(%rbp)
leaq 0x1f0e5(%rip), %rdi     # 0x98e7e
callq 0x64a70
movq %rax, %rdi
movabsq $-0x6000000000000, %rsi # imm = 0xFFFA000000000000
callq 0x7b550
movq %rax, %rcx
movq -0x48(%rbp), %rax
movq %rcx, -0x28(%rbp)
movq -0x28(%rbp), %rcx
movq %rcx, (%rax)
movl $0x1, -0x4(%rbp)
jmp 0x79ec4
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
cmpq $0x0, 0x20(%rax)
je 0x79e47
movq -0x10(%rbp), %rax
movl (%rax), %eax
andl $0x40000, %eax          # imm = 0x40000
cmpl $0x0, %eax
je 0x79e47
movq -0x18(%rbp), %rax
movq %rax, -0x50(%rbp)
movl -0x1c(%rbp), %ecx
leaq 0x1f429(%rip), %rdi     # 0x99230
leaq 0x1f3fa(%rip), %rax     # 0x99208
cmpl $0x0, %ecx
cmovneq %rax, %rdi
callq 0x64a70
movq %rax, %rdi
movabsq $-0x6000000000000, %rsi # imm = 0xFFFA000000000000
callq 0x7b550
movq %rax, %rcx
movq -0x50(%rbp), %rax
movq %rcx, -0x30(%rbp)
movq -0x30(%rbp), %rcx
movq %rcx, (%rax)
movl $0x1, -0x4(%rbp)
jmp 0x79ec4
cmpl $0xf, -0x20(%rbp)
je 0x79e65
cmpl $0x0, -0x20(%rbp)
je 0x79e65
cmpl $0x4, -0x20(%rbp)
jb 0x79e5f
cmpl $0x8, -0x20(%rbp)
jbe 0x79e65
cmpl $0x1, -0x20(%rbp)
jne 0x79ebd
movl -0x20(%rbp), %eax
movl %eax, %ecx
leaq 0x35eaf(%rip), %rax     # 0xafd20
movq (%rax,%rcx,8), %rsi
leaq 0x1f3d8(%rip), %rdi     # 0x99254
movb $0x0, %al
callq 0x5bdd0
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x38(%rbp), %rdi
movabsq $-0x6000000000000, %rsi # imm = 0xFFFA000000000000
callq 0x7b550
movq %rax, %rcx
movq -0x58(%rbp), %rax
movq %rcx, -0x40(%rbp)
movq -0x40(%rbp), %rcx
movq %rcx, (%rax)
movl $0x1, -0x4(%rbp)
jmp 0x79ec4
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)