// File: /workspace/github_c_makefile_star2_O2/BernardTatin[P]s7sh/s7.c
// Function: g_varlet
static s7_pointer g_varlet(s7_scheme *sc, s7_pointer args)
    {
#define H_varlet "(varlet env ...) adds its arguments (a let, a cons: symbol . value, or two arguments, the symbol and its value) \
        to the let env, and returns env.  (varlet (curlet) 'a 1) adds 'a to the current environment with the value 1."
#define Q_varlet s7_make_circular_signature(sc, 2, 4, sc->is_let_symbol, \
        s7_make_signature(sc, 2, sc->is_let_symbol, sc->is_null_symbol), \
        s7_make_signature(sc, 3, sc->is_pair_symbol, sc->is_symbol_symbol, sc->is_let_symbol), \
        sc->T)
        /* varlet = with-let + define */
        s7_pointer x, e, sym, val, p;

        e = car(args);
        if (is_null(e))
            e = sc->rootlet;
        else
        {
            check_method(sc, e, sc->varlet_symbol, args);
            if (!is_let(e))
                return(wrong_type_argument_with_type(sc, sc->varlet_symbol, 1, e, a_let_string));
            if ((is_immutable(e)) || (e == sc->s7_let))
                return(s7_wrong_type_arg_error(sc, "varlet", 1, e, "a mutable let"));
        }
        for (x = cdr(args); is_pair(x); x = cdr(x))
        {
            p = car(x);
            switch (type(p))
            {
                case T_SYMBOL:
                    if (is_keyword(p))
                        sym = keyword_symbol(p);
                    else sym = p;
                    if (!is_pair(cdr(x)))
                        s7_error(sc, sc->error_symbol, set_elist_3(sc, value_is_missing_string, sc->varlet_symbol, car(x)));
                    if (is_constant_symbol(sc, sym))
                        return(wrong_type_argument_with_type(sc, sc->varlet_symbol, position_of(x, args), sym, a_non_constant_symbol_string));
                    x = cdr(x);
                    val = car(x);
                    break;

                case T_PAIR:
                    sym = car(p);
                    if (!is_symbol(sym))
                        return(wrong_type_argument_with_type(sc, sc->varlet_symbol, position_of(x, args), p, a_symbol_string));
                    if (is_constant_symbol(sc, sym))
                        return(wrong_type_argument_with_type(sc, sc->varlet_symbol, position_of(x, args), sym, a_non_constant_symbol_string));
                    val = cdr(p);
                    break;

                case T_LET:
                    append_let(sc, e, check_c_obj_env(sc, p, sc->varlet_symbol));
                    continue;

                default:
                    return(wrong_type_argument_with_type(sc, sc->varlet_symbol, position_of(x, args), p, a_symbol_string));
            }

            if (e == sc->rootlet)
            {
                if (is_slot(global_slot(sym)))
                {
                    if (is_syntax(slot_value(global_slot(sym))))
                        return(wrong_type_argument_with_type(sc, sc->varlet_symbol, position_of(x, args), p, wrap_string(sc, "a non-syntactic keyword", 23)));
                    /*  without this check we can end up turning our code into gibberish:
                     *    (set! quote 1) -> ;can't set! quote
                     *    (varlet (rootlet) '(quote . 1)), :quote -> 1
                     * or worse set quote to a function of one arg that tries to quote something -- infinite loop
                     */
                    slot_set_value_with_hook(global_slot(sym), val);
                }
                else s7_make_slot(sc, e, sym, val);
            }
            else
            {
                if ((has_let_fallback(e)) &&
                        ((sym == sc->let_ref_fallback_symbol) || (sym == sc->let_set_fallback_symbol)))
                    return(s7_error(sc, sc->error_symbol, set_elist_2(sc, wrap_string(sc, "varlet can't shadow ~S", 22), sym)));

                make_slot_1(sc, e, sym, val);
            }
            /* this used to check for sym already defined, and set its value, but that greatly slows down
             *   the most common use (adding a slot), and makes it hard to shadow explicitly.  Don't use
             *   varlet as a substitute for set!/let-set!.
             */
        }
        return(e);
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %rbp
movq %rdi, %rbx
movq 0x8(%rsi), %rax
cmpq 0x110(%rdi), %rax
je 0x4d1a9
movq %rax, %r12
movq (%rax), %r15
btl $0x1e, %r15d
jae 0x4d162
cmpb $0x1, 0x24c(%rbx)
jne 0x4d162
movq %rbx, %rdi
movq %r12, %rsi
callq 0x88f3
movq 0x1640(%rbx), %rdx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x888f
cmpq 0x128(%rbx), %rax
je 0x4d162
movq %rax, %r14
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x35492
movq %rbx, %rdi
movq %r14, %rsi
movq %rax, %rdx
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xa34c
cmpb $0x1c, %r15b
jne 0x4d365
btl $0x18, %r15d
movq %r12, %r14
jb 0x4d17f
cmpq 0x2150(%rbx), %r14
jne 0x4d1b0
leaq 0x8b43f(%rip), %rsi     # 0xd85c5
leaq 0x9a398(%rip), %r8      # 0xe7525
pushq $0x1
popq %rdx
movq %rbx, %rdi
movq %r14, %rcx
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xc2b0
movq 0x150(%rbx), %r14
movq %rbp, 0x8(%rsp)
movq %r14, 0x10(%rsp)
movq 0x10(%rbp), %rbp
cmpb $0x1, (%rbp)
jne 0x4d460
movq 0x8(%rbp), %r12
movzbl (%r12), %eax
cmpl $0x1, %eax
je 0x4d28e
cmpl $0x1c, %eax
je 0x4d269
cmpl $0xa, %eax
jne 0x4d38d
testb $-0x80, 0x6(%r12)
movq %r12, %r13
je 0x4d204
movq 0x8(%r12), %rax
movq 0x20(%rax), %rax
movq 0x18(%rax), %r13
movq 0x10(%rbp), %rax
cmpb $0x1, (%rax)
je 0x4d24c
movq 0xea8(%rbx), %rsi
movq 0xcfc95(%rip), %rax     # 0x11ceb0
movq 0x1640(%rbx), %rcx
movq 0x6e8(%rbx), %rdx
movq %rax, 0x8(%rdx)
movq 0x10(%rdx), %rax
movq %rcx, 0x8(%rax)
movq 0x10(%rax), %rax
movq %r12, 0x8(%rax)
movq 0x6e8(%rbx), %rdx
movq %rbx, %rdi
callq 0x2cdc0
movq %rbx, %rdi
movq %r13, %rsi
callq 0x72bfa
testb %al, %al
jne 0x4d3c5
movq 0x10(%rbp), %rbp
leaq 0x8(%rbp), %rax
jmp 0x4d2b6
movq 0x1640(%rbx), %rdx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x72bca
movq %rbx, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x72a93
jmp 0x4d1ba
movq 0x8(%r12), %r13
cmpb $0xa, (%r13)
jne 0x4d38d
movq %rbx, %rdi
movq %r13, %rsi
callq 0x72bfa
testb %al, %al
jne 0x4d3c5
leaq 0x10(%r12), %rax
movq (%rax), %r15
cmpq 0x150(%rbx), %r14
je 0x4d2f9
testb $0xc, 0x3(%r14)
je 0x4d2e3
cmpq 0x1228(%rbx), %r13
je 0x4d3fd
cmpq 0x1238(%rbx), %r13
je 0x4d3fd
movq %rbx, %rdi
movq %r14, %rsi
movq %r13, %rdx
movq %r15, %rcx
callq 0x9a09
jmp 0x4d1ba
movq 0x10(%r13), %r14
cmpb $0x20, (%r14)
jne 0x4d33c
movq 0x10(%r14), %rax
cmpb $0x9, (%rax)
je 0x4d527
movq 0x200(%rbx), %rsi
movq %rbx, %rdi
callq 0x97c7
cmpb $0x1, (%rax)
jne 0x4d357
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x97da
movq 0x10(%rsp), %r14
jmp 0x4d1ba
movq %rbx, %rdi
movq 0x10(%rsp), %r14
movq %r14, %rsi
movq %r13, %rdx
movq %r15, %rcx
callq 0x94fb
jmp 0x4d1ba
movq %r15, 0x10(%r14)
movq 0x10(%rsp), %r14
jmp 0x4d1ba
movq 0x1640(%rbx), %rax
movq 0x8(%rax), %rsi
movq 0xc85e1(%rip), %rdx     # 0x115958
movq 0x140(%rbx), %r8
movq 0xcc5d3(%rip), %r9      # 0x119958
movq %rbx, %rdi
jmp 0x4d4bf
movq 0x1640(%rbx), %rax
movq 0x8(%rax), %r14
movq %rbp, %rdi
movq 0x8(%rsp), %rsi
callq 0x72a82
movslq %eax, %r15
cmpl $0x7ff, %r15d           # imm = 0x7FF
ja 0x4d472
leaq 0xc8594(%rip), %rax     # 0x115950
movq (%rax,%r15,8), %rdx
jmp 0x4d4ab
movq 0x1640(%rbx), %rax
movq 0x8(%rax), %r14
movq %rbp, %rdi
movq 0x8(%rsp), %rsi
callq 0x72a82
movslq %eax, %r15
cmpl $0x7ff, %r15d           # imm = 0x7FF
ja 0x4d4c4
leaq 0xc855c(%rip), %rax     # 0x115950
movq (%rax,%r15,8), %rdx
jmp 0x4d4fd
movq 0xea8(%rbx), %r14
movq 0x820(%rbx), %rax
movslq 0x7dc(%rbx), %rcx
movq (%rax,%rcx,8), %rax
incl %ecx
andl $0x7, %ecx
movl %ecx, 0x7dc(%rbx)
leaq 0x9a10b(%rip), %rcx     # 0xe7533
movq %rcx, 0x10(%rax)
movq $0x16, 0x8(%rax)
movq 0x6e0(%rbx), %rcx
movq %rax, 0x8(%rcx)
movq 0x6e0(%rbx), %rax
movq 0x10(%rax), %rax
movq %r13, 0x8(%rax)
movq 0x6e0(%rbx), %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2cdc0
movq %r14, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0x4d491
movq %rbx, %rdi
callq 0x9c27
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %rdx
movq $0xb, (%rdx)
movq %r15, 0x8(%rdx)
movq 0x140(%rbx), %r8
movq 0xcc4a7(%rip), %r9      # 0x119960
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rcx
jmp 0x4d514
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0x4d4e3
movq %rbx, %rdi
callq 0x9c27
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %rdx
movq $0xb, (%rdx)
movq %r15, 0x8(%rdx)
movq 0x140(%rbx), %r8
movq 0xcf9ad(%rip), %r9      # 0x11ceb8
movq %rbx, %rdi
movq %r14, %rsi
movq %r13, %rcx
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x9bbb
movq 0x1640(%rbx), %rax
movq 0x8(%rax), %r14
movq %rbp, %rdi
movq 0x8(%rsp), %rsi
callq 0x72a82
movslq %eax, %r15
cmpl $0x7ff, %r15d           # imm = 0x7FF
ja 0x4d558
leaq 0xc83fe(%rip), %rax     # 0x115950
movq (%rax,%r15,8), %rdx
jmp 0x4d591
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0x4d577
movq %rbx, %rdi
callq 0x9c27
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %rdx
movq $0xb, (%rdx)
movq %r15, 0x8(%rdx)
movq 0x140(%rbx), %r8
movq 0x820(%rbx), %rax
movslq 0x7dc(%rbx), %rcx
movq (%rax,%rcx,8), %r9
leal 0x1(%rcx), %eax
andl $0x7, %eax
movl %eax, 0x7dc(%rbx)
leaq 0x94ff0(%rip), %rax     # 0xe25ad
movq %rax, 0x10(%r9)
movq $0x17, 0x8(%r9)
jmp 0x4d4b9