// File: /workspace/github_c_makefile_star2_O0/janet-lang[P]janet/src/core/specials.c
// Function: janetc_break
static JanetSlot janetc_break(JanetFopts opts, int32_t argn, const Janet *argv) {
    JanetCompiler *c = opts.compiler;
    JanetScope *scope = c->scope;
    if (argn > 1) {
        janetc_cerror(c, "expected at most 1 argument");
        return janetc_cslot(janet_wrap_nil());
    }

    /* Find scope to break from */
    while (scope) {
        if (scope->flags & (JANET_SCOPE_FUNCTION | JANET_SCOPE_WHILE))
            break;
        scope = scope->parent;
    }
    if (NULL == scope) {
        janetc_cerror(c, "break must occur in while loop or closure");
        return janetc_cslot(janet_wrap_nil());
    }

    /* Emit code to break from that scope */
    JanetFopts subopts = janetc_fopts_default(c);
    if (scope->flags & JANET_SCOPE_FUNCTION) {
        if (!(scope->flags & JANET_SCOPE_WHILE) && argn) {
            /* Closure body with return argument */
            subopts.flags |= JANET_FOPTS_TAIL;
            janetc_value(subopts, argv[0]);
            return janetc_cslot(janet_wrap_nil());
        } else {
            /* while loop IIFE or no argument */
            if (argn) {
                subopts.flags |= JANET_FOPTS_DROP;
                janetc_value(subopts, argv[0]);
            }
            janetc_emit(c, JOP_RETURN_NIL);
            return janetc_cslot(janet_wrap_nil());
        }
    } else {
        if (argn) {
            subopts.flags |= JANET_FOPTS_DROP;
            janetc_value(subopts, argv[0]);
        }
        /* Tag the instruction so the while special can turn it into a proper jump */
        janetc_emit(c, 0x80 | JOP_JUMP);
        return janetc_cslot(janet_wrap_nil());
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0xc8(%rbp)
movq %rdi, -0xc0(%rbp)
leaq 0x10(%rbp), %rax
movl %esi, -0x4(%rbp)
movq %rdx, -0x10(%rbp)
movq (%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
cmpl $0x1, -0x4(%rbp)
jle 0x5edb4
movq -0x18(%rbp), %rdi
leaq 0x36f10(%rip), %rsi     # 0x95c97
callq 0x1fff0
movabsq $-0x77fffffffffff, %rdi # imm = 0xFFF8800000000001
callq 0x7b460
movq -0xc8(%rbp), %rdi
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rsi
callq 0x1ff40
jmp 0x5ef9a
jmp 0x5edb6
cmpq $0x0, -0x20(%rbp)
je 0x5eddc
movq -0x20(%rbp), %rax
movl 0x6c(%rax), %eax
andl $0x21, %eax
cmpl $0x0, %eax
je 0x5edce
jmp 0x5eddc
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x5edb6
xorl %eax, %eax
cmpq -0x20(%rbp), %rax
jne 0x5ee1c
movq -0x18(%rbp), %rdi
leaq 0x36ec4(%rip), %rsi     # 0x95cb3
callq 0x1fff0
movabsq $-0x77fffffffffff, %rdi # imm = 0xFFF8800000000001
callq 0x7b460
movq -0xc8(%rbp), %rdi
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rsi
callq 0x1ff40
jmp 0x5ef9a
movq -0x18(%rbp), %rsi
leaq -0x58(%rbp), %rdi
callq 0x1fed0
movq -0x20(%rbp), %rax
movl 0x6c(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x5ef25
movq -0x20(%rbp), %rax
movl 0x6c(%rax), %eax
andl $0x20, %eax
cmpl $0x0, %eax
jne 0x5eeae
cmpl $0x0, -0x4(%rbp)
je 0x5eeae
movl -0x38(%rbp), %eax
orl $0x10000, %eax          # imm = 0x10000
movl %eax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rsi
movq -0x38(%rbp), %rcx
movq %rsp, %rax
movq %rcx, 0x20(%rax)
movups -0x58(%rbp), %xmm0
movups -0x48(%rbp), %xmm1
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
leaq -0x70(%rbp), %rdi
callq 0x21590
movabsq $-0x77fffffffffff, %rdi # imm = 0xFFF8800000000001
callq 0x7b460
movq -0xc8(%rbp), %rdi
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rsi
callq 0x1ff40
jmp 0x5ef9a
cmpl $0x0, -0x4(%rbp)
je 0x5eeec
movl -0x38(%rbp), %eax
orl $0x40000, %eax          # imm = 0x40000
movl %eax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rsi
movq -0x38(%rbp), %rcx
movq %rsp, %rax
movq %rcx, 0x20(%rax)
movups -0x58(%rbp), %xmm0
movups -0x48(%rbp), %xmm1
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
leaq -0x90(%rbp), %rdi
callq 0x21590
movq -0x18(%rbp), %rdi
movl $0x4, %esi
callq 0x29410
movabsq $-0x77fffffffffff, %rdi # imm = 0xFFF8800000000001
callq 0x7b460
movq -0xc8(%rbp), %rdi
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rsi
callq 0x1ff40
jmp 0x5ef9a
cmpl $0x0, -0x4(%rbp)
je 0x5ef63
movl -0x38(%rbp), %eax
orl $0x40000, %eax          # imm = 0x40000
movl %eax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rsi
movq -0x38(%rbp), %rcx
movq %rsp, %rax
movq %rcx, 0x20(%rax)
movups -0x58(%rbp), %xmm0
movups -0x48(%rbp), %xmm1
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
leaq -0xb0(%rbp), %rdi
callq 0x21590
movq -0x18(%rbp), %rdi
movl $0x9c, %esi
callq 0x29410
movabsq $-0x77fffffffffff, %rdi # imm = 0xFFF8800000000001
callq 0x7b460
movq -0xc8(%rbp), %rdi
movq %rax, -0xb8(%rbp)
movq -0xb8(%rbp), %rsi
callq 0x1ff40
movq -0xc0(%rbp), %rax
addq $0xf0, %rsp
popq %rbp
retq
nopw (%rax,%rax)