// File: /workspace/github_c_makefile_star2_O2/Ihsoh[P]ilang/compiler/frontend/semantics.c
// Function: expr_member_arridx_fncall
static void _expr_member_arridx_fncall(
	ParserContext *ctx,
	ParserASTNode *node
) {
	assert(ctx);
	assert(node);

	switch (node->type) {
		case FE_NODE_EXPR_MEMBER: {
			assert(node->nchilds == 2);

			ParserASTNode *node_expr = node->childs[0];
			ParserASTNode *node_id = node->childs[1];
			_expr_parenthesis(ctx, node_expr);

			if (FE_EXPR_AST_NODE_GET_TYPE(node_expr) != FE_TYPE_STRUCT) {
				_SYNERR_NODE(ctx, node_expr, "need struct type expression.");
			}
			ParserASTNode *struct_type_node = FE_EXPR_AST_NODE_GET_TYPE_NODE(node_expr);
			ParserASTNode *type_node = _get_struct_member_type_node(
				ctx, node, struct_type_node->childs[0]->token, node_id->token
			);
			FE_EXPR_AST_NODE_SET_TYPE(node, _get_type_by_type_node(ctx, type_node));
			FE_EXPR_AST_NODE_SET_TYPE_NODE(node, type_node);

			FE_EXPR_AST_NODE_SET_CONSTANT(node, false);
			break;
		}
		case FE_NODE_EXPR_PMEMBER: {
			assert(node->nchilds == 2);

			ParserASTNode *node_expr = node->childs[0];
			ParserASTNode *node_id = node->childs[1];
			_expr_parenthesis(ctx, node_expr);
			
			if (FE_EXPR_AST_NODE_GET_TYPE(node_expr) != FE_TYPE_POINTER) {
				_SYNERR_NODE(ctx, node_expr, "need struct pointer type expression.");
			}
			ParserASTNode *struct_pointer_type_node = FE_EXPR_AST_NODE_GET_TYPE_NODE(node_expr);
			assert(struct_pointer_type_node);
			ParserASTNode *struct_type_node = struct_pointer_type_node->childs[0];
			if (_get_type_by_type_node(ctx, struct_type_node) != FE_TYPE_STRUCT) {
				_SYNERR_NODE(ctx, node_expr, "need struct pointer type expression.");
			}
			assert(struct_type_node);
			assert(struct_type_node->nchilds == 1);
			assert(struct_type_node->childs[0]);
			assert(struct_type_node->childs[0]->token);
			assert(node_id->token);

			ParserASTNode *type_node = _get_struct_member_type_node(
				ctx, node, struct_type_node->childs[0]->token, node_id->token
			);
			FE_EXPR_AST_NODE_SET_TYPE(node, _get_type_by_type_node(ctx, type_node));
			FE_EXPR_AST_NODE_SET_TYPE_NODE(node, type_node);

			FE_EXPR_AST_NODE_SET_CONSTANT(node, false);
			break;
		}
		case FE_NODE_EXPR_ARRAY_INDEX: {
			assert(node->nchilds == 2);

			ParserASTNode *node_expr = node->childs[0];
			ParserASTNode *node_index = node->childs[1];
			_expr_parenthesis(ctx, node_expr);
			_expr(ctx, node_index);

			uint8_t node_expr_type = FE_EXPR_AST_NODE_GET_TYPE(node_expr);
			if (node_expr_type == FE_TYPE_POINTER) {
				ParserASTNode *node_type = FE_EXPR_AST_NODE_GET_TYPE_NODE(node_expr);
				assert(node_type);
				assert(node_type->nchilds == 1);
				
				FE_EXPR_AST_NODE_SET_TYPE(node, _get_type_by_type_node(ctx, node_type->childs[0]));
				FE_EXPR_AST_NODE_SET_TYPE_NODE(node, node_type->childs[0]);
			} else if (node_expr_type == FE_TYPE_ARRAY) {
				ParserASTNode *node_type = FE_EXPR_AST_NODE_GET_TYPE_NODE(node_expr);
				assert(node_type);
				assert(node_type->nchilds == 2);

				ParserASTNode *node_array_dims = node_type->childs[0];
				ParserASTNode *node_array_type = node_type->childs[1];

				if (node_array_dims->nchilds == 1) {
					FE_EXPR_AST_NODE_SET_TYPE(node, _get_type_by_type_node(ctx, node_array_type));
					FE_EXPR_AST_NODE_SET_TYPE_NODE(node, node_array_type);
				} else if (node_array_dims->nchilds > 1) {
					ParserASTNode *new_node_array_type = _NEW_NODE(ctx, FE_NODE_TYPE_ARRAY, NULL);
					ParserASTNode *new_node_array_dims = _NEW_NODE(ctx, FE_NODE_TYPE_ARRAY_DIMS, NULL);

					for (int32_t i = 1; i < node_array_dims->nchilds; i++) {
						parser_add_child(ctx, new_node_array_dims, node_array_dims->childs[i]);
					}

					parser_add_child(ctx, new_node_array_type, new_node_array_dims);
					parser_add_child(ctx, new_node_array_type, node_array_type);
					FE_EXPR_AST_NODE_SET_TYPE(node, _get_type_by_type_node(ctx, new_node_array_type));
					FE_EXPR_AST_NODE_SET_TYPE_NODE(node, new_node_array_type);
				} else {
					assert(0);
				}
			} else {
				_SYNERR_NODE(ctx, node_expr, "need pointer type or array type expression.");
			}

			FE_EXPR_AST_NODE_SET_CONSTANT(node, false);
			break;
		}
		case FE_NODE_EXPR_FUNC_CALL: {
			assert(node->nchilds == 2);
			
			ParserASTNode *node_expr = node->childs[0];
			ParserASTNode *node_func_params = node->childs[1];

			_expr_parenthesis(ctx, node_expr);

			ParserASTNode *node_expr_type = FE_EXPR_AST_NODE_GET_TYPE_NODE(node_expr);

			if (node_expr_type->type == FE_NODE_TYPE_POINTER
					&& node_expr_type->childs[0]->type == FE_NODE_TYPE_FUNC) {
				ParserASTNode *node_expr_params = node_expr_type->childs[0]->childs[0];

				_check_fncall_params(ctx, node_expr, node_expr_params, node_func_params);

				if (node_expr_type->childs[0]->nchilds == 1) {
					FE_EXPR_AST_NODE_SET_TYPE(node, FE_TYPE_VOID);
					FE_EXPR_AST_NODE_SET_TYPE_NODE(node, _NODE_TYPE_VOID);
				} else {
					ParserASTNode *node_expr_ret_type = node_expr_type->childs[0]->childs[1];
					FE_EXPR_AST_NODE_SET_TYPE(node, _get_type_by_type_node(ctx, node_expr_ret_type));
					FE_EXPR_AST_NODE_SET_TYPE_NODE(node, node_expr_ret_type);
				}
			} else {
				_SYNERR_NODE(ctx, node_expr, "function call need function pointer type.");
			}

			FE_EXPR_AST_NODE_SET_CONSTANT(node, false);
			break;
		}
		default: {
			_expr_parenthesis(ctx, node);
			break;
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x428, %rsp            # imm = 0x428
testq %rsi, %rsi
je 0x2f5e5
movq %rsi, %rbx
movq %rdi, %r14
movl $0xfffff130, %eax       # imm = 0xFFFFF130
addl (%rsi), %eax
cmpl $0x3, %eax
ja 0x2f32c
leaq 0x185d7(%rip), %rcx     # 0x47638
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpl $0x2, 0x44(%rbx)
jne 0x2f642
movq 0x48(%rbx), %rax
movq (%rax), %r15
movq 0x8(%rax), %r12
movq %r14, %rdi
movq %r15, %rsi
callq 0x2f813
cmpb $0xd, 0x60(%r15)
je 0x2f0b7
movups 0x196cd(%rip), %xmm0    # 0x48765
leaq -0x450(%rbp), %rdx
movups %xmm0, 0xd(%rdx)
movups 0x196ae(%rip), %xmm0    # 0x48758
movaps %xmm0, (%rdx)
movq %r14, %rdi
movq %r15, %rsi
callq *0x58(%r14)
movq 0x68(%r15), %rax
movq 0x48(%rax), %rax
movq (%rax), %rax
movq 0x10(%rax), %rdx
movq 0x10(%r12), %rcx
jmp 0x2f307
cmpl $0x2, 0x44(%rbx)
jne 0x2f604
movq 0x48(%rbx), %rax
movq (%rax), %r15
movq 0x8(%rax), %r12
movq %r14, %rdi
movq %r15, %rsi
callq 0x2f813
movq %r14, %rdi
movq %r12, %rsi
callq 0x294d8
movzbl 0x60(%r15), %eax
cmpl $0xe, %eax
je 0x2f36e
cmpl $0x10, %eax
jne 0x2f3b0
movq 0x68(%r15), %r15
testq %r15, %r15
je 0x2f73a
cmpl $0x1, 0x44(%r15)
jne 0x2f778
movq 0x48(%r15), %rax
movq (%rax), %rsi
movq %r14, %rdi
callq 0x285a5
movb %al, 0x60(%rbx)
movq 0x48(%r15), %rax
movq (%rax), %rax
jmp 0x2f5b8
cmpl $0x2, 0x44(%rbx)
jne 0x2f623
movq 0x48(%rbx), %rax
movq (%rax), %r15
movq 0x8(%rax), %r12
movq %r14, %rdi
movq %r15, %rsi
callq 0x2f813
movq 0x68(%r15), %rcx
cmpl $0x440, (%rcx)          # imm = 0x440
jne 0x2f348
movq 0x48(%rcx), %rax
movq (%rax), %rax
cmpl $0x430, (%rax)          # imm = 0x430
jne 0x2f348
movq 0x48(%rax), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x2f7b6
testq %r12, %r12
je 0x2f7d5
movq %rcx, -0x40(%rbp)
movl 0x44(%r12), %ecx
movl 0x44(%rdi), %eax
testl %eax, %eax
jle 0x2f1d7
movq 0x48(%rdi), %rdx
leal -0x1(%rax), %esi
movq (%rdx,%rsi,8), %rdx
cmpl $0xa03, (%rdx)          # imm = 0xA03
sete %dl
cmpl %esi, %ecx
setge %sil
testb %sil, %dl
jne 0x2f46a
cmpl %eax, %ecx
je 0x2f46a
movups 0x19826(%rip), %xmm0    # 0x48a0c
leaq -0x450(%rbp), %rdx
movups %xmm0, 0x1b(%rdx)
movups 0x19809(%rip), %xmm0    # 0x48a01
movaps %xmm0, 0x10(%rdx)
movups 0x197ee(%rip), %xmm0    # 0x489f1
movaps %xmm0, (%rdx)
movq %r14, %rdi
movq %r15, %rsi
callq *0x58(%r14)
jmp 0x2f59c
cmpl $0x2, 0x44(%rbx)
jne 0x2f661
movq 0x48(%rbx), %rax
movq (%rax), %r15
movq 0x8(%rax), %r13
movq %r14, %rdi
movq %r15, %rsi
callq 0x2f813
cmpb $0x10, 0x60(%r15)
movabsq $0x2e6e6f69737365, %rax # imm = 0x2E6E6F69737365
je 0x2f270
movups 0x19538(%rip), %xmm0    # 0x48785
leaq -0x450(%rbp), %rdx
movaps %xmm0, 0x10(%rdx)
movups 0x19516(%rip), %xmm0    # 0x48775
movaps %xmm0, (%rdx)
movq %rax, 0x1d(%rdx)
movq %r14, %rdi
movq %r15, %rsi
callq *0x58(%r14)
movq 0x68(%r15), %rax
testq %rax, %rax
je 0x2f680
movq 0x48(%rax), %rax
movq (%rax), %r12
movq %r14, %rdi
movq %r12, %rsi
callq 0x285a5
cmpb $0xd, %al
je 0x2f2c7
movups 0x194eb(%rip), %xmm0    # 0x48785
leaq -0x450(%rbp), %rdx
movaps %xmm0, 0x10(%rdx)
movups 0x194c9(%rip), %xmm0    # 0x48775
movaps %xmm0, (%rdx)
movabsq $0x2e6e6f69737365, %rax # imm = 0x2E6E6F69737365
movq %rax, 0x1d(%rdx)
movq %r14, %rdi
movq %r15, %rsi
callq *0x58(%r14)
testq %r12, %r12
je 0x2f69f
cmpl $0x1, 0x44(%r12)
jne 0x2f6be
movq 0x48(%r12), %rax
movq (%rax), %rax
testq %rax, %rax
je 0x2f6dd
movq 0x10(%rax), %rdx
testq %rdx, %rdx
je 0x2f6fc
movq 0x10(%r13), %rcx
testq %rcx, %rcx
je 0x2f71b
movq %r14, %rdi
movq %rbx, %rsi
callq 0x28150
movq %rax, %r15
movq %r14, %rdi
movq %rax, %rsi
callq 0x285a5
movb %al, 0x60(%rbx)
movq %r15, 0x68(%rbx)
jmp 0x2f5bc
movq %r14, %rdi
movq %rbx, %rsi
addq $0x428, %rsp            # imm = 0x428
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2f813
movups 0x19528(%rip), %xmm0    # 0x48877
leaq -0x450(%rbp), %rdx
movups %xmm0, 0x1a(%rdx)
movups 0x1950c(%rip), %xmm0    # 0x4886d
movaps %xmm0, 0x10(%rdx)
movups 0x194f1(%rip), %xmm0    # 0x4885d
jmp 0x2f3d4
movq 0x68(%r15), %rax
testq %rax, %rax
je 0x2f759
cmpl $0x2, 0x44(%rax)
jne 0x2f797
movq 0x48(%rax), %rax
movq (%rax), %r15
movq 0x8(%rax), %r12
movl 0x44(%r15), %eax
cmpl $0x1, %eax
jne 0x2f3e6
movq %r14, %rdi
movq %r12, %rsi
callq 0x285a5
movb %al, 0x60(%rbx)
movq %r12, 0x68(%rbx)
jmp 0x2f5bc
movups 0x19496(%rip), %xmm0    # 0x4884d
leaq -0x450(%rbp), %rdx
movups %xmm0, 0x1c(%rdx)
movups 0x19478(%rip), %xmm0    # 0x48841
movaps %xmm0, 0x10(%rdx)
movups 0x1945d(%rip), %xmm0    # 0x48831
movaps %xmm0, (%rdx)
movq %r14, %rdi
movq %r15, %rsi
callq *0x58(%r14)
jmp 0x2f5bc
movq %r12, -0x30(%rbp)
jle 0x2f7f4
leaq 0x171e1(%rip), %rdx     # 0x465d8
movq %r14, %rdi
movl $0x420, %esi            # imm = 0x420
callq 0x2e924
movq %rax, -0x38(%rbp)
leaq 0xf39a(%rip), %rdx      # 0x3e7a9
movq %r14, %rdi
movl $0x421, %esi            # imm = 0x421
callq 0x2e924
movq %rax, %r13
pushq $0x1
popq %r12
movslq 0x44(%r15), %rax
cmpq %rax, %r12
jge 0x2f444
movq 0x48(%r15), %rax
movq (%rax,%r12,8), %rdx
movq %r14, %rdi
movq %r13, %rsi
callq 0x63c4
incq %r12
jmp 0x2f423
movq %r14, %rdi
movq -0x38(%rbp), %r15
movq %r15, %rsi
movq %r13, %rdx
callq 0x63c4
movq %r14, %rdi
movq %r15, %rsi
movq -0x30(%rbp), %rdx
callq 0x63c4
jmp 0x2f5da
movq %r15, -0x48(%rbp)
xorl %r13d, %r13d
movq %r12, -0x30(%rbp)
movq %rdi, -0x38(%rbp)
cltq
cmpq %rax, %r13
jge 0x2f592
movq 0x48(%rdi), %rax
movq (%rax,%r13,8), %r15
cmpl $0xa03, (%r15)          # imm = 0xA03
je 0x2f592
movq 0x48(%r12), %rax
movq (%rax,%r13,8), %r12
movq %r14, %rdi
movq %r12, %rsi
callq 0x2f813
movb 0x60(%r12), %al
addb $-0xd, %al
cmpb $0x2, %al
ja 0x2f4df
leaq -0x450(%rbp), %rdi
leaq 0x194b3(%rip), %rsi     # 0x48979
pushq $0x4d
popq %rdx
callq 0x3100
movq %r14, %rdi
movq %r12, %rsi
leaq -0x450(%rbp), %rdx
callq *0x58(%r14)
movq 0x48(%r15), %rax
movq 0x8(%rax), %rsi
movq 0x68(%r12), %rdx
movq %r14, %rdi
callq 0x29c4c
testb %al, %al
jne 0x2f534
movups 0x194e2(%rip), %xmm0    # 0x489e1
movups %xmm0, -0x435(%rbp)
movups 0x194c9(%rip), %xmm0    # 0x489d6
movaps %xmm0, -0x440(%rbp)
movups 0x194ab(%rip), %xmm0    # 0x489c6
movaps %xmm0, -0x450(%rbp)
movq %r14, %rdi
movq -0x48(%rbp), %rsi
leaq -0x450(%rbp), %rdx
callq *0x58(%r14)
incq %r13
movq -0x38(%rbp), %rdi
movl 0x44(%rdi), %eax
movq -0x30(%rbp), %r12
jmp 0x2f479
movq 0x48(%r12), %rax
movq (%rax,%r13,8), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x2f813
movb 0x60(%r15), %al
addb $-0xd, %al
cmpb $0x2, %al
ja 0x2f58f
leaq 0x1940d(%rip), %rsi     # 0x48979
leaq -0x450(%rbp), %r12
pushq $0x4d
popq %rdx
movq %r12, %rdi
callq 0x3100
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
movq -0x30(%rbp), %r12
callq *0x58(%r14)
incq %r13
movslq 0x44(%r12), %rax
cmpq %rax, %r13
jl 0x2f547
movq -0x40(%rbp), %rax
movq 0x48(%rax), %rax
movq (%rax), %rax
cmpl $0x1, 0x44(%rax)
jne 0x2f5d2
movb $-0x1, 0x60(%rbx)
leaq 0x264d0(%rip), %rax     # 0x55a88
movq %rax, 0x68(%rbx)
movb $0x0, 0x70(%rbx)
addq $0x428, %rsp            # imm = 0x428
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x48(%rax), %rax
movq 0x8(%rax), %r15
movq %r14, %rdi
movq %r15, %rsi
jmp 0x2f31b
leaq 0x10806(%rip), %rdi     # 0x3fdf2
leaq 0x18347(%rip), %rsi     # 0x4793a
leaq 0x1911c(%rip), %rcx     # 0x48716
movl $0xd1d, %edx            # imm = 0xD1D
callq 0x30a0
leaq 0x1872a(%rip), %rdi     # 0x47d35
leaq 0x18328(%rip), %rsi     # 0x4793a
leaq 0x190fd(%rip), %rcx     # 0x48716
movl $0xd54, %edx            # imm = 0xD54
callq 0x30a0
leaq 0x1870b(%rip), %rdi     # 0x47d35
leaq 0x18309(%rip), %rsi     # 0x4793a
leaq 0x190de(%rip), %rcx     # 0x48716
movl $0xd85, %edx            # imm = 0xD85
callq 0x30a0
leaq 0x186ec(%rip), %rdi     # 0x47d35
leaq 0x182ea(%rip), %rsi     # 0x4793a
leaq 0x190bf(%rip), %rcx     # 0x48716
movl $0xd21, %edx            # imm = 0xD21
callq 0x30a0
leaq 0x186cd(%rip), %rdi     # 0x47d35
leaq 0x182cb(%rip), %rsi     # 0x4793a
leaq 0x190a0(%rip), %rcx     # 0x48716
movl $0xd35, %edx            # imm = 0xD35
callq 0x30a0
leaq 0x19113(%rip), %rdi     # 0x4879a
leaq 0x182ac(%rip), %rsi     # 0x4793a
leaq 0x19081(%rip), %rcx     # 0x48716
movl $0xd3f, %edx            # imm = 0xD3F
callq 0x30a0
leaq 0x1910d(%rip), %rdi     # 0x487b3
leaq 0x1828d(%rip), %rsi     # 0x4793a
leaq 0x19062(%rip), %rcx     # 0x48716
movl $0xd44, %edx            # imm = 0xD44
callq 0x30a0
leaq 0x190ff(%rip), %rdi     # 0x487c4
leaq 0x1826e(%rip), %rsi     # 0x4793a
leaq 0x19043(%rip), %rcx     # 0x48716
movl $0xd45, %edx            # imm = 0xD45
callq 0x30a0
leaq 0x190ff(%rip), %rdi     # 0x487e3
leaq 0x1824f(%rip), %rsi     # 0x4793a
leaq 0x19024(%rip), %rcx     # 0x48716
movl $0xd46, %edx            # imm = 0xD46
callq 0x30a0
leaq 0x190fc(%rip), %rdi     # 0x487ff
leaq 0x18230(%rip), %rsi     # 0x4793a
leaq 0x19005(%rip), %rcx     # 0x48716
movl $0xd47, %edx            # imm = 0xD47
callq 0x30a0
leaq 0x19100(%rip), %rdi     # 0x48822
leaq 0x18211(%rip), %rsi     # 0x4793a
leaq 0x18fe6(%rip), %rcx     # 0x48716
movl $0xd48, %edx            # imm = 0xD48
callq 0x30a0
leaq 0xefd2(%rip), %rdi      # 0x3e713
leaq 0x181f2(%rip), %rsi     # 0x4793a
leaq 0x18fc7(%rip), %rcx     # 0x48716
movl $0xd5e, %edx            # imm = 0xD5E
callq 0x30a0
leaq 0xefb3(%rip), %rdi      # 0x3e713
leaq 0x181d3(%rip), %rsi     # 0x4793a
leaq 0x18fa8(%rip), %rcx     # 0x48716
movl $0xd65, %edx            # imm = 0xD65
callq 0x30a0
leaq 0xefd5(%rip), %rdi      # 0x3e754
leaq 0x181b4(%rip), %rsi     # 0x4793a
leaq 0x18f89(%rip), %rcx     # 0x48716
movl $0xd5f, %edx            # imm = 0xD5F
callq 0x30a0
leaq 0xf08a(%rip), %rdi      # 0x3e828
leaq 0x18195(%rip), %rsi     # 0x4793a
leaq 0x18f6a(%rip), %rcx     # 0x48716
movl $0xd66, %edx            # imm = 0xD66
callq 0x30a0
leaq 0x191a7(%rip), %rdi     # 0x48964
leaq 0x18176(%rip), %rsi     # 0x4793a
leaq 0x1913b(%rip), %rcx     # 0x48906
movl $0xcda, %edx            # imm = 0xCDA
callq 0x30a0
leaq 0x1134b(%rip), %rdi     # 0x40b27
leaq 0x18157(%rip), %rsi     # 0x4793a
leaq 0x1911c(%rip), %rcx     # 0x48906
movl $0xcdb, %edx            # imm = 0xCDB
callq 0x30a0
leaq 0xcb65(%rip), %rdi      # 0x3c360
leaq 0x18138(%rip), %rsi     # 0x4793a
leaq 0x18f0d(%rip), %rcx     # 0x48716
movl $0xd7b, %edx            # imm = 0xD7B
callq 0x30a0