// File: /workspace/github_c_makefile_star2_O2/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 0x7c5d2
movq %rsi, %r15
movq 0x150(%rbx), %rax
cmpq %rsi, %rax
je 0x7c5ed
movq 0x10(%r15), %rsi
movq %rbx, %rdi
callq 0x72a1d
movq (%r15), %rcx
andl $0x4c000000, %ecx       # imm = 0x4C000000
orq %rcx, (%rax)
movq %rax, (%rsp)
movq %rax, 0x508(%rbx)
movq 0x8(%r15), %r12
testq %r12, %r12
je 0x7c5db
movq (%rsp), %rax
movq %rax, %r13
addq $0x8, %r13
movq 0x18(%rax), %rbp
xorl %r14d, %r14d
testq %r12, %r12
je 0x7c5db
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0x7c54e
movq %rbx, %rdi
callq 0x9c27
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %r15
movq $0x20, (%r15)
movq 0x8(%r12), %rax
movq %rax, 0x8(%r15)
movq 0x10(%r12), %rcx
movq %rcx, 0x10(%r15)
cmpq %rbp, 0x20(%rax)
je 0x7c596
movq 0x8(%r12), %rax
movq %r15, 0x18(%rax)
movq 0x8(%r12), %rax
movq %rbp, 0x20(%rax)
movq 0x8(%r12), %rax
incl 0x28(%rax)
testb $0x4, 0x2(%r12)
je 0x7c5b0
movq 0x28(%r12), %rsi
movq %r15, %rdi
callq 0x32b2e
orb $0x4, 0x2(%r15)
addq $0x18, %r14
cmpq $0x0, (%r13)
cmoveq %r13, %r14
movq %r15, (%r14)
andq $0x0, 0x18(%r15)
movq 0x18(%r12), %r12
movq %r15, %r14
jmp 0x7c526
movq 0x110(%rbx), %rax
jmp 0x7c5ed
movq 0x110(%rbx), %rax
movq %rax, 0x508(%rbx)
movq (%rsp), %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq