// File: /workspace/github_c_makefile_star2_O1/BernardTatin[P]s7sh/s7.c
// Function: check_lambda_1
static int32_t check_lambda_1(s7_scheme *sc, bool optl)
                {
                    /* code is a lambda form minus the "lambda": ((a b) (+ a b)) */
                    /* this includes unevaluated symbols (direct symbol table refs) in macro arg list */
                    s7_pointer code, body, form;
                    int32_t arity = 0;

                    /* fprintf(stderr, "%s[%d]: %s\n", __func__, __LINE__, DISPLAY(sc->code)); */

                    form = sc->code;
                    if ((sc->safety > NO_SAFETY) &&
                            (tree_is_cyclic(sc, form)))
                        s7_error(sc, sc->wrong_type_arg_symbol, wrap_string(sc, "lambda: body is cyclic", 22));

                    sc->code = cdr(sc->code);
                    code = sc->code;
                    if (!is_pair(code))                                 /* (lambda) or (lambda . 1) */
                        eval_error_no_return(sc, sc->syntax_error_symbol, "lambda: no args? ~A", 19, form);

                    body = cdr(code);
                    if (!is_pair(body))                                 /* (lambda #f) */
                        eval_error_no_return(sc, sc->syntax_error_symbol, "lambda: no body? ~A", 19, form);

                    /* in many cases, this is a no-op -- we already checked at define */
                    check_lambda_args(sc, car(code), &arity);
                    clear_symbol_list(sc);

                    /* look for (define f (let (...) (lambda ...))) and treat as equivalent to (define (f ...)...)
                     *   one problem the hop=0 fixes is that safe closures assume the old frame exists, so we need to check for define below
                     *   I wonder about apply define...
                     */
                    if ((optl) ||
                            (main_stack_op(sc) == OP_DEFINE1) ||
                            (((sc->stack_end - sc->stack_start) > 4) &&
                             (((opcode_t)(sc->stack_end[-5])) == OP_DEFINE1) &&  /* surely if define is ok, so is define dilambda? 16-Apr-16 */
                             (sc->op_stack_now > sc->op_stack) &&
                             ((*(sc->op_stack_now - 1)) == (s7_pointer)slot_value(global_slot(sc->dilambda_symbol)))))
                        optimize_lambda(sc, true, sc->unused, car(code), body);
                    else
                    {
                        if (optimize(sc, body, 0,
                                    /* ((sc->op_stack_now > sc->op_stack) && (is_c_function((*(sc->op_stack_now - 1)))) && (is_scope_safe((*(sc->op_stack_now - 1))))) ? 1 : 0, */
                                    /* this works except when someone resets outlet(curlet) after defining a local function! */
                                    collect_parameters(sc, car(sc->code), sc->nil)) == OPT_OOPS)
                            clear_all_optimizations(sc, body);
                    }
                    pair_set_syntax_op(form, OP_LAMBDA_UNCHECKED);
                    if (arity < -1) arity++; /* confusing! at least 0 = (), but (lambda arg...) has same "arity" here as (lambda (a . b)...)? */
                    set_opt3_any(sc->code, (s7_pointer)((intptr_t)arity));
                    return(arity);
                }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movl %esi, %ebp
