// File: /workspace/github_c_makefile_star2_O2/BernardTatin[P]s7sh/s7.c
// Function: lambda_star_set_args
static inline s7_pointer lambda_star_set_args(s7_scheme *sc)
                {
                    bool allow_other_keys;
                    s7_pointer lx, cx, zx, code, args, slot;

                    code = sc->code;
                    args = sc->args;
                    cx = closure_args(code);
                    slot = let_slots(sc->envir);
                    allow_other_keys = ((is_pair(cx)) && (allows_other_keys(cx)));
                    lx = sc->args;
                    zx = sc->nil;
                    while ((is_pair(cx)) &&
                            (is_pair(lx)))
                    {
                        if (car(cx) == sc->key_rest_symbol)           /* the rest arg: a default is not allowed here (see check_lambda_star_args) */
                        {
                            /* next arg is bound to trailing args from this point as a list */
                            zx = sc->key_rest_symbol;
                            cx = cdr(cx);
                            if ((is_keyword(car(lx))) &&
                                    (is_pair(cdr(lx))) &&
                                    (keyword_symbol(car(lx)) == car(cx)))
                                return(s7_error(sc, sc->wrong_type_arg_symbol,
                                            set_elist_3(sc, wrap_string(sc, "can't set rest arg ~S to ~S via keyword", 39), car(cx), cadr(lx))));
                            lambda_star_argument_set_value(sc, car(cx), lx, slot, false);
                            lx = cdr(lx);
                            cx = cdr(cx);
                            slot = next_slot(slot);
                        }
                        else
                        {
                            s7_pointer car_lx;
                            car_lx = car(lx);
                            if (is_keyword(car_lx))
                            {
                                s7_pointer sym;
                                if (!is_pair(cdr(lx)))
                                {
                                    if (!sc->accept_all_keyword_arguments)
                                        return(s7_error(sc, sc->wrong_type_arg_symbol,
                                                    set_elist_4(sc, wrap_string(sc, "~A: keyword argument's value is missing: ~S in ~S", 49), closure_name(sc, code), lx, args)));
                                    slot_set_value(slot, car_lx);
                                    set_checked_slot(slot);
                                    lx = cdr(lx);
                                }
                                else
                                {
                                    sym = keyword_symbol(car_lx);
                                    if (lambda_star_argument_set_value(sc, sym, cadr(lx), slot, true) == sc->no_value)
                                    {
                                        /* if default value is a key, go ahead and use this value.
                                         *    (define* (f (a :b)) a) (f :c)
                                         * this has become much trickier than I anticipated...
                                         */
                                        if (allow_other_keys)
                                        {
                                            /* in CL: (defun hi (&key (a 1) &allow-other-keys) a) (hi :b :a :a 3) -> 3
                                             * in s7: (define* (hi (a 1) :allow-other-keys) a)    (hi :b :a :a 3) -> 3
                                             */
                                            lx = cddr(lx);
                                        }
                                        else
                                        {
                                            if (!sc->accept_all_keyword_arguments)
                                                return(s7_error(sc, sc->wrong_type_arg_symbol,
                                                            set_elist_4(sc, wrap_string(sc, "~A: unknown key: ~S in ~S", 25), closure_name(sc, code), lx, args)));
                                            slot_set_value(slot, car_lx);
                                            set_checked_slot(slot);
                                            lx = cdr(lx);
                                            cx = cdr(cx);
                                            slot = next_slot(slot);
                                        }
                                        continue;
                                    }
                                    lx = cddr(lx);
                                }
                                slot = next_slot(slot);
                            }
                            else                                  /* not a key/value pair */
                            {
                                if (is_checked_slot(slot))
                                    return(s7_error(sc, sc->wrong_type_arg_symbol, set_elist_3(sc, parameter_set_twice_string, slot_symbol(slot), sc->args)));
                                set_checked_slot(slot);
                                slot_set_value(slot, car(lx));
                                slot = next_slot(slot);
                                lx = cdr(lx);
                            }
                            cx = cdr(cx);
                        }
                    }
                    /* (let () (define* (hi (a 1) :allow-other-keys) a) (hi :a 2 32)) -> 'error */
                    /* (let () (define* (f (a :b)) a) (list (f) (f 1) (f :c) (f :a :c) (f :a 1) (f))) -> 'error */

                    /* check for trailing args with no :rest arg */
                    if (is_not_null(lx))
                    {
                        if ((is_not_null(cx)) ||
                                (zx == sc->key_rest_symbol))
                        {
                            if (is_symbol(cx))
                            {
                                if ((is_keyword(car(lx))) &&
                                        (is_pair(cdr(lx))) &&
                                        (keyword_symbol(car(lx)) == cx))
                                    return(s7_error(sc, sc->wrong_type_arg_symbol,
                                                set_elist_3(sc, wrap_string(sc, "can't set rest arg ~S to ~S via keyword", 39), cx, cadr(lx))));
                                slot_set_value(slot, lx);
                            }
                        }
                        else
                        {
                            if (!allow_other_keys)                       /* ((lambda* (a) a) :a 1 2) */
                                return(s7_error(sc, sc->wrong_number_of_args_symbol, set_elist_3(sc, too_many_arguments_string, closure_name(sc, code), args)));
                            /* check trailing args for repeated keys or keys with no values or values with no keys */
                            while (is_pair(lx))
                            {
                                if ((!is_keyword(car(lx))) ||     /* ((lambda* (a :allow-other-keys) a) :a 1 :b 2 3) */
                                        (!is_pair(cdr(lx))))          /* ((lambda* (a :allow-other-keys) a) :a 1 :b) */
                                    return(s7_error(sc, sc->wrong_type_arg_symbol,
                                                set_elist_3(sc, wrap_string(sc, "~A: not a key/value pair: ~S", 28), closure_name(sc, code), lx)));
                                slot = symbol_to_local_slot(sc, keyword_symbol(car(lx)), sc->envir);
                                if ((is_slot(slot)) &&
                                        (is_checked_slot(slot)))
                                    return(s7_error(sc, sc->wrong_type_arg_symbol, set_elist_3(sc, parameter_set_twice_string, slot_symbol(slot), sc->args)));
                                lx = cddr(lx);
                            }
                        }
                    }
                    return(sc->nil);
                }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
movq (%rdi), %rcx
movq 0x8(%rdi), %rax
movq %rcx, 0x18(%rsp)
movq 0x8(%rcx), %r14
cmpb $0x1, (%r14)
jne 0xa830e
movb 0x3(%r14), %cl
andb $0x2, %cl
shrb %cl
movl %ecx, 0xc(%rsp)
jmp 0xa8316
movl $0x0, 0xc(%rsp)
movq 0x10(%rbx), %rbp
movq 0x8(%rax), %r12
movq 0x110(%rbx), %rax
movq %rax, 0x10(%rsp)
movq %rbp, 0x20(%rsp)
movb (%r14), %al
cmpb $0x1, %al
jne 0xa848d
cmpb $0x1, (%rbp)
jne 0xa848d
movq 0x8(%r14), %r13
cmpq 0x1890(%rbx), %r13
je 0xa83da
movq 0x8(%rbp), %r13
testb $-0x80, 0x6(%r13)
je 0xa8422
leaq 0x10(%rbp), %r15
movq 0x10(%rbp), %rax
cmpb $0x1, (%rax)
jne 0xa8451
movq 0x8(%r13), %rcx
movq 0x20(%rcx), %rcx
movq 0x18(%rcx), %rsi
movq 0x8(%rax), %rdx
movq %rbx, %rdi
movq %r12, %rcx
pushq $0x1
popq %r8
callq 0xa8869
cmpq 0x138(%rbx), %rax
jne 0xa846b
cmpb $0x0, 0xc(%rsp)
je 0xa83b1
movq (%r15), %r15
addq $0x10, %r15
jmp 0xa83d2
cmpb $0x0, 0x24d(%rbx)
je 0xa8543
movq %r13, 0x10(%r12)
orb $0x40, 0x2(%r12)
movq 0x10(%r14), %r14
movq 0x18(%r12), %r12
movq (%r15), %rbp
jmp 0xa832f
movq 0x10(%r14), %r14
movq 0x8(%rbp), %rax
testb $-0x80, 0x6(%rax)
je 0xa8407
movq 0x10(%rbp), %rcx
cmpb $0x1, (%rcx)
jne 0xa8407
movq 0x8(%rax), %rax
movq 0x20(%rax), %rax
movq 0x18(%rax), %rax
cmpq 0x8(%r14), %rax
je 0xa8762
movq 0x8(%r14), %rsi
movq %rbx, %rdi
movq %rbp, %rdx
movq %r12, %rcx
xorl %r8d, %r8d
callq 0xa8869
addq $0x10, %rbp
jmp 0xa844c
movq (%r12), %rax
btl $0x16, %eax
jb 0xa86da
orq $0x400000, %rax         # imm = 0x400000
movq %rax, (%r12)
movq 0x8(%rbp), %rax
movq %rax, 0x10(%r12)
addq $0x10, %rbp
movq 0x10(%rsp), %r13
movq %rbp, %r15
jmp 0xa8477
cmpb $0x0, 0x24d(%rbx)
je 0xa86f6
movq %r13, 0x10(%r12)
orb $0x40, 0x2(%r12)
jmp 0xa8472
movq (%r15), %r15
addq $0x10, %r15
movq 0x10(%rsp), %r13
movq (%r15), %rbp
movq 0x18(%r12), %r12
movq 0x10(%r14), %r14
movq %r13, 0x10(%rsp)
jmp 0xa832f
movq 0x110(%rbx), %rcx
cmpq %rcx, %rbp
je 0xa84cc
cmpq %rcx, %r14
je 0xa84db
cmpb $0xa, %al
jne 0xa84cc
movq 0x8(%rbp), %rax
testb $-0x80, 0x6(%rax)
je 0xa84c7
movq 0x10(%rbp), %rcx
cmpb $0x1, (%rcx)
jne 0xa84c7
movq 0x8(%rax), %rax
movq 0x20(%rax), %rax
cmpq %r14, 0x18(%rax)
je 0xa867b
movq %rbp, 0x10(%r12)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x10(%rsp), %rcx
cmpq 0x1890(%rbx), %rcx
je 0xa849e
cmpb $0x0, 0xc(%rsp)
je 0xa85c2
cmpb $0x1, (%rbp)
jne 0xa84cc
movq 0x8(%rbp), %rax
testb $-0x80, 0x6(%rax)
je 0xa860f
movq 0x10(%rbp), %r14
cmpb $0x1, (%r14)
jne 0xa860f
movq 0x8(%rax), %rax
movq 0x20(%rax), %rax
movq 0x18(%rax), %rsi
movq 0x8(%rbx), %rdx
movq %rbx, %rdi
callq 0xb1df
cmpb $0x20, (%rax)
jne 0xa853d
testb $0x40, 0x2(%rax)
jne 0xa8733
movq 0x10(%r14), %rbp
jmp 0xa84f4
movq 0x1940(%rbx), %r12
movq 0x820(%rbx), %rax
movslq 0x7dc(%rbx), %rcx
movq (%rax,%rcx,8), %r14
leal 0x1(%rcx), %eax
andl $0x7, %eax
movl %eax, 0x7dc(%rbx)
leaq 0x3b4fd(%rip), %rax     # 0xe3a6c
movq %rax, 0x10(%r14)
movq $0x19, 0x8(%r14)
movq %rbx, %rdi
movq 0x18(%rsp), %rsi
callq 0xa8203
movq 0x6f0(%rbx), %rcx
movq %r14, 0x8(%rcx)
movq 0x10(%rcx), %rcx
movq %rax, 0x8(%rcx)
movq 0x10(%rcx), %rax
movq %rbp, 0x8(%rax)
movq 0x10(%rax), %rax
movq 0x20(%rsp), %rcx
movq %rcx, 0x8(%rax)
movq 0x6f0(%rbx), %rdx
movq %rbx, %rdi
movq %r12, %rsi
jmp 0xa87ca
movq 0x1900(%rbx), %r15
movq 0x79ac8(%rip), %r14     # 0x122098
movq %rbx, %rdi
movq 0x18(%rsp), %rsi
callq 0xa8203
movq 0x6e8(%rbx), %rcx
movq %r14, 0x8(%rcx)
movq 0x10(%rcx), %rcx
movq %rax, 0x8(%rcx)
movq 0x10(%rcx), %rax
movq 0x20(%rsp), %rcx
movq %rcx, 0x8(%rax)
movq 0x6e8(%rbx), %rdx
movq %rbx, %rdi
movq %r15, %rsi
jmp 0xa87ca
movq 0x1940(%rbx), %r12
movq 0x820(%rbx), %rax
movslq 0x7dc(%rbx), %rcx
movq (%rax,%rcx,8), %r14
leal 0x1(%rcx), %eax
andl $0x7, %eax
movl %eax, 0x7dc(%rbx)
leaq 0x3b44b(%rip), %rax     # 0xe3a86
movq %rax, 0x10(%r14)
movq $0x1c, 0x8(%r14)
movq %rbx, %rdi
movq 0x18(%rsp), %rsi
callq 0xa8203
movq 0x6e8(%rbx), %rcx
movq %r14, 0x8(%rcx)
movq 0x10(%rcx), %rcx
movq %rax, 0x8(%rcx)
movq 0x10(%rcx), %rax
movq %rbp, 0x8(%rax)
movq 0x6e8(%rbx), %rdx
jmp 0xa85b7
movq 0x1940(%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 0x3b39e(%rip), %rcx     # 0xe3a44
movq %rcx, 0x10(%rax)
movq $0x27, 0x8(%rax)
movq 0x10(%rbp), %rcx
movq 0x8(%rcx), %rcx
movq 0x6e8(%rbx), %rdx
movq %rax, 0x8(%rdx)
movq 0x10(%rdx), %rax
movq %r14, 0x8(%rax)
movq 0x10(%rax), %rax
movq %rcx, 0x8(%rax)
jmp 0xa87c0
movq 0x1940(%rbx), %rsi
movq 0x799a8(%rip), %rax     # 0x122090
movq 0x8(%r12), %rcx
movq 0x10(%rbx), %rdx
jmp 0xa87a5
movq 0x1940(%rbx), %r12
movq 0x820(%rbx), %rax
movslq 0x7dc(%rbx), %rcx
movq (%rax,%rcx,8), %r14
leal 0x1(%rcx), %eax
andl $0x7, %eax
movl %eax, 0x7dc(%rbx)
leaq 0x3b2c9(%rip), %rax     # 0xe39eb
movq %rax, 0x10(%r14)
movq $0x31, 0x8(%r14)
jmp 0xa857b
movq 0x1940(%rbx), %rsi
movq 0x7994f(%rip), %rcx     # 0x122090
movq 0x8(%rax), %rax
movq 0x10(%rbx), %rdx
movq 0x6e8(%rbx), %rdi
movq %rcx, 0x8(%rdi)
movq 0x10(%rdi), %rcx
movq %rax, 0x8(%rcx)
movq 0x10(%rcx), %rax
jmp 0xa87bc
movq 0x1940(%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 0x3b2b7(%rip), %rcx     # 0xe3a44
movq %rcx, 0x10(%rax)
movq $0x27, 0x8(%rax)
movq 0x8(%r14), %rcx
movq 0x10(%rbp), %rdx
movq 0x8(%rdx), %rdx
movq 0x6e8(%rbx), %rdi
movq %rax, 0x8(%rdi)
movq 0x10(%rdi), %rax
movq %rcx, 0x8(%rax)
movq 0x10(%rax), %rax
movq %rdx, 0x8(%rax)
movq 0x6e8(%rbx), %rdx
movq %rbx, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2cdc0