// File: /workspace/github_c_makefile_star2_O3/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 0xe1356
movq %rbx, %rdi
movq %r14, %rsi
callq 0x38d93
testb %al, %al
je 0xe1356
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 0x36c9f(%rip), %rax     # 0x117fe1
movq %rax, 0x10(%rdx)
movq $0x16, 0x8(%rdx)
movq %rbx, %rdi
callq 0x38dfa
movq (%rbx), %rax
movq 0x10(%rax), %r12
movq %r12, (%rbx)
cmpb $0x1, (%r12)
je 0xe13c7
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 0x36c66(%rip), %rcx     # 0x117ff8
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 0x38dfa
movq 0x10(%r12), %r15
cmpb $0x1, (%r15)
je 0xe1432
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 0x36c0f(%rip), %rcx     # 0x11800c
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 0x38dfa
movq 0x8(%r12), %rsi
leaq 0xc(%rsp), %rdx
movq %rbx, %rdi
callq 0xc0548
incl 0xa88(%rbx)
jne 0xe145c
movl $0x1, 0xa88(%rbx)
incl 0xa8c(%rbx)
testb %bpl, %bpl
jne 0xe14da
movq 0x50(%rbx), %rax
cmpq $0x19e, -0x8(%rax)      # imm = 0x19E
je 0xe14da
movq %rax, %rcx
subq 0x48(%rbx), %rcx
cmpq $0x21, %rcx
jl 0xe14a5
cmpq $0x19e, -0x28(%rax)     # imm = 0x19E
jne 0xe14a5
movq 0x68(%rbx), %rax
cmpq 0x60(%rbx), %rax
jbe 0xe14a5
movq -0x8(%rax), %rax
movq 0xe78(%rbx), %rcx
movq 0x10(%rcx), %rcx
cmpq 0x10(%rcx), %rax
je 0xe14da
movq (%rbx), %rax
movq 0x110(%rbx), %rdx
movq 0x8(%rax), %rsi
movq %rbx, %rdi
callq 0xe0710
movq %rbx, %rdi
movq %r15, %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0xe1a2a
cmpl $0x2, %eax
jne 0xe14f6
movq %r15, %rdi
callq 0xcc395
jmp 0xe14f6
movq 0x140(%rbx), %rdx
movq 0x8(%r12), %rcx
movq %rbx, %rdi
movl $0x1, %esi
movq %r15, %r8
callq 0xe1622
movw $0x214, 0x4(%r14)       # imm = 0x214
movw $0x201, (%r14)          # imm = 0x201
movl 0xc(%rsp), %eax
xorl %ecx, %ecx
cmpl $-0x1, %eax
setl %cl
addl %eax, %ecx
movslq %ecx, %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