// File: /workspace/github_c_makefile_star2_O1/BernardTatin[P]s7sh/s7.c
// Function: protected_list_copy
static s7_pointer protected_list_copy(s7_scheme *sc, s7_pointer a)
    {
        s7_pointer slow, fast, p;
#if S7_DEBUGGING
#define wrap_return(W) do {fast = W; W = sc->nil; return(check_wrap_return(sc, fast));} while (0)
#else
#define wrap_return(W) do {fast = W; W = sc->nil; return(fast);} while (0)
#endif

        sc->w = cons(sc, car(a), sc->nil);
        p = sc->w;

        slow = fast = cdr(a);
        while (true)
        {
            if (!is_pair(fast))
            {
                if (is_null(fast))
                    wrap_return(sc->w);
                set_cdr(p, fast);
                wrap_return(sc->w);
            }

            set_cdr(p, cons(sc, car(fast), sc->nil));
            p = cdr(p);

            fast = cdr(fast);
            if (!is_pair(fast))
            {
                if (is_null(fast))
                    wrap_return(sc->w);
                set_cdr(p, fast);
                wrap_return(sc->w);
            }
            /* if unrolled further, it's a lot slower? */
            set_cdr(p, cons(sc, car(fast), sc->nil));
            p = cdr(p);

            fast = cdr(fast);
            slow = cdr(slow);
            if (fast == slow)
            {
                /* try to preserve the original cyclic structure */
                s7_pointer p1, f1, p2, f2;
                set_match_pair(a);
                for (p1 = sc->w, f1 = a; !(is_matched_pair(cdr(f1))); f1 = cdr(f1), p1 = cdr(p1))
                    set_match_pair(f1);
                for (p2 = sc->w, f2 = a; cdr(f1) != f2; f2 = cdr(f2), p2 = cdr(p2))
                    clear_match_pair(f2);
                for (f1 = f2; is_pair(f1); f1 = cdr(f1), f2 = cdr(f2))
                {
                    clear_match_pair(f1);
                    f1 = cdr(f1);
                    clear_match_pair(f1);
                    if (f1 == f2) break;
                }
                clear_match_pair(a);
                if (is_null(p1))
                    set_cdr(p2, p2);
                else set_cdr(p1, p2);
                wrap_return(sc->w);
            }
        }
        wrap_return(sc->w);
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r13
movq %rdi, %rbx
movq 0x8(%rsi), %r15
movq 0x90(%rdi), %rax
movq 0x110(%rdi), %r14
cmpq 0x98(%rdi), %rax
ja 0x9562b
movq %rbx, %rdi
callq 0xb389
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %r12
movq $0x200001, (%r12)       # imm = 0x200001
movq %r15, 0x8(%r12)
movq %r14, 0x10(%r12)
movq %r12, 0x4d8(%rbx)
movq %r13, (%rsp)
movq 0x10(%r13), %r13
movq %r13, %r15
cmpb $0x1, (%r13)
jne 0x9576f
movq 0x8(%r13), %rdx
movq 0x90(%rbx), %rax
movq 0x110(%rbx), %r14
cmpq 0x98(%rbx), %rax
ja 0x95699
movq %rbx, %rdi
movq %rdx, %rbp
callq 0xb389
movq %rbp, %rdx
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %rbp
movq $0x200001, (%rbp)       # imm = 0x200001
movq %rdx, 0x8(%rbp)
movq %r14, 0x10(%rbp)
movq %rbp, 0x10(%r12)
movq 0x10(%r13), %r13
cmpb $0x1, (%r13)
jne 0x95786
movq 0x8(%r13), %rdx
movq 0x90(%rbx), %rax
movq 0x110(%rbx), %r14
cmpq 0x98(%rbx), %rax
ja 0x956fc
movq %rbx, %rdi
movq %rdx, %r12
callq 0xb389
movq %r12, %rdx
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %r12
movq $0x200001, (%r12)       # imm = 0x200001
movq %rdx, 0x8(%r12)
movq %r14, 0x10(%r12)
movq %r12, 0x10(%rbp)
movq 0x10(%r13), %r13
movq 0x10(%r15), %r15
cmpq %r15, %r13
jne 0x95665
movq (%rsp), %rdi
orb $-0x80, 0x1(%rdi)
movq 0x4d8(%rbx), %rax
movq 0x10(%rdi), %rcx
cmpw $0x0, (%rcx)
js 0x95798
movq %rdi, %rdx
movq %rcx, %rsi
orb $-0x80, 0x1(%rdx)
movq 0x10(%rax), %rax
movq 0x10(%rcx), %rcx
cmpw $0x0, (%rcx)
movq %rsi, %rdx
jns 0x95755
jmp 0x9579b
movq 0x110(%rbx), %rcx
cmpq %rcx, %r13
je 0x95803
movq %r13, 0x10(%r12)
jmp 0x957fc
movq 0x110(%rbx), %rcx
cmpq %rcx, %r13
je 0x95803
movq %r13, 0x10(%rbp)
jmp 0x957fc
movq %rdi, %rsi
movq 0x4d8(%rbx), %rcx
cmpq %rdi, 0x10(%rsi)
je 0x957bf
movq %rdi, %rdx
andb $0x7f, 0x1(%rdx)
movq 0x10(%rdx), %rdx
movq 0x10(%rcx), %rcx
cmpq %rdx, 0x10(%rsi)
jne 0x957ab
jmp 0x957c2
movq %rdi, %rdx
cmpb $0x1, (%rdx)
jne 0x957e9
movq %rdx, %rsi
andb $0x7f, 0x1(%rsi)
movq 0x10(%rsi), %rsi
andw $0x7fff, (%rsi)         # imm = 0x7FFF
cmpq %rdx, %rsi
je 0x957e9
movq 0x10(%rsi), %rsi
movq 0x10(%rdx), %rdx
cmpb $0x1, (%rsi)
je 0x957ca
andb $0x7f, 0x1(%rdi)
cmpq 0x110(%rbx), %rax
cmoveq %rcx, %rax
movq %rcx, 0x10(%rax)
movq 0x110(%rbx), %rcx
movq 0x4d8(%rbx), %rax
movq %rcx, 0x4d8(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq