// File: /workspace/github_c_makefile_star2_O3/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 0x7ec66
xorl %eax, %eax
movq %r14, %rcx
movq 0x8(%rcx), %rdx
cmpb $0x1, (%rdx)
jne 0x7ec13
movb 0x2(%rdx), %dl
andb $0x40, %dl
shrb $0x6, %dl
orb %dl, %al
jmp 0x7ec1c
cmpq 0x138(%rbx), %rdx
je 0x7ec25
movq 0x10(%rcx), %rcx
cmpb $0x1, (%rcx)
je 0x7ebfd
movq 0x110(%rbx), %r15
cmpq %r15, %rcx
jne 0x7ec76
testb $0x1, %al
je 0x7ed23
movq %r14, 0x4c8(%rbx)
movl $0x2000, %esi           # imm = 0x2000
movq %rbx, %rdi
callq 0x3bbd4
movq %rbx, %rdi
movq %r14, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x9baf3
movq 0x110(%rbx), %r15
cmpq %r14, %r15
je 0x7ed23
leaq 0x110(%rbx), %r12
movq %r15, 0x4d8(%rbx)
cmpb $0x1, (%r14)
jne 0x7ecee
movq 0x8(%r14), %r13
cmpq 0x138(%rbx), %r13
je 0x7ecde
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0x7ecb6
movq %rbx, %rdi
callq 0xa550
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 %r15, 0x10(%rax)
movq %rax, 0x4d8(%rbx)
movq %rax, %r15
movq 0x10(%r14), %r14
cmpb $0x1, (%r14)
je 0x7ec8a
movq (%r12), %r12
jmp 0x7ecf1
movq %r15, %r12
movq %r12, 0x4c8(%rbx)
cmpb $0x1, (%r15)
jne 0x7ee0e
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x9975a
movq 0x110(%rbx), %rcx
movq %rcx, 0x4d8(%rbx)
jmp 0x7ee11
movq (%r14), %rax
btl $0x18, %eax
jb 0x7ed34
movq %r14, %r12
jmp 0x7ee0e
cmpb $0x1, %al
jne 0x7ee0b
movq %r14, 0x4c8(%rbx)
movq 0x8(%r14), %r13
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0x7ed66
movq %rbx, %rdi
callq 0xa550
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %r12
movq $0x200001, (%r12)       # imm = 0x200001
movq %r13, 0x8(%r12)
movq %r15, 0x10(%r12)
movq %r12, 0x4e8(%rbx)
movq 0x10(%r14), %r14
cmpb $0x1, (%r14)
jne 0x7edf4
movq %r12, %r15
movq 0x8(%r14), %r13
movq 0x90(%rbx), %rax
movq 0x110(%rbx), %rbp
cmpq 0x98(%rbx), %rax
ja 0x7edc5
movq %rbx, %rdi
callq 0xa550
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(%r15)
movq 0x10(%r14), %r14
cmpb $0x1, (%r14)
movq %rax, %r15
je 0x7ed9b
movq 0x110(%rbx), %rax
movq %rax, 0x4e8(%rbx)
movq %rax, 0x4c8(%rbx)
jmp 0x7ee0e
movq %r15, %r12
movq %r12, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq