// File: /workspace/github_c_makefile_star2_O3/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 0x1e438(%rip), %rax     # 0x4b720
testq %rdx, %rdx
je 0x2d55d
movl (%rdx), %ecx
cmpl $0x42f, %ecx            # imm = 0x42F
jg 0x2d349
addl $0xfffffc00, %ecx       # imm = 0xFFFFFC00
cmpl $0x20, %ecx
ja 0x2d59b
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
cmpl $0x2, 0x44(%rdx)
jne 0x2d57c
movq 0x48(%rdx), %rcx
movq 0x8(%rcx), %rdx
testq %rdx, %rdx
jne 0x2d2e8
leaq 0x1f333(%rip), %rdi     # 0x4c664
leaq 0x1ee08(%rip), %rsi     # 0x4c140
leaq 0x1f2c2(%rip), %rcx     # 0x4c601
movl $0x47d, %edx            # imm = 0x47D
callq 0x30a0
cmpl $0x430, %ecx            # imm = 0x430
je 0x2d4cc
cmpl $0x440, %ecx            # imm = 0x440
je 0x2d4d1
cmpl $0x4ff, %ecx            # imm = 0x4FF
jne 0x2d59b
movl $0x1, %r15d
jmp 0x2d4ee
movl $0x4, %r15d
jmp 0x2d4ee
movl $0x2, %r15d
jmp 0x2d4ee
cmpl $0x1, 0x44(%rdx)
jne 0x2d5f8
movq 0x48(%rdx), %rax
movq (%rax), %r15
testq %r15, %r15
je 0x2d617
cmpl $0x200, (%r15)          # imm = 0x200
jne 0x2d636
movq 0x10(%r15), %rcx
movq %rbx, %rdi
movq %r14, %rsi
movl $0x2, %edx
callq 0x6c49
movq %rax, %r12
testq %rax, %rax
jne 0x2d3e2
movq 0x10(%r15), %rsi
leaq 0x1f139(%rip), %rdx     # 0x4c515
movq %rbx, %rdi
callq *0x50(%rbx)
movq 0x30(%r12), %rax
testq %rax, %rax
je 0x2d655
cmpl $0xd00, (%rax)          # imm = 0xD00
jne 0x2d674
movl $0x1, %r15d
cmpb $0x0, 0x68(%rax)
jne 0x2d4ee
movq 0x38(%r12), %rdx
testq %rdx, %rdx
je 0x2d6b2
cmpl $0xd01, (%rdx)          # imm = 0xD01
jne 0x2d6d1
movl 0x44(%rdx), %eax
testl %eax, %eax
jle 0x2d4ee
xorl %esi, %esi
movq %rdx, -0x30(%rbp)
movq 0x48(%rdx), %rcx
movq (%rcx,%rsi,8), %r12
testq %r12, %r12
je 0x2d5ba
cmpl $0xc00, (%r12)          # imm = 0xC00
jne 0x2d5d9
cmpl $0x0, 0x44(%r12)
jle 0x2d4bb
movq %rsi, -0x38(%rbp)
xorl %r13d, %r13d
movq 0x48(%r12), %rax
movq (%rax,%r13,8), %rax
testq %rax, %rax
je 0x2d51f
cmpl $0xc01, (%rax)          # imm = 0xC01
jne 0x2d53e
cmpl $0x1, 0x44(%rax)
jle 0x2d500
movq 0x48(%rax), %rax
movq 0x8(%rax), %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2d2ca
cmpq %r15, %rax
cmovaq %rax, %r15
incq %r13
movslq 0x44(%r12), %rax
cmpq %rax, %r13
jl 0x2d465
movq -0x30(%rbp), %rdx
movl 0x44(%rdx), %eax
movq -0x38(%rbp), %rsi
incq %rsi
movslq %eax, %rcx
cmpq %rcx, %rsi
jl 0x2d437
jmp 0x2d4ee
xorl %r15d, %r15d
jmp 0x2d4ee
movl 0x30(%rbx), %eax
movl $0x4, %r15d
cmpl $0x1, %eax
je 0x2d4ee
cmpl $0x2, %eax
jne 0x2d693
movl $0x8, %r15d
movq %r15, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1f2c1(%rip), %rdi     # 0x4c7c8
leaq 0x1ec32(%rip), %rsi     # 0x4c140
leaq 0x1f15f(%rip), %rcx     # 0x4c674
movl $0x43b, %edx            # imm = 0x43B
callq 0x30a0
leaq 0x1f26c(%rip), %rdi     # 0x4c792
leaq 0x1ec13(%rip), %rsi     # 0x4c140
leaq 0x1f140(%rip), %rcx     # 0x4c674
movl $0x439, %edx            # imm = 0x439
callq 0x30a0
leaq 0x1f25b(%rip), %rdi     # 0x4c7a0
leaq 0x1ebf4(%rip), %rsi     # 0x4c140
leaq 0x1f121(%rip), %rcx     # 0x4c674
movl $0x43a, %edx            # imm = 0x43A
callq 0x30a0
leaq 0x21255(%rip), %rdi     # 0x4e7b9
leaq 0x1ebd5(%rip), %rsi     # 0x4c140
leaq 0x1f08f(%rip), %rcx     # 0x4c601
movl $0x44f, %edx            # imm = 0x44F
callq 0x30a0
leaq 0x1f0c9(%rip), %rdi     # 0x4c64c
leaq 0x1ebb6(%rip), %rsi     # 0x4c140
leaq 0x1f070(%rip), %rcx     # 0x4c601
movl $0x47a, %edx            # imm = 0x47A
callq 0x30a0
leaq 0x10dc7(%rip), %rdi     # 0x3e369
leaq 0x1eb97(%rip), %rsi     # 0x4c140
leaq 0x1f051(%rip), %rcx     # 0x4c601
movl $0x492, %edx            # imm = 0x492
callq 0x30a0
leaq 0x1f18c(%rip), %rdi     # 0x4c74d
leaq 0x1eb78(%rip), %rsi     # 0x4c140
leaq 0x1f0a5(%rip), %rcx     # 0x4c674
movl $0x435, %edx            # imm = 0x435
callq 0x30a0
leaq 0x1f185(%rip), %rdi     # 0x4c765
leaq 0x1eb59(%rip), %rsi     # 0x4c140
leaq 0x1f086(%rip), %rcx     # 0x4c674
movl $0x436, %edx            # imm = 0x436
callq 0x30a0
leaq 0x1f0c7(%rip), %rdi     # 0x4c6c6
leaq 0x1eb3a(%rip), %rsi     # 0x4c140
leaq 0x1f067(%rip), %rcx     # 0x4c674
movl $0x41b, %edx            # imm = 0x41B
callq 0x30a0
leaq 0x141f8(%rip), %rdi     # 0x41816
leaq 0x1eb1b(%rip), %rsi     # 0x4c140
leaq 0x1f048(%rip), %rcx     # 0x4c674
movl $0x41e, %edx            # imm = 0x41E
callq 0x30a0
leaq 0x14157(%rip), %rdi     # 0x41794
leaq 0x1eafc(%rip), %rsi     # 0x4c140
leaq 0x1f029(%rip), %rcx     # 0x4c674
movl $0x41f, %edx            # imm = 0x41F
callq 0x30a0
leaq 0x1f082(%rip), %rdi     # 0x4c6de
leaq 0x1eadd(%rip), %rsi     # 0x4c140
leaq 0x1f00a(%rip), %rcx     # 0x4c674
movl $0x427, %edx            # imm = 0x427
callq 0x30a0
leaq 0x1f06f(%rip), %rdi     # 0x4c6ea
leaq 0x1eabe(%rip), %rsi     # 0x4c140
leaq 0x1efeb(%rip), %rcx     # 0x4c674
movl $0x428, %edx            # imm = 0x428
callq 0x30a0
leaq 0x10ccf(%rip), %rdi     # 0x3e369
leaq 0x1ea9f(%rip), %rsi     # 0x4c140
leaq 0x1ef59(%rip), %rcx     # 0x4c601
movl $0x48a, %edx            # imm = 0x48A
callq 0x30a0
leaq 0x1f055(%rip), %rdi     # 0x4c70e
leaq 0x1ea80(%rip), %rsi     # 0x4c140
leaq 0x1efad(%rip), %rcx     # 0x4c674
movl $0x42e, %edx            # imm = 0x42E
callq 0x30a0
leaq 0x1f047(%rip), %rdi     # 0x4c71f
leaq 0x1ea61(%rip), %rsi     # 0x4c140
leaq 0x1ef8e(%rip), %rcx     # 0x4c674
movl $0x42f, %edx            # imm = 0x42F
callq 0x30a0