// File: /workspace/github_c_makefile_star2_O1/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 %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %rbp
movq %rdi, %rbx
movq 0x8(%rsi), %r14
movq 0x110(%rdi), %r15
cmpq %r15, %r14
movq %rsi, 0x8(%rsp)
je 0x659fb
movb $0x1, %r13b
testb $0x40, 0x3(%r14)
je 0x65991
cmpb $0x1, 0x24c(%rbx)
jne 0x65991
movq %rbx, %rdi
movq %r14, %rsi
callq 0x9a55
movq 0xe60(%rbx), %rdx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x99ef
cmpq 0x128(%rbx), %rax
je 0x65991
cmpb $0x1, (%rbp)
jne 0x65c63
movq %rax, 0x10(%rsp)
movq %rbp, 0x4c8(%rbx)
movq 0x8(%rbp), %r13
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0x658d2
movq %rbx, %rdi
callq 0xb389
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %rax
movq $0x200001, (%rax)       # imm = 0x200001
movq %r13, 0x8(%rax)
movq %r15, 0x10(%rax)
movq %rax, (%rsp)
movq %rax, 0x4e8(%rbx)
movq 0x10(%rbp), %r15
cmpb $0x1, (%r15)
jne 0x65969
movq (%rsp), %r13
movq 0x8(%r15), %rbp
movq 0x90(%rbx), %rax
movq 0x110(%rbx), %r12
cmpq 0x98(%rbx), %rax
ja 0x65933
movq %rbx, %rdi
callq 0xb389
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %rax
movq $0x200001, (%rax)       # imm = 0x200001
movq %rbp, 0x8(%rax)
movq %r12, 0x10(%rax)
movq %rax, 0x10(%r13)
movq 0x10(%r15), %r15
cmpb $0x1, (%r15)
movq %rax, %r13
je 0x65910
movq 0x110(%rbx), %rax
movq %rax, 0x4e8(%rbx)
movq %rax, 0x4c8(%rbx)
movq 0x8(%rsp), %rbp
movq 0x10(%rsp), %rax
movq (%rsp), %rdx
jmp 0x65c66
testb %r13b, %r13b
je 0x65c18
cmpb $0x1c, (%r14)
jne 0x65c2a
testb $0x1, 0x3(%r14)
jne 0x659b4
cmpq 0x2150(%rbx), %r14
jne 0x65a02
movq 0xecfad(%rip), %rax     # 0x152968
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), %rdx
movq 0xea8(%rbx), %r12
movq %rbx, %rdi
movq %r12, %rsi
callq 0x3b366
jmp 0x65c18
movq 0x150(%rbx), %r14
movq %rbp, %r15
movq 0x10(%r15), %r15
cmpb $0x1, (%r15)
jne 0x65c15
movq 0x8(%r15), %r13
cmpb $0xa, (%r13)
jne 0x65ab4
testb $-0x80, 0x6(%r13)
je 0x65a35
movq 0x8(%r13), %rax
movq 0x20(%rax), %rax
movq 0x18(%rax), %r13
cmpq 0x150(%rbx), %r14
je 0x65b58
testb $0xc, 0x3(%r14)
je 0x65a63
cmpq 0x1228(%rbx), %r13
je 0x65b89
cmpq 0x1238(%rbx), %r13
je 0x65b89
movq 0x8(%r14), %rcx
movb $0x1, %al
testq %rcx, %rcx
je 0x65b4b
cmpq %r13, 0x8(%rcx)
je 0x65bf3
movq %rcx, %rdx
movq 0x18(%rcx), %rcx
testq %rcx, %rcx
je 0x65b4b
cmpq %r13, 0x8(%rcx)
jne 0x65a7c
movq 0x250(%rbx), %rsi
incq %rsi
movq %rsi, 0x250(%rbx)
movq %rsi, 0x20(%r13)
movq 0x18(%rcx), %rcx
movq %rcx, 0x18(%rdx)
jmp 0x65b4b
movl $0x1, %eax
cmpq %rbp, %r15
je 0x65ac9
incl %eax
movq 0x10(%rbp), %rbp
cmpq %r15, %rbp
jne 0x65abe
movq 0xe60(%rbx), %rcx
movq 0x8(%rcx), %r12
movslq %eax, %rbp
cmpl $0x7ff, %ebp            # imm = 0x7FF
ja 0x65aec
leaq 0xe8e6a(%rip), %rax     # 0x14e950
movq (%rax,%rbp,8), %rdx
jmp 0x65b25
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0x65b04
movq %rbx, %rdi
callq 0xb389
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %rdx
movq $0xb, (%rdx)
movq %rbp, 0x8(%rdx)
movq 0x140(%rbx), %r8
movq 0xece2d(%rip), %r9      # 0x152960
movq %rbx, %rdi
movq %r12, %rsi
movq %r13, %rcx
callq 0xb31d
movq %rax, %r12
xorl %eax, %eax
movq 0x8(%rsp), %rbp
testb %al, %al
jne 0x65a05
jmp 0x65c18
movq 0x10(%r13), %rcx
movb $0x1, %al
cmpb $0x20, (%rcx)
jne 0x65b4b
movq 0x250(%rbx), %rcx
incq %rcx
movq %rcx, 0x250(%rbx)
movq %rcx, 0x20(%r13)
movq 0x128(%rbx), %rcx
movq 0x10(%r13), %rdx
movq %rcx, 0x10(%rdx)
jmp 0x65b4b
movq 0xea8(%rbx), %r12
movq 0x820(%rbx), %rax
movslq 0x7dc(%rbx), %rcx
movq (%rax,%rcx,8), %rax
incl %ecx
andl $0x7, %ecx
movl %ecx, 0x7dc(%rbx)
leaq 0xbe8e6(%rip), %rcx     # 0x12449a
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 %r13, 0x8(%rax)
movq 0x6e0(%rbx), %rdx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x3b366
xorl %eax, %eax
jmp 0x65b4b
movq 0x18(%rcx), %rcx
movq %rcx, 0x8(%r14)
movq 0x250(%rbx), %rcx
incq %rcx
movq %rcx, 0x250(%rbx)
movq %rcx, 0x20(%r13)
jmp 0x65b4b
movq %r14, %r12
movq %r12, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xe60(%rbx), %rax
movq 0x8(%rax), %rsi
movq 0xe8d1c(%rip), %rdx     # 0x14e958
movq 0x140(%rbx), %r8
movq 0xecd0e(%rip), %r9      # 0x152958
movq %rbx, %rdi
movq %r14, %rcx
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xb31d
movq %r15, %rdx
movq %rbx, %rdi
movq %rax, %rsi
callq 0xbd41
movq %rax, %r12
xorl %r13d, %r13d
jmp 0x65991