// File: /workspace/github_c_makefile_star2_O0/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
subq $0x850, %rsp            # imm = 0x850
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x5d96c
jmp 0x5d98b
leaq 0x1ebe3(%rip), %rdi     # 0x7c556
leaq 0x208d0(%rip), %rsi     # 0x7e24a
movl $0x4d1, %edx            # imm = 0x4D1
leaq 0x22d4f(%rip), %rcx     # 0x806d5
callq 0x30a0
cmpq $0x0, -0x10(%rbp)
je 0x5d994
jmp 0x5d9b3
leaq 0x18638(%rip), %rdi     # 0x75fd3
leaq 0x208a8(%rip), %rsi     # 0x7e24a
movl $0x4d2, %edx            # imm = 0x4D2
leaq 0x22d27(%rip), %rcx     # 0x806d5
callq 0x30a0
movq -0x10(%rbp), %rax
cmpl $0xb10, (%rax)          # imm = 0xB10
jne 0x5d9c1
jmp 0x5d9e0
leaq 0x22d3d(%rip), %rdi     # 0x80705
leaq 0x2087b(%rip), %rsi     # 0x7e24a
movl $0x4d3, %edx            # imm = 0x4D3
leaq 0x22cfa(%rip), %rcx     # 0x806d5
callq 0x30a0
movq -0x10(%rbp), %rax
cmpl $0x2, 0x44(%rax)
jl 0x5d9ec
jmp 0x5da0b
leaq 0x20e3c(%rip), %rdi     # 0x7e82f
leaq 0x20850(%rip), %rsi     # 0x7e24a
movl $0x4d4, %edx            # imm = 0x4D4
leaq 0x22ccf(%rip), %rcx     # 0x806d5
callq 0x30a0
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x4f680
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x526c0
testb $0x1, %al
jne 0x5da77
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x52770
testb $0x1, %al
jne 0x5da77
leaq -0x420(%rbp), %rdi
leaq 0x22ccc(%rip), %rsi     # 0x80723
movb $0x0, %al
callq 0x3160
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
leaq -0x420(%rbp), %rdx
callq *%rax
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x428(%rbp)
movq -0x8(%rbp), %rdi
movq -0x428(%rbp), %rsi
callq 0x5d3d0
movl $0x2, -0x42c(%rbp)
movl -0x42c(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x44(%rcx), %eax
jge 0x5dc42
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movslq -0x42c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x438(%rbp)
movq -0x438(%rbp), %rax
cmpl $0xb11, (%rax)          # imm = 0xB11
jne 0x5dbb5
movq -0x438(%rbp), %rax
cmpl $0x2, 0x44(%rax)
jne 0x5daf3
jmp 0x5db12
leaq 0x22c74(%rip), %rdi     # 0x8076e
leaq 0x20749(%rip), %rsi     # 0x7e24a
movl $0x4e7, %edx            # imm = 0x4E7
leaq 0x22bc8(%rip), %rcx     # 0x806d5
callq 0x30a0
movq -0x438(%rbp), %rax
movq 0x48(%rax), %rax
movq (%rax), %rax
movq %rax, -0x440(%rbp)
movq -0x8(%rbp), %rdi
movq -0x440(%rbp), %rsi
callq 0x4f680
movq -0x8(%rbp), %rdi
movq -0x440(%rbp), %rsi
callq 0x526c0
testb $0x1, %al
jne 0x5db8d
movq -0x8(%rbp), %rdi
movq -0x440(%rbp), %rsi
callq 0x52770
testb $0x1, %al
jne 0x5db8d
leaq -0x840(%rbp), %rdi
leaq 0x22c15(%rip), %rsi     # 0x80782
movb $0x0, %al
callq 0x3160
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
leaq -0x840(%rbp), %rdx
callq *%rax
movq -0x438(%rbp), %rax
movq 0x48(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x848(%rbp)
movq -0x8(%rbp), %rdi
movq -0x848(%rbp), %rsi
callq 0x5d3d0
jmp 0x5dc2c
movq -0x438(%rbp), %rax
cmpl $0xb12, (%rax)          # imm = 0xB12
jne 0x5dc0b
movq -0x438(%rbp), %rax
cmpl $0x1, 0x44(%rax)
jne 0x5dbd3
jmp 0x5dbf2
leaq 0x22bf5(%rip), %rdi     # 0x807cf
leaq 0x20669(%rip), %rsi     # 0x7e24a
movl $0x4f6, %edx            # imm = 0x4F6
leaq 0x22ae8(%rip), %rcx     # 0x806d5
callq 0x30a0
movq -0x8(%rbp), %rdi
movq -0x438(%rbp), %rax
movq 0x48(%rax), %rax
movq (%rax), %rsi
callq 0x5d3d0
jmp 0x5dc2a
leaq 0x14849(%rip), %rdi     # 0x7245b
leaq 0x20631(%rip), %rsi     # 0x7e24a
movl $0x4f9, %edx            # imm = 0x4F9
leaq 0x22ab0(%rip), %rcx     # 0x806d5
callq 0x30a0
jmp 0x5dc2c
jmp 0x5dc2e
movl -0x42c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x42c(%rbp)
jmp 0x5daa4
addq $0x850, %rsp            # imm = 0x850
popq %rbp
retq
nopl (%rax,%rax)