// File: /workspace/github_c_makefile_star2_O0/janet-lang[P]janet/src/core/compile.c
// Function: macroexpand1
static int macroexpand1(
    JanetCompiler *c,
    Janet x,
    Janet *out,
    const JanetSpecial **spec) {
    if (!janet_checktype(x, JANET_TUPLE))
        return 0;
    const Janet *form = janet_unwrap_tuple(x);
    if (janet_tuple_length(form) == 0)
        return 0;
    /* Source map - only set when we get a tuple */
    if (janet_tuple_sm_line(form) >= 0) {
        c->current_mapping.line = janet_tuple_sm_line(form);
        c->current_mapping.column = janet_tuple_sm_column(form);
    }
    /* Bracketed tuples are not specials or macros! */
    if (janet_tuple_flag(form) & JANET_TUPLE_FLAG_BRACKETCTOR)
        return 0;
    if (!janet_checktype(form[0], JANET_SYMBOL))
        return 0;
    const uint8_t *name = janet_unwrap_symbol(form[0]);
    const JanetSpecial *s = janetc_special(name);
    if (s) {
        *spec = s;
        return 0;
    }
    Janet macroval;
    JanetBindingType btype = janet_resolve(c->env, name, &macroval);
    if (!(btype == JANET_BINDING_MACRO || btype == JANET_BINDING_DYNAMIC_MACRO) ||
            !janet_checktype(macroval, JANET_FUNCTION))
        return 0;

    /* Evaluate macro */
    JanetFunction *macro = janet_unwrap_function(macroval);
    int32_t arity = janet_tuple_length(form) - 1;
    JanetFiber *fiberp = janet_fiber(macro, 64, arity, form + 1);
    if (NULL == fiberp) {
        int32_t minar = macro->def->min_arity;
        int32_t maxar = macro->def->max_arity;
        const uint8_t *es = NULL;
        if (minar >= 0 && arity < minar)
            es = janet_formatc("macro arity mismatch, expected at least %d, got %d", minar, arity);
        if (maxar >= 0 && arity > maxar)
            es = janet_formatc("macro arity mismatch, expected at most %d, got %d", maxar, arity);
        c->result.macrofiber = NULL;
        janetc_error(c, es);
        return 0;
    }
    /* Set env */
    fiberp->env = c->env;
    int lock = janet_gclock();
    Janet mf_kw = janet_ckeywordv("macro-form");
    janet_table_put(c->env, mf_kw, x);
    Janet ml_kw = janet_ckeywordv("macro-lints");
    if (c->lints) {
        janet_table_put(c->env, ml_kw, janet_wrap_array(c->lints));
    }
    Janet tempOut;
    JanetSignal status = janet_continue(fiberp, janet_wrap_nil(), &tempOut);
    janet_table_put(c->env, mf_kw, janet_wrap_nil());
    janet_table_put(c->env, ml_kw, janet_wrap_nil());
    janet_gcunlock(lock);
    if (status != JANET_SIGNAL_OK) {
        const uint8_t *es = janet_formatc("(macro) %V", tempOut);
        c->result.macrofiber = fiberp;
        janetc_error(c, es);
        return 0;
    } else {
        *out = tempOut;
    }

    return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rsi, -0x10(%rbp)
movq %rdi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
xorl %eax, %eax
testb $0x1, %al
jne 0x22583
jmp 0x225a9
movsd -0x10(%rbp), %xmm0
ucomisd %xmm0, %xmm0
setp %al
testb $0x1, %al
jne 0x22595
jmp 0x225d2
movq -0x10(%rbp), %rax
shrq $0x2f, %rax
andq $0xf, %rax
cmpq $0x0, %rax
je 0x225d2
jmp 0x225c6
movabsq $-0x800000000000, %rax  # imm = 0xFFFF800000000000
andq -0x10(%rbp), %rax
movabsq $-0x4000000000000, %rcx # imm = 0xFFFC000000000000
cmpq %rcx, %rax
je 0x225d2
movl $0x0, -0x4(%rbp)
jmp 0x22a18
movq -0x10(%rbp), %rdi
callq 0x7b260
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x0, -0x10(%rax)
jne 0x225f5
movl $0x0, -0x4(%rbp)
jmp 0x22a18
movq -0x30(%rbp), %rax
cmpl $0x0, -0x8(%rax)
jl 0x2261b
movq -0x30(%rbp), %rax
movl -0x8(%rax), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x50(%rax)
movq -0x30(%rbp), %rax
movl -0x4(%rax), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x54(%rax)
movq -0x30(%rbp), %rax
movl -0x20(%rax), %eax
andl $0x10000, %eax          # imm = 0x10000
cmpl $0x0, %eax
je 0x22638
movl $0x0, -0x4(%rbp)
jmp 0x22a18
xorl %eax, %eax
testb $0x1, %al
jne 0x22640
jmp 0x2266c
movq -0x30(%rbp), %rax
movsd (%rax), %xmm0
ucomisd %xmm0, %xmm0
setp %al
testb $0x1, %al
jne 0x22655
jmp 0x22698
movq -0x30(%rbp), %rax
movq (%rax), %rax
shrq $0x2f, %rax
andq $0xf, %rax
cmpq $0x0, %rax
je 0x22698
jmp 0x2268c
movq -0x30(%rbp), %rcx
movabsq $-0x800000000000, %rax  # imm = 0xFFFF800000000000
andq (%rcx), %rax
movabsq $-0x5800000000000, %rcx # imm = 0xFFFA800000000000
cmpq %rcx, %rax
je 0x22698
movl $0x0, -0x4(%rbp)
jmp 0x22a18
movq -0x30(%rbp), %rax
movq (%rax), %rdi
callq 0x7b260
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
callq 0x5ed10
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x226d3
movq -0x40(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movl $0x0, -0x4(%rbp)
jmp 0x22a18
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x38(%rbp), %rsi
leaq -0x48(%rbp), %rdx
callq 0x6cff0
movl %eax, -0x4c(%rbp)
cmpl $0x3, -0x4c(%rbp)
je 0x226f7
cmpl $0x5, -0x4c(%rbp)
jne 0x22742
xorl %eax, %eax
testb $0x1, %al
jne 0x226ff
jmp 0x22725
movsd -0x48(%rbp), %xmm0
ucomisd %xmm0, %xmm0
setp %al
testb $0x1, %al
jne 0x22711
jmp 0x2274e
movq -0x48(%rbp), %rax
shrq $0x2f, %rax
andq $0xf, %rax
cmpq $0x0, %rax
je 0x2274e
jmp 0x22742
movabsq $-0x800000000000, %rax  # imm = 0xFFFF800000000000
andq -0x48(%rbp), %rax
movabsq $-0x2000000000000, %rcx # imm = 0xFFFE000000000000
cmpq %rcx, %rax
je 0x2274e
movl $0x0, -0x4(%rbp)
jmp 0x22a18
movq -0x48(%rbp), %rdi
callq 0x7b260
movq %rax, -0x58(%rbp)
movq -0x30(%rbp), %rax
movl -0x10(%rax), %eax
subl $0x1, %eax
movl %eax, -0x5c(%rbp)
movq -0x58(%rbp), %rdi
movl -0x5c(%rbp), %edx
movq -0x30(%rbp), %rcx
addq $0x8, %rcx
movl $0x40, %esi
callq 0x36450
movq %rax, -0x68(%rbp)
xorl %eax, %eax
cmpq -0x68(%rbp), %rax
jne 0x22826
movq -0x58(%rbp), %rax
movq 0x10(%rax), %rax
movl 0x64(%rax), %eax
movl %eax, -0x6c(%rbp)
movq -0x58(%rbp), %rax
movq 0x10(%rax), %rax
movl 0x68(%rax), %eax
movl %eax, -0x70(%rbp)
movq $0x0, -0x78(%rbp)
cmpl $0x0, -0x6c(%rbp)
jl 0x227db
movl -0x5c(%rbp), %eax
cmpl -0x6c(%rbp), %eax
jge 0x227db
movl -0x6c(%rbp), %esi
movl -0x5c(%rbp), %edx
leaq 0x5ef2b(%rip), %rdi     # 0x816fb
movb $0x0, %al
callq 0x5bdd0
movq %rax, -0x78(%rbp)
cmpl $0x0, -0x70(%rbp)
jl 0x22801
movl -0x5c(%rbp), %eax
cmpl -0x70(%rbp), %eax
jle 0x22801
movl -0x70(%rbp), %esi
movl -0x5c(%rbp), %edx
leaq 0x5ef38(%rip), %rdi     # 0x8172e
movb $0x0, %al
callq 0x5bdd0
movq %rax, -0x78(%rbp)
movq -0x18(%rbp), %rax
movq $0x0, 0x38(%rax)
movq -0x18(%rbp), %rdi
movq -0x78(%rbp), %rsi
callq 0x1ffb0
movl $0x0, -0x4(%rbp)
jmp 0x22a18
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rcx
movq -0x68(%rbp), %rax
movq %rcx, 0x28(%rax)
callq 0x3a810
movl %eax, -0x7c(%rbp)
leaq 0x5ef1b(%rip), %rdi     # 0x81760
callq 0x68d90
movq %rax, %rdi
movabsq $-0x5000000000000, %rsi # imm = 0xFFFB000000000000
callq 0x7b550
movq %rax, -0x88(%rbp)
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x88(%rbp), %rsi
movq -0x10(%rbp), %rdx
callq 0x697e0
leaq 0x5eee9(%rip), %rdi     # 0x8176b
callq 0x68d90
movq %rax, %rdi
movabsq $-0x5000000000000, %rsi # imm = 0xFFFB000000000000
callq 0x7b550
movq %rax, -0x90(%rbp)
movq -0x18(%rbp), %rax
cmpq $0x0, 0x60(%rax)
je 0x228f2
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0xd0(%rbp)
movq -0x18(%rbp), %rax
movq 0x60(%rax), %rdi
movabsq $-0x4800000000000, %rsi # imm = 0xFFFB800000000000
callq 0x7b610
movq -0xd0(%rbp), %rdi
movq %rax, -0x98(%rbp)
movq -0x90(%rbp), %rsi
movq -0x98(%rbp), %rdx
callq 0x697e0
movq -0x68(%rbp), %rax
movq %rax, -0xe8(%rbp)
movabsq $-0x77fffffffffff, %rdi # imm = 0xFFF8800000000001
callq 0x7b460
movq -0xe8(%rbp), %rdi
movq %rax, -0xb0(%rbp)
movq -0xb0(%rbp), %rsi
leaq -0xa0(%rbp), %rdx
callq 0x70a80
movl %eax, -0xa4(%rbp)
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0xe0(%rbp)
movabsq $-0x77fffffffffff, %rdi # imm = 0xFFF8800000000001
callq 0x7b460
movq -0xe0(%rbp), %rdi
movq %rax, -0xb8(%rbp)
movq -0x88(%rbp), %rsi
movq -0xb8(%rbp), %rdx
callq 0x697e0
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0xd8(%rbp)
movabsq $-0x77fffffffffff, %rdi # imm = 0xFFF8800000000001
callq 0x7b460
movq -0xd8(%rbp), %rdi
movq %rax, -0xc0(%rbp)
movq -0x90(%rbp), %rsi
movq -0xc0(%rbp), %rdx
callq 0x697e0
movl -0x7c(%rbp), %edi
callq 0x3a840
cmpl $0x0, -0xa4(%rbp)
je 0x22a03
movq -0xa0(%rbp), %rsi
leaq 0x5eda7(%rip), %rdi     # 0x81777
movb $0x0, %al
callq 0x5bdd0
movq %rax, -0xc8(%rbp)
movq -0x68(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x18(%rbp), %rdi
movq -0xc8(%rbp), %rsi
callq 0x1ffb0
movl $0x0, -0x4(%rbp)
jmp 0x22a18
movq -0x20(%rbp), %rax
movq -0xa0(%rbp), %rcx
movq %rcx, (%rax)
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xf0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)