// File: /workspace/github_c_makefile_star2_O1/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 0xf17f7
cmpl $0xa, %eax
jne 0xf17ef
testb $-0x80, 0x6(%r14)
je 0xf182e
movq %r14, %r15
jmp 0xf1bc4
movq 0x8(%r14), %rax
cmpq 0x17b8(%rbx), %rax
je 0xf18a0
testb %dl, %dl
je 0xf181b
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3b2ff
testb %al, %al
jne 0xf182e
movq %rbx, %rdi
movq %r14, %rsi
callq 0xf1c68
testb %al, %al
je 0xf1905
movq 0x17b0(%rbx), %r12
movq 0x90(%rbx), %rax
movq 0x110(%rbx), %r15
cmpq 0x98(%rbx), %rax
ja 0xf1854
movq %rbx, %rdi
callq 0xb389
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 0xf1bc4
movq 0x10(%r14), %rax
cmpb $0x1, (%rax)
jne 0xf1a1b
movq 0x10(%rax), %rcx
cmpq 0x110(%rbx), %rcx
je 0xf1b7f
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 0x30d86(%rip), %rcx     # 0x12266f
movq %rcx, 0x10(%rax)
movq $0x1f, 0x8(%rax)
movq 0x6e0(%rbx), %rcx
movq %rax, 0x8(%rcx)
jmp 0xf1ba3
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3c299
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), %rcx
movq %rcx, 0x4d8(%rbx)
movq %rax, %r13
negq %r13
movq %rax, 0x10(%rsp)
cmovsq %rax, %r13
leaq 0x1(%r13), %rbp
movq 0x90(%rbx), %rax
movq 0x110(%rbx), %r12
movq 0x4d8(%rbx), %r15
cmpq 0x98(%rbx), %rax
ja 0xf197c
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 %r12, 0x8(%rax)
movq %r15, 0x10(%rax)
movq %rax, 0x4d8(%rbx)
decq %rbp
jne 0xf1956
movq 0x1278(%rbx), %rax
movq 0x4d8(%rbx), %rcx
movq %rax, 0x8(%rcx)
movq 0x10(%rsp), %rcx
testq %rcx, %rcx
js 0xf1a65
je 0xf1b65
movq 0x4d8(%rbx), %r15
movq %r14, %rbp
movq 0x10(%r15), %r15
movq 0x10(%rbp), %rax
cmpb $0x1, (%rax)
jne 0xf19fb
movq 0x8(%rax), %rcx
cmpq 0x17b8(%rbx), %rcx
je 0xf1bd6
movq 0x8(%rbp), %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0xf17c7
movq %rax, 0x8(%r15)
movq 0x10(%rbp), %rbp
decq %r13
jne 0xf19dd
jmp 0xf1b65
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 0xf1b85
leaq 0x30c04(%rip), %rax     # 0x122658
movq %rax, 0x10(%rcx)
movq $0x16, 0x8(%rcx)
jmp 0xf1b98
movq 0x4d8(%rbx), %rax
movq 0x10(%rax), %rbp
cmpq $-0x1, %rcx
je 0xf1aa6
decq %r13
cmpq $0x2, %r13
movl $0x1, %r15d
cmovgeq %r13, %r15
movq 0x8(%r14), %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0xf17c7
movq %rax, 0x8(%rbp)
movq 0x10(%r14), %r14
movq 0x10(%rbp), %rbp
decq %r15
jne 0xf1a87
movq 0x8(%r14), %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0xf17c7
movq %rax, 0x8(%rbp)
movq 0xbb8(%rbx), %r15
movq 0x4d8(%rbx), %r13
movq 0x10(%r14), %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0xf17c7
movq %rax, %r14
movq 0x90(%rbx), %rax
movq 0x110(%rbx), %rbp
cmpq 0x98(%rbx), %rax
ja 0xf1af6
movq %rbx, %rdi
callq 0xb389
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 %rbp, 0x10(%rax)
movq 0x90(%rbx), %rdx
leaq -0x8(%rdx), %rsi
movq %rsi, 0x90(%rbx)
movq -0x8(%rdx), %rdx
movq %rcx, (%rdx)
movq %r13, 0x8(%rdx)
movq %rax, 0x10(%rdx)
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rsi
movq %rsi, 0x90(%rbx)
movq -0x8(%rax), %rax
movq %rcx, (%rax)
movq %r15, 0x8(%rax)
movq %rdx, 0x10(%rax)
movq %rax, 0x4d8(%rbx)
movq 0x4d8(%rbx), %r15
movq 0x8(%rsp), %rax
movq %rax, 0x4d8(%rbx)
addq $-0x20, 0x50(%rbx)
jmp 0xf1bc4
movq 0x8(%rax), %r15
jmp 0xf1bc4
leaq 0x30ab3(%rip), %rax     # 0x12263f
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 0x3b366
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 0xf1c1b
movq 0x8(%rbp), %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0xf17c7
movq %rax, 0x8(%r15)
movq 0x110(%rbx), %rax
movq %rax, 0x10(%r15)
movq 0xbb8(%rbx), %r15
movq 0x4d8(%rbx), %r13
movq 0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %r14
jmp 0xf1ad7
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 0x309e8(%rip), %rcx     # 0x12263f
movq %rcx, 0x10(%rax)
movq $0x18, 0x8(%rax)
jmp 0xf18f5