// File: /workspace/github_c_makefile_star2_O1/vtereshkov[P]umka-lang/src/umka_types.c
// Function: typeSizeRecompute
static int typeSizeRecompute(const Type *type)
{
    switch (type->kind)
    {
        case TYPE_VOID:     return 0;
        case TYPE_INT8:     return sizeof(int8_t);
        case TYPE_INT16:    return sizeof(int16_t);
        case TYPE_INT32:    return sizeof(int32_t);
        case TYPE_INT:      return sizeof(int64_t);
        case TYPE_UINT8:    return sizeof(uint8_t);
        case TYPE_UINT16:   return sizeof(uint16_t);
        case TYPE_UINT32:   return sizeof(uint32_t);
        case TYPE_UINT:     return sizeof(uint64_t);
        case TYPE_BOOL:     return sizeof(bool);
        case TYPE_CHAR:     return sizeof(unsigned char);
        case TYPE_REAL32:   return sizeof(float);
        case TYPE_REAL:     return sizeof(double);
        case TYPE_PTR:      return sizeof(void *);
        case TYPE_WEAKPTR:  return sizeof(uint64_t);
        case TYPE_STR:      return sizeof(void *);
        case TYPE_ARRAY:    return type->numItems > 0 ? (type->numItems * typeSizeRecompute(type->base)) : 0;
        case TYPE_DYNARRAY: return sizeof(DynArray);
        case TYPE_MAP:      return sizeof(Map);
        case TYPE_STRUCT:
        case TYPE_INTERFACE:
        case TYPE_CLOSURE:
        {
            int size = 0;
            for (int i = 0; i < type->numItems; i++)
            {
                const int fieldSize = typeSizeRecompute(type->field[i]->type);
                size = align(size + fieldSize, typeAlignmentRecompute(type->field[i]->type));
            }
            size = align(size, typeAlignmentRecompute(type));
            return size;
        }
        case TYPE_FIBER:    return sizeof(void *);
        case TYPE_FN:       return sizeof(int64_t);
        default:            return -1;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r15
movl $0x1, %ebx
leaq 0x59dfd(%rip), %rax     # 0x788d8
movl (%r15), %ecx
addl $-0x2, %ecx
cmpl $0x18, %ecx
ja 0x1ebc6
xorl %r14d, %r14d
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movl 0x10(%r15), %ecx
testl %ecx, %ecx
jle 0x1ebcc
movq 0x8(%r15), %r15
imull %ecx, %ebx
jmp 0x1eadb
movl $0x8, %r14d
jmp 0x1ebcc
movl $0x1, %r14d
jmp 0x1ebcc
movl $0x4, %r14d
jmp 0x1ebcc
movslq 0x10(%r15), %r13
testq %r13, %r13
jle 0x1eb94
movl %ebx, 0x4(%rsp)
movq 0x28(%r15), %rbp
xorl %ebx, %ebx
xorl %r14d, %r14d
movq (%rbp,%rbx,8), %rax
movq 0x108(%rax), %r12
movq %r12, %rdi
callq 0x1eac1
addl %r14d, %eax
movslq %eax, %r14
movq %r12, %rdi
callq 0x1ebe1
movslq %eax, %rcx
addq %rcx, %r14
decq %r14
movq %r14, %rax
cqto
idivq %rcx
subq %rdx, %r14
incq %rbx
cmpq %rbx, %r13
jne 0x1eb42
movslq %r14d, %r14
decq %r14
movl 0x4(%rsp), %ebx
jmp 0x1eb9b
movl $0x2, %r14d
jmp 0x1ebcc
movq $-0x1, %r14
movq %r15, %rdi
callq 0x1ebe1
movslq %eax, %rcx
addq %rcx, %r14
movq %r14, %rax
cqto
idivq %rcx
subl %edx, %r14d
jmp 0x1ebcc
movl $0x18, %r14d
jmp 0x1ebcc
movl $0x10, %r14d
jmp 0x1ebcc
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
imull %r14d, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq