// File: /workspace/github_c_makefile_star2_O2/BernardTatin[P]s7sh/s7.c
// Function: g_cutlet
static s7_pointer g_cutlet(s7_scheme *sc, s7_pointer args)
    {
#define H_cutlet "(cutlet e symbol ...) removes symbols from the let e."
#define Q_cutlet s7_make_circular_signature(sc, 2, 3, sc->is_let_symbol, sc->is_let_symbol, sc->is_symbol_symbol)

        s7_pointer e, syms;
#define THE_UN_ID ++sc->let_number

        e = car(args);
        if (is_null(e))
            e = sc->rootlet;
        else
        {
            check_method(sc, e, sc->cutlet_symbol, args);
            if (!is_let(e))
                return(wrong_type_argument_with_type(sc, sc->cutlet_symbol, 1, e, a_let_string));
            if ((is_immutable(e)) || (e == sc->s7_let))
                return(immutable_object_error(sc, set_elist_3(sc, immutable_error_string, sc->cutlet_symbol, e)));
        }
        /* besides removing the slot we have to make sure the symbol_id does not match else
         *   let-ref and others will use the old slot!  What's the un-id?  Perhaps the next one?
         *   (let ((b 1)) (let ((b 2)) (cutlet (curlet) 'b)) b)
         */

        for (syms = cdr(args); is_pair(syms); syms = cdr(syms))
        {
            s7_pointer sym, slot;
            sym = car(syms);

            if (!is_symbol(sym))
                return(wrong_type_argument_with_type(sc, sc->cutlet_symbol, position_of(syms, args), sym, a_symbol_string));

            if (is_keyword(sym))
                sym = keyword_symbol(sym);

            if (e == sc->rootlet)
            {
                if (is_slot(global_slot(sym)))
                {
                    symbol_set_id(sym, THE_UN_ID);
                    slot_set_value(global_slot(sym), sc->undefined);
                }
            }
            else
            {
                if ((has_let_fallback(e)) &&
                        ((sym == sc->let_ref_fallback_symbol) || (sym == sc->let_set_fallback_symbol)))
                    return(s7_error(sc, sc->error_symbol, set_elist_2(sc, wrap_string(sc, "cutlet can't remove ~S", 22), sym)));

                slot = let_slots(e);
                if (tis_slot(slot))
                {
                    if (slot_symbol(slot) == sym)
                    {
                        let_set_slots(e, next_slot(let_slots(e)));
                        symbol_set_id(sym, THE_UN_ID);
                    }
                    else
                    {
                        s7_pointer last_slot;
                        last_slot = slot;
                        for (slot = next_slot(let_slots(e)); tis_slot(slot); last_slot = slot, slot = next_slot(slot))
                            if (slot_symbol(slot) == sym)
                            {
                                symbol_set_id(sym, THE_UN_ID);
                                slot_set_next(last_slot, next_slot(slot));
                                break;
                            }}}}}
        return(e);
    }

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rsi, %r15
movq %rdi, %rbx
movq 0x8(%rsi), %r14
cmpq 0x110(%rdi), %r14
je 0x4d6a7
movq (%r14), %r13
btl $0x1e, %r13d
jae 0x4d64c
cmpb $0x1, 0x24c(%rbx)
jne 0x4d64c
movq %rbx, %rdi
movq %r14, %rsi
callq 0x88f3
movq 0xe60(%rbx), %rdx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x888f
cmpq 0x128(%rbx), %rax
je 0x4d64c
movq %rax, %r12
movq %rbx, %rdi
movq %r15, %rsi
callq 0x35492
movq %rbx, %rdi
movq %r12, %rsi
movq %rax, %rdx
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0xa34c
cmpb $0x1c, %r13b
jne 0x4d7ac
btl $0x18, %r13d
jb 0x4d666
cmpq 0x2150(%rbx), %r14
jne 0x4d6ae
movq 0xcc2fb(%rip), %rax     # 0x119968
movq 0xe60(%rbx), %rcx
movq 0x6e8(%rbx), %rdx
movq %rax, 0x8(%rdx)
movq 0x10(%rdx), %rax
movq %rcx, 0x8(%rax)
movq 0x10(%rax), %rax
movq %r14, 0x8(%rax)
movq 0x6e8(%rbx), %rsi
movq %rbx, %rdi
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x972b
movq 0x150(%rbx), %r14
movq %r15, %rdi
movq 0x10(%rdi), %rdi
cmpb $0x1, (%rdi)
jne 0x4d86d
movq 0x8(%rdi), %r12
cmpb $0xa, (%r12)
jne 0x4d7d7
testb $-0x80, 0x6(%r12)
je 0x4d6e2
movq 0x8(%r12), %rax
movq 0x20(%rax), %rax
movq 0x18(%rax), %r12
cmpq 0x150(%rbx), %r14
je 0x4d750
testb $0xc, 0x3(%r14)
je 0x4d70c
cmpq 0x1228(%rbx), %r12
je 0x4d80a
cmpq 0x1238(%rbx), %r12
je 0x4d80a
movq 0x8(%r14), %rax
testq %rax, %rax
je 0x4d6b1
cmpq %r12, 0x8(%rax)
je 0x4d789
movq %rax, %rcx
movq 0x18(%rax), %rax
testq %rax, %rax
je 0x4d6b1
cmpq %r12, 0x8(%rax)
jne 0x4d71b
movq 0x250(%rbx), %rdx
incq %rdx
movq %rdx, 0x250(%rbx)
movq %rdx, 0x20(%r12)
movq 0x18(%rax), %rax
movq %rax, 0x18(%rcx)
jmp 0x4d6b1
movq 0x10(%r12), %rax
cmpb $0x20, (%rax)
jne 0x4d6b1
movq 0x250(%rbx), %rax
incq %rax
movq %rax, 0x250(%rbx)
movq %rax, 0x20(%r12)
movq 0x128(%rbx), %rax
movq 0x10(%r12), %rcx
movq %rax, 0x10(%rcx)
jmp 0x4d6b1
movq 0x18(%rax), %rax
movq %rax, 0x8(%r14)
movq 0x250(%rbx), %rax
incq %rax
movq %rax, 0x250(%rbx)
movq %rax, 0x20(%r12)
jmp 0x4d6b1
movq 0xe60(%rbx), %rax
movq 0x8(%rax), %rsi
movq 0xc819a(%rip), %rdx     # 0x115958
movq 0x140(%rbx), %r8
movq 0xcc18c(%rip), %r9      # 0x119958
movq %rbx, %rdi
movq %r14, %rcx
jmp 0x4d8ca
movq 0xe60(%rbx), %rax
movq 0x8(%rax), %r14
movq %r15, %rsi
callq 0x72a82
movslq %eax, %r15
cmpl $0x7ff, %r15d           # imm = 0x7FF
ja 0x4d87a
leaq 0xc814f(%rip), %rax     # 0x115950
movq (%rax,%r15,8), %rdx
jmp 0x4d8b3
movq 0xea8(%rbx), %r14
movq 0x820(%rbx), %rax
movslq 0x7dc(%rbx), %rcx
movq (%rax,%rcx,8), %rax
incl %ecx
andl $0x7, %ecx
movl %ecx, 0x7dc(%rbx)
leaq 0x99d15(%rip), %rcx     # 0xe754a
movq %rcx, 0x10(%rax)
movq $0x16, 0x8(%rax)
movq 0x6e0(%rbx), %rcx
movq %rax, 0x8(%rcx)
movq 0x6e0(%rbx), %rax
movq 0x10(%rax), %rax
movq %r12, 0x8(%rax)
movq 0x6e0(%rbx), %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2cdc0
movq %r14, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0x4d899
movq %rbx, %rdi
callq 0x9c27
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %rdx
movq $0xb, (%rdx)
movq %r15, 0x8(%rdx)
movq 0x140(%rbx), %r8
movq 0xcc09f(%rip), %r9      # 0x119960
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rcx
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x9bbb