// File: /workspace/github_c_makefile_star2_O0/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
subq $0x50, %rsp
movq %rsi, -0x8(%rbp)
movq %rdi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rdi
callq 0x36a40
movl %eax, -0x1c(%rbp)
cmpl $0xf, -0x1c(%rbp)
je 0x70912
cmpl $0x0, -0x1c(%rbp)
je 0x70912
cmpl $0x1, -0x1c(%rbp)
jne 0x70930
movl -0x1c(%rbp), %eax
movl %eax, %ecx
leaq 0x3f402(%rip), %rax     # 0xafd20
movq (%rax,%rcx,8), %rsi
leaq 0x284ff(%rip), %rdi     # 0x98e28
movb $0x0, %al
callq 0x1ac40
movq -0x10(%rbp), %rcx
movq 0x30(%rcx), %rax
movslq 0x14(%rcx), %rcx
movq -0x18(%rax,%rcx,8), %rax
movq %rax, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
movl $0x0, -0x40(%rbp)
movq -0x28(%rbp), %rax
movl (%rax), %eax
andl $0x7f, %eax
movl %eax, -0x48(%rbp)
subl $0x1, %eax
je 0x709b2
jmp 0x70976
movl -0x48(%rbp), %eax
addl $-0x3, %eax
subl $0x2, %eax
jb 0x709b2
jmp 0x70983
movl -0x48(%rbp), %eax
subl $0x1c, %eax
je 0x709b4
jmp 0x7098d
movl -0x48(%rbp), %eax
addl $-0x1d, %eax
subl $0x2, %eax
jb 0x709d1
jmp 0x7099a
movl -0x48(%rbp), %eax
subl $0x36, %eax
je 0x709b2
jmp 0x709a4
movq -0x28(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x30(%rbp)
jmp 0x709f8
jmp 0x709f8
movq -0x28(%rbp), %rax
movq -0x28(%rbp), %rcx
movl (%rcx), %ecx
sarl $0x8, %ecx
movslq %ecx, %rcx
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
jmp 0x709f8
movq -0x28(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rax
movq -0x28(%rbp), %rcx
movl (%rcx), %ecx
sarl $0x10, %ecx
movslq %ecx, %rcx
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x70a16
movq -0x30(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x3c(%rbp)
movq -0x30(%rbp), %rax
movl (%rax), %ecx
orl $0x80, %ecx
movl %ecx, (%rax)
cmpq $0x0, -0x38(%rbp)
je 0x70a34
movq -0x38(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x40(%rbp)
movq -0x38(%rbp), %rax
movl (%rax), %ecx
orl $0x80, %ecx
movl %ecx, (%rax)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rdx
movq -0x8(%rbp), %rsi
callq 0x70a80
movl %eax, -0x44(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x70a58
movl -0x3c(%rbp), %ecx
movq -0x30(%rbp), %rax
movl %ecx, (%rax)
cmpq $0x0, -0x38(%rbp)
je 0x70a68
movl -0x40(%rbp), %ecx
movq -0x38(%rbp), %rax
movl %ecx, (%rax)
movl -0x44(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)