// File: /workspace/github_c_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rdi, %rbx
movq 0x10(%rbp), %r15
cmpl $0x1, %esi
jle 0x41a07
leaq 0x27e22(%rip), %rsi     # 0x69827
jmp 0x41a2c
movq (%r15), %r14
testq %r14, %r14
je 0x41a25
movq %rdx, %r12
movl %esi, %r13d
testb $0x21, 0x6c(%r14)
jne 0x41a60
movq 0x8(%r14), %r14
testq %r14, %r14
jne 0x41a15
leaq 0x27e17(%rip), %rsi     # 0x69843
movq %r15, %rdi
callq 0x1bc9e
movabsq $-0x77fffffffffff, %rdi # imm = 0xFFF8800000000001
callq 0x4f95a
movq %rbx, %rdi
movq %rax, %rsi
callq 0x1bc4e
movq %rbx, %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq -0x50(%rbp), %rdi
movq %r15, %rsi
callq 0x1bbf0
movl 0x6c(%r14), %eax
testb $0x1, %al
jne 0x41aae
testl %r13d, %r13d
je 0x41aa4
orb $0x4, -0x2e(%rbp)
movq (%r12), %rsi
movq -0x30(%rbp), %rax
movq %rax, 0x20(%rsp)
movups -0x50(%rbp), %xmm0
movups -0x40(%rbp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
leaq -0x68(%rbp), %rdi
callq 0x1ca05
movq %r15, %rdi
movl $0x9c, %esi
jmp 0x41b20
testl %r13d, %r13d
je 0x41ae8
andl $0x20, %eax
jne 0x41ae8
orb $0x1, -0x2e(%rbp)
movq (%r12), %rsi
movq -0x30(%rbp), %rax
movq %rax, 0x20(%rsp)
movups -0x50(%rbp), %xmm0
movups -0x40(%rbp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
leaq -0x68(%rbp), %rdi
callq 0x1ca05
jmp 0x41a34
testl %r13d, %r13d
je 0x41b18
orb $0x4, -0x2e(%rbp)
movq (%r12), %rsi
movq -0x30(%rbp), %rax
movq %rax, 0x20(%rsp)
movups -0x50(%rbp), %xmm0
movups -0x40(%rbp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
leaq -0x68(%rbp), %rdi
callq 0x1ca05
movq %r15, %rdi
movl $0x4, %esi
callq 0x21a88
jmp 0x41a34