// File: /workspace/github_c_makefile_star2_O2/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
subq $0x18, %rsp
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
callq 0x27553
cmpl $0xf, %eax
ja 0x47aa2
movl $0x8003, %ecx           # imm = 0x8003
btl %eax, %ecx
jb 0x47b9d
movq 0x30(%r15), %rax
movslq 0x14(%r15), %rcx
movq -0x18(%rax,%rcx,8), %r13
movl (%r13), %eax
movl %eax, %ecx
andl $0x7f, %ecx
cmpl $0x36, %ecx
ja 0x47b26
movabsq $0x4000000000001a, %rdx # imm = 0x4000000000001A
btq %rcx, %rdx
jae 0x47aed
movb $0x1, %al
movl %eax, -0x2c(%rbp)
movq %r14, %rsi
movq %rbx, %rdx
movq $0x0, -0x38(%rbp)
xorl %ebx, %ebx
xorl %r13d, %r13d
movb $0x1, %r14b
jmp 0x47b6d
movl $0x60000000, %edx       # imm = 0x60000000
btq %rcx, %rdx
jae 0x47b11
movq %rbx, %rdx
sarl $0x10, %eax
cltq
leaq (,%rax,4), %rbx
addq %r13, %rbx
addq $0x4, %r13
jmp 0x47b2f
cmpq $0x1c, %rcx
jne 0x47b26
movq %rbx, %rdx
sarl $0x8, %eax
cltq
leaq (%r13,%rax,4), %r13
jmp 0x47b2d
movq %rbx, %rdx
addq $0x4, %r13
xorl %ebx, %ebx
movq %r14, %rsi
movl (%r13), %ecx
movl %ecx, %eax
orl $0x80, %eax
movl %eax, (%r13)
testq %rbx, %rbx
movq %rcx, -0x38(%rbp)
je 0x47b63
movl (%rbx), %r12d
movl %r12d, %eax
orl $0x80, %eax
movl %eax, (%rbx)
movl $0x0, -0x2c(%rbp)
xorl %r14d, %r14d
jmp 0x47b70
movb $0x1, %al
movl %eax, -0x2c(%rbp)
xorl %ebx, %ebx
xorl %r14d, %r14d
xorl %r12d, %r12d
movq %r15, %rdi
callq 0x47bb8
testb %r14b, %r14b
jne 0x47b85
movq -0x38(%rbp), %rcx
movl %ecx, (%r13)
cmpb $0x0, -0x2c(%rbp)
jne 0x47b8e
movl %r12d, (%rbx)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %eax, %eax
leaq 0x3795a(%rip), %rcx     # 0x7f500
movq (%rcx,%rax,8), %rsi
leaq 0x1feef(%rip), %rdi     # 0x67aa0
xorl %eax, %eax
callq 0x176c9