// File: /workspace/github_c_makefile_star2_O3/BernardTatin[P]s7sh/s7.c
// Function: let_copy
static s7_pointer let_copy(s7_scheme *sc, s7_pointer env)
    {
        if (is_let(env))
        {
            s7_pointer new_e;

            if (env == sc->rootlet)   /* (copy (rootlet)) or (copy (funclet abs)) etc */
                return(sc->rootlet);

            /* we can't make copy handle environments-as-objects specially because the make-object function in define-class uses copy to make a new object!
             *   So if it is present, we get it here, and then there's almost surely trouble.
             */
            new_e = new_frame_in_env(sc, outlet(env));
            set_all_methods(new_e, env);
            sc->temp3 = new_e;
            if (tis_slot(let_slots(env)))
            {
                s7_int id;
                s7_pointer x, y = NULL;

                id = let_id(new_e);
                for (x = let_slots(env); tis_slot(x); x = next_slot(x))
                {
                    s7_pointer z;
                    new_cell(sc, z, T_SLOT);
                    slot_set_symbol(z, slot_symbol(x));
                    slot_set_value(z, slot_value(x));
                    if (symbol_id(slot_symbol(z)) != id) /* keep shadowing intact */
                        symbol_set_local(slot_symbol(x), id, z);
                    if (slot_has_setter(x))
                    {
                        slot_set_setter(z, slot_setter(x));
                        slot_set_has_setter(z);
                    }
                    if (tis_slot(let_slots(new_e)))
                        slot_set_next(y, z);
                    else let_set_slots(new_e, z);
                    slot_set_next(z, slot_end(sc));              /* in case GC runs during this loop */
                    y = z;
                }
            }
            /* We can't do a (normal) loop here then reverse the slots later because the symbol's local_slot has to
             *    match the unshadowed slot, not the last in the list:
             *    (let ((e1 (inlet 'a 1 'a 2))) (let ((e2 (copy e1))) (list (equal? e1 e2) (equal? (e1 'a) (e2 'a)))))
             */
            sc->temp3 = sc->nil;
            return(new_e);
        }
        return(sc->nil);
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
cmpb $0x1c, (%rsi)
jne 0x9b905
movq %rsi, %r15
movq 0x150(%rbx), %r14
cmpq %rsi, %r14
je 0x9b90c
movq 0x10(%r15), %r12
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0x9b7e4
movq %rbx, %rdi
callq 0xa550
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %r14
movq $0x20001c, (%r14)       # imm = 0x20001C
movq 0x250(%rbx), %rax
incq %rax
movq %rax, 0x250(%rbx)
movq %rax, 0x18(%r14)
movq $0x0, 0x8(%r14)
movq %r12, 0x10(%r14)
movq (%r15), %rax
andl $0x4c000000, %eax       # imm = 0x4C000000
orq %rax, (%r14)
movq %r14, 0x508(%rbx)
movq 0x8(%r15), %r15
testq %r15, %r15
je 0x9b8f5
leaq 0x8(%r14), %r12
movq 0x18(%r14), %r13
xorl %ebp, %ebp
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0x9b863
movq %rbx, %rdi
callq 0xa550
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %rax
movq $0x20, (%rax)
movq 0x8(%r15), %rcx
movq %rcx, 0x8(%rax)
movq 0x10(%r15), %rdx
movq %rdx, 0x10(%rax)
cmpq %r13, 0x20(%rcx)
je 0x9b8a6
movq 0x8(%r15), %rcx
movq %rax, 0x18(%rcx)
movq 0x8(%r15), %rcx
movq %r13, 0x20(%rcx)
movq 0x8(%r15), %rcx
incl 0x28(%rcx)
testb $0x4, 0x2(%r15)
je 0x9b8cc
movq 0x28(%r15), %rcx
cmpb $0x30, (%rcx)
jne 0x9b8c4
testb $0x2, 0x6(%rcx)
je 0x9b8c4
movq 0x8(%rcx), %rcx
movq 0x50(%rcx), %rcx
movq %rcx, 0x28(%rax)
orb $0x4, 0x2(%rax)
addq $0x18, %rbp
cmpq $0x0, (%r12)
cmoveq %r12, %rbp
movq %rax, (%rbp)
movq $0x0, 0x18(%rax)
movq 0x18(%r15), %r15
movq %rax, %rbp
testq %r15, %r15
jne 0x9b844
movq 0x110(%rbx), %rax
movq %rax, 0x508(%rbx)
jmp 0x9b90c
movq 0x110(%rbx), %r14
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq