// File: /workspace/github_c_makefile_star2_O1/Ihsoh[P]ilang/compiler/frontend/semantics.c
// Function: calc_type_size
static size_t _calc_type_size(
	ParserContext *ctx,
	ParserASTNode *node,
	ParserASTNode *node_type
) {
	assert(ctx);
	assert(node);
	assert(node_type);

	switch (node_type->type) {
		case FE_NODE_TYPE_CHAR: {
			return 1;
		}
		case FE_NODE_TYPE_INT8: {
			return 1;
		}
		case FE_NODE_TYPE_INT16: {
			return 2;
		}
		case FE_NODE_TYPE_INT32: {
			return 4;
		}
		case FE_NODE_TYPE_INT64: {
			return 8;
		}
		case FE_NODE_TYPE_UINT8: {
			return 1;
		}
		case FE_NODE_TYPE_UINT16: {
			return 2;
		}
		case FE_NODE_TYPE_UINT32: {
			return 4;
		}
		case FE_NODE_TYPE_UINT64: {
			return 8;
		}
		case FE_NODE_TYPE_FLOAT: {
			return 4;
		}
		case FE_NODE_TYPE_DOUBLE: {
			return 8;
		}
		case FE_NODE_TYPE_VA_LIST: {
			return 0;
		}
		case FE_NODE_TYPE_STRUCT: {
			return _calc_struct_type_size(ctx, node, node_type);
		}
		case FE_NODE_TYPE_ARRAY: {
			assert(node_type->nchilds == 2);

			ParserASTNode *node_array_dims = node_type->childs[0];
			assert(node_array_dims);
			assert(node_array_dims->type == FE_NODE_TYPE_ARRAY_DIMS);

			ParserASTNode *node_array_type = node_type->childs[1];
			assert(node_array_type);

			size_t size = _calc_type_size(ctx, node, node_array_type);
			for (int i = 0; i < node_array_dims->nchilds; i++) {
				ParserASTNode *node_array_dim = node_array_dims->childs[i];
				assert(node_array_dim);

				size *= fe_parser_get_uint_val(ctx, node_array_dim);
			}

			return size;
		}
		case FE_NODE_TYPE_FUNC: {
			return 0;
		}
		case FE_NODE_TYPE_POINTER: {
			if (ctx->arch == FE_ARCH_32) {
				return 4;
			} else if (ctx->arch == FE_ARCH_64) {
				return 8;
			} else {
				assert(0);
				return 0;
			}
		}
		case FE_NODE_TYPE_VOID: {
			return 1;
		}
		default: {
			assert(0);
			return 0;
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, -0x38(%rbp)
movq %rdi, -0x30(%rbp)
testq %rdx, %rdx
je 0x31939
movl (%rdx), %eax
movl $0x1, %r14d
cmpl $0x42f, %eax            # imm = 0x42F
jg 0x315c0
addl $0xfffffc00, %eax       # imm = 0xFFFFFC00
cmpl $0x20, %eax
ja 0x315dd
leaq 0x19bb8(%rip), %rcx     # 0x4b164
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x4, %r14d
jmp 0x3186d
cmpl $0x430, %eax            # imm = 0x430
je 0x31607
cmpl $0x440, %eax            # imm = 0x440
je 0x31825
cmpl $0x4ff, %eax            # imm = 0x4FF
je 0x3186d
leaq 0xeda0(%rip), %rdi      # 0x40384
leaq 0x1a26f(%rip), %rsi     # 0x4b85a
leaq 0x1b421(%rip), %rcx     # 0x4ca13
movl $0x823, %edx            # imm = 0x823
callq 0x30a0
movl $0x2, %r14d
jmp 0x3186d
xorl %r14d, %r14d
jmp 0x3186d
cmpl $0x2, 0x44(%rdx)
jne 0x31958
movq 0x48(%rdx), %rax
movq (%rax), %rbx
testq %rbx, %rbx
je 0x31996
cmpl $0x421, (%rbx)          # imm = 0x421
jne 0x319d4
movq 0x8(%rax), %rdx
testq %rdx, %rdx
je 0x31a12
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x3156a
movq %rax, %r14
cmpl $0x0, 0x44(%rbx)
jle 0x3186d
xorl %r15d, %r15d
movq 0x48(%rbx), %rax
movq (%rax,%r15,8), %rsi
testq %rsi, %rsi
je 0x318dc
movq -0x30(%rbp), %rdi
callq 0x24ee8
imulq %rax, %r14
incq %r15
movslq 0x44(%rbx), %rax
cmpq %rax, %r15
jl 0x3165f
jmp 0x3186d
cmpl $0x1, 0x44(%rdx)
jne 0x31977
movq 0x48(%rdx), %rax
movq (%rax), %r14
testq %r14, %r14
je 0x319b5
cmpl $0x200, (%r14)          # imm = 0x200
jne 0x319f3
movq 0x10(%r14), %rcx
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
movl $0x2, %edx
callq 0x6db9
movq %rax, %rbx
testq %rax, %rax
jne 0x316e5
movq 0x10(%r14), %rsi
leaq 0x1a515(%rip), %rdx     # 0x4bbf3
movq -0x30(%rbp), %rdi
callq *0x50(%rdi)
movq 0x30(%rbx), %rax
testq %rax, %rax
je 0x31a31
cmpl $0xd00, (%rax)          # imm = 0xD00
jne 0x31a50
movq 0x38(%rbx), %rcx
testq %rcx, %rcx
je 0x31a6f
cmpl $0xd01, (%rcx)          # imm = 0xD01
jne 0x31a8e
cmpl $0x0, 0x44(%rcx)
jle 0x31848
movq %rax, -0x58(%rbp)
movl $0x1, %eax
movq %rax, -0x40(%rbp)
xorl %edx, %edx
xorl %r12d, %r12d
movq %rcx, -0x48(%rbp)
movq 0x48(%rcx), %rax
movq (%rax,%rdx,8), %r14
testq %r14, %r14
je 0x318fb
cmpl $0xc00, (%r14)          # imm = 0xC00
jne 0x3191a
movq %rdx, -0x50(%rbp)
cmpl $0x0, 0x44(%r14)
jle 0x31805
xorl %r15d, %r15d
movq 0x48(%r14), %rax
movq (%rax,%r15,8), %rax
testq %rax, %rax
je 0x3189e
cmpl $0xc01, (%rax)          # imm = 0xC01
jne 0x318bd
cmpl $0x1, 0x44(%rax)
jle 0x3187f
movq 0x48(%rax), %rax
movq 0x8(%rax), %rbx
movl $0x1, %r13d
movq -0x58(%rbp), %rax
cmpb $0x0, 0x68(%rax)
jne 0x317b9
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq %rbx, %rdx
callq 0x2bbfc
movq %rax, %r13
movq -0x40(%rbp), %rax
cmpq %rax, %r13
cmovaq %r13, %rax
movq %rax, -0x40(%rbp)
movq %r12, %rax
xorl %edx, %edx
divq %r13
subq %rdx, %r13
testq %rdx, %rdx
cmoveq %rdx, %r13
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq %rbx, %rdx
callq 0x3156a
addq %r12, %r13
addq %rax, %r13
incq %r15
movslq 0x44(%r14), %rax
movq %r13, %r12
cmpq %rax, %r15
jl 0x31767
jmp 0x31808
movq %r12, %r13
movq -0x50(%rbp), %rdx
incq %rdx
movq -0x48(%rbp), %rcx
movslq 0x44(%rcx), %rax
movq %r13, %r12
cmpq %rax, %rdx
jl 0x31737
jmp 0x31854
movq -0x30(%rbp), %rax
movl 0x30(%rax), %eax
movl $0x4, %r14d
cmpl $0x1, %eax
je 0x3186d
cmpl $0x2, %eax
jne 0x31aad
movl $0x8, %r14d
jmp 0x3186d
movl $0x1, %eax
movq %rax, -0x40(%rbp)
xorl %r13d, %r13d
movq %r13, %rax
xorl %edx, %edx
movq -0x40(%rbp), %r14
divq %r14
subq %rdx, %r14
testq %rdx, %rdx
cmoveq %rdx, %r14
addq %r13, %r14
movq %r14, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1a581(%rip), %rdi     # 0x4be07
leaq 0x19fcd(%rip), %rsi     # 0x4b85a
leaq 0x1b1e8(%rip), %rcx     # 0x4ca7c
movl $0x7b0, %edx            # imm = 0x7B0
callq 0x30a0
leaq 0x1a52c(%rip), %rdi     # 0x4bdd1
leaq 0x19fae(%rip), %rsi     # 0x4b85a
leaq 0x1b1c9(%rip), %rcx     # 0x4ca7c
movl $0x7ae, %edx            # imm = 0x7AE
callq 0x30a0
leaq 0x1a51b(%rip), %rdi     # 0x4bddf
leaq 0x19f8f(%rip), %rsi     # 0x4b85a
leaq 0x1b1aa(%rip), %rcx     # 0x4ca7c
movl $0x7af, %edx            # imm = 0x7AF
callq 0x30a0
leaq 0x1b18a(%rip), %rdi     # 0x4ca6d
leaq 0x19f70(%rip), %rsi     # 0x4b85a
leaq 0x1b122(%rip), %rcx     # 0x4ca13
movl $0x80b, %edx            # imm = 0x80B
callq 0x30a0
leaq 0x1a48a(%rip), %rdi     # 0x4bd8c
leaq 0x19f51(%rip), %rsi     # 0x4b85a
leaq 0x1b16c(%rip), %rcx     # 0x4ca7c
movl $0x7aa, %edx            # imm = 0x7AA
callq 0x30a0
leaq 0x1a483(%rip), %rdi     # 0x4bda4
leaq 0x19f32(%rip), %rsi     # 0x4b85a
leaq 0x1b14d(%rip), %rcx     # 0x4ca7c
movl $0x7ab, %edx            # imm = 0x7AB
callq 0x30a0
leaq 0x10d77(%rip), %rdi     # 0x426b7
leaq 0x19f13(%rip), %rsi     # 0x4b85a
leaq 0x1b0c5(%rip), %rcx     # 0x4ca13
movl $0x7d4, %edx            # imm = 0x7D4
callq 0x30a0
leaq 0x10e6d(%rip), %rdi     # 0x427cc
leaq 0x19ef4(%rip), %rsi     # 0x4b85a
leaq 0x1b0a6(%rip), %rcx     # 0x4ca13
movl $0x7ff, %edx            # imm = 0x7FF
callq 0x30a0
leaq 0x10d7a(%rip), %rdi     # 0x426f8
leaq 0x19ed5(%rip), %rsi     # 0x4b85a
leaq 0x1b0f0(%rip), %rcx     # 0x4ca7c
movl $0x792, %edx            # imm = 0x792
callq 0x30a0
leaq 0x1b0c0(%rip), %rdi     # 0x4ca5d
leaq 0x19eb6(%rip), %rsi     # 0x4b85a
leaq 0x1b068(%rip), %rcx     # 0x4ca13
movl $0x802, %edx            # imm = 0x802
callq 0x30a0
leaq 0x1a359(%rip), %rdi     # 0x4bd15
leaq 0x19e97(%rip), %rsi     # 0x4b85a
leaq 0x1b0b2(%rip), %rcx     # 0x4ca7c
movl $0x795, %edx            # imm = 0x795
callq 0x30a0
leaq 0x10d59(%rip), %rdi     # 0x42734
leaq 0x19e78(%rip), %rsi     # 0x4b85a
leaq 0x1b02a(%rip), %rcx     # 0x4ca13
movl $0x803, %edx            # imm = 0x803
callq 0x30a0
leaq 0x10d16(%rip), %rdi     # 0x42710
leaq 0x19e59(%rip), %rsi     # 0x4b85a
leaq 0x1b074(%rip), %rcx     # 0x4ca7c
movl $0x796, %edx            # imm = 0x796
callq 0x30a0
leaq 0x1a29a(%rip), %rdi     # 0x4bcb3
leaq 0x19e3a(%rip), %rsi     # 0x4b85a
leaq 0x1afec(%rip), %rcx     # 0x4ca13
movl $0x806, %edx            # imm = 0x806
callq 0x30a0
leaq 0x1a2e5(%rip), %rdi     # 0x4bd1d
leaq 0x19e1b(%rip), %rsi     # 0x4b85a
leaq 0x1b036(%rip), %rcx     # 0x4ca7c
movl $0x79e, %edx            # imm = 0x79E
callq 0x30a0
leaq 0x1a2d2(%rip), %rdi     # 0x4bd29
leaq 0x19dfc(%rip), %rsi     # 0x4b85a
leaq 0x1b017(%rip), %rcx     # 0x4ca7c
movl $0x79f, %edx            # imm = 0x79F
callq 0x30a0
leaq 0x1a2d7(%rip), %rdi     # 0x4bd4d
leaq 0x19ddd(%rip), %rsi     # 0x4b85a
leaq 0x1aff8(%rip), %rcx     # 0x4ca7c
movl $0x7a2, %edx            # imm = 0x7A2
callq 0x30a0
leaq 0x1a2c9(%rip), %rdi     # 0x4bd5e
leaq 0x19dbe(%rip), %rsi     # 0x4b85a
leaq 0x1afd9(%rip), %rcx     # 0x4ca7c
movl $0x7a3, %edx            # imm = 0x7A3
callq 0x30a0
leaq 0xe8d0(%rip), %rdi      # 0x40384
leaq 0x19d9f(%rip), %rsi     # 0x4b85a
leaq 0x1af51(%rip), %rcx     # 0x4ca13
movl $0x81b, %edx            # imm = 0x81B
callq 0x30a0