// File: /workspace/github_c_makefile_star2_O2/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
subq $0x18, %rsp
movq %rsi, %r12
movq %rdi, %rbx
movq 0x8(%rsi), %r15
movq 0x90(%rdi), %rax
movq 0x110(%rdi), %r14
cmpq 0x98(%rdi), %rax
ja 0x72ec5
movq %rbx, %rdi
callq 0x9c27
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %r13
movq $0x200001, (%r13)       # imm = 0x200001
movq %r15, 0x8(%r13)
movq %r14, 0x10(%r13)
leaq 0x4d8(%rbx), %rax
movq %rax, 0x8(%rsp)
movq %r13, 0x4d8(%rbx)
movq %r12, 0x10(%rsp)
movq 0x10(%r12), %rbp
movq %rbp, %r12
cmpb $0x1, (%rbp)
jne 0x73002
movq 0x8(%rbp), %rdx
movq 0x90(%rbx), %rax
movq 0x110(%rbx), %r14
cmpq 0x98(%rbx), %rax
ja 0x72f3e
movq %rbx, %rdi
movq %rdx, %r15
callq 0x9c27
movq %r15, %rdx
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %r15
movq $0x200001, (%r15)       # imm = 0x200001
movq %rdx, 0x8(%r15)
movq %r14, 0x10(%r15)
movq %r15, 0x10(%r13)
movq 0x10(%rbp), %rbp
cmpb $0x1, (%rbp)
jne 0x73019
movq 0x8(%rbp), %rdx
movq 0x90(%rbx), %rax
movq 0x110(%rbx), %r14
cmpq 0x98(%rbx), %rax
ja 0x72f9e
movq %rbx, %rdi
movq %rdx, %r13
callq 0x9c27
movq %r13, %rdx
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %r13
movq $0x200001, (%r13)       # imm = 0x200001
movq %rdx, 0x8(%r13)
movq %r14, 0x10(%r13)
movq %r13, 0x10(%r15)
movq 0x10(%rbp), %rbp
movq 0x10(%r12), %r12
cmpq %r12, %rbp
jne 0x72f04
movq 0x10(%rsp), %r9
orb $-0x80, 0x1(%r9)
movq 0x8(%rsp), %r8
movq %r8, %rax
movq %r9, %rsi
movq (%rax), %rax
movq 0x10(%rsi), %rdi
cmpw $0x0, (%rdi)
js 0x73030
orb $-0x80, 0x1(%rsi)
addq $0x10, %rax
movq %rdi, %rsi
jmp 0x72fe8
movq 0x110(%rbx), %rcx
cmpq %rcx, %rbp
movq 0x8(%rsp), %r8
je 0x7308f
movq %rbp, 0x10(%r13)
jmp 0x73088
movq 0x110(%rbx), %rcx
cmpq %rcx, %rbp
movq 0x8(%rsp), %r8
je 0x7308f
movq %rbp, 0x10(%r15)
jmp 0x73088
movq %r8, %rcx
movq %r9, %rdx
movq (%rcx), %rcx
cmpq %rdx, %rdi
je 0x73050
andb $0x7f, 0x1(%rdx)
movq 0x10(%rdx), %rdx
addq $0x10, %rcx
movq 0x10(%rsi), %rdi
jmp 0x73036
movq %rdx, %rsi
cmpb $0x1, (%rdx)
jne 0x73074
andb $0x7f, 0x1(%rdx)
movq 0x10(%rdx), %rdx
andw $0x7fff, (%rdx)         # imm = 0x7FFF
cmpq %rsi, %rdx
je 0x73074
movq 0x10(%rdx), %rdx
movq 0x10(%rsi), %rsi
jmp 0x73053
andb $0x7f, 0x1(%r9)
cmpq 0x110(%rbx), %rax
cmoveq %rcx, %rax
movq %rcx, 0x10(%rax)
movq 0x110(%rbx), %rcx
movq (%r8), %rax
movq %rcx, (%r8)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq