// File: /workspace/github_c_makefile_star2_O1/BernardTatin[P]s7sh/s7.c
// Function: g_list_values
static s7_pointer g_list_values(s7_scheme *sc, s7_pointer args)
                {
#define H_list_values "(list-values ...) returns its arguments in a list (internal to quasiquote)"
#define Q_list_values s7_make_circular_signature(sc, 1, 2, sc->is_list_symbol, sc->T)

                    /* list-values can't be replaced by list(-n) because (list-values (values)) -> () and anything can be #<values> (see s7test) */
                    s7_pointer x;
                    bool checked = false;

                    for (x = args; is_pair(x); x = cdr(x))
                    {
                        if (is_pair(car(x)))
                        {
                            if (is_checked(car(x)))
                                checked = true;
                        }
                        else
                        {
                            if (car(x) == sc->no_value) /* unchecked_car|cdr unrolled here is not faster */
                                break;
                        }
                    }
                    if (is_null(x))
                    {
                        if (checked)
                        {
                            sc->u = args;
                            check_heap_size(sc, 8192);
#if S7_DEBUGGING
                            if (tree_is_cyclic(sc, args))
                            {
                                fprintf(stderr, "%s[%d]: hit a cyclic list?\n", __func__, __LINE__);
                                abort();
                            }
#endif
                            return(copy_tree(sc, args)); /* copy_tree can't handle cyclic trees */
                        }
                        return((is_immutable(args)) ? copy_list(sc, args) : args);
                    }
                    /* if a macro expands into a recursive function with a macro argument as its body (or reasonable facsimile thereof),
                     *   and the safety (as in safe_closure) of the body changes from safe to unsafe, then (due to the checked bits
                     *   protecting against cycles in optimize_expression|syntax), the possible safe_closure call will not be fixed,
                     *   the safe_closure's assumption about the saved local frame will be violated, and we'll get "<arg> unbound".
                     *   examples:
                     *     (define-macro (badmac tst) `(let loop ((x 1)) (if (> x 0) (loop (- x 1)) ,tst)))
                     *     (badmac (vector 0))
                     *     (badmac (let ((x (lambda () 1))) (eq? x x)))
                     *     (define-macro (badmac1 tst) `(let () (define (badf x) (if (> x 0) (badf (- x 1)) ,tst)) (badf 1)))
                     *     (badmac1 (vector 0))
                     *     (badmac1 (let ((x (lambda () 1))) (eq? x x)))
                     * clear_all_optimizations assumes its argument has no cycles, and automatically calling copy_tree slows
                     *   everything down intolerably, so...
                     * if the checked bit is on in a macro expansion, that means we're re-expanding this macro, and therefore
                     *   have to copy the tree.
                     * we can't set_cdr(pc...) as in earlier versions of this code -- might be an embedded permanent list
                     */

                    /* splice out #<values>, (list-values (apply-values ())) -> () etc */
                    sc->w = sc->nil;
                    for (x = args; is_pair(x); x = cdr(x))
                        if (car(x) != sc->no_value)
                            sc->w = cons(sc, car(x), sc->w);
                    sc->u = sc->nil;
                    if (is_pair(sc->w))
                    {
                        x = safe_reverse_in_place(sc, sc->w);
                        sc->w = sc->nil;
                        return(x);
                    }
                    return(sc->nil);
                }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
cmpb $0x1, (%rsi)
jne 0x84f6b
xorl %eax, %eax
movl $0x1, %edx
movq %r14, %rcx
movq 0x8(%rcx), %rsi
cmpb $0x1, (%rsi)
jne 0x84f57
testb $0x40, 0x2(%rsi)
movzbl %al, %eax
cmovnel %edx, %eax
jmp 0x84f60
cmpq 0x138(%rbx), %rsi
je 0x84f70
movq 0x10(%rcx), %rcx
cmpb $0x1, (%rcx)
je 0x84f42
jmp 0x84f70
xorl %eax, %eax
movq %r14, %rcx
movq 0x110(%rbx), %r12
cmpq %r12, %rcx
je 0x85027
movq %r12, 0x4d8(%rbx)
cmpb $0x1, (%r14)
jne 0x84feb
movq 0x8(%r14), %r15
cmpq 0x138(%rbx), %r15
je 0x84fe5
movq 0x4d8(%rbx), %r12
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0x84fb9
movq %rbx, %rdi
callq 0xb389
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %rax
movq $0x200001, (%rax)       # imm = 0x200001
movq %r15, 0x8(%rax)
movq %r12, 0x10(%rax)
movq %rax, 0x4d8(%rbx)
movq 0x10(%r14), %r14
jmp 0x84f87
movq 0x110(%rbx), %r15
movq %r15, 0x4c8(%rbx)
movq 0x4d8(%rbx), %rdx
cmpb $0x1, (%rdx)
jne 0x85141
movq %rbx, %rdi
movq %r15, %rsi
callq 0xa000b
movq 0x110(%rbx), %rcx
movq %rcx, 0x4d8(%rbx)
jmp 0x85144
testb $0x1, %al
je 0x85058
movq %r14, 0x4c8(%rbx)
movl $0x2000, %esi           # imm = 0x2000
movq %rbx, %rdi
callq 0x3e1dd
movq %rbx, %rdi
movq %r14, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xa24d1
testb $0x1, 0x3(%r14)
jne 0x85067
movq %r14, %r15
jmp 0x85141
cmpb $0x1, (%r14)
jne 0x8513e
movq %r14, 0x4c8(%rbx)
movq 0x8(%r14), %r13
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0x85094
movq %rbx, %rdi
callq 0xb389
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %r15
movq $0x200001, (%r15)       # imm = 0x200001
movq %r13, 0x8(%r15)
movq %r12, 0x10(%r15)
movq %r15, 0x4e8(%rbx)
movq 0x10(%r14), %r14
cmpb $0x1, (%r14)
jne 0x85127
movq %r15, %r12
movq 0x8(%r14), %r13
movq 0x90(%rbx), %rax
movq 0x110(%rbx), %rbp
cmpq 0x98(%rbx), %rax
ja 0x850f0
movq %rbx, %rdi
callq 0xb389
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %rax
movq $0x200001, (%rax)       # imm = 0x200001
movq %r13, 0x8(%rax)
movq %rbp, 0x10(%rax)
movq %rax, 0x10(%r12)
movq 0x10(%r14), %r14
cmpb $0x1, (%r14)
movq %rax, %r12
je 0x850cd
movq 0x110(%rbx), %rax
movq %rax, 0x4e8(%rbx)
movq %rax, 0x4c8(%rbx)
jmp 0x85141
movq %r12, %r15
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq