// File: /workspace/github_c_makefile_star2_O0/Ihsoh[P]ilang/compiler/backend/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 BE_NODE_TYPE_CHAR: {
			return 1;
		}
		case BE_NODE_TYPE_INT8: {
			return 1;
		}
		case BE_NODE_TYPE_INT16: {
			return 2;
		}
		case BE_NODE_TYPE_INT32: {
			return 4;
		}
		case BE_NODE_TYPE_INT64: {
			return 8;
		}
		case BE_NODE_TYPE_UINT8: {
			return 1;
		}
		case BE_NODE_TYPE_UINT16: {
			return 2;
		}
		case BE_NODE_TYPE_UINT32: {
			return 4;
		}
		case BE_NODE_TYPE_UINT64: {
			return 8;
		}
		case BE_NODE_TYPE_FLOAT: {
			return 4;
		}
		case BE_NODE_TYPE_DOUBLE: {
			return 8;
		}
		case BE_NODE_TYPE_VA_LIST: {
			return 8;
		}
		case BE_NODE_TYPE_STRUCT: {
			return _calc_struct_type_size(ctx, node, node_type);
		}
		case BE_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 == BE_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 *= be_parser_get_uint_val(ctx, node_array_dim);
			}

			return size;
		}
		case BE_NODE_TYPE_FUNC: {
			return 0;
		}
		case BE_NODE_TYPE_POINTER: {
			if (ctx->arch == BE_ARCH_32) {
				return 4;
			} else if (ctx->arch == BE_ARCH_64) {
				return 8;
			} else {
				assert(0);
				return 0;
			}
		}
		case BE_NODE_TYPE_VOID: {
			return 1;
		}
		default: {
			assert(0);
			return 0;
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x4d5bd
jmp 0x4d5dc
leaq 0x32b9d(%rip), %rdi     # 0x80161
leaq 0x352b5(%rip), %rsi     # 0x82880
movl $0x4e7, %edx            # imm = 0x4E7
leaq 0x3841a(%rip), %rcx     # 0x859f1
callq 0x30a0
cmpq $0x0, -0x18(%rbp)
je 0x4d5e5
jmp 0x4d604
leaq 0x28f70(%rip), %rdi     # 0x7655c
leaq 0x3528d(%rip), %rsi     # 0x82880
movl $0x4e8, %edx            # imm = 0x4E8
leaq 0x383f2(%rip), %rcx     # 0x859f1
callq 0x30a0
cmpq $0x0, -0x20(%rbp)
je 0x4d60d
jmp 0x4d62c
leaq 0x37c2a(%rip), %rdi     # 0x8523e
leaq 0x35265(%rip), %rsi     # 0x82880
movl $0x4e9, %edx            # imm = 0x4E9
leaq 0x383ca(%rip), %rcx     # 0x859f1
callq 0x30a0
movq -0x20(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x4c(%rbp)
subl $0x400, %eax            # imm = 0x400
je 0x4d745
jmp 0x4d642
movl -0x4c(%rbp), %eax
subl $0x401, %eax            # imm = 0x401
je 0x4d752
jmp 0x4d652
movl -0x4c(%rbp), %eax
subl $0x402, %eax            # imm = 0x402
je 0x4d75f
jmp 0x4d662
movl -0x4c(%rbp), %eax
subl $0x403, %eax            # imm = 0x403
je 0x4d76c
jmp 0x4d672
movl -0x4c(%rbp), %eax
subl $0x404, %eax            # imm = 0x404
je 0x4d779
jmp 0x4d682
movl -0x4c(%rbp), %eax
subl $0x405, %eax            # imm = 0x405
je 0x4d786
jmp 0x4d692
movl -0x4c(%rbp), %eax
subl $0x406, %eax            # imm = 0x406
je 0x4d793
jmp 0x4d6a2
movl -0x4c(%rbp), %eax
subl $0x407, %eax            # imm = 0x407
je 0x4d7a0
jmp 0x4d6b2
movl -0x4c(%rbp), %eax
subl $0x408, %eax            # imm = 0x408
je 0x4d7ad
jmp 0x4d6c2
movl -0x4c(%rbp), %eax
subl $0x409, %eax            # imm = 0x409
je 0x4d7ba
jmp 0x4d6d2
movl -0x4c(%rbp), %eax
subl $0x40a, %eax            # imm = 0x40A
je 0x4d7c7
jmp 0x4d6e2
movl -0x4c(%rbp), %eax
subl $0x40b, %eax            # imm = 0x40B
je 0x4d7d4
jmp 0x4d6f2
movl -0x4c(%rbp), %eax
subl $0x410, %eax            # imm = 0x410
je 0x4d7e1
jmp 0x4d702
movl -0x4c(%rbp), %eax
subl $0x420, %eax            # imm = 0x420
je 0x4d7fb
jmp 0x4d712
movl -0x4c(%rbp), %eax
subl $0x430, %eax            # imm = 0x430
je 0x4d951
jmp 0x4d722
movl -0x4c(%rbp), %eax
subl $0x440, %eax            # imm = 0x440
je 0x4d95b
jmp 0x4d732
movl -0x4c(%rbp), %eax
subl $0x4ff, %eax            # imm = 0x4FF
je 0x4d9a2
jmp 0x4d9ac
movq $0x1, -0x8(%rbp)
jmp 0x4d9cb
movq $0x1, -0x8(%rbp)
jmp 0x4d9cb
movq $0x2, -0x8(%rbp)
jmp 0x4d9cb
movq $0x4, -0x8(%rbp)
jmp 0x4d9cb
movq $0x8, -0x8(%rbp)
jmp 0x4d9cb
movq $0x1, -0x8(%rbp)
jmp 0x4d9cb
movq $0x2, -0x8(%rbp)
jmp 0x4d9cb
movq $0x4, -0x8(%rbp)
jmp 0x4d9cb
movq $0x8, -0x8(%rbp)
jmp 0x4d9cb
movq $0x4, -0x8(%rbp)
jmp 0x4d9cb
movq $0x8, -0x8(%rbp)
jmp 0x4d9cb
movq $0x8, -0x8(%rbp)
jmp 0x4d9cb
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x60dc0
movq %rax, -0x8(%rbp)
jmp 0x4d9cb
movq -0x20(%rbp), %rax
cmpl $0x2, 0x44(%rax)
jne 0x4d807
jmp 0x4d826
leaq 0x355ad(%rip), %rdi     # 0x82dbb
leaq 0x3506b(%rip), %rsi     # 0x82880
movl $0x514, %edx            # imm = 0x514
leaq 0x381d0(%rip), %rcx     # 0x859f1
callq 0x30a0
movq -0x20(%rbp), %rax
movq 0x48(%rax), %rax
movq (%rax), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x4d83e
jmp 0x4d85d
leaq 0x381f6(%rip), %rdi     # 0x85a3b
leaq 0x35034(%rip), %rsi     # 0x82880
movl $0x517, %edx            # imm = 0x517
leaq 0x38199(%rip), %rcx     # 0x859f1
callq 0x30a0
movq -0x28(%rbp), %rax
cmpl $0x421, (%rax)          # imm = 0x421
jne 0x4d86b
jmp 0x4d88a
leaq 0x3543c(%rip), %rdi     # 0x82cae
leaq 0x35007(%rip), %rsi     # 0x82880
movl $0x518, %edx            # imm = 0x518
leaq 0x3816c(%rip), %rcx     # 0x859f1
callq 0x30a0
movq -0x20(%rbp), %rax
movq 0x48(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x4d8a3
jmp 0x4d8c2
leaq 0x35529(%rip), %rdi     # 0x82dd3
leaq 0x34fcf(%rip), %rsi     # 0x82880
movl $0x51b, %edx            # imm = 0x51B
leaq 0x38134(%rip), %rcx     # 0x859f1
callq 0x30a0
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x30(%rbp), %rdx
callq 0x4d5a0
movq %rax, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movq -0x28(%rbp), %rcx
cmpl 0x44(%rcx), %eax
jge 0x4d947
movq -0x28(%rbp), %rax
movq 0x48(%rax), %rax
movslq -0x3c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
je 0x4d907
jmp 0x4d926
leaq 0x3813d(%rip), %rdi     # 0x85a4b
leaq 0x34f6b(%rip), %rsi     # 0x82880
movl $0x520, %edx            # imm = 0x520
leaq 0x380d0(%rip), %rcx     # 0x859f1
callq 0x30a0
movq -0x10(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0x3e290
imulq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x4d8de
movq -0x38(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x4d9cb
movq $0x0, -0x8(%rbp)
jmp 0x4d9cb
movq -0x10(%rbp), %rax
cmpl $0x1, 0x30(%rax)
jne 0x4d96f
movq $0x4, -0x8(%rbp)
jmp 0x4d9cb
movq -0x10(%rbp), %rax
cmpl $0x2, 0x30(%rax)
jne 0x4d983
movq $0x8, -0x8(%rbp)
jmp 0x4d9cb
leaq 0x25ad0(%rip), %rdi     # 0x7345a
leaq 0x34eef(%rip), %rsi     # 0x82880
movl $0x530, %edx            # imm = 0x530
leaq 0x38054(%rip), %rcx     # 0x859f1
callq 0x30a0
movq $0x1, -0x8(%rbp)
jmp 0x4d9cb
leaq 0x25aa7(%rip), %rdi     # 0x7345a
leaq 0x34ec6(%rip), %rsi     # 0x82880
movl $0x538, %edx            # imm = 0x538
leaq 0x3802b(%rip), %rcx     # 0x859f1
callq 0x30a0
movq -0x8(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)