// File: /workspace/github_c_makefile_star2_O2/Ihsoh[P]ilang/compiler/backend/semantics.c
// Function: calc_type_align
static size_t _calc_type_align(
	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 1;
		}
		case BE_NODE_TYPE_STRUCT: {
			return _calc_struct_type_align(ctx, node, node_type);
		}
		case BE_NODE_TYPE_ARRAY: {
			assert(node_type->nchilds == 2);

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

			return _calc_type_align(ctx, node, node_array_type);
		}
		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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x1de17(%rip), %rax     # 0x48750
testq %rdx, %rdx
je 0x2ab84
movl (%rdx), %ecx
leal -0x400(%rcx), %esi
cmpl $0x20, %esi
ja 0x2a98e
movslq (%rax,%rsi,4), %rcx
addq %rax, %rcx
jmpq *%rcx
cmpl $0x2, 0x44(%rdx)
jne 0x2aba3
movq 0x48(%rdx), %rcx
movq 0x8(%rcx), %rdx
testq %rdx, %rdx
jne 0x2a939
leaq 0x1ed1e(%rip), %rdi     # 0x49694
leaq 0x1e7f3(%rip), %rsi     # 0x49170
leaq 0x1ecad(%rip), %rcx     # 0x49631
movl $0x47d, %edx            # imm = 0x47D
callq 0x30a0
cmpl $0x430, %ecx            # imm = 0x430
je 0x2aa50
cmpl $0x440, %ecx            # imm = 0x440
je 0x2aa55
cmpl $0x4ff, %ecx            # imm = 0x4FF
je 0x2aa4c
leaq 0x109b0(%rip), %rdi     # 0x3b369
leaq 0x1e7b0(%rip), %rsi     # 0x49170
leaq 0x1ec6a(%rip), %rcx     # 0x49631
movl $0x492, %edx            # imm = 0x492
callq 0x30a0
pushq $0x2
jmp 0x2aa6c
cmpl $0x1, 0x44(%rdx)
jne 0x2ac00
movq 0x48(%rdx), %rax
movq (%rax), %r12
testq %r12, %r12
je 0x2ac1f
cmpl $0x200, (%r12)          # imm = 0x200
jne 0x2ac3e
movq 0x10(%r12), %rcx
pushq $0x2
popq %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x6779
movq %rax, %r15
testq %rax, %rax
jne 0x2aa2d
movq 0x10(%r12), %rsi
leaq 0x1eb1e(%rip), %rdx     # 0x49545
movq %rbx, %rdi
callq *0x50(%rbx)
movq 0x30(%r15), %rax
testq %rax, %rax
je 0x2ac5d
cmpl $0xd00, (%rax)          # imm = 0xD00
jne 0x2ac7c
cmpb $0x0, 0x68(%rax)
je 0x2aa80
pushq $0x1
jmp 0x2aa6c
xorl %r15d, %r15d
jmp 0x2aa6e
movl 0x30(%rbx), %eax
cmpl $0x1, %eax
je 0x2aa6a
cmpl $0x2, %eax
jne 0x2ac9b
pushq $0x8
jmp 0x2aa6c
pushq $0x4
popq %r15
movq %r15, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x38(%r15), %rcx
testq %rcx, %rcx
je 0x2acba
cmpl $0xd01, (%rcx)          # imm = 0xD01
jne 0x2acd9
pushq $0x1
popq %r15
xorl %edx, %edx
movq %rcx, -0x30(%rbp)
movslq 0x44(%rcx), %rax
cmpq %rax, %rdx
jge 0x2aa6e
movq 0x48(%rcx), %rax
movq (%rax,%rdx,8), %r12
testq %r12, %r12
je 0x2abc2
movq %rdx, -0x38(%rbp)
cmpl $0xc00, (%r12)          # imm = 0xC00
jne 0x2abe1
xorl %r13d, %r13d
movslq 0x44(%r12), %rax
cmpq %rax, %r13
jge 0x2ab17
movq 0x48(%r12), %rax
movq (%rax,%r13,8), %rax
testq %rax, %rax
je 0x2ab65
cmpl $0xc01, (%rax)          # imm = 0xC01
jne 0x2ab27
cmpl $0x1, 0x44(%rax)
jle 0x2ab46
movq 0x48(%rax), %rax
movq 0x8(%rax), %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2a91b
cmpq %r15, %rax
cmovaq %rax, %r15
incq %r13
jmp 0x2aad2
movq -0x38(%rbp), %rdx
incq %rdx
movq -0x30(%rbp), %rcx
jmp 0x2aaa3
leaq 0x1eca2(%rip), %rdi     # 0x497d0
leaq 0x1e63b(%rip), %rsi     # 0x49170
leaq 0x1eb68(%rip), %rcx     # 0x496a4
movl $0x43a, %edx            # imm = 0x43A
callq 0x30a0
leaq 0x1ecab(%rip), %rdi     # 0x497f8
leaq 0x1e61c(%rip), %rsi     # 0x49170
leaq 0x1eb49(%rip), %rcx     # 0x496a4
movl $0x43b, %edx            # imm = 0x43B
callq 0x30a0
leaq 0x1ec56(%rip), %rdi     # 0x497c2
leaq 0x1e5fd(%rip), %rsi     # 0x49170
leaq 0x1eb2a(%rip), %rcx     # 0x496a4
movl $0x439, %edx            # imm = 0x439
callq 0x30a0
leaq 0x20c5e(%rip), %rdi     # 0x4b7e9
leaq 0x1e5de(%rip), %rsi     # 0x49170
leaq 0x1ea98(%rip), %rcx     # 0x49631
movl $0x44f, %edx            # imm = 0x44F
callq 0x30a0
leaq 0x1ead2(%rip), %rdi     # 0x4967c
leaq 0x1e5bf(%rip), %rsi     # 0x49170
leaq 0x1ea79(%rip), %rcx     # 0x49631
movl $0x47a, %edx            # imm = 0x47A
callq 0x30a0
leaq 0x1ebb4(%rip), %rdi     # 0x4977d
leaq 0x1e5a0(%rip), %rsi     # 0x49170
leaq 0x1eacd(%rip), %rcx     # 0x496a4
movl $0x435, %edx            # imm = 0x435
callq 0x30a0
leaq 0x1ebad(%rip), %rdi     # 0x49795
leaq 0x1e581(%rip), %rsi     # 0x49170
leaq 0x1eaae(%rip), %rcx     # 0x496a4
movl $0x436, %edx            # imm = 0x436
callq 0x30a0
leaq 0x1eaef(%rip), %rdi     # 0x496f6
leaq 0x1e562(%rip), %rsi     # 0x49170
leaq 0x1ea8f(%rip), %rcx     # 0x496a4
movl $0x41b, %edx            # imm = 0x41B
callq 0x30a0
leaq 0x13c22(%rip), %rdi     # 0x3e848
leaq 0x1e543(%rip), %rsi     # 0x49170
leaq 0x1ea70(%rip), %rcx     # 0x496a4
movl $0x41e, %edx            # imm = 0x41E
callq 0x30a0
leaq 0x13b81(%rip), %rdi     # 0x3e7c6
leaq 0x1e524(%rip), %rsi     # 0x49170
leaq 0x1ea51(%rip), %rcx     # 0x496a4
movl $0x41f, %edx            # imm = 0x41F
callq 0x30a0
leaq 0x1eaaa(%rip), %rdi     # 0x4970e
leaq 0x1e505(%rip), %rsi     # 0x49170
leaq 0x1ea32(%rip), %rcx     # 0x496a4
movl $0x427, %edx            # imm = 0x427
callq 0x30a0
leaq 0x1ea97(%rip), %rdi     # 0x4971a
leaq 0x1e4e6(%rip), %rsi     # 0x49170
leaq 0x1ea13(%rip), %rcx     # 0x496a4
movl $0x428, %edx            # imm = 0x428
callq 0x30a0
leaq 0x106c7(%rip), %rdi     # 0x3b369
leaq 0x1e4c7(%rip), %rsi     # 0x49170
leaq 0x1e981(%rip), %rcx     # 0x49631
movl $0x48a, %edx            # imm = 0x48A
callq 0x30a0
leaq 0x1ea7d(%rip), %rdi     # 0x4973e
leaq 0x1e4a8(%rip), %rsi     # 0x49170
leaq 0x1e9d5(%rip), %rcx     # 0x496a4
movl $0x42e, %edx            # imm = 0x42E
callq 0x30a0
leaq 0x1ea6f(%rip), %rdi     # 0x4974f
leaq 0x1e489(%rip), %rsi     # 0x49170
leaq 0x1e9b6(%rip), %rcx     # 0x496a4
movl $0x42f, %edx            # imm = 0x42F
callq 0x30a0