// File: /workspace/github_c_makefile_star2_O3/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, %rbx
movl $0x1, %ebp
leaq 0x5ddfd(%rip), %rax     # 0x77900
movl (%rbx), %ecx
addl $-0x2, %ecx
cmpl $0x18, %ecx
ja 0x19bde
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movl 0x10(%rbx), %ecx
testl %ecx, %ecx
jle 0x19bb7
movq 0x8(%rbx), %rbx
imull %ecx, %ebp
jmp 0x19b03
movl $0x8, %r14d
jmp 0x19bf4
movl $0x1, %r14d
jmp 0x19bf4
movl $0x4, %r14d
jmp 0x19bf4
movslq 0x10(%rbx), %r12
testq %r12, %r12
jle 0x19bbc
movl %ebp, 0x4(%rsp)
movq 0x28(%rbx), %r13
xorl %ebp, %ebp
xorl %r14d, %r14d
movq (%r13,%rbp,8), %rax
movq 0x108(%rax), %r15
movq %r15, %rdi
callq 0x19ae9
addl %r14d, %eax
movslq %eax, %r14
movq %r15, %rdi
callq 0x19c0a
movslq %eax, %rcx
addq %rcx, %r14
decq %r14
movq %r14, %rax
cqto
idivq %rcx
subq %rdx, %r14
incq %rbp
cmpq %rbp, %r12
jne 0x19b65
movslq %r14d, %r14
decq %r14
movl 0x4(%rsp), %ebp
jmp 0x19bc3
movl $0x2, %r14d
jmp 0x19bf4
xorl %r14d, %r14d
jmp 0x19bf4
movq $-0x1, %r14
movq %rbx, %rdi
callq 0x19c0a
movslq %eax, %rcx
addq %rcx, %r14
movq %r14, %rax
cqto
idivq %rcx
subl %edx, %r14d
jmp 0x19bf4
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
jmp 0x19bf4
movl $0x10, %r14d
jmp 0x19bf4
movl $0x18, %r14d
imull %ebp, %r14d
movl %r14d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq