// File: /workspace/github_c_makefile_star2_O2/janet-lang[P]janet/src/core/gc.c
// Function: janet_deinit_block
static void janet_deinit_block(JanetGCObject *mem) {
    switch (mem->flags & JANET_MEM_TYPEBITS) {
        default:
        case JANET_MEMORY_FUNCTION:
            break; /* Do nothing for non gc types */
        case JANET_MEMORY_SYMBOL:
            janet_symbol_deinit(((JanetStringHead *) mem)->data);
            break;
        case JANET_MEMORY_ARRAY:
        case JANET_MEMORY_ARRAY_WEAK:
            janet_free(((JanetArray *) mem)->data);
            break;
        case JANET_MEMORY_TABLE:
        case JANET_MEMORY_TABLE_WEAKK:
        case JANET_MEMORY_TABLE_WEAKV:
        case JANET_MEMORY_TABLE_WEAKKV:
            janet_free(((JanetTable *) mem)->data);
            break;
        case JANET_MEMORY_FIBER: {
            JanetFiber *f = (JanetFiber *)mem;
#ifdef JANET_EV
            if (f->ev_state && !(f->flags & JANET_FIBER_EV_FLAG_IN_FLIGHT)) {
                janet_ev_dec_refcount();
                janet_free(f->ev_state);
            }
#endif
            janet_free(f->data);
        }
        break;
        case JANET_MEMORY_BUFFER:
            janet_buffer_deinit((JanetBuffer *) mem);
            break;
        case JANET_MEMORY_ABSTRACT: {
            JanetAbstractHead *head = (JanetAbstractHead *)mem;
            if (head->type->gc) {
                janet_assert(!head->type->gc(head->data, head->size), "finalizer failed");
            }
        }
        break;
        case JANET_MEMORY_FUNCENV: {
            JanetFuncEnv *env = (JanetFuncEnv *)mem;
            if (0 == env->offset)
                janet_free(env->as.values);
        }
        break;
        case JANET_MEMORY_FUNCDEF: {
            JanetFuncDef *def = (JanetFuncDef *)mem;
            /* TODO - get this all with one alloc and one free */
            janet_free(def->defs);
            janet_free(def->environments);
            janet_free(def->constants);
            janet_free(def->bytecode);
            janet_free(def->sourcemap);
            janet_free(def->closure_bitset);
            janet_free(def->symbolmap);
        }
        break;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movzbl (%rdi), %eax
addl $-0x2, %eax
cmpl $0xf, %eax
ja 0x2915b
movq %rdi, %rbx
leaq 0x30c53(%rip), %rcx     # 0x59cf0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x20(%rbx), %rdi
jmp 0x29132
movq 0x18(%rbx), %rdi
jmp 0x29132
cmpl $0x0, 0x1c(%rbx)
jne 0x2915b
movq 0x10(%rbx), %rdi
jmp 0x29132
addq $0x18, %rbx
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x43640
movq 0x20(%rbx), %rdi
callq 0x120b0
movq 0x10(%rbx), %rdi
callq 0x120b0
movq 0x18(%rbx), %rdi
callq 0x120b0
movq 0x28(%rbx), %rdi
callq 0x120b0
movq 0x38(%rbx), %rdi
callq 0x120b0
movq 0x30(%rbx), %rdi
callq 0x120b0
movq 0x50(%rbx), %rdi
jmp 0x29132
cmpq $0x0, 0x60(%rbx)
je 0x2912e
testb $0x1, 0x10(%rbx)
jne 0x2912e
callq 0x2046b
movq 0x60(%rbx), %rdi
callq 0x120b0
movq 0x30(%rbx), %rdi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x120b0
movq 0x10(%rbx), %rax
movq 0x8(%rax), %rax
testq %rax, %rax
je 0x2915b
movq 0x18(%rbx), %rsi
addq $0x20, %rbx
movq %rbx, %rdi
callq *%rax
testl %eax, %eax
jne 0x29170
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x15f62
movq 0x56e79(%rip), %rax     # 0x7fff0
movq (%rax), %rdi
leaq 0x26e8f(%rip), %rsi     # 0x50010
leaq 0x30ba8(%rip), %rcx     # 0x59d30
leaq 0x30baf(%rip), %r8      # 0x59d3e
movl $0x15e, %edx            # imm = 0x15E
xorl %eax, %eax
callq 0x125e0
callq 0x12100