// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x48, %rsp
movq %rdi, 0x38(%rsp)
movq %rsi, 0x30(%rsp)
movq 0x30(%rsp), %rax
movzbl (%rax), %eax
cmpl $0x1c, %eax
jne 0xdc0a6
movq 0x30(%rsp), %rax
movq 0x38(%rsp), %rcx
cmpq 0x150(%rcx), %rax
jne 0xdbea8
movq 0x38(%rsp), %rax
movq 0x150(%rax), %rax
movq %rax, 0x40(%rsp)
jmp 0xdc0b7
movq 0x38(%rsp), %rdi
movq 0x30(%rsp), %rax
movq 0x10(%rax), %rsi
callq 0xc53b0
movq %rax, 0x28(%rsp)
movq 0x30(%rsp), %rax
movq (%rax), %rcx
andq $0x4c000000, %rcx       # imm = 0x4C000000
movq 0x28(%rsp), %rax
orq (%rax), %rcx
movq %rcx, (%rax)
movq 0x28(%rsp), %rcx
movq 0x38(%rsp), %rax
movq %rcx, 0x508(%rax)
movq 0x30(%rsp), %rax
cmpq $0x0, 0x8(%rax)
je 0xdc082
movq $0x0, 0x10(%rsp)
movq 0x28(%rsp), %rax
movq 0x18(%rax), %rax
movq %rax, 0x20(%rsp)
movq 0x30(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x18(%rsp)
cmpq $0x0, 0x18(%rsp)
je 0xdc080
jmp 0xdbf2e
movq 0x38(%rsp), %rax
movq 0x90(%rax), %rax
movq 0x38(%rsp), %rcx
cmpq 0x98(%rcx), %rax
ja 0xdbf52
movq 0x38(%rsp), %rdi
callq 0xc670
movq 0x38(%rsp), %rcx
movq 0x90(%rcx), %rax
movq %rax, %rdx
addq $-0x8, %rdx
movq %rdx, 0x90(%rcx)
movq -0x8(%rax), %rax
movq %rax, 0x8(%rsp)
movq 0x8(%rsp), %rax
movq $0x20, (%rax)
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rcx
movq 0x8(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rcx
movq 0x8(%rsp), %rax
movq %rcx, 0x10(%rax)
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x20(%rax), %rax
cmpq 0x20(%rsp), %rax
je 0xdbff3
jmp 0xdbfbb
movq 0x8(%rsp), %rcx
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rax
movq %rcx, 0x18(%rax)
movq 0x20(%rsp), %rcx
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rax
movq %rcx, 0x20(%rax)
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rax
movl 0x28(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x28(%rax)
jmp 0xdbff3
movq 0x18(%rsp), %rax
movq (%rax), %rax
andq $0x40000, %rax          # imm = 0x40000
cmpq $0x0, %rax
je 0xdc02c
movq 0x8(%rsp), %rdi
movq 0x18(%rsp), %rax
movq 0x28(%rax), %rsi
callq 0x3de20
movq 0x8(%rsp), %rax
movq (%rax), %rcx
orq $0x40000, %rcx          # imm = 0x40000
movq %rcx, (%rax)
movq 0x28(%rsp), %rax
cmpq $0x0, 0x8(%rax)
je 0xdc048
movq 0x8(%rsp), %rcx
movq 0x10(%rsp), %rax
movq %rcx, 0x18(%rax)
jmp 0xdc056
movq 0x8(%rsp), %rcx
movq 0x28(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x8(%rsp), %rax
movq $0x0, 0x18(%rax)
movq 0x8(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x18(%rsp), %rax
movq 0x18(%rax), %rax
movq %rax, 0x18(%rsp)
jmp 0xdbf20
jmp 0xdc082
movq 0x38(%rsp), %rax
movq 0x110(%rax), %rcx
movq 0x38(%rsp), %rax
movq %rcx, 0x508(%rax)
movq 0x28(%rsp), %rax
movq %rax, 0x40(%rsp)
jmp 0xdc0b7
movq 0x38(%rsp), %rax
movq 0x110(%rax), %rax
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rax
addq $0x48, %rsp
retq
nopw %cs:(%rax,%rax)