// File: /workspace/github_c_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x400, %rsp            # imm = 0x400
cmpl $0xb70, (%rsi)          # imm = 0xB70
jne 0x34854
movq %rsi, %r14
movq %rdi, %rbx
movq 0x30(%rsi), %rdi
movl $0xa00, %esi            # imm = 0xA00
xorl %edx, %edx
xorl %eax, %eax
callq 0x34e18
movq %rax, %r15
testq %rax, %rax
jne 0x34762
movups 0x19845(%rip), %xmm0    # 0x4df7e
leaq -0x420(%rbp), %rdx
movups %xmm0, 0x1c(%rdx)
movups 0x19827(%rip), %xmm0    # 0x4df72
movaps %xmm0, 0x10(%rdx)
movups 0x1980c(%rip), %xmm0    # 0x4df62
movaps %xmm0, (%rdx)
movq %rbx, %rdi
movq %r14, %rsi
callq *0x58(%rbx)
cmpl $0x4, 0x44(%r15)
jne 0x34773
movq 0x48(%r15), %rax
movq 0x10(%rax), %r15
jmp 0x34776
xorl %r15d, %r15d
movl 0x44(%r14), %eax
cmpl $0x1, %eax
je 0x347c2
testl %eax, %eax
jne 0x34873
testq %r15, %r15
je 0x34844
movups 0x19807(%rip), %xmm0    # 0x4df9e
leaq -0x420(%rbp), %rdx
movaps %xmm0, 0x10(%rdx)
movups 0x197e5(%rip), %xmm0    # 0x4df8e
movaps %xmm0, (%rdx)
movabsq $0x2e6e6f69737365, %rax # imm = 0x2E6E6F69737365
movq %rax, 0x20(%rdx)
movq %rbx, %rdi
movq %r14, %rsi
jmp 0x34841
testq %r15, %r15
jne 0x347f7
movups 0x19808(%rip), %xmm0    # 0x4dfd6
leaq -0x420(%rbp), %rdx
movaps %xmm0, 0x20(%rdx)
movups 0x197e6(%rip), %xmm0    # 0x4dfc6
movaps %xmm0, 0x10(%rdx)
movups 0x197cb(%rip), %xmm0    # 0x4dfb6
movaps %xmm0, (%rdx)
movq %rbx, %rdi
movq %r14, %rsi
callq *0x58(%rbx)
movq 0x48(%r14), %rax
movq (%rax), %r12
movq %rbx, %rdi
movq %r12, %rsi
callq 0x2c76c
movq 0x68(%r12), %rdx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2c7f6
testb %al, %al
jne 0x34844
leaq 0x197c2(%rip), %rsi     # 0x4dfe6
leaq -0x420(%rbp), %r15
movl $0x45, %edx
movq %r15, %rdi
callq 0x3100
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq *0x58(%rbx)
addq $0x400, %rsp            # imm = 0x400
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x196e5(%rip), %rdi     # 0x4df40
leaq 0x16ff8(%rip), %rsi     # 0x4b85a
leaq 0x196a3(%rip), %rcx     # 0x4df0c
movl $0x5b8, %edx            # imm = 0x5B8
callq 0x30a0
leaq 0xbb0a(%rip), %rdi      # 0x40384
leaq 0x16fd9(%rip), %rsi     # 0x4b85a
leaq 0x19684(%rip), %rcx     # 0x4df0c
movl $0x5e6, %edx            # imm = 0x5E6
callq 0x30a0