// File: /workspace/github_c_makefile_star2_O3/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, %r13
movq %rsi, %r14
movq %rdi, %r15
callq 0x2996f
cmpl $0xf, %eax
ja 0x4b5cb
movl $0x8003, %ecx           # imm = 0x8003
btl %eax, %ecx
jb 0x4b6a6
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 0x4b672
movabsq $0x4000000000001a, %rdx # imm = 0x4000000000001A
btq %rcx, %rdx
jae 0x4b616
movq %r15, %rdi
movq %r14, %rsi
movq %r13, %rdx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4b6c1
movl $0x60000000, %edx       # imm = 0x60000000
btq %rcx, %rdx
jae 0x4b661
movl 0x4(%r12), %edx
movl %edx, -0x2c(%rbp)
movl $0x80, %ecx
orl %ecx, %edx
movl %edx, 0x4(%r12)
sarl $0x10, %eax
movq %r13, %rdx
movslq %eax, %r13
movl (%r12,%r13,4), %ebx
orl %ebx, %ecx
movl %ecx, (%r12,%r13,4)
movq %r15, %rdi
movq %r14, %rsi
callq 0x4b6c1
movl -0x2c(%rbp), %ecx
movl %ecx, 0x4(%r12)
movl %ebx, (%r12,%r13,4)
jmp 0x4b697
cmpq $0x1c, %rcx
jne 0x4b672
sarl $0x8, %eax
cltq
leaq (%r12,%rax,4), %r12
jmp 0x4b676
addq $0x4, %r12
movl (%r12), %ebx
movl %ebx, %eax
orl $0x80, %eax
movl %eax, (%r12)
movq %r15, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x4b6c1
movl %ebx, (%r12)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %eax, %eax
leaq 0x38e51(%rip), %rcx     # 0x84500
movq (%rcx,%rax,8), %rsi
leaq 0x203c6(%rip), %rdi     # 0x6ba80
xorl %eax, %eax
callq 0x190bb