// File: /workspace/github_c_makefile_star2_O0/Ihsoh[P]ilang/compiler/backend/semantics.c
// Function: process_struct_member
static void _process_struct_member(
	ParserContext *ctx,
	ParserASTNode *node,
	ParserASTNode *node_struct_body,
	ParserSymbol *symbol_struct
) {
	assert(ctx);
	assert(node);
	assert(node->type == BE_NODE_STRUCT);
	assert(node->nchilds == 2);
	assert(node_struct_body);
	assert(node_struct_body->type == BE_NODE_STRUCT_BODY);
	assert(symbol_struct);

	size_t max_align = 1;
	size_t size = 0;

	for (int i = 0; i < node_struct_body->nchilds; i++) {
		ParserASTNode *child = node_struct_body->childs[i];
		assert(child);
		if (child->type == BE_NODE_VAR) {
			for (int j = 0; j < child->nchilds; j++) {
				ParserASTNode *node_var_item = child->childs[j];
				assert(node_var_item->type == BE_NODE_VAR_ITEM);
				
				if (node_var_item->nchilds == 2) {
					ParserASTNode *node_var_id = node_var_item->childs[0];
					assert(node_var_id->type == BE_NODE_IDENTIFIER);

					ParserASTNode *node_var_type = node_var_item->childs[1];
					uint8_t var_type = 0;
					_type(ctx, node_var_type, &var_type);

					size_t align = 1;
					if (BE_STRUCT_AST_NODE_GET_PACKED(node)) {
						align = 1;
					} else {
						align = _calc_type_align(ctx, node, node_var_type);
					}

					size_t offset = size;

					be_parser_add_struct_member_var_symbol_to_symbol(
						ctx,
						symbol_struct,
						node_var_id->token,
						var_type,
						node_var_type,
						offset
					);

					if (align > max_align) {
						max_align = align;
					}

					if (size % align > 0) {
						size += align - size % align;
					}

					size += _calc_type_size(ctx, node, node_var_type);
				} else if (node_var_item->nchilds == 3) {
					_SYNERR_NODE(
						ctx,
						node,
						"struct variable cannot contain initial expression."
					);
				} else {
					assert(0);
				}
			}
		} else {
			assert(0);
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x490, %rsp            # imm = 0x490
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x5b044
jmp 0x5b063
leaq 0x25116(%rip), %rdi     # 0x80161
leaq 0x2782e(%rip), %rsi     # 0x82880
movl $0xf36, %edx            # imm = 0xF36
leaq 0x2962c(%rip), %rcx     # 0x8468a
callq 0x30a0
cmpq $0x0, -0x10(%rbp)
je 0x5b06c
jmp 0x5b08b
leaq 0x1b4e9(%rip), %rdi     # 0x7655c
leaq 0x27806(%rip), %rsi     # 0x82880
movl $0xf37, %edx            # imm = 0xF37
leaq 0x29604(%rip), %rcx     # 0x8468a
callq 0x30a0
movq -0x10(%rbp), %rax
cmpl $0xd00, (%rax)          # imm = 0xD00
jne 0x5b099
jmp 0x5b0b8
leaq 0x27de7(%rip), %rdi     # 0x82e87
leaq 0x277d9(%rip), %rsi     # 0x82880
movl $0xf38, %edx            # imm = 0xF38
leaq 0x295d7(%rip), %rcx     # 0x8468a
callq 0x30a0
movq -0x10(%rbp), %rax
cmpl $0x2, 0x44(%rax)
jne 0x5b0c4
jmp 0x5b0e3
leaq 0x27c79(%rip), %rdi     # 0x82d44
leaq 0x277ae(%rip), %rsi     # 0x82880
movl $0xf39, %edx            # imm = 0xF39
leaq 0x295ac(%rip), %rcx     # 0x8468a
callq 0x30a0
cmpq $0x0, -0x18(%rbp)
je 0x5b0ec
jmp 0x5b10b
leaq 0x295f6(%rip), %rdi     # 0x846e9
leaq 0x27786(%rip), %rsi     # 0x82880
movl $0xf3a, %edx            # imm = 0xF3A
leaq 0x29584(%rip), %rcx     # 0x8468a
callq 0x30a0
movq -0x18(%rbp), %rax
cmpl $0xd01, (%rax)          # imm = 0xD01
jne 0x5b119
jmp 0x5b138
leaq 0x295da(%rip), %rdi     # 0x846fa
leaq 0x27759(%rip), %rsi     # 0x82880
movl $0xf3b, %edx            # imm = 0xF3B
leaq 0x29557(%rip), %rcx     # 0x8468a
callq 0x30a0
cmpq $0x0, -0x20(%rbp)
je 0x5b141
jmp 0x5b160
leaq 0x295e0(%rip), %rdi     # 0x84728
leaq 0x27731(%rip), %rsi     # 0x82880
movl $0xf3c, %edx            # imm = 0xF3C
leaq 0x2952f(%rip), %rcx     # 0x8468a
callq 0x30a0
movq $0x1, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x44(%rcx), %eax
jge 0x5b3fa
movq -0x18(%rbp), %rax
movq 0x48(%rax), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x5b1a4
jmp 0x5b1c3
leaq 0x1824d(%rip), %rdi     # 0x733f8
leaq 0x276ce(%rip), %rsi     # 0x82880
movl $0xf43, %edx            # imm = 0xF43
leaq 0x294cc(%rip), %rcx     # 0x8468a
callq 0x30a0
movq -0x40(%rbp), %rax
cmpl $0xc00, (%rax)          # imm = 0xC00
jne 0x5b3cb
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
movq -0x40(%rbp), %rcx
cmpl 0x44(%rcx), %eax
jge 0x5b3c9
movq -0x40(%rbp), %rax
movq 0x48(%rax), %rax
movslq -0x44(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
cmpl $0xc01, (%rax)          # imm = 0xC01
jne 0x5b20c
jmp 0x5b22b
leaq 0x1a9db(%rip), %rdi     # 0x75bee
leaq 0x27666(%rip), %rsi     # 0x82880
movl $0xf47, %edx            # imm = 0xF47
leaq 0x29464(%rip), %rcx     # 0x8468a
callq 0x30a0
movq -0x50(%rbp), %rax
cmpl $0x2, 0x44(%rax)
jne 0x5b35e
movq -0x50(%rbp), %rax
movq 0x48(%rax), %rax
movq (%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
cmpl $0x200, (%rax)          # imm = 0x200
jne 0x5b256
jmp 0x5b275
leaq 0x294d9(%rip), %rdi     # 0x84736
leaq 0x2761c(%rip), %rsi     # 0x82880
movl $0xf4b, %edx            # imm = 0xF4B
leaq 0x2941a(%rip), %rcx     # 0x8468a
callq 0x30a0
movq -0x50(%rbp), %rax
movq 0x48(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x60(%rbp)
movb $0x0, -0x61(%rbp)
movq -0x8(%rbp), %rdi
movq -0x60(%rbp), %rsi
leaq -0x61(%rbp), %rdx
callq 0x4f020
movq $0x1, -0x70(%rbp)
movq -0x10(%rbp), %rax
testb $0x1, 0x68(%rax)
je 0x5b2b6
movq $0x1, -0x70(%rbp)
jmp 0x5b2cb
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x60(%rbp), %rdx
callq 0x4f0a0
movq %rax, -0x70(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x58(%rbp), %rax
movq 0x10(%rax), %rdx
movb -0x61(%rbp), %al
movq -0x60(%rbp), %r8
movq -0x78(%rbp), %r9
movzbl %al, %ecx
callq 0x3e770
movq -0x70(%rbp), %rax
cmpq -0x28(%rbp), %rax
jbe 0x5b308
movq -0x70(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x30(%rbp), %rax
xorl %ecx, %ecx
movl %ecx, %edx
divq -0x70(%rbp)
cmpq $0x0, %rdx
jbe 0x5b343
movq -0x70(%rbp), %rax
movq %rax, -0x488(%rbp)
movq -0x30(%rbp), %rax
xorl %ecx, %ecx
movl %ecx, %edx
divq -0x70(%rbp)
movq -0x488(%rbp), %rax
subq %rdx, %rax
addq -0x30(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x60(%rbp), %rdx
callq 0x4d5a0
addq -0x30(%rbp), %rax
movq %rax, -0x30(%rbp)
jmp 0x5b3b9
movq -0x50(%rbp), %rax
cmpl $0x3, 0x44(%rax)
jne 0x5b398
leaq -0x480(%rbp), %rdi
leaq 0x293e8(%rip), %rsi     # 0x8475e
movb $0x0, %al
callq 0x3160
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
leaq -0x480(%rbp), %rdx
callq *%rax
jmp 0x5b3b7
leaq 0x180bb(%rip), %rdi     # 0x7345a
leaq 0x274da(%rip), %rsi     # 0x82880
movl $0xf73, %edx            # imm = 0xF73
leaq 0x292d8(%rip), %rcx     # 0x8468a
callq 0x30a0
jmp 0x5b3b9
jmp 0x5b3bb
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x5b1da
jmp 0x5b3ea
leaq 0x18088(%rip), %rdi     # 0x7345a
leaq 0x274a7(%rip), %rsi     # 0x82880
movl $0xf77, %edx            # imm = 0xF77
leaq 0x292a5(%rip), %rcx     # 0x8468a
callq 0x30a0
jmp 0x5b3ec
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x5b177
addq $0x490, %rsp            # imm = 0x490
popq %rbp
retq
nopw %cs:(%rax,%rax)