// File: /workspace/github_c_makefile_star2_O2/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 0xb900b
cmpl $0xa, %eax
jne 0xb9003
testb $-0x80, 0x6(%r14)
je 0xb9042
movq %r14, %r15
jmp 0xb9474
movq 0x8(%r14), %rax
cmpq 0x17b8(%rbx), %rax
je 0xb90b4
testb %dl, %dl
je 0xb902f
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2cd63
testb %al, %al
jne 0xb9042
movq %rbx, %rdi
movq %r14, %rsi
callq 0xb94d3
testb %al, %al
je 0xb9119
movq 0x17b0(%rbx), %r12
movq 0x90(%rbx), %rax
movq 0x110(%rbx), %r15
cmpq 0x98(%rbx), %rax
ja 0xb906f
movq %rbx, %rdi
callq 0x9c27
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 0xb9474
movq 0x10(%r14), %rax
cmpb $0x1, (%rax)
jne 0xb9224
movq 0x10(%rax), %rcx
cmpq 0x110(%rbx), %rcx
je 0xb9352
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 0x2c622(%rip), %rcx     # 0xe571f
movq %rcx, 0x10(%rax)
movq $0x1f, 0x8(%rax)
movq 0x6e0(%rbx), %rcx
movq %rax, 0x8(%rcx)
jmp 0xb9379
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2dada
movq %rax, %r13
negq %r13
movq %rax, 0x10(%rsp)
cmovsq %rax, %r13
movq 0x4d8(%rbx), %rcx
movq 0x50(%rbx), %rax
movq %rcx, 0x8(%rsp)
movq %rcx, 0x10(%rax)
movq 0x50(%rbx), %rax
movq $0x1, 0x18(%rax)
addq $0x20, 0x50(%rbx)
movq 0x110(%rbx), %rbp
movq %rbp, 0x4d8(%rbx)
xorl %r12d, %r12d
cmpq %r13, %r12
ja 0xb91c1
movq 0x90(%rbx), %rax
movq 0x110(%rbx), %r15
cmpq 0x98(%rbx), %rax
ja 0xb9194
movq %rbx, %rdi
callq 0x9c27
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 %rbp, 0x10(%rax)
movq %rax, 0x4d8(%rbx)
incq %r12
movq %rax, %rbp
jmp 0xb9169
movq 0x1278(%rbx), %rax
movq %rax, 0x8(%rbp)
movq 0x4d8(%rbx), %rbp
movq 0x10(%rsp), %rax
testq %rax, %rax
js 0xb927a
movq %r14, %r15
subq $0x1, %r13
jb 0xb926e
movq 0x10(%rbp), %rbp
movq 0x10(%r15), %rax
cmpb $0x1, (%rax)
jne 0xb920c
movq 0x8(%rax), %rcx
cmpq 0x17b8(%rbx), %rcx
je 0xb939f
movq 0x8(%r15), %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0xb8fdb
movq %rax, 0x8(%rbp)
movq 0x10(%r15), %r15
jmp 0xb91e4
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 0xb935b
leaq 0x2c4ab(%rip), %rax     # 0xe5708
movq %rax, 0x10(%rcx)
movq $0x16, 0x8(%rcx)
jmp 0xb936e
movq 0x4d8(%rbx), %r15
jmp 0xb9463
xorl %r12d, %r12d
movq %rax, %r13
movq 0x10(%rbp), %rbp
movq %r13, %r15
xorq %r12, %r15
movq 0x8(%r14), %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0xb8fdb
movq %rax, 0x8(%rbp)
cmpq $-0x1, %r15
je 0xb92ab
incq %r12
movq 0x10(%r14), %r14
jmp 0xb9280
movq 0xbb8(%rbx), %r13
movq 0x4d8(%rbx), %r15
movq 0x10(%r14), %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0xb8fdb
movq %rax, %r14
movq 0x90(%rbx), %rax
movq 0x110(%rbx), %r12
cmpq 0x98(%rbx), %rax
ja 0xb92f0
movq %rbx, %rdi
callq 0x9c27
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 %r12, 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 %r13, 0x8(%r15)
jmp 0xb945f
movq 0x8(%rax), %r15
jmp 0xb9474
leaq 0x2c38d(%rip), %rax     # 0xe56ef
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 0x2cdc0
jmp 0xb9474
movq 0x10(%rax), %rax
cmpb $0x1, (%rax)
jne 0xb9486
movq 0x8(%r15), %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0xb8fdb
movq %rax, 0x8(%rbp)
movq 0x110(%rbx), %r13
movq %r13, 0x10(%rbp)
movq 0xbb8(%rbx), %r14
movq 0x4d8(%rbx), %r12
movq 0x10(%r15), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %r15
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0xb9402
movq %rbx, %rdi
callq 0x9c27
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 %r15, 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 %r12, 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)
movq %rdx, 0x10(%r15)
movq 0x8(%rsp), %rax
movq %rax, 0x4d8(%rbx)
addq $-0x20, 0x50(%rbx)
movq %r15, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
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 0x2c22d(%rip), %rcx     # 0xe56ef
movq %rcx, 0x10(%rax)
movq $0x18, 0x8(%rax)
jmp 0xb9109