// File: /workspace/github_c_makefile_star2_O0/BernardTatin[P]s7sh/s7.c
// Function: s7_remove_from_heap
static inline void s7_remove_from_heap(s7_scheme *sc, s7_pointer x)
    {
        /* global functions are very rarely redefined, so we can remove the function body from
         *   the heap when it is defined.  If redefined, we currently lose the memory held by the
         *   old definition.  (It is not trivial to recover this memory because it is allocated
         *   in blocks, not by the pointer, I think, but s7_define is the point to try).
         */
        if (not_in_heap(x)) return;
        if (is_pair(x))
        {
            s7_pointer p;
            p = x;
            do {
                petrify(sc, p);
                s7_remove_from_heap(sc, car(p));
                p = cdr(p);
            } while (is_pair(p) && (in_heap(p)));
            if (in_heap(p)) petrify(sc, p);
            return;
        }

        switch (type(x))
        {
            case T_LET:
                if (is_funclet(x)) set_immutable(x);
            case T_HASH_TABLE:
            case T_VECTOR:
                /* not int|float_vector or string because none of their elements are GC-able (so unheap below is ok)
                 *   but hash-table and let seem like they need protection? And let does happen via define-class.
                 */
                add_permanent_object(sc, x);
                return;

            case T_SYMBOL:
                if (is_gensym(x))
                {
                    s7_int i;
                    gc_list *gp;
                    int64_t loc;
                    loc = heap_location(sc, x);
#if S7_DEBUGGING
                    check_heap_location(sc, x, loc, __func__, __LINE__);
                    petrified_pointers++;
#endif
                    sc->heap[loc] = (s7_pointer)alloc_big_pointer(sc, loc);
                    free_cell(sc, sc->heap[loc]);
                    unheap(sc, x);

                    gp = sc->gensyms;
                    for (i = 0; i < gp->loc; i++) /* sc->gensyms reaches size 512 during s7test, but this search is called 3 times and costs nothing */
                        if (gp->list[i] == x)
                        {
                            s7_int j;
                            for (j = i + 1; i < gp->loc - 1; i++, j++)
                                gp->list[i] = gp->list[j];
                            gp->list[i] = NULL;
                            gp->loc--;
                            if (gp->loc == 0) mark_function[T_SYMBOL] = mark_noop;
                            break;
                        }
                }
                return;

            case T_CLOSURE: case T_CLOSURE_STAR:
            case T_MACRO:   case T_MACRO_STAR:
            case T_BACRO:   case T_BACRO_STAR:
                /* these need to be GC-protected! */
                add_permanent_object(sc, x);
                return;

            default:
                break;
        }

        petrify(sc, x);
    }

