// File: /workspace/github_c_makefile_star2_O0/Ihsoh[P]ilang/compiler/frontend/semantics.c
// Function: calc_struct_type_align
static size_t _calc_struct_type_align(
	ParserContext *ctx,
	ParserASTNode *node,
	ParserASTNode *node_type
) {
	assert(ctx);
	assert(node);
	assert(node_type);
	assert(node_type->type == FE_NODE_TYPE_STRUCT);
	assert(node_type->nchilds == 1);

	ParserASTNode *node_id = node_type->childs[0];
	assert(node_id);
	assert(node_id->type == FE_NODE_IDENTIFIER);

	ParserSymbol *struct_symbol = parser_get_symbol_from_node(ctx, node, FE_SYM_STRUCT, node_id->token);
	if (struct_symbol == NULL) {
		_SYNERR_TOKEN(ctx, node_id->token, "undefined struct.");
	}

	ParserASTNode *struct_node = FE_STRUCT_SYMBOL_GET_STRUCT_NODE(struct_symbol);
	assert(struct_node);
	assert(struct_node->type == FE_NODE_STRUCT);
	if (FE_STRUCT_AST_NODE_GET_PACKED(struct_node)) {
		return 1;
	}

	ParserASTNode *struct_body_node = FE_STRUCT_SYMBOL_GET_BODY_NODE(struct_symbol);
	assert(struct_body_node);
	assert(struct_body_node->type == FE_NODE_STRUCT_BODY);

	size_t max_align = 1;

	for (int i = 0; i < struct_body_node->nchilds; i++) {
		ParserASTNode *struct_body_member_node = struct_body_node->childs[i];
		assert(struct_body_member_node);
		assert(struct_body_member_node->type == FE_NODE_VAR);
		for (int j = 0; j < struct_body_member_node->nchilds; j++) {
			ParserASTNode *var_item_node = struct_body_member_node->childs[j];
			assert(var_item_node);
			assert(var_item_node->type == FE_NODE_VAR_ITEM);
			assert(var_item_node->nchilds >= 2);

			ParserASTNode *node_var_type = var_item_node->childs[1];
			size_t align = _calc_type_align(ctx, node, node_var_type);
			if (align > max_align) {
				max_align = align;
			}
		}
	}

	return max_align;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x50210
jmp 0x5022f
leaq 0x2c33f(%rip), %rdi     # 0x7c556
leaq 0x2e02c(%rip), %rsi     # 0x7e24a
movl $0x702, %edx            # imm = 0x702
leaq 0x2e4b8(%rip), %rcx     # 0x7e6e2
callq 0x30a0
cmpq $0x0, -0x18(%rbp)
je 0x50238
jmp 0x50257
leaq 0x25d94(%rip), %rdi     # 0x75fd3
leaq 0x2e004(%rip), %rsi     # 0x7e24a
movl $0x703, %edx            # imm = 0x703
leaq 0x2e490(%rip), %rcx     # 0x7e6e2
callq 0x30a0
cmpq $0x0, -0x20(%rbp)
je 0x50260
jmp 0x5027f
leaq 0x244cc(%rip), %rdi     # 0x74733
leaq 0x2dfdc(%rip), %rsi     # 0x7e24a
movl $0x704, %edx            # imm = 0x704
leaq 0x2e468(%rip), %rcx     # 0x7e6e2
callq 0x30a0
movq -0x20(%rbp), %rax
cmpl $0x410, (%rax)          # imm = 0x410
jne 0x5028d
jmp 0x502ac
leaq 0x24d8d(%rip), %rdi     # 0x75021
leaq 0x2dfaf(%rip), %rsi     # 0x7e24a
movl $0x705, %edx            # imm = 0x705
leaq 0x2e43b(%rip), %rcx     # 0x7e6e2
callq 0x30a0
movq -0x20(%rbp), %rax
cmpl $0x1, 0x44(%rax)
jne 0x502b8
jmp 0x502d7
leaq 0x244b5(%rip), %rdi     # 0x74774
leaq 0x2df84(%rip), %rsi     # 0x7e24a
movl $0x706, %edx            # imm = 0x706
leaq 0x2e410(%rip), %rcx     # 0x7e6e2
callq 0x30a0
movq -0x20(%rbp), %rax
movq 0x48(%rax), %rax
movq (%rax), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x502ef
jmp 0x5030e
leaq 0x2e43e(%rip), %rdi     # 0x7e734
leaq 0x2df4d(%rip), %rsi     # 0x7e24a
movl $0x709, %edx            # imm = 0x709
leaq 0x2e3d9(%rip), %rcx     # 0x7e6e2
callq 0x30a0
movq -0x28(%rbp), %rax
cmpl $0x200, (%rax)          # imm = 0x200
jne 0x5031c
jmp 0x5033b
leaq 0x24469(%rip), %rdi     # 0x7478c
leaq 0x2df20(%rip), %rsi     # 0x7e24a
movl $0x70a, %edx            # imm = 0x70A
leaq 0x2e3ac(%rip), %rcx     # 0x7e6e2
callq 0x30a0
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rcx
movl $0x2, %edx
callq 0x82f0
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x5037d
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rcx
movq 0x10(%rcx), %rsi
leaq 0x2e297(%rip), %rdx     # 0x7e612
callq *%rax
movq -0x30(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x50392
jmp 0x503b1
leaq 0x2e3a3(%rip), %rdi     # 0x7e73c
leaq 0x2deaa(%rip), %rsi     # 0x7e24a
movl $0x712, %edx            # imm = 0x712
leaq 0x2e336(%rip), %rcx     # 0x7e6e2
callq 0x30a0
movq -0x38(%rbp), %rax
cmpl $0xd00, (%rax)          # imm = 0xD00
jne 0x503bf
jmp 0x503de
leaq 0x2e382(%rip), %rdi     # 0x7e748
leaq 0x2de7d(%rip), %rsi     # 0x7e24a
movl $0x713, %edx            # imm = 0x713
leaq 0x2e309(%rip), %rcx     # 0x7e6e2
callq 0x30a0
movq -0x38(%rbp), %rax
testb $0x1, 0x68(%rax)
je 0x503f5
movq $0x1, -0x8(%rbp)
jmp 0x505e8
movq -0x30(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x5040a
jmp 0x50429
leaq 0x2e35b(%rip), %rdi     # 0x7e76c
leaq 0x2de32(%rip), %rsi     # 0x7e24a
movl $0x719, %edx            # imm = 0x719
leaq 0x2e2be(%rip), %rcx     # 0x7e6e2
callq 0x30a0
movq -0x40(%rbp), %rax
cmpl $0xd01, (%rax)          # imm = 0xD01
jne 0x50437
jmp 0x50456
leaq 0x2e33f(%rip), %rdi     # 0x7e77d
leaq 0x2de05(%rip), %rsi     # 0x7e24a
movl $0x71a, %edx            # imm = 0x71A
leaq 0x2e291(%rip), %rcx     # 0x7e6e2
callq 0x30a0
movq $0x1, -0x48(%rbp)
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
movq -0x40(%rbp), %rcx
cmpl 0x44(%rcx), %eax
jge 0x505e0
movq -0x40(%rbp), %rax
movq 0x48(%rax), %rax
movslq -0x4c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
je 0x50492
jmp 0x504b1
leaq 0x2e312(%rip), %rdi     # 0x7e7ab
leaq 0x2ddaa(%rip), %rsi     # 0x7e24a
movl $0x720, %edx            # imm = 0x720
leaq 0x2e236(%rip), %rcx     # 0x7e6e2
callq 0x30a0
movq -0x58(%rbp), %rax
cmpl $0xc00, (%rax)          # imm = 0xC00
jne 0x504bf
jmp 0x504de
leaq 0x2e2fd(%rip), %rdi     # 0x7e7c3
leaq 0x2dd7d(%rip), %rsi     # 0x7e24a
movl $0x721, %edx            # imm = 0x721
leaq 0x2e209(%rip), %rcx     # 0x7e6e2
callq 0x30a0
movl $0x0, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
movq -0x58(%rbp), %rcx
cmpl 0x44(%rcx), %eax
jge 0x505d0
movq -0x58(%rbp), %rax
movq 0x48(%rax), %rax
movslq -0x5c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x68(%rbp)
cmpq $0x0, -0x68(%rbp)
je 0x50512
jmp 0x50531
leaq 0x2e2d7(%rip), %rdi     # 0x7e7f0
leaq 0x2dd2a(%rip), %rsi     # 0x7e24a
movl $0x724, %edx            # imm = 0x724
leaq 0x2e1b6(%rip), %rcx     # 0x7e6e2
callq 0x30a0
movq -0x68(%rbp), %rax
cmpl $0xc01, (%rax)          # imm = 0xC01
jne 0x5053f
jmp 0x5055e
leaq 0x2e2b8(%rip), %rdi     # 0x7e7fe
leaq 0x2dcfd(%rip), %rsi     # 0x7e24a
movl $0x725, %edx            # imm = 0x725
leaq 0x2e189(%rip), %rcx     # 0x7e6e2
callq 0x30a0
movq -0x68(%rbp), %rax
cmpl $0x2, 0x44(%rax)
jl 0x5056a
jmp 0x50589
leaq 0x2e2b5(%rip), %rdi     # 0x7e826
leaq 0x2dcd2(%rip), %rsi     # 0x7e24a
movl $0x726, %edx            # imm = 0x726
leaq 0x2e15e(%rip), %rcx     # 0x7e6e2
callq 0x30a0
movq -0x68(%rbp), %rax
movq 0x48(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x70(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x70(%rbp), %rdx
callq 0x4f150
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
cmpq -0x48(%rbp), %rax
jbe 0x505c0
movq -0x78(%rbp), %rax
movq %rax, -0x48(%rbp)
jmp 0x505c2
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x504e5
jmp 0x505d2
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x50465
movq -0x48(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)