// File: /workspace/github_c_makefile_star2_O1/janet-lang[P]janet/src/core/vm.c
// Function: janet_step
JanetSignal janet_step(JanetFiber *fiber, Janet in, Janet *out) {
    /* No finished or currently alive fibers. */
    JanetFiberStatus status = janet_fiber_status(fiber);
    if (status == JANET_STATUS_ALIVE ||
            status == JANET_STATUS_DEAD ||
            status == JANET_STATUS_ERROR) {
        janet_panicf("cannot step fiber with status :%s", janet_status_names[status]);
    }

    /* Get PC for setting breakpoints */
    uint32_t *pc = janet_stack_frame(fiber->data + fiber->frame)->pc;

    /* Check current opcode (sans debug flag). This tells us where the next or next two candidate
     * instructions will be. Usually it's the next instruction in memory,
     * but for branching instructions it is also the target of the branch. */
    uint32_t *nexta = NULL, *nextb = NULL, olda = 0, oldb = 0;

    /* Set temporary breakpoints */
    switch (*pc & 0x7F) {
        default:
            nexta = pc + 1;
            break;
        /* These we just ignore for now. Supporting them means
         * we could step into and out of functions (including JOP_CALL). */
        case JOP_RETURN_NIL:
        case JOP_RETURN:
        case JOP_ERROR:
        case JOP_TAILCALL:
            break;
        case JOP_JUMP:
            nexta = pc + DS;
            break;
        case JOP_JUMP_IF:
        case JOP_JUMP_IF_NOT:
            nexta = pc + 1;
            nextb = pc + ES;
            break;
    }
    if (nexta) {
        olda = *nexta;
        *nexta |= 0x80;
    }
    if (nextb) {
        oldb = *nextb;
        *nextb |= 0x80;
    }

    /* Go */
    JanetSignal signal = janet_continue(fiber, in, out);

    /* Restore */
    if (nexta) *nexta = olda;
    if (nextb) *nextb = oldb;

    return signal;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
callq 0x29e47
cmpl $0xf, %eax
ja 0x4c19b
movl $0x8003, %ecx           # imm = 0x8003
btl %eax, %ecx
jb 0x4c272
movq 0x30(%r15), %rax
movslq 0x14(%r15), %rcx
movq -0x18(%rax,%rcx,8), %r12
movl (%r12), %eax
movl %eax, %ecx
andl $0x7f, %ecx
cmpl $0x36, %ecx
ja 0x4c20b
movabsq $0x4000000000001a, %rdx # imm = 0x4000000000001A
btq %rcx, %rdx
jae 0x4c1d4
movq %r14, %rsi
movq %rbx, %rdx
xorl %r13d, %r13d
xorl %r12d, %r12d
jmp 0x4c218
movl $0x60000000, %edx       # imm = 0x60000000
btq %rcx, %rdx
jae 0x4c1f4
movq %r14, %rsi
movq %rbx, %rdx
sarl $0x10, %eax
cltq
leaq (%r12,%rax,4), %r13
addq $0x4, %r12
jmp 0x4c218
cmpq $0x1c, %rcx
jne 0x4c20b
movq %r14, %rsi
movq %rbx, %rdx
sarl $0x8, %eax
cltq
leaq (%r12,%rax,4), %r12
jmp 0x4c215
movq %r14, %rsi
movq %rbx, %rdx
addq $0x4, %r12
xorl %r13d, %r13d
xorl %ebx, %ebx
movl $0x0, %r14d
testq %r12, %r12
je 0x4c235
movl (%r12), %r14d
movl %r14d, %eax
orl $0x80, %eax
movl %eax, (%r12)
testq %r13, %r13
je 0x4c249
movl (%r13), %ebx
movl %ebx, %eax
orl $0x80, %eax
movl %eax, (%r13)
movq %r15, %rdi
callq 0x4c28d
testq %r12, %r12
je 0x4c25a
movl %r14d, (%r12)
testq %r13, %r13
je 0x4c263
movl %ebx, (%r13)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %eax, %eax
leaq 0x39285(%rip), %rcx     # 0x85500
movq (%rcx,%rax,8), %rsi
leaq 0x2081a(%rip), %rdi     # 0x6caa0
xorl %eax, %eax
callq 0x1917b