// File: /workspace/github_c_makefile_star2_O3/Ihsoh[P]ilang/compiler/frontend/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 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 1;
		}
		case FE_NODE_TYPE_STRUCT: {
			return _calc_struct_type_align(ctx, node, node_type);
		}
		case FE_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 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 $0x18, %rsp
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x1ec15(%rip), %rax     # 0x49eb4
testq %rdx, %rdx
je 0x2b514
movl (%rdx), %ecx
cmpl $0x42f, %ecx            # imm = 0x42F
jg 0x2b300
addl $0xfffffc00, %ecx       # imm = 0xFFFFFC00
cmpl $0x20, %ecx
ja 0x2b552
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
cmpl $0x2, 0x44(%rdx)
jne 0x2b533
movq 0x48(%rdx), %rcx
movq 0x8(%rcx), %rdx
testq %rdx, %rdx
jne 0x2b29f
leaq 0x1fa6b(%rip), %rdi     # 0x4ad53
leaq 0x1f60b(%rip), %rsi     # 0x4a8fa
leaq 0x1fa12(%rip), %rcx     # 0x4ad08
movl $0x768, %edx            # imm = 0x768
callq 0x30a0
cmpl $0x430, %ecx            # imm = 0x430
je 0x2b483
cmpl $0x440, %ecx            # imm = 0x440
je 0x2b488
cmpl $0x4ff, %ecx            # imm = 0x4FF
jne 0x2b552
movl $0x1, %r15d
jmp 0x2b4a5
movl $0x4, %r15d
jmp 0x2b4a5
movl $0x2, %r15d
jmp 0x2b4a5
cmpl $0x1, 0x44(%rdx)
jne 0x2b5af
movq 0x48(%rdx), %rax
movq (%rax), %r15
testq %r15, %r15
je 0x2b5ce
cmpl $0x200, (%r15)          # imm = 0x200
jne 0x2b5ed
movq 0x10(%r15), %rcx
movq %rbx, %rdi
movq %r14, %rsi
movl $0x2, %edx
callq 0x6c89
movq %rax, %r12
testq %rax, %rax
jne 0x2b399
movq 0x10(%r15), %rsi
leaq 0x1f900(%rip), %rdx     # 0x4ac93
movq %rbx, %rdi
callq *0x50(%rbx)
movq 0x30(%r12), %rax
testq %rax, %rax
je 0x2b60c
cmpl $0xd00, (%rax)          # imm = 0xD00
jne 0x2b62b
movl $0x1, %r15d
cmpb $0x0, 0x68(%rax)
jne 0x2b4a5
movq 0x38(%r12), %rdx
testq %rdx, %rdx
je 0x2b669
cmpl $0xd01, (%rdx)          # imm = 0xD01
jne 0x2b688
movl 0x44(%rdx), %eax
testl %eax, %eax
jle 0x2b4a5
xorl %esi, %esi
movq %rdx, -0x30(%rbp)
movq 0x48(%rdx), %rcx
movq (%rcx,%rsi,8), %r12
testq %r12, %r12
je 0x2b571
cmpl $0xc00, (%r12)          # imm = 0xC00
jne 0x2b590
cmpl $0x0, 0x44(%r12)
jle 0x2b472
movq %rsi, -0x38(%rbp)
xorl %r13d, %r13d
movq 0x48(%r12), %rax
movq (%rax,%r13,8), %rax
testq %rax, %rax
je 0x2b4d6
cmpl $0xc01, (%rax)          # imm = 0xC01
jne 0x2b4f5
cmpl $0x1, 0x44(%rax)
jle 0x2b4b7
movq 0x48(%rax), %rax
movq 0x8(%rax), %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2b281
cmpq %r15, %rax
cmovaq %rax, %r15
incq %r13
movslq 0x44(%r12), %rax
cmpq %rax, %r13
jl 0x2b41c
movq -0x30(%rbp), %rdx
movl 0x44(%rdx), %eax
movq -0x38(%rbp), %rsi
incq %rsi
movslq %eax, %rcx
cmpq %rcx, %rsi
jl 0x2b3ee
jmp 0x2b4a5
xorl %r15d, %r15d
jmp 0x2b4a5
movl 0x30(%rbx), %eax
movl $0x4, %r15d
cmpl $0x1, %eax
je 0x2b4a5
cmpl $0x2, %eax
jne 0x2b64a
movl $0x8, %r15d
movq %r15, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1f9e9(%rip), %rdi     # 0x4aea7
leaq 0x1f435(%rip), %rsi     # 0x4a8fa
leaq 0x1f897(%rip), %rcx     # 0x4ad63
movl $0x726, %edx            # imm = 0x726
callq 0x30a0
leaq 0x1f994(%rip), %rdi     # 0x4ae71
leaq 0x1f416(%rip), %rsi     # 0x4a8fa
leaq 0x1f878(%rip), %rcx     # 0x4ad63
movl $0x724, %edx            # imm = 0x724
callq 0x30a0
leaq 0x1f983(%rip), %rdi     # 0x4ae7f
leaq 0x1f3f7(%rip), %rsi     # 0x4a8fa
leaq 0x1f859(%rip), %rcx     # 0x4ad63
movl $0x725, %edx            # imm = 0x725
callq 0x30a0
leaq 0x161e8(%rip), %rdi     # 0x41703
leaq 0x1f3d8(%rip), %rsi     # 0x4a8fa
leaq 0x1f7df(%rip), %rcx     # 0x4ad08
movl $0x73a, %edx            # imm = 0x73A
callq 0x30a0
leaq 0x162de(%rip), %rdi     # 0x41818
leaq 0x1f3b9(%rip), %rsi     # 0x4a8fa
leaq 0x1f7c0(%rip), %rcx     # 0x4ad08
movl $0x765, %edx            # imm = 0x765
callq 0x30a0
leaq 0x13e07(%rip), %rdi     # 0x3f360
leaq 0x1f39a(%rip), %rsi     # 0x4a8fa
leaq 0x1f7a1(%rip), %rcx     # 0x4ad08
movl $0x77d, %edx            # imm = 0x77D
callq 0x30a0
leaq 0x1f8b4(%rip), %rdi     # 0x4ae2c
leaq 0x1f37b(%rip), %rsi     # 0x4a8fa
leaq 0x1f7dd(%rip), %rcx     # 0x4ad63
movl $0x720, %edx            # imm = 0x720
callq 0x30a0
leaq 0x1f8ad(%rip), %rdi     # 0x4ae44
leaq 0x1f35c(%rip), %rsi     # 0x4a8fa
leaq 0x1f7be(%rip), %rcx     # 0x4ad63
movl $0x721, %edx            # imm = 0x721
callq 0x30a0
leaq 0x1618e(%rip), %rdi     # 0x41744
leaq 0x1f33d(%rip), %rsi     # 0x4a8fa
leaq 0x1f79f(%rip), %rcx     # 0x4ad63
movl $0x706, %edx            # imm = 0x706
callq 0x30a0
leaq 0x1f7e0(%rip), %rdi     # 0x4adb5
leaq 0x1f31e(%rip), %rsi     # 0x4a8fa
leaq 0x1f780(%rip), %rcx     # 0x4ad63
movl $0x709, %edx            # imm = 0x709
callq 0x30a0
leaq 0x16168(%rip), %rdi     # 0x4175c
leaq 0x1f2ff(%rip), %rsi     # 0x4a8fa
leaq 0x1f761(%rip), %rcx     # 0x4ad63
movl $0x70a, %edx            # imm = 0x70A
callq 0x30a0
leaq 0x1f7aa(%rip), %rdi     # 0x4adbd
leaq 0x1f2e0(%rip), %rsi     # 0x4a8fa
leaq 0x1f742(%rip), %rcx     # 0x4ad63
movl $0x712, %edx            # imm = 0x712
callq 0x30a0
leaq 0x1f797(%rip), %rdi     # 0x4adc9
leaq 0x1f2c1(%rip), %rsi     # 0x4a8fa
leaq 0x1f723(%rip), %rcx     # 0x4ad63
movl $0x713, %edx            # imm = 0x713
callq 0x30a0
leaq 0x13d0f(%rip), %rdi     # 0x3f360
leaq 0x1f2a2(%rip), %rsi     # 0x4a8fa
leaq 0x1f6a9(%rip), %rcx     # 0x4ad08
movl $0x775, %edx            # imm = 0x775
callq 0x30a0
leaq 0x1f77d(%rip), %rdi     # 0x4aded
leaq 0x1f283(%rip), %rsi     # 0x4a8fa
leaq 0x1f6e5(%rip), %rcx     # 0x4ad63
movl $0x719, %edx            # imm = 0x719
callq 0x30a0
leaq 0x1f76f(%rip), %rdi     # 0x4adfe
leaq 0x1f264(%rip), %rsi     # 0x4a8fa
leaq 0x1f6c6(%rip), %rcx     # 0x4ad63
movl $0x71a, %edx            # imm = 0x71A
callq 0x30a0