// File: /workspace/github_c_makefile_star2_O2/Ihsoh[P]ilang/compiler/frontend/semantics.c
// Function: stat_if
static void _stat_if(
	ParserContext *ctx,
	ParserASTNode *node
) {
	assert(ctx);
	assert(node);
	assert(node->type == FE_NODE_STAT_IF);
	assert(node->nchilds >= 2);

	ParserASTNode *node_if_cond_expr = node->childs[0];
	_expr_wrapper(ctx, node_if_cond_expr);
	if (!_is_integer_type_node(ctx, node_if_cond_expr)
			&& !_is_pointer_type_node(ctx, node_if_cond_expr)) {
		_SYNERR_NODE(
			ctx,
			node,
			"statement 'if' condition expression requires integer type or pointer type."
		);
	}

	ParserASTNode *node_if_body = node->childs[1];
	_stats_block(ctx, node_if_body);

	for (int i = 2; i < node->nchilds; i++) {
		ParserASTNode *child = node->childs[i];
		if (child->type == FE_NODE_STAT_ELIF) {
			assert(child->nchilds == 2);
			ParserASTNode *node_elif_cond_expr = child->childs[0];
			_expr_wrapper(ctx, node_elif_cond_expr);
			if (!_is_integer_type_node(ctx, node_elif_cond_expr)
					&& !_is_pointer_type_node(ctx, node_elif_cond_expr)) {
				_SYNERR_NODE(
					ctx,
					node,
					"statement 'elif' condition expression requires integer type or pointer type."
				);
			}

			ParserASTNode *node_elif_body = child->childs[1];
			_stats_block(ctx, node_elif_body);
		} else if (child->type == FE_NODE_STAT_ELSE) {
			assert(child->nchilds == 1);
			_stats_block(ctx, child->childs[0]);
		} else {
			assert(0);
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x408, %rsp            # imm = 0x408
cmpl $0xb10, (%rsi)          # imm = 0xB10
jne 0x313df
movq %rsi, %rbx
cmpl $0x1, 0x44(%rsi)
jle 0x313fe
movq %rdi, %r14
movq 0x48(%rbx), %rax
movq (%rax), %r15
movq %r15, %rsi
callq 0x29bc2
movq %r15, %rdi
callq 0x2b3d4
testb %al, %al
jne 0x312a9
movq %r15, %rdi
callq 0x2b435
testb %al, %al
jne 0x312a9
leaq 0x189be(%rip), %rsi     # 0x49c48
leaq -0x430(%rbp), %r15
pushq $0x4b
popq %rdx
movq %r15, %rdi
callq 0x3100
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq *0x58(%r14)
movq 0x48(%rbx), %rax
movq 0x8(%rax), %rsi
movq %r14, %rdi
callq 0x3099a
pushq $0x2
popq %r13
movslq 0x44(%rbx), %rax
cmpq %rax, %r13
jge 0x31370
movq 0x48(%rbx), %rax
movq (%rax,%r13,8), %r12
movl (%r12), %eax
cmpl $0xb12, %eax            # imm = 0xB12
je 0x31350
cmpl $0xb11, %eax            # imm = 0xB11
jne 0x31382
cmpl $0x2, 0x44(%r12)
jne 0x313a1
movq 0x48(%r12), %rax
movq (%rax), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x29bc2
movq %r15, %rdi
callq 0x2b3d4
testb %al, %al
jne 0x31345
movq %r15, %rdi
callq 0x2b435
testb %al, %al
jne 0x31345
leaq -0x430(%rbp), %r15
movq %r15, %rdi
leaq 0x18977(%rip), %rsi     # 0x49ca7
pushq $0x4d
popq %rdx
callq 0x3100
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq *0x58(%r14)
movq 0x48(%r12), %rax
addq $0x8, %rax
jmp 0x3135d
cmpl $0x1, 0x44(%r12)
jne 0x313c0
movq 0x48(%r12), %rax
movq (%rax), %rsi
movq %r14, %rdi
callq 0x3099a
incq %r13
jmp 0x312bd
addq $0x408, %rsp            # imm = 0x408
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xafd7(%rip), %rdi      # 0x3c360
leaq 0x165aa(%rip), %rsi     # 0x4793a
leaq 0x18863(%rip), %rcx     # 0x49bfa
movl $0x4f9, %edx            # imm = 0x4F9
callq 0x30a0
leaq 0x188eb(%rip), %rdi     # 0x49c93
leaq 0x1658b(%rip), %rsi     # 0x4793a
leaq 0x18844(%rip), %rcx     # 0x49bfa
movl $0x4e7, %edx            # imm = 0x4E7
callq 0x30a0
leaq 0x1892d(%rip), %rdi     # 0x49cf4
leaq 0x1656c(%rip), %rsi     # 0x4793a
leaq 0x18825(%rip), %rcx     # 0x49bfa
movl $0x4f6, %edx            # imm = 0x4F6
callq 0x30a0
leaq 0x18844(%rip), %rdi     # 0x49c2a
leaq 0x1654d(%rip), %rsi     # 0x4793a
leaq 0x18806(%rip), %rcx     # 0x49bfa
movl $0x4d3, %edx            # imm = 0x4D3
callq 0x30a0
leaq 0x16aeb(%rip), %rdi     # 0x47ef0
leaq 0x1652e(%rip), %rsi     # 0x4793a
leaq 0x187e7(%rip), %rcx     # 0x49bfa
movl $0x4d4, %edx            # imm = 0x4D4
callq 0x30a0