movq %rdi, %rbx
movl $0x0, 0xc(%rsp)
movq (%rdi), %r14
cmpq $0x0, 0x6a0(%rdi)
jle 0xe9c3f
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3b2ff
testb %al, %al
je 0xe9c3f
movq 0x1940(%rbx), %rsi
movq 0x820(%rbx), %rax
movslq 0x7dc(%rbx), %rcx
movq (%rax,%rcx,8), %rdx
leal 0x1(%rcx), %eax
andl $0x7, %eax
movl %eax, 0x7dc(%rbx)
leaq 0x372a6(%rip), %rax     # 0x120ed1
movq %rax, 0x10(%rdx)
movq $0x16, 0x8(%rdx)
movq %rbx, %rdi
callq 0x3b366
movq (%rbx), %rax
movq 0x10(%rax), %r12
movq %r12, (%rbx)
cmpb $0x1, (%r12)
je 0xe9cb0
movq 0x1918(%rbx), %rsi
movq 0x820(%rbx), %rax
movslq 0x7dc(%rbx), %rcx
movq (%rax,%rcx,8), %rax
incl %ecx
andl $0x7, %ecx
movl %ecx, 0x7dc(%rbx)
leaq 0x3726d(%rip), %rcx     # 0x120ee8
movq %rcx, 0x10(%rax)
movq $0x13, 0x8(%rax)
movq 0x6e0(%rbx), %rcx
movq %rax, 0x8(%rcx)
movq 0x6e0(%rbx), %rax
movq 0x10(%rax), %rax
movq %r14, 0x8(%rax)
movq 0x6e0(%rbx), %rdx
movq %rbx, %rdi
callq 0x3b366
movq 0x10(%r12), %r15
cmpb $0x1, (%r15)
je 0xe9d1b
movq 0x1918(%rbx), %rsi
movq 0x820(%rbx), %rax
movslq 0x7dc(%rbx), %rcx
movq (%rax,%rcx,8), %rax
incl %ecx
andl $0x7, %ecx
movl %ecx, 0x7dc(%rbx)
leaq 0x37216(%rip), %rcx     # 0x120efc
movq %rcx, 0x10(%rax)
movq $0x13, 0x8(%rax)
movq 0x6e0(%rbx), %rcx
movq %rax, 0x8(%rcx)
movq 0x6e0(%rbx), %rax
movq 0x10(%rax), %rax
movq %r14, 0x8(%rax)
movq 0x6e0(%rbx), %rdx
movq %rbx, %rdi
callq 0x3b366
movq 0x8(%r12), %rsi
leaq 0xc(%rsp), %rdx
movq %rbx, %rdi
callq 0xc8775
incl 0xa88(%rbx)
jne 0xe9d45
movl $0x1, 0xa88(%rbx)
incl 0xa8c(%rbx)
testb %bpl, %bpl
jne 0xe9dc3
movq 0x50(%rbx), %rax
cmpq $0x19e, -0x8(%rax)      # imm = 0x19E
je 0xe9dc3
movq %rax, %rcx
subq 0x48(%rbx), %rcx
cmpq $0x21, %rcx
jl 0xe9d8e
cmpq $0x19e, -0x28(%rax)     # imm = 0x19E
jne 0xe9d8e
movq 0x68(%rbx), %rax
cmpq 0x60(%rbx), %rax
jbe 0xe9d8e
movq -0x8(%rax), %rax
movq 0xe78(%rbx), %rcx
movq 0x10(%rcx), %rcx
cmpq 0x10(%rcx), %rax
je 0xe9dc3
movq (%rbx), %rax
movq 0x110(%rbx), %rdx
movq 0x8(%rax), %rsi
movq %rbx, %rdi
callq 0xe9007
movq %rbx, %rdi
movq %r15, %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0xea2f3
cmpl $0x2, %eax
jne 0xe9ddf
movq %r15, %rdi
callq 0xd4d0e
jmp 0xe9ddf
movq 0x140(%rbx), %rdx
movq 0x8(%r12), %rcx
movq %rbx, %rdi
movl $0x1, %esi
movq %r15, %r8
callq 0xe9f0e
movw $0x214, 0x4(%r14)       # imm = 0x214
movw $0x201, (%r14)          # imm = 0x201
movl 0xc(%rsp), %eax
cmpl $-0x2, %eax
jg 0xe9dfb
incl %eax
movl %eax, 0xc(%rsp)
movslq 0xc(%rsp), %rax
movq (%rbx), %rcx
movq %rax, 0x28(%rcx)
movq (%rbx), %rcx
andq $-0x40001, (%rcx)       # imm = 0xFFFBFFFF
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq