// File: /workspace/github_c_makefile_star2_O2/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 0x3157b
movq %rsi, %r14
movq %rdi, %rbx
movq 0x30(%rsi), %rdi
movl $0xa00, %esi            # imm = 0xA00
xorl %edx, %edx
xorl %eax, %eax
callq 0x31b06
movq %rax, %r15
testq %rax, %rax
jne 0x3148b
movups 0x18ba5(%rip), %xmm0    # 0x4a007
leaq -0x420(%rbp), %rdx
movups %xmm0, 0x1c(%rdx)
movups 0x18b87(%rip), %xmm0    # 0x49ffb
movaps %xmm0, 0x10(%rdx)
movups 0x18b6c(%rip), %xmm0    # 0x49feb
movaps %xmm0, (%rdx)
movq %rbx, %rdi
movq %r14, %rsi
callq *0x58(%rbx)
cmpl $0x4, 0x44(%r15)
jne 0x3149c
movq 0x48(%r15), %rax
movq 0x10(%rax), %r15
jmp 0x3149f
xorl %r15d, %r15d
movl 0x44(%r14), %eax
cmpl $0x1, %eax
je 0x314eb
testl %eax, %eax
jne 0x3159a
testq %r15, %r15
je 0x3156b
movups 0x18b67(%rip), %xmm0    # 0x4a027
leaq -0x420(%rbp), %rdx
movaps %xmm0, 0x10(%rdx)
movups 0x18b45(%rip), %xmm0    # 0x4a017
movaps %xmm0, (%rdx)
movabsq $0x2e6e6f69737365, %rax # imm = 0x2E6E6F69737365
movq %rax, 0x20(%rdx)
movq %rbx, %rdi
movq %r14, %rsi
jmp 0x31568
testq %r15, %r15
jne 0x31520
movups 0x18b68(%rip), %xmm0    # 0x4a05f
leaq -0x420(%rbp), %rdx
movaps %xmm0, 0x20(%rdx)
movups 0x18b46(%rip), %xmm0    # 0x4a04f
movaps %xmm0, 0x10(%rdx)
movups 0x18b2b(%rip), %xmm0    # 0x4a03f
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 0x29bc2
movq 0x68(%r12), %rdx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x29c4c
testb %al, %al
jne 0x3156b
leaq 0x18b22(%rip), %rsi     # 0x4a06f
leaq -0x420(%rbp), %r15
pushq $0x45
popq %rdx
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 0x18a47(%rip), %rdi     # 0x49fc9
leaq 0x163b1(%rip), %rsi     # 0x4793a
leaq 0x18a05(%rip), %rcx     # 0x49f95
movl $0x5b8, %edx            # imm = 0x5B8
callq 0x30a0
leaq 0xadbf(%rip), %rdi      # 0x3c360
leaq 0x16392(%rip), %rsi     # 0x4793a
leaq 0x189e6(%rip), %rcx     # 0x49f95
movl $0x5e6, %edx            # imm = 0x5E6
callq 0x30a0