// File: /workspace/github_c_makefile_star2_O3/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 0x33a49
movq %rsi, %r14
movq %rdi, %rbx
movq 0x30(%rsi), %rdi
movl $0xa00, %esi            # imm = 0xA00
xorl %edx, %edx
xorl %eax, %eax
callq 0x33ffb
movq %rax, %r15
testq %rax, %rax
jne 0x33957
movups 0x19699(%rip), %xmm0    # 0x4cfc7
leaq -0x420(%rbp), %rdx
movups %xmm0, 0x1c(%rdx)
movups 0x1967b(%rip), %xmm0    # 0x4cfbb
movaps %xmm0, 0x10(%rdx)
movups 0x19660(%rip), %xmm0    # 0x4cfab
movaps %xmm0, (%rdx)
movq %rbx, %rdi
movq %r14, %rsi
callq *0x58(%rbx)
cmpl $0x4, 0x44(%r15)
jne 0x33968
movq 0x48(%r15), %rax
movq 0x10(%rax), %r15
jmp 0x3396b
xorl %r15d, %r15d
movl 0x44(%r14), %eax
cmpl $0x1, %eax
je 0x339b7
testl %eax, %eax
jne 0x33a68
testq %r15, %r15
je 0x33a39
movups 0x1965b(%rip), %xmm0    # 0x4cfe7
leaq -0x420(%rbp), %rdx
movaps %xmm0, 0x10(%rdx)
movups 0x19639(%rip), %xmm0    # 0x4cfd7
movaps %xmm0, (%rdx)
movabsq $0x2e6e6f69737365, %rax # imm = 0x2E6E6F69737365
movq %rax, 0x20(%rdx)
movq %rbx, %rdi
movq %r14, %rsi
jmp 0x33a36
testq %r15, %r15
jne 0x339ec
movups 0x1965c(%rip), %xmm0    # 0x4d01f
leaq -0x420(%rbp), %rdx
movaps %xmm0, 0x20(%rdx)
movups 0x1963a(%rip), %xmm0    # 0x4d00f
movaps %xmm0, 0x10(%rdx)
movups 0x1961f(%rip), %xmm0    # 0x4cfff
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 0x2bd91
movq 0x68(%r12), %rdx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2be1b
testb %al, %al
jne 0x33a39
leaq 0x19616(%rip), %rsi     # 0x4d02f
leaq -0x420(%rbp), %r15
movl $0x45, %edx
movq %r15, %rdi
callq 0x3110
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 0x19539(%rip), %rdi     # 0x4cf89
leaq 0x16ea3(%rip), %rsi     # 0x4a8fa
leaq 0x194f7(%rip), %rcx     # 0x4cf55
movl $0x5b8, %edx            # imm = 0x5B8
callq 0x30a0
leaq 0xb8f1(%rip), %rdi      # 0x3f360
leaq 0x16e84(%rip), %rsi     # 0x4a8fa
leaq 0x194d8(%rip), %rcx     # 0x4cf55
movl $0x5e6, %edx            # imm = 0x5E6
callq 0x30a0