// File: /workspace/github_c_makefile_star2_O1/Ihsoh[P]ilang/compiler/frontend/irgen_llvmir.c
// Function: ir_expr_cond
static bool _ir_expr_cond(
	IRGeneratorLlvmirContext *ctx,
	ResizableString *rstr,
	_ExprResult *expr_result,
	ParserASTNode *node
) {
	assert(ctx);
	assert(rstr);
	assert(expr_result);
	assert(node);

	if (node->type == FE_NODE_EXPR_COND) {
		assert(node->nchilds == 3);

		ParserASTNode *node_expr_cond = node->childs[0];
		ParserASTNode *node_expr_true = node->childs[1];
		ParserASTNode *node_expr_false = node->childs[2];

		ParserASTNode *node_target_type = FE_EXPR_AST_NODE_GET_TYPE_NODE(node);
		ResizableString rstr_target_type;
		rstr_init(&rstr_target_type);
		_ir_type(ctx, &rstr_target_type, node_target_type);

		_TMP_LABEL_DEF(ctx, expr_true)
		_TMP_LABEL_DEF(ctx, expr_true_end)
		_TMP_LABEL_DEF(ctx, expr_false)
		_TMP_LABEL_DEF(ctx, expr_false_end)
		_TMP_LABEL_DEF(ctx, end)
		_TMP_LABEL_DEF(ctx, result)

		_ExprResult result_expr_cond;
		_expr_result_init(&result_expr_cond);

		_ir_expr(ctx, rstr, &result_expr_cond, node_expr_cond);
		rstr_append_with_rstr(rstr, &(result_expr_cond.rstr_for_result_ptr));
		rstr_append_with_rstr(rstr, &(result_expr_cond.rstr_for_result));

		ResizableString rstr_expr_cond;
		rstr_init(&rstr_expr_cond);
		_ir_cond_expr_with_rstr(ctx, rstr, &rstr_expr_cond, &result_expr_cond, node_expr_cond);

		// 根据条件表达式选择执行expr_true块还是expr_false块。
		rstr_appendf(
			rstr,
			"br i1 %s, label %s, label %s\n",
			RSTR_CSTR(&rstr_expr_cond),
			_TMP_LABEL_CSTR(expr_true),
			_TMP_LABEL_CSTR(expr_false)
		);

		rstr_appendf(
			rstr,
			"%s:\n",
			_TMP_LABEL_NAME_CSTR(expr_true)
		);

		// expr_true块的代码。
		_ExprResult result_expr_true;
		_expr_result_init(&result_expr_true);

		_ir_expr(ctx, rstr, &result_expr_true, node_expr_true);
		rstr_append_with_rstr(rstr, &(result_expr_true.rstr_for_result_ptr));
		rstr_append_with_rstr(rstr, &(result_expr_true.rstr_for_result));

		_ExprResult result_expr_true_casted;
		_expr_result_init(&result_expr_true_casted);

		_expr_result_cast(
			ctx,
			&result_expr_true_casted,
			node_target_type,
			&result_expr_true,
			FE_EXPR_AST_NODE_GET_TYPE_NODE(node_expr_true)
		);
		rstr_append_with_rstr(rstr, &(result_expr_true_casted.rstr_for_result_ptr));
		rstr_append_with_rstr(rstr, &(result_expr_true_casted.rstr_for_result));

		rstr_appendf(
			rstr,
			"br label %s\n%s:\n",
			_TMP_LABEL_CSTR(expr_true_end),
			_TMP_LABEL_NAME_CSTR(expr_true_end)
		);
		rstr_appendf(
			rstr,
			"br label %s\n",
			_TMP_LABEL_CSTR(end)
		);

		rstr_appendf(
			rstr,
			"%s:\n",
			_TMP_LABEL_NAME_CSTR(expr_false)
		);

		// expr_false块的代码。
		_ExprResult result_expr_false;
		_expr_result_init(&result_expr_false);

		_ir_expr(ctx, rstr, &result_expr_false, node_expr_false);
		rstr_append_with_rstr(rstr, &(result_expr_false.rstr_for_result_ptr));
		rstr_append_with_rstr(rstr, &(result_expr_false.rstr_for_result));

		_ExprResult result_expr_false_casted;
		_expr_result_init(&result_expr_false_casted);

		_expr_result_cast(
			ctx,
			&result_expr_false_casted,
			node_target_type,
			&result_expr_false,
			FE_EXPR_AST_NODE_GET_TYPE_NODE(node_expr_false)
		);
		rstr_append_with_rstr(rstr, &(result_expr_false_casted.rstr_for_result_ptr));
		rstr_append_with_rstr(rstr, &(result_expr_false_casted.rstr_for_result));

		rstr_appendf(
			rstr,
			"br label %s\n%s:\n",
			_TMP_LABEL_CSTR(expr_false_end),
			_TMP_LABEL_NAME_CSTR(expr_false_end)
		);
		rstr_appendf(
			rstr,
			"br label %s\n",
			_TMP_LABEL_CSTR(end)
		);

		rstr_appendf(
			rstr,
			"%s:\n",
			_TMP_LABEL_NAME_CSTR(end)
		);

		rstr_appendf(
			&(expr_result->rstr_for_result),
			"%s = phi %s [ %s, %s ], [ %s, %s ]\n",
			_TMP_LABEL_CSTR(result),
			RSTR_CSTR(&rstr_target_type),
			RSTR_CSTR(&(result_expr_true_casted.rstr_result_val)),
			_TMP_LABEL_CSTR(expr_true_end),
			RSTR_CSTR(&(result_expr_false_casted.rstr_result_val)),
			_TMP_LABEL_CSTR(expr_false_end)
		);
		_expr_result_set_result(
			expr_result,
			RSTR_CSTR(&rstr_target_type),
			_TMP_LABEL_CSTR(result)
		);

		_TMP_LABEL_FREE(expr_true)
		_TMP_LABEL_FREE(expr_true_end)
		_TMP_LABEL_FREE(expr_false)
		_TMP_LABEL_FREE(expr_false_end)
		_TMP_LABEL_FREE(end)
		_TMP_LABEL_FREE(result)

		_expr_result_free(&result_expr_cond);
		_expr_result_free(&result_expr_true);
		_expr_result_free(&result_expr_true_casted);
		_expr_result_free(&result_expr_false);
		_expr_result_free(&result_expr_false_casted);

		rstr_free(&rstr_target_type);
		rstr_free(&rstr_expr_cond);

		return true;
	} else {
		return false;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x328, %rsp            # imm = 0x328
movl (%rcx), %eax
cmpl $0xecd, %eax            # imm = 0xECD
jne 0x1dc7a
movq %rdx, -0x50(%rbp)
movl %eax, -0x2c(%rbp)
cmpl $0x3, 0x44(%rcx)
jne 0x1dc94
movq %rsi, %r12
movq %rdi, %r13
movq 0x48(%rcx), %rax
movq 0x68(%rcx), %r15
movq %r15, -0x38(%rbp)
movq (%rax), %r14
movq 0x8(%rax), %rcx
movq %rcx, -0x40(%rbp)
movq 0x10(%rax), %rax
movq %rax, -0x48(%rbp)
leaq -0xd0(%rbp), %rbx
movq %rbx, %rdi
callq 0x7548
movq %rbx, %rdi
movq %r15, %rsi
callq 0x198ea
leaq -0xa0(%rbp), %rbx
movq %rbx, %rdi
callq 0x7548
movq 0x40(%r13), %rdi
movq %rbx, %rsi
callq 0x1e318
leaq -0x80(%rbp), %rbx
movq %rbx, %rdi
callq 0x7548
movq 0x40(%r13), %rdi
movq %rbx, %rsi
callq 0x1e318
leaq -0x70(%rbp), %rbx
movq %rbx, %rdi
callq 0x7548
movq 0x40(%r13), %rdi
movq %rbx, %rsi
callq 0x1e318
leaq -0x90(%rbp), %rbx
movq %rbx, %rdi
callq 0x7548
movq 0x40(%r13), %rdi
movq %rbx, %rsi
callq 0x1e318
leaq -0x60(%rbp), %rbx
movq %rbx, %rdi
callq 0x7548
movq 0x40(%r13), %rdi
movq %rbx, %rsi
callq 0x1e318
leaq -0xc0(%rbp), %rbx
movq %rbx, %rdi
callq 0x7548
movq 0x40(%r13), %rdi
movq %rbx, %rsi
callq 0x1e318
leaq -0x350(%rbp), %r15
movq %r15, %rdi
callq 0x19eca
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x1ad56
leaq -0x340(%rbp), %rsi
movq %r12, %rdi
callq 0x788c
movq %r12, %rdi
movq %r15, %rsi
callq 0x788c
leaq -0xb0(%rbp), %rbx
movq %rbx, %rdi
callq 0x7548
movq %r13, %rdi
movq %r12, %rsi
movq %rbx, %rdx
movq %r15, %rcx
movq %r14, %r8
callq 0x20138
movq 0x8(%rbx), %rdx
testq %rdx, %rdx
leaq 0x26596(%rip), %rax     # 0x43eba
cmoveq %rax, %rdx
leaq -0xa0(%rbp), %r14
movq 0x8(%r14), %rcx
testq %rcx, %rcx
cmoveq %rax, %rcx
leaq -0x70(%rbp), %rsi
movq 0x8(%rsi), %r8
testq %r8, %r8
cmoveq %rax, %r8
movq %rax, %rbx
leaq 0x29381(%rip), %rsi     # 0x46cd4
movq %r12, %rdi
xorl %eax, %eax
callq 0x7b31
movq 0x8(%r14), %rdx
testq %rdx, %rdx
cmoveq %rbx, %rdx
incq %rdx
leaq 0x2935d(%rip), %rsi     # 0x46ccf
movq %r12, %rdi
xorl %eax, %eax
callq 0x7b31
leaq -0x2d0(%rbp), %r15
movq %r15, %rdi
callq 0x19eca
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq -0x40(%rbp), %rbx
movq %rbx, %rcx
callq 0x1ad56
leaq -0x2c0(%rbp), %rsi
movq %r12, %rdi
callq 0x788c
movq %r12, %rdi
movq %r15, %rsi
callq 0x788c
leaq -0x150(%rbp), %r14
movq %r14, %rdi
callq 0x19eca
movq 0x68(%rbx), %r8
movq %r13, %rdi
movq %r14, %rsi
movq -0x38(%rbp), %rdx
movq %r15, %rcx
callq 0x19f71
leaq -0x140(%rbp), %rsi
movq %r12, %rdi
callq 0x788c
movq %r12, %rdi
movq %r14, %rsi
callq 0x788c
leaq -0x80(%rbp), %rax
movq 0x8(%rax), %rdx
testq %rdx, %rdx
leaq 0x264af(%rip), %rbx     # 0x43eba
cmoveq %rbx, %rdx
leaq 0x1(%rdx), %rcx
leaq 0x292a9(%rip), %rsi     # 0x46cc3
movq %r12, %rdi
xorl %eax, %eax
callq 0x7b31
leaq -0x60(%rbp), %rax
movq 0x8(%rax), %rdx
testq %rdx, %rdx
cmoveq %rbx, %rdx
leaq 0x29412(%rip), %rsi     # 0x46e4c
movq %r12, %rdi
xorl %eax, %eax
callq 0x7b31
leaq -0x70(%rbp), %rax
movq 0x8(%rax), %rdx
testq %rdx, %rdx
cmoveq %rbx, %rdx
incq %rdx
movq %r12, %rdi
leaq 0x2926f(%rip), %rsi     # 0x46ccf
xorl %eax, %eax
callq 0x7b31
leaq -0x250(%rbp), %r15
movq %r15, %rdi
callq 0x19eca
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq -0x48(%rbp), %r14
movq %r14, %rcx
callq 0x1ad56
leaq -0x240(%rbp), %rsi
movq %r12, %rdi
callq 0x788c
movq %r12, %rdi
movq %r15, %rsi
callq 0x788c
leaq -0x1d0(%rbp), %rbx
movq %rbx, %rdi
callq 0x19eca
movq 0x68(%r14), %r8
movq %r13, %rdi
movq %rbx, %rsi
movq -0x38(%rbp), %rdx
movq %r15, %rcx
callq 0x19f71
leaq -0x1c0(%rbp), %r13
movq %r12, %rdi
movq %r13, %rsi
callq 0x788c
movq %r12, %rdi
movq %rbx, %rsi
callq 0x788c
leaq -0x90(%rbp), %r14
movq 0x8(%r14), %rdx
testq %rdx, %rdx
leaq 0x263be(%rip), %rbx     # 0x43eba
cmoveq %rbx, %rdx
leaq 0x1(%rdx), %rcx
movq %r12, %rdi
leaq 0x291b5(%rip), %rsi     # 0x46cc3
xorl %eax, %eax
callq 0x7b31
leaq -0x60(%rbp), %r15
movq 0x8(%r15), %rdx
testq %rdx, %rdx
cmoveq %rbx, %rdx
movq %r12, %rdi
leaq 0x2931e(%rip), %rsi     # 0x46e4c
xorl %eax, %eax
callq 0x7b31
movq 0x8(%r15), %rdx
testq %rdx, %rdx
cmoveq %rbx, %rdx
incq %rdx
movq %r12, %rdi
leaq 0x29182(%rip), %rsi     # 0x46ccf
xorl %eax, %eax
callq 0x7b31
leaq -0xc0(%rbp), %r15
movq 0x8(%r15), %rdx
testq %rdx, %rdx
cmoveq %rbx, %rdx
leaq -0xd0(%rbp), %r12
movq 0x8(%r12), %rcx
testq %rcx, %rcx
cmoveq %rbx, %rcx
leaq -0x140(%rbp), %rsi
movq 0x38(%rsi), %r8
testq %r8, %r8
cmoveq %rbx, %r8
leaq -0x80(%rbp), %rsi
movq 0x8(%rsi), %r9
testq %r9, %r9
cmoveq %rbx, %r9
movq 0x38(%r13), %r10
testq %r10, %r10
cmoveq %rbx, %r10
movq 0x8(%r14), %r11
testq %r11, %r11
cmoveq %rbx, %r11
leaq 0x292a2(%rip), %rsi     # 0x46e59
movq -0x50(%rbp), %r13
movq %r13, %rdi
xorl %eax, %eax
pushq %r11
pushq %r10
callq 0x7b31
addq $0x10, %rsp
movq 0x8(%r12), %rsi
testq %rsi, %rsi
cmoveq %rbx, %rsi
movq 0x8(%r15), %rdx
testq %rdx, %rdx
cmoveq %rbx, %rdx
movq %r13, %rdi
callq 0x1e280
leaq -0xa0(%rbp), %rdi
callq 0x7a38
leaq -0x80(%rbp), %rdi
callq 0x7a38
leaq -0x70(%rbp), %rdi
callq 0x7a38
leaq -0x90(%rbp), %rdi
callq 0x7a38
leaq -0x60(%rbp), %rdi
callq 0x7a38
movq %r15, %rdi
callq 0x7a38
leaq -0x350(%rbp), %rdi
callq 0x1a7ab
leaq -0x2d0(%rbp), %rdi
callq 0x1a7ab
leaq -0x150(%rbp), %rdi
callq 0x1a7ab
leaq -0x250(%rbp), %rdi
callq 0x1a7ab
leaq -0x1d0(%rbp), %rdi
callq 0x1a7ab
movq %r12, %rdi
callq 0x7a38
leaq -0xb0(%rbp), %rdi
callq 0x7a38
movl -0x2c(%rbp), %eax
cmpl $0xecd, %eax            # imm = 0xECD
sete %al
addq $0x328, %rsp            # imm = 0x328
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x25fe3(%rip), %rdi     # 0x43c7e
leaq 0x27bd2(%rip), %rsi     # 0x45874
leaq 0x29140(%rip), %rcx     # 0x46de9
movl $0x1118, %edx           # imm = 0x1118
callq 0x30a0