// File: /workspace/github_c_makefile_star2_O2/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 0x2e791
movl (%rdx), %eax
pushq $0x1
popq %r15
leal -0x400(%rax), %ecx
cmpl $0x20, %ecx
ja 0x2e43f
leaq 0x18e45(%rip), %rax     # 0x47274
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
pushq $0x4
jmp 0x2e6a8
cmpl $0x430, %eax            # imm = 0x430
je 0x2e482
cmpl $0x440, %eax            # imm = 0x440
je 0x2e68d
cmpl $0x4ff, %eax            # imm = 0x4FF
je 0x2e6aa
leaq 0xdefd(%rip), %rdi      # 0x3c360
leaq 0x194d0(%rip), %rsi     # 0x4793a
leaq 0x1a682(%rip), %rcx     # 0x48af3
movl $0x823, %edx            # imm = 0x823
callq 0x30a0
pushq $0x2
jmp 0x2e6a8
xorl %r15d, %r15d
jmp 0x2e6aa
cmpl $0x2, 0x44(%rdx)
jne 0x2e7b0
movq 0x48(%rdx), %rax
movq (%rax), %rbx
testq %rbx, %rbx
je 0x2e7ee
cmpl $0x421, (%rbx)          # imm = 0x421
jne 0x2e82c
movq 0x8(%rax), %rdx
testq %rdx, %rdx
je 0x2e86a
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x2e3f5
movq %rax, %r15
xorl %r14d, %r14d
movslq 0x44(%rbx), %rax
cmpq %rax, %r14
jge 0x2e6aa
movq 0x48(%rbx), %rax
movq (%rax,%r14,8), %rsi
testq %rsi, %rsi
je 0x2e734
movq -0x30(%rbp), %rdi
callq 0x23493
imulq %rax, %r15
incq %r14
jmp 0x2e4d0
cmpl $0x1, 0x44(%rdx)
jne 0x2e7cf
movq 0x48(%rdx), %rax
movq (%rax), %r14
testq %r14, %r14
je 0x2e80d
cmpl $0x200, (%r14)          # imm = 0x200
jne 0x2e84b
movq 0x10(%r14), %rcx
pushq $0x2
popq %rdx
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x6779
movq %rax, %rbx
testq %rax, %rax
jne 0x2e555
movq 0x10(%r14), %rsi
leaq 0x19785(%rip), %rdx     # 0x47cd3
movq -0x30(%rbp), %rdi
callq *0x50(%rdi)
movq 0x30(%rbx), %rcx
testq %rcx, %rcx
je 0x2e889
cmpl $0xd00, (%rcx)          # imm = 0xD00
jne 0x2e8a8
movq 0x38(%rbx), %rdx
testq %rdx, %rdx
je 0x2e8c7
cmpl $0xd01, (%rdx)          # imm = 0xD01
jne 0x2e8e6
pushq $0x1
popq %rax
xorl %esi, %esi
xorl %edi, %edi
movq %rax, -0x40(%rbp)
movq %rdx, -0x48(%rbp)
movslq 0x44(%rdx), %rax
cmpq %rax, %rsi
jge 0x2e6bc
movq 0x48(%rdx), %rax
movq (%rax,%rsi,8), %r12
testq %r12, %r12
je 0x2e753
movq %rsi, -0x50(%rbp)
cmpl $0xc00, (%r12)          # imm = 0xC00
jne 0x2e772
xorl %r14d, %r14d
movq %r12, -0x58(%rbp)
movslq 0x44(%r12), %rax
cmpq %rax, %r14
jge 0x2e67d
movq 0x48(%r12), %rax
movq (%rax,%r14,8), %rax
testq %rax, %rax
je 0x2e6f6
cmpl $0xc01, (%rax)          # imm = 0xC01
jne 0x2e715
cmpl $0x1, 0x44(%rax)
jle 0x2e6d7
movq 0x48(%rax), %rax
movq 0x8(%rax), %rbx
movq %rcx, %r12
cmpb $0x0, 0x68(%rcx)
pushq $0x1
popq %r13
jne 0x2e631
movq %rdi, %r13
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq %rbx, %rdx
callq 0x290fb
movq %r13, %rdi
movq %rax, %r13
movq -0x40(%rbp), %rax
cmpq %rax, %r13
cmovaq %r13, %rax
movq %rax, -0x40(%rbp)
movq %rdi, %rax
xorl %edx, %edx
divq %r13
subq %rdx, %r13
testq %rdx, %rdx
cmoveq %rdx, %r13
movq %rdi, %r15
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq %rbx, %rdx
callq 0x2e3f5
addq %r15, %r13
addq %rax, %r13
incq %r14
movq %r13, %rdi
movq %r12, %rcx
movq -0x58(%rbp), %r12
jmp 0x2e5cd
movq -0x50(%rbp), %rsi
incq %rsi
movq -0x48(%rbp), %rdx
jmp 0x2e596
movq -0x30(%rbp), %rax
movl 0x30(%rax), %eax
cmpl $0x1, %eax
je 0x2e438
cmpl $0x2, %eax
jne 0x2e905
pushq $0x8
popq %r15
movq %r15, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rdi, %rax
xorl %edx, %edx
movq -0x40(%rbp), %r15
divq %r15
subq %rdx, %r15
testq %rdx, %rdx
cmoveq %rdx, %r15
addq %rdi, %r15
jmp 0x2e6aa
leaq 0x19809(%rip), %rdi     # 0x47ee7
leaq 0x19255(%rip), %rsi     # 0x4793a
leaq 0x1a470(%rip), %rcx     # 0x48b5c
movl $0x7b0, %edx            # imm = 0x7B0
callq 0x30a0
leaq 0x197b4(%rip), %rdi     # 0x47eb1
leaq 0x19236(%rip), %rsi     # 0x4793a
leaq 0x1a451(%rip), %rcx     # 0x48b5c
movl $0x7ae, %edx            # imm = 0x7AE
callq 0x30a0
leaq 0x197a3(%rip), %rdi     # 0x47ebf
leaq 0x19217(%rip), %rsi     # 0x4793a
leaq 0x1a432(%rip), %rcx     # 0x48b5c
movl $0x7af, %edx            # imm = 0x7AF
callq 0x30a0
leaq 0x1a412(%rip), %rdi     # 0x48b4d
leaq 0x191f8(%rip), %rsi     # 0x4793a
leaq 0x1a3aa(%rip), %rcx     # 0x48af3
movl $0x80b, %edx            # imm = 0x80B
callq 0x30a0
leaq 0x19712(%rip), %rdi     # 0x47e6c
leaq 0x191d9(%rip), %rsi     # 0x4793a
leaq 0x1a3f4(%rip), %rcx     # 0x48b5c
movl $0x7aa, %edx            # imm = 0x7AA
callq 0x30a0
leaq 0x1970b(%rip), %rdi     # 0x47e84
leaq 0x191ba(%rip), %rsi     # 0x4793a
leaq 0x1a3d5(%rip), %rcx     # 0x48b5c
movl $0x7ab, %edx            # imm = 0x7AB
callq 0x30a0
leaq 0xff7b(%rip), %rdi      # 0x3e713
leaq 0x1919b(%rip), %rsi     # 0x4793a
leaq 0x1a34d(%rip), %rcx     # 0x48af3
movl $0x7d4, %edx            # imm = 0x7D4
callq 0x30a0
leaq 0x10071(%rip), %rdi     # 0x3e828
leaq 0x1917c(%rip), %rsi     # 0x4793a
leaq 0x1a32e(%rip), %rcx     # 0x48af3
movl $0x7ff, %edx            # imm = 0x7FF
callq 0x30a0
leaq 0xff7e(%rip), %rdi      # 0x3e754
leaq 0x1915d(%rip), %rsi     # 0x4793a
leaq 0x1a378(%rip), %rcx     # 0x48b5c
movl $0x792, %edx            # imm = 0x792
callq 0x30a0
leaq 0x1a348(%rip), %rdi     # 0x48b3d
leaq 0x1913e(%rip), %rsi     # 0x4793a
leaq 0x1a2f0(%rip), %rcx     # 0x48af3
movl $0x802, %edx            # imm = 0x802
callq 0x30a0
leaq 0x195e1(%rip), %rdi     # 0x47df5
leaq 0x1911f(%rip), %rsi     # 0x4793a
leaq 0x1a33a(%rip), %rcx     # 0x48b5c
movl $0x795, %edx            # imm = 0x795
callq 0x30a0
leaq 0xff5d(%rip), %rdi      # 0x3e790
leaq 0x19100(%rip), %rsi     # 0x4793a
leaq 0x1a2b2(%rip), %rcx     # 0x48af3
movl $0x803, %edx            # imm = 0x803
callq 0x30a0
leaq 0xff1a(%rip), %rdi      # 0x3e76c
leaq 0x190e1(%rip), %rsi     # 0x4793a
leaq 0x1a2fc(%rip), %rcx     # 0x48b5c
movl $0x796, %edx            # imm = 0x796
callq 0x30a0
leaq 0x19522(%rip), %rdi     # 0x47d93
leaq 0x190c2(%rip), %rsi     # 0x4793a
leaq 0x1a274(%rip), %rcx     # 0x48af3
movl $0x806, %edx            # imm = 0x806
callq 0x30a0
leaq 0x1956d(%rip), %rdi     # 0x47dfd
leaq 0x190a3(%rip), %rsi     # 0x4793a
leaq 0x1a2be(%rip), %rcx     # 0x48b5c
movl $0x79e, %edx            # imm = 0x79E
callq 0x30a0
leaq 0x1955a(%rip), %rdi     # 0x47e09
leaq 0x19084(%rip), %rsi     # 0x4793a
leaq 0x1a29f(%rip), %rcx     # 0x48b5c
movl $0x79f, %edx            # imm = 0x79F
callq 0x30a0
leaq 0x1955f(%rip), %rdi     # 0x47e2d
leaq 0x19065(%rip), %rsi     # 0x4793a
leaq 0x1a280(%rip), %rcx     # 0x48b5c
movl $0x7a2, %edx            # imm = 0x7A2
callq 0x30a0
leaq 0x19551(%rip), %rdi     # 0x47e3e
leaq 0x19046(%rip), %rsi     # 0x4793a
leaq 0x1a261(%rip), %rcx     # 0x48b5c
movl $0x7a3, %edx            # imm = 0x7A3
callq 0x30a0
leaq 0xda54(%rip), %rdi      # 0x3c360
leaq 0x19027(%rip), %rsi     # 0x4793a
leaq 0x1a1d9(%rip), %rcx     # 0x48af3
movl $0x81b, %edx            # imm = 0x81B
callq 0x30a0