// File: /workspace/github_c_makefile_star2_O1/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 0x346b6
movq %rsi, %rbx
cmpl $0x1, 0x44(%rsi)
jle 0x346d5
movq %rdi, %r14
movq 0x48(%rbx), %rax
movq (%rax), %r15
movq %r15, %rsi
callq 0x2c76c
movq %r15, %rdi
callq 0x2e28f
testb %al, %al
jne 0x34577
movq %r15, %rdi
callq 0x2e2f0
testb %al, %al
jne 0x34577
leaq 0x19669(%rip), %rsi     # 0x4dbbf
leaq -0x430(%rbp), %r15
movl $0x4b, %edx
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 0x33bec
cmpl $0x3, 0x44(%rbx)
jl 0x34647
movl $0x2, %r15d
movq 0x48(%rbx), %rax
movq (%rax,%r15,8), %r12
movl (%r12), %eax
cmpl $0xb12, %eax            # imm = 0xB12
je 0x3461f
cmpl $0xb11, %eax            # imm = 0xB11
jne 0x34678
cmpl $0x2, 0x44(%r12)
jne 0x34697
movq 0x48(%r12), %rax
movq (%rax), %r13
movq %r14, %rdi
movq %r13, %rsi
callq 0x2c76c
movq %r13, %rdi
callq 0x2e28f
testb %al, %al
jne 0x34614
movq %r13, %rdi
callq 0x2e2f0
testb %al, %al
jne 0x34614
movl $0x4d, %edx
leaq -0x430(%rbp), %r13
movq %r13, %rdi
leaq 0x1961c(%rip), %rsi     # 0x4dc1e
callq 0x3100
movq %r14, %rdi
movq %rbx, %rsi
movq %r13, %rdx
callq *0x58(%r14)
movq 0x48(%r12), %rax
addq $0x8, %rax
jmp 0x3462c
cmpl $0x1, 0x44(%r12)
jne 0x34659
movq 0x48(%r12), %rax
movq (%rax), %rsi
movq %r14, %rdi
callq 0x33bec
incq %r15
movslq 0x44(%rbx), %rax
cmpq %rax, %r15
jl 0x34597
addq $0x408, %rsp            # imm = 0x408
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1960b(%rip), %rdi     # 0x4dc6b
leaq 0x171f3(%rip), %rsi     # 0x4b85a
leaq 0x19503(%rip), %rcx     # 0x4db71
movl $0x4f6, %edx            # imm = 0x4F6
callq 0x30a0
leaq 0xbd05(%rip), %rdi      # 0x40384
leaq 0x171d4(%rip), %rsi     # 0x4b85a
leaq 0x194e4(%rip), %rcx     # 0x4db71
movl $0x4f9, %edx            # imm = 0x4F9
callq 0x30a0
leaq 0x1956c(%rip), %rdi     # 0x4dc0a
leaq 0x171b5(%rip), %rsi     # 0x4b85a
leaq 0x194c5(%rip), %rcx     # 0x4db71
movl $0x4e7, %edx            # imm = 0x4E7
callq 0x30a0
leaq 0x194e4(%rip), %rdi     # 0x4dba1
leaq 0x17196(%rip), %rsi     # 0x4b85a
leaq 0x194a6(%rip), %rcx     # 0x4db71
movl $0x4d3, %edx            # imm = 0x4D3
callq 0x30a0
leaq 0x17734(%rip), %rdi     # 0x4be10
leaq 0x17177(%rip), %rsi     # 0x4b85a
leaq 0x19487(%rip), %rcx     # 0x4db71
movl $0x4d4, %edx            # imm = 0x4D4
callq 0x30a0