// Assembly:
subq $0x48, %rsp
movq %rdi, 0x40(%rsp)
movq %rsi, 0x38(%rsp)
movq 0x38(%rsp), %rax
movzwl 0x6(%rax), %eax
andl $0x4000, %eax           # imm = 0x4000
cmpl $0x0, %eax
je 0xbbf6
jmp 0xbeb6
movq 0x38(%rsp), %rax
movzbl (%rax), %eax
cmpl $0x1, %eax
jne 0xbc9b
movq 0x38(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0x40(%rsp), %rdi
movq 0x30(%rsp), %rsi
callq 0xc0da0
movq 0x40(%rsp), %rdi
movq 0x30(%rsp), %rax
movq 0x8(%rax), %rsi
callq 0xbbd0
movq 0x30(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0x30(%rsp)
movq 0x30(%rsp), %rax
movzbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x1, %ecx
movb %al, 0xf(%rsp)
jne 0xbc6c
movq 0x30(%rsp), %rax
movzwl 0x6(%rax), %eax
andl $0x4000, %eax           # imm = 0x4000
cmpl $0x0, %eax
sete %al
movb %al, 0xf(%rsp)
movb 0xf(%rsp), %al
testb $0x1, %al
jne 0xbc11
movq 0x30(%rsp), %rax
movzwl 0x6(%rax), %eax
andl $0x4000, %eax           # imm = 0x4000
cmpl $0x0, %eax
jne 0xbc96
movq 0x40(%rsp), %rdi
movq 0x30(%rsp), %rsi
callq 0xc0da0
jmp 0xbeb6
movq 0x38(%rsp), %rax
movzbl (%rax), %eax
addl $-0xa, %eax
movl %eax, %ecx
movq %rcx, (%rsp)
subl $0x23, %eax
ja 0xbea5
movq (%rsp), %rax
leaq 0x1d1350(%rip), %rcx    # 0x1dd010
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x38(%rsp), %rax
movq (%rax), %rax
andq $0x20000000, %rax       # imm = 0x20000000
cmpq $0x0, %rax
je 0xbcef
movq 0x38(%rsp), %rax
movq (%rax), %rcx
orq $0x1000000, %rcx        # imm = 0x1000000
movq %rcx, (%rax)
jmp 0xbcf1
movq 0x40(%rsp), %rdi
movq 0x38(%rsp), %rsi
callq 0xc0e20
jmp 0xbeb6
movq 0x38(%rsp), %rax
movq (%rax), %rax
andq $0x20000000, %rax       # imm = 0x20000000
cmpq $0x0, %rax
je 0xbe92
movq 0x40(%rsp), %rdi
movq 0x38(%rsp), %rsi
callq 0x2cb30
movq %rax, 0x18(%rsp)
movq 0x40(%rsp), %rdi
movq 0x18(%rsp), %rsi
callq 0xc0e80
movq %rax, %rdx
movq 0x40(%rsp), %rax
movq 0x80(%rax), %rax
movq 0x18(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
movq 0x40(%rsp), %rdi
movq 0x40(%rsp), %rax
movq 0x80(%rax), %rax
movq 0x18(%rsp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x2bcd0
movq 0x38(%rsp), %rax
movzwl 0x6(%rax), %ecx
orl $0x4000, %ecx           # imm = 0x4000
movw %cx, 0x6(%rax)
movq 0x40(%rsp), %rax
movq 0x778(%rax), %rax
movq %rax, 0x20(%rsp)
movq $0x0, 0x28(%rsp)
movq 0x28(%rsp), %rax
movq 0x20(%rsp), %rcx
cmpq 0x10(%rcx), %rax
jge 0xbe90
movq 0x20(%rsp), %rax
movq (%rax), %rax
movq 0x28(%rsp), %rcx
movq (%rax,%rcx,8), %rax
cmpq 0x38(%rsp), %rax
jne 0xbe7b
movq 0x28(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x10(%rsp)
movq 0x28(%rsp), %rax
movq 0x20(%rsp), %rcx
movq 0x10(%rcx), %rcx
subq $0x1, %rcx
cmpq %rcx, %rax
jge 0xbe39
movq 0x20(%rsp), %rax
movq (%rax), %rax
movq 0x10(%rsp), %rcx
movq (%rax,%rcx,8), %rdx
movq 0x20(%rsp), %rax
movq (%rax), %rax
movq 0x28(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
movq 0x28(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x28(%rsp)
movq 0x10(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x10(%rsp)
jmp 0xbde2
movq 0x20(%rsp), %rax
movq (%rax), %rax
movq 0x28(%rsp), %rcx
movq $0x0, (%rax,%rcx,8)
movq 0x20(%rsp), %rax
movq 0x10(%rax), %rcx
addq $-0x1, %rcx
movq %rcx, 0x10(%rax)
movq 0x20(%rsp), %rax
cmpq $0x0, 0x10(%rax)
jne 0xbe79
leaq 0xb50be(%rip), %rax     # 0xc0f30
movq %rax, 0x20a477(%rip)    # 0x2162f0
jmp 0xbe90
jmp 0xbe7d
movq 0x28(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x28(%rsp)
jmp 0xbda4
jmp 0xbe92
jmp 0xbeb6
movq 0x40(%rsp), %rdi
movq 0x38(%rsp), %rsi
callq 0xc0e20
jmp 0xbeb6
jmp 0xbea7
movq 0x40(%rsp), %rdi
movq 0x38(%rsp), %rsi
callq 0xc0da0
addq $0x48, %rsp
retq
nopl (%rax,%rax)