// File: /workspace/github_c_makefile_star2_O0/Ihsoh[P]ilang/compiler/frontend/semantics.c
// Function: stat_return
static void _stat_return(
	ParserContext *ctx,
	ParserASTNode *node
) {
	assert(ctx);
	assert(node);
	assert(node->type == FE_NODE_STAT_RETURN);

	ParserASTNode *node_func = _search_node_along_parent(node->parent, FE_NODE_FUNC, 0);
	if (node_func == NULL) {
		_SYNERR_NODE(
			ctx,
			node,
			"statement 'return' must be use in function."
		);
	}

	ParserASTNode *node_return_type = NULL;
	if (node_func->nchilds == 4) {
		node_return_type = node_func->childs[2];
	}

	if (node->nchilds == 0) {
		if (node_return_type != NULL) {
			_SYNERR_NODE(
				ctx,
				node,
				"statement 'return' requires expression."
			);
		}
	} else if (node->nchilds == 1) {
		if (node_return_type == NULL) {
			_SYNERR_NODE(
				ctx,
				node,
				"statement 'return' does not require expression."
			);
		}

		ParserASTNode *node_return_expr = node->childs[0];
		_expr_wrapper(ctx, node_return_expr);

		if (!_is_compatible_type_for_assign(
			ctx, node_return_type, FE_EXPR_AST_NODE_GET_TYPE_NODE(node_return_expr), false
		)) {
			_SYNERR_NODE(
				ctx,
				node,
				"statement 'return' expression type not matched function return type."
			);
		}
	} else {
		assert(0);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1040, %rsp           # imm = 0x1040
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x5e4ac
jmp 0x5e4cb
leaq 0x1e0a3(%rip), %rdi     # 0x7c556
leaq 0x1fd90(%rip), %rsi     # 0x7e24a
movl $0x5b6, %edx            # imm = 0x5B6
leaq 0x2262e(%rip), %rcx     # 0x80af4
callq 0x30a0
cmpq $0x0, -0x10(%rbp)
je 0x5e4d4
jmp 0x5e4f3
leaq 0x17af8(%rip), %rdi     # 0x75fd3
leaq 0x1fd68(%rip), %rsi     # 0x7e24a
movl $0x5b7, %edx            # imm = 0x5B7
leaq 0x22606(%rip), %rcx     # 0x80af4
callq 0x30a0
movq -0x10(%rbp), %rax
cmpl $0xb70, (%rax)          # imm = 0xB70
jne 0x5e501
jmp 0x5e520
leaq 0x22620(%rip), %rdi     # 0x80b28
leaq 0x1fd3b(%rip), %rsi     # 0x7e24a
movl $0x5b8, %edx            # imm = 0x5B8
leaq 0x225d9(%rip), %rcx     # 0x80af4
callq 0x30a0
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rdi
movl $0xa00, %esi            # imm = 0xA00
xorl %edx, %edx
movb $0x0, %al
callq 0x5f190
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x5e56f
leaq -0x420(%rbp), %rdi
leaq 0x225fb(%rip), %rsi     # 0x80b4a
movb $0x0, %al
callq 0x3160
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
leaq -0x420(%rbp), %rdx
callq *%rax
movq $0x0, -0x428(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x4, 0x44(%rax)
jne 0x5e597
movq -0x18(%rbp), %rax
movq 0x48(%rax), %rax
movq 0x10(%rax), %rax
movq %rax, -0x428(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x44(%rax)
jne 0x5e5de
cmpq $0x0, -0x428(%rbp)
je 0x5e5d9
leaq -0x830(%rbp), %rdi
leaq 0x225bd(%rip), %rsi     # 0x80b76
movb $0x0, %al
callq 0x3160
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
leaq -0x830(%rbp), %rdx
callq *%rax
jmp 0x5e6b8
movq -0x10(%rbp), %rax
cmpl $0x1, 0x44(%rax)
jne 0x5e697
cmpq $0x0, -0x428(%rbp)
jne 0x5e624
leaq -0xc30(%rbp), %rdi
leaq 0x2259a(%rip), %rsi     # 0x80b9e
movb $0x0, %al
callq 0x3160
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
leaq -0xc30(%rbp), %rdx
callq *%rax
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq (%rax), %rax
movq %rax, -0xc38(%rbp)
movq -0x8(%rbp), %rdi
movq -0xc38(%rbp), %rsi
callq 0x4f680
movq -0x8(%rbp), %rdi
movq -0x428(%rbp), %rsi
movq -0xc38(%rbp), %rax
movq 0x68(%rax), %rdx
xorl %ecx, %ecx
callq 0x4f750
testb $0x1, %al
jne 0x5e695
leaq -0x1040(%rbp), %rdi
leaq 0x22559(%rip), %rsi     # 0x80bce
movb $0x0, %al
callq 0x3160
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
leaq -0x1040(%rbp), %rdx
callq *%rax
jmp 0x5e6b6
leaq 0x13dbd(%rip), %rdi     # 0x7245b
leaq 0x1fba5(%rip), %rsi     # 0x7e24a
movl $0x5e6, %edx            # imm = 0x5E6
leaq 0x22443(%rip), %rcx     # 0x80af4
callq 0x30a0
jmp 0x5e6b8
addq $0x1040, %rsp           # imm = 0x1040
popq %rbp
retq
nopw %cs:(%rax,%rax)