// File: /workspace/github_c_makefile_star2_O1/ryvnf[P]czc/eval.c
// Function: sizeof_type
size_t sizeof_type(struct loc *loc, struct type *type)
{
    switch (type_type(type->tag)) {
        case VOID_TYPE_FLAG:
            fatal(loc, "cannot compute the size of void");
            return 0;
        case FUNC_TYPE_FLAG:
            fatal(loc, "cannot compute the size of a function");
            return 0;
        case BOOL_TYPE_FLAG:
        case INT_TYPE_FLAG:
        case FLOAT_TYPE_FLAG:
            return sizeof_basic_type(type);
        case PTR_TYPE_FLAG:
            // This would not be portable on computers where size of function
            // pointers is different from regular pointers.
            return sizeof (void *);
        case ARRAY_TYPE_FLAG: {
            struct type *elem_type = array_type(type)->of;
            size_t elem_size = sizeof_type(loc, elem_type);
            size_t elem_align = alignof_type(loc, elem_type);
            size_t n_elems = array_type(type)->len;
            return align_size(elem_size, elem_align) * n_elems;
        }
        case STRUCT_TYPE_FLAG: {
            size_t n_fields = struct_type(type)->n_fields;
            struct field *fields = struct_type(type)->fields;
            size_t size = 0;

            for (size_t i = 0; i < n_fields; i++) {
                size_t field_size = sizeof_type(loc, fields[i].type);
                size_t field_align = alignof_type(loc, fields[i].type);
                size += align_size(field_size, field_align);
            }

            return size;
        }
    }

    unreachable();
    return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rsi, %r15
movq %rdi, %rbx
movl (%rsi), %r14d
andl $0x3ff, %r14d           # imm = 0x3FF
cmpl $0xf, %r14d
jg 0x6677
leal -0x1(%r14), %eax
cmpl $0x7, %eax
ja 0x6783
leaq 0x749a(%rip), %rcx      # 0xdafc
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x7957(%rip), %rsi      # 0xdfc9
jmp 0x6779
cmpl $0x3f, %r14d
jle 0x66a1
cmpl $0x40, %r14d
je 0x66fa
cmpl $0x80, %r14d
jne 0x6783
movq %r15, %rdi
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0xb758
cmpl $0x10, %r14d
jne 0x676c
movq %r15, %rdi
callq 0xbbd9
movq 0x8(%rax), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x662f
movq %rax, %r12
movq %rbx, %rdi
movq %r14, %rsi
callq 0x6514
movq %rax, %r14
movq %r15, %rdi
callq 0xbbd9
movq %rax, %rcx
movq %r12, %rax
xorl %edx, %edx
divq %r14
subq %rdx, %r14
testq %rdx, %rdx
cmoveq %rdx, %r14
addq %r12, %r14
imulq 0x10(%rcx), %r14
jmp 0x675f
movq %r15, %rdi
callq 0xbc3d
movq 0x10(%rax), %r13
movq %r15, %rdi
callq 0xbc3d
testq %r13, %r13
je 0x675c
movq %rax, %r15
addq $0x28, %r15
xorl %r14d, %r14d
movq (%r15), %rsi
movq %rbx, %rdi
callq 0x662f
movq %rax, %r12
movq (%r15), %rsi
movq %rbx, %rdi
callq 0x6514
movq %rax, %rcx
movq %r12, %rax
xorl %edx, %edx
divq %rcx
subq %rdx, %rcx
testq %rdx, %rdx
cmoveq %rdx, %rcx
addq %r12, %r14
addq %rcx, %r14
addq $0x10, %r15
decq %r13
jne 0x671d
jmp 0x675f
xorl %r14d, %r14d
movq %r14, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
cmpl $0x20, %r14d
jne 0x6783
leaq 0x7870(%rip), %rsi      # 0xdfe9
movq %rbx, %rdi
xorl %eax, %eax
callq 0x5011
leaq 0x7736(%rip), %rdi      # 0xdec0
leaq 0x7755(%rip), %rsi      # 0xdee6
leaq 0x7884(%rip), %rcx      # 0xe01c
movl $0x34b, %edx            # imm = 0x34B
xorl %eax, %eax
callq 0x4f1c