// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movl (%rax), %eax
addl $-0x2, %eax
movl %eax, %ecx
movq %rcx, -0x28(%rbp)
subl $0x18, %eax
ja 0x21c05
movq -0x28(%rbp), %rax
leaq 0x1b8205(%rip), %rcx    # 0x1d9c34
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x0, -0x4(%rbp)
jmp 0x21c0c
movl $0x1, -0x4(%rbp)
jmp 0x21c0c
movl $0x2, -0x4(%rbp)
jmp 0x21c0c
movl $0x4, -0x4(%rbp)
jmp 0x21c0c
movl $0x8, -0x4(%rbp)
jmp 0x21c0c
movl $0x1, -0x4(%rbp)
jmp 0x21c0c
movl $0x2, -0x4(%rbp)
jmp 0x21c0c
movl $0x4, -0x4(%rbp)
jmp 0x21c0c
movl $0x8, -0x4(%rbp)
jmp 0x21c0c
movl $0x1, -0x4(%rbp)
jmp 0x21c0c
movl $0x1, -0x4(%rbp)
jmp 0x21c0c
movl $0x4, -0x4(%rbp)
jmp 0x21c0c
movl $0x8, -0x4(%rbp)
jmp 0x21c0c
movl $0x8, -0x4(%rbp)
jmp 0x21c0c
movl $0x8, -0x4(%rbp)
jmp 0x21c0c
movl $0x8, -0x4(%rbp)
jmp 0x21c0c
movq -0x10(%rbp), %rax
cmpl $0x0, 0x10(%rax)
jle 0x21b26
movq -0x10(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x21a00
movl %eax, %ecx
movl -0x30(%rbp), %eax
imull %ecx, %eax
movl %eax, -0x2c(%rbp)
jmp 0x21b2d
xorl %eax, %eax
movl %eax, -0x2c(%rbp)
jmp 0x21b2d
movl -0x2c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x21c0c
movl $0x18, -0x4(%rbp)
jmp 0x21c0c
movl $0x10, -0x4(%rbp)
jmp 0x21c0c
movl $0x0, -0x14(%rbp)
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jge 0x21bcb
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x108(%rax), %rdi
callq 0x21a00
movl %eax, -0x1c(%rbp)
movl -0x14(%rbp), %eax
addl -0x1c(%rbp), %eax
cltq
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x108(%rax), %rdi
callq 0x21c20
movq -0x38(%rbp), %rdi
movslq %eax, %rsi
callq 0x233b0
movl %eax, -0x14(%rbp)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x21b5e
movslq -0x14(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rdi
callq 0x21c20
movq -0x40(%rbp), %rdi
movslq %eax, %rsi
callq 0x233b0
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x21c0c
movl $0x8, -0x4(%rbp)
jmp 0x21c0c
movl $0x8, -0x4(%rbp)
jmp 0x21c0c
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)