// File: /workspace/github_c_makefile_star2_O3/BernardTatin[P]s7sh/s7.c
// Function: g_quasiquote_1
static s7_pointer g_quasiquote_1(s7_scheme *sc, s7_pointer form, bool check_cycles)
                {
#define H_quasiquote "(quasiquote arg) is the same as `arg.  If arg is a list, it can contain \
                    comma (\"unquote\") and comma-atsign (\"apply values\") to pre-evaluate portions of the list. \
                    unquoted expressions are evaluated and plugged into the list, apply-values evaluates the expression \
                    and splices the resultant list into the outer list. `(1 ,(+ 1 1) ,@(list 3 4)) -> (1 2 3 4)."

                    if (!is_pair(form))
                    {
                        if (is_normal_symbol(form))
                            return(list_2(sc, sc->quote_symbol, form));
                        /* things that evaluate to themselves don't need to be quoted. */
                        return(form);
                    }

                    if (car(form) == sc->unquote_symbol)
                    {
                        if (!is_pair(cdr(form)))             /* (unquote) or (unquote . 1) */
                        {
                            if (is_null(cdr(form)))
                                eval_error(sc, "unquote: no argument, ~S", 24, form);
                            else eval_error(sc, "unquote: stray dot, ~S", 22, form);
                        }
                        if (is_not_null(cddr(form)))
                            eval_error(sc, "unquote: too many arguments, ~S", 31, form);
                        return(cadr(form));
                    }

                    /* it's a list, so return the list with each element handled as above.
                     *    we try to support dotted lists which makes the code much messier.
                     * if no element of the list is a list or unquote, just return the original quoted
                     */
                    if (((check_cycles) && (tree_is_cyclic(sc, form))) ||
                            (is_simple_code(sc, form)))
                        return(list_2(sc, sc->quote_symbol, form));

                    {
                        s7_int len, i;
                        s7_pointer orig, bq, old_scw;
                        bool dotted = false;

                        len = s7_list_length(sc, form);
                        if (len < 0)
                        {
                            len = -len;
                            dotted = true;
                        }
                        old_scw = sc->w;
                        push_stack_no_let_no_code(sc, OP_GC_PROTECT, sc->w);

                        sc->w = sc->nil;
                        for (i = 0; i <= len; i++)
                            sc->w = cons(sc, sc->nil, sc->w);

                        set_car(sc->w, sc->list_values_symbol);
                        if (!dotted)
                        {
                            for (orig = form, bq = cdr(sc->w), i = 0; i < len; i++, orig = cdr(orig), bq = cdr(bq))
                            {
                                if ((is_pair(cdr(orig))) &&             /* this was is_pair(orig) which seems to be always the case */
                                        (cadr(orig) == sc->unquote_symbol)) /* `(1 . ,(+ 1 1)) -> '(1 unquote (+ 1 1)) -> '(1 . 2) etc */
                                {
                                    if (!is_pair(cddr(orig)))
                                    {
                                        sc->w = old_scw;
                                        unstack(sc);
                                        eval_error(sc, "unquote: no argument, ~S", 24, form);
                                    }
                                    set_car(bq, g_quasiquote_1(sc, car(orig), false));
                                    set_cdr(bq, sc->nil);
                                    sc->w = list_3(sc, sc->append_symbol, sc->w, caddr(orig));
                                    break;
                                }
                                else set_car(bq, g_quasiquote_1(sc, car(orig), false));
                            }
                        }
                        else
                        {
                            /* `(1 2 . 3) */
                            len--;
                            for (orig = form, bq = cdr(sc->w), i = 0; i < len; i++, orig = cdr(orig), bq = cdr(bq))
                                set_car(bq, g_quasiquote_1(sc, car(orig), false));
                            set_car(bq, g_quasiquote_1(sc, car(orig), false));

                            sc->w = list_3(sc, sc->append_symbol, sc->w, g_quasiquote_1(sc, cdr(orig), false));
                            /* quasiquote might quote a symbol in cdr(orig), so it's not completely pointless */
                        }
                        bq = sc->w;
                        sc->w = old_scw;
                        unstack(sc);
                        return(bq);
                    }
                }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movzbl (%rsi), %eax
cmpl $0x1, %eax
je 0xe8a15
cmpl $0xa, %eax
jne 0xe8a0d
testb $-0x80, 0x6(%r14)
je 0xe8a4c
movq %r14, %r15
jmp 0xe8dcb
movq 0x8(%r14), %rax
cmpq 0x17b8(%rbx), %rax
je 0xe8abe
testb %dl, %dl
je 0xe8a39
movq %rbx, %rdi
movq %r14, %rsi
callq 0x38d93
testb %al, %al
jne 0xe8a4c
movq %rbx, %rdi
movq %r14, %rsi
callq 0xe8ef1
testb %al, %al
je 0xe8b23
movq 0x17b0(%rbx), %r12
movq 0x90(%rbx), %rax
movq 0x110(%rbx), %r15
cmpq 0x98(%rbx), %rax
ja 0xe8a79
movq %rbx, %rdi
callq 0xa550
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %rax
movl $0x200001, %ecx         # imm = 0x200001
movq %rcx, (%rax)
movq %r14, 0x8(%rax)
movq %r15, 0x10(%rax)
movq 0x90(%rbx), %rdx
leaq -0x8(%rdx), %rsi
movq %rsi, 0x90(%rbx)
movq -0x8(%rdx), %r15
movq %rcx, (%r15)
movq %r12, 0x8(%r15)
movq %rax, 0x10(%r15)
jmp 0xe8dcb
movq 0x10(%r14), %rax
cmpb $0x1, (%rax)
jne 0xe8c38
movq 0x10(%rax), %rcx
cmpq 0x110(%rbx), %rcx
je 0xe8d86
movq 0x1918(%rbx), %r15
movq 0x820(%rbx), %rax
movslq 0x7dc(%rbx), %rcx
movq (%rax,%rcx,8), %rax
incl %ecx
andl $0x7, %ecx
movl %ecx, 0x7dc(%rbx)
leaq 0x30c78(%rip), %rcx     # 0x11977f
movq %rcx, 0x10(%rax)
movq $0x1f, 0x8(%rax)
movq 0x6e0(%rbx), %rcx
movq %rax, 0x8(%rcx)
jmp 0xe8daa
movq %rbx, %rdi
movq %r14, %rsi
callq 0x39d0d
movq 0x4d8(%rbx), %rdx
movq 0x50(%rbx), %rcx
movq %rdx, 0x8(%rsp)
movq %rdx, 0x10(%rcx)
movq 0x50(%rbx), %rcx
movq $0x1, 0x18(%rcx)
addq $0x20, 0x50(%rbx)
movq 0x110(%rbx), %r15
movq %r15, 0x4d8(%rbx)
movq %rax, %rbp
negq %rbp
movq %rax, 0x10(%rsp)
cmovsq %rax, %rbp
leaq 0x1(%rbp), %r13
movq 0x90(%rbx), %rax
movq 0x110(%rbx), %r12
cmpq 0x98(%rbx), %rax
ja 0xe8b9a
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 %r12, 0x8(%rax)
movq %r15, 0x10(%rax)
movq %rax, 0x4d8(%rbx)
movq %rax, %r15
decq %r13
jne 0xe8b74
movq 0x1278(%rbx), %rcx
movq %rcx, 0x8(%rax)
movq 0x4d8(%rbx), %r15
movq 0x10(%rsp), %r12
testq %r12, %r12
js 0xe8c82
je 0xe8d73
movq %r14, %r12
movq 0x10(%r15), %r15
movq 0x10(%r12), %rax
cmpb $0x1, (%rax)
jne 0xe8c0f
movq 0x8(%rax), %rcx
cmpq 0x17b8(%rbx), %rcx
je 0xe8ddd
movq 0x8(%r12), %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0xe89e5
movq %rax, 0x8(%r15)
movq 0x10(%r12), %r12
decq %rbp
jne 0xe8bf0
movq 0x4d8(%rbx), %r15
jmp 0xe8d73
movslq 0x7dc(%rbx), %rcx
leal 0x1(%rcx), %edx
andl $0x7, %edx
movq 0x820(%rbx), %rsi
movq (%rsi,%rcx,8), %rcx
movq 0x1918(%rbx), %r15
cmpq 0x110(%rbx), %rax
movl %edx, 0x7dc(%rbx)
je 0xe8d8c
leaq 0x30af7(%rip), %rax     # 0x119768
movq %rax, 0x10(%rcx)
movq $0x16, 0x8(%rcx)
jmp 0xe8d9f
movq 0x10(%r15), %r15
cmpq $-0x1, %r12
je 0xe8cbb
movl $0x1, %r13d
movq 0x8(%r14), %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0xe89e5
movq %rax, 0x8(%r15)
movq 0x10(%r14), %r14
movq 0x10(%r15), %r15
movq %r12, %rax
xorq %r13, %rax
incq %r13
cmpq $-0x1, %rax
jne 0xe8c92
movq 0x8(%r14), %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0xe89e5
movq %rax, 0x8(%r15)
movq 0xbb8(%rbx), %r12
movq 0x4d8(%rbx), %r15
movq 0x10(%r14), %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0xe89e5
movq %rax, %r14
movq 0x90(%rbx), %rax
movq 0x110(%rbx), %r13
cmpq 0x98(%rbx), %rax
ja 0xe8d12
movq %rbx, %rdi
callq 0xa550
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %rax
movl $0x200001, %ecx         # imm = 0x200001
movq %rcx, (%rax)
movq %r14, 0x8(%rax)
movq %r13, 0x10(%rax)
movq 0x90(%rbx), %rdx
leaq -0x8(%rdx), %rsi
movq %rsi, 0x90(%rbx)
movq -0x8(%rdx), %rdx
movq %rcx, (%rdx)
movq %r15, 0x8(%rdx)
movq %rax, 0x10(%rdx)
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rsi
movq %rsi, 0x90(%rbx)
movq -0x8(%rax), %r15
movq %rcx, (%r15)
movq %r12, 0x8(%r15)
movq %rdx, 0x10(%r15)
movq 0x8(%rsp), %rax
movq %rax, 0x4d8(%rbx)
addq $-0x20, 0x50(%rbx)
jmp 0xe8dcb
movq 0x8(%rax), %r15
jmp 0xe8dcb
leaq 0x309bc(%rip), %rax     # 0x11974f
movq %rax, 0x10(%rcx)
movq $0x18, 0x8(%rcx)
movq 0x6e0(%rbx), %rax
movq %rcx, 0x8(%rax)
movq 0x6e0(%rbx), %rax
movq 0x10(%rax), %rax
movq %r14, 0x8(%rax)
movq 0x6e0(%rbx), %rdx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x38dfa
movq %r15, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x10(%rax), %rax
cmpb $0x1, (%rax)
jne 0xe8ea4
movq 0x8(%r12), %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0xe89e5
movq %rax, 0x8(%r15)
movq 0x110(%rbx), %r13
movq %r13, 0x10(%r15)
movq 0xbb8(%rbx), %r14
movq 0x4d8(%rbx), %r15
movq 0x10(%r12), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %r12
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0xe8e42
movq %rbx, %rdi
callq 0xa550
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %rax
movl $0x200001, %ecx         # imm = 0x200001
movq %rcx, (%rax)
movq %r12, 0x8(%rax)
movq %r13, 0x10(%rax)
movq 0x90(%rbx), %rdx
leaq -0x8(%rdx), %rsi
movq %rsi, 0x90(%rbx)
movq -0x8(%rdx), %rdx
movq %rcx, (%rdx)
movq %r15, 0x8(%rdx)
movq %rax, 0x10(%rdx)
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rsi
movq %rsi, 0x90(%rbx)
movq -0x8(%rax), %r15
movq %rcx, (%r15)
movq %r14, 0x8(%r15)
jmp 0xe8d6f
movq 0x8(%rsp), %rax
movq %rax, 0x4d8(%rbx)
addq $-0x20, 0x50(%rbx)
movq 0x1918(%rbx), %r15
movq 0x820(%rbx), %rax
movslq 0x7dc(%rbx), %rcx
movq (%rax,%rcx,8), %rax
incl %ecx
andl $0x7, %ecx
movl %ecx, 0x7dc(%rbx)
leaq 0x3086f(%rip), %rcx     # 0x11974f
movq %rcx, 0x10(%rax)
movq $0x18, 0x8(%rax)
jmp 0xe8b13