// File: /workspace/github_c_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x438, %rsp            # imm = 0x438
movq %rcx, -0x30(%rbp)
cmpl $0xd00, (%rsi)          # imm = 0xD00
jne 0x307fd
movq %rsi, %r14
cmpl $0x2, 0x44(%rsi)
jne 0x3081c
testq %rdx, %rdx
je 0x3083b
cmpl $0xd01, (%rdx)          # imm = 0xD01
jne 0x3085a
cmpq $0x0, -0x30(%rbp)
je 0x30879
movq %rdi, %r15
xorl %ecx, %ecx
xorl %ebx, %ebx
movq %rdx, -0x40(%rbp)
movq %r14, -0x38(%rbp)
movslq 0x44(%rdx), %rax
cmpq %rax, %rcx
jge 0x30750
movq 0x48(%rdx), %rax
movq (%rax,%rcx,8), %r12
testq %r12, %r12
je 0x307bf
movq %rcx, -0x48(%rbp)
cmpl $0xc00, (%r12)          # imm = 0xC00
jne 0x307de
xorl %r13d, %r13d
movq %r12, -0x50(%rbp)
movslq 0x44(%r12), %rax
cmpq %rax, %r13
jge 0x30740
movq 0x48(%r12), %rax
movq (%rax,%r13,8), %rax
cmpl $0xc01, (%rax)          # imm = 0xC01
jne 0x30762
movl 0x44(%rax), %ecx
cmpl $0x3, %ecx
je 0x306f3
cmpl $0x2, %ecx
jne 0x30781
movq 0x48(%rax), %rax
movq (%rax), %r12
cmpl $0x200, (%r12)          # imm = 0x200
jne 0x307a0
movq %r13, -0x58(%rbp)
movq %rbx, -0x60(%rbp)
movq 0x8(%rax), %rbx
movb $0x0, -0x460(%rbp)
movq %r15, %rdi
movq %rbx, %rsi
leaq -0x460(%rbp), %rdx
callq 0x2a8eb
cmpb $0x0, 0x68(%r14)
pushq $0x1
popq %r14
jne 0x30697
movq %r15, %rdi
movq -0x38(%rbp), %rsi
movq %rbx, %rdx
callq 0x2a91b
movq %rax, %r14
movq 0x10(%r12), %rdx
movzbl -0x460(%rbp), %ecx
movq %r15, %rdi
movq -0x30(%rbp), %rsi
movq %rbx, %r8
movq -0x60(%rbp), %r12
movq %r12, %r9
callq 0x20fc0
movq %r12, %rax
xorl %edx, %edx
divq %r14
subq %rdx, %r14
testq %rdx, %rdx
cmoveq %rdx, %r14
movq %r15, %rdi
movq -0x38(%rbp), %r13
movq %r13, %rsi
movq %rbx, %rdx
callq 0x27acb
addq %r12, %r14
addq %rax, %r14
movq %r14, %rbx
movq %r13, %r14
movq -0x50(%rbp), %r12
movq -0x58(%rbp), %r13
jmp 0x30738
movups 0x1a692(%rip), %xmm0    # 0x4ad8c
movaps %xmm0, -0x440(%rbp)
movups 0x1a674(%rip), %xmm0    # 0x4ad7c
movaps %xmm0, -0x450(%rbp)
movups 0x1a656(%rip), %xmm0    # 0x4ad6c
movaps %xmm0, -0x460(%rbp)
movl $0x2e6e6f, -0x431(%rbp) # imm = 0x2E6E6F
movq %r15, %rdi
movq %r14, %rsi
leaq -0x460(%rbp), %rdx
callq *0x58(%r15)
incq %r13
jmp 0x30608
movq -0x48(%rbp), %rcx
incq %rcx
movq -0x40(%rbp), %rdx
jmp 0x305d1
addq $0x438, %rsp            # imm = 0x438
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xcf7a(%rip), %rdi      # 0x3d6e3
leaq 0x18a00(%rip), %rsi     # 0x49170
leaq 0x1a521(%rip), %rcx     # 0x4ac98
movl $0xf47, %edx            # imm = 0xF47
callq 0x30a0
leaq 0xabe1(%rip), %rdi      # 0x3b369
leaq 0x189e1(%rip), %rsi     # 0x49170
leaq 0x1a502(%rip), %rcx     # 0x4ac98
movl $0xf73, %edx            # imm = 0xF73
callq 0x30a0
leaq 0x1a59d(%rip), %rdi     # 0x4ad44
leaq 0x189c2(%rip), %rsi     # 0x49170
leaq 0x1a4e3(%rip), %rcx     # 0x4ac98
movl $0xf4b, %edx            # imm = 0xF4B
callq 0x30a0
leaq 0xab41(%rip), %rdi      # 0x3b307
leaq 0x189a3(%rip), %rsi     # 0x49170
leaq 0x1a4c4(%rip), %rcx     # 0x4ac98
movl $0xf43, %edx            # imm = 0xF43
callq 0x30a0
leaq 0xab84(%rip), %rdi      # 0x3b369
leaq 0x18984(%rip), %rsi     # 0x49170
leaq 0x1a4a5(%rip), %rcx     # 0x4ac98
movl $0xf77, %edx            # imm = 0xF77
callq 0x30a0
leaq 0x18f1d(%rip), %rdi     # 0x49721
leaq 0x18965(%rip), %rsi     # 0x49170
leaq 0x1a486(%rip), %rcx     # 0x4ac98
movl $0xf38, %edx            # imm = 0xF38
callq 0x30a0
leaq 0x18de2(%rip), %rdi     # 0x49605
leaq 0x18946(%rip), %rsi     # 0x49170
leaq 0x1a467(%rip), %rcx     # 0x4ac98
movl $0xf39, %edx            # imm = 0xF39
callq 0x30a0
leaq 0x1a4b5(%rip), %rdi     # 0x4acf7
leaq 0x18927(%rip), %rsi     # 0x49170
leaq 0x1a448(%rip), %rcx     # 0x4ac98
movl $0xf3a, %edx            # imm = 0xF3A
callq 0x30a0
leaq 0x1a4a7(%rip), %rdi     # 0x4ad08
leaq 0x18908(%rip), %rsi     # 0x49170
leaq 0x1a429(%rip), %rcx     # 0x4ac98
movl $0xf3b, %edx            # imm = 0xF3B
callq 0x30a0
leaq 0x1a4b6(%rip), %rdi     # 0x4ad36
leaq 0x188e9(%rip), %rsi     # 0x49170
leaq 0x1a40a(%rip), %rcx     # 0x4ac98
movl $0xf3c, %edx            # imm = 0xF3C
callq 0x30a0