// File: /workspace/github_c_makefile_star2_O3/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 0x1d8ef
movq %rdx, -0x50(%rbp)
movl %eax, -0x2c(%rbp)
cmpl $0x3, 0x44(%rcx)
jne 0x1d909
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 0x7354
movq %rbx, %rdi
movq %r15, %rsi
callq 0x19540
leaq -0xa0(%rbp), %rbx
movq %rbx, %rdi
callq 0x7354
movq 0x40(%r13), %rdi
movq %rbx, %rsi
callq 0x1df8d
leaq -0x80(%rbp), %rbx
movq %rbx, %rdi
callq 0x7354
movq 0x40(%r13), %rdi
movq %rbx, %rsi
callq 0x1df8d
leaq -0x70(%rbp), %rbx
movq %rbx, %rdi
callq 0x7354
movq 0x40(%r13), %rdi
movq %rbx, %rsi
callq 0x1df8d
leaq -0x90(%rbp), %rbx
movq %rbx, %rdi
callq 0x7354
movq 0x40(%r13), %rdi
movq %rbx, %rsi
callq 0x1df8d
leaq -0x60(%rbp), %rbx
movq %rbx, %rdi
callq 0x7354
movq 0x40(%r13), %rdi
movq %rbx, %rsi
callq 0x1df8d
leaq -0xc0(%rbp), %rbx
movq %rbx, %rdi
callq 0x7354
movq 0x40(%r13), %rdi
movq %rbx, %rsi
callq 0x1df8d
leaq -0x350(%rbp), %r15
movq %r15, %rdi
callq 0x19b1c
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x1a9a8
leaq -0x340(%rbp), %rsi
movq %r12, %rdi
callq 0x769e
movq %r12, %rdi
movq %r15, %rsi
callq 0x769e
leaq -0xb0(%rbp), %rbx
movq %rbx, %rdi
callq 0x7354
movq %r13, %rdi
movq %r12, %rsi
movq %rbx, %rdx
movq %r15, %rcx
movq %r14, %r8
callq 0x1fdad
movq 0x8(%rbx), %rdx
testq %rdx, %rdx
leaq 0x2596d(%rip), %rax     # 0x42f06
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 0x287dc(%rip), %rsi     # 0x45da4
movq %r12, %rdi
xorl %eax, %eax
callq 0x7945
movq 0x8(%r14), %rdx
testq %rdx, %rdx
cmoveq %rbx, %rdx
incq %rdx
leaq 0x287b8(%rip), %rsi     # 0x45d9f
movq %r12, %rdi
xorl %eax, %eax
callq 0x7945
leaq -0x2d0(%rbp), %r15
movq %r15, %rdi
callq 0x19b1c
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq -0x40(%rbp), %rbx
movq %rbx, %rcx
callq 0x1a9a8
leaq -0x2c0(%rbp), %rsi
movq %r12, %rdi
callq 0x769e
movq %r12, %rdi
movq %r15, %rsi
callq 0x769e
leaq -0x150(%rbp), %r14
movq %r14, %rdi
callq 0x19b1c
movq 0x68(%rbx), %r8
movq %r13, %rdi
movq %r14, %rsi
movq -0x38(%rbp), %rdx
movq %r15, %rcx
callq 0x19bc3
leaq -0x140(%rbp), %rsi
movq %r12, %rdi
callq 0x769e
movq %r12, %rdi
movq %r14, %rsi
callq 0x769e
leaq -0x80(%rbp), %rax
movq 0x8(%rax), %rdx
testq %rdx, %rdx
leaq 0x25886(%rip), %rbx     # 0x42f06
cmoveq %rbx, %rdx
leaq 0x1(%rdx), %rcx
leaq 0x28704(%rip), %rsi     # 0x45d93
movq %r12, %rdi
xorl %eax, %eax
callq 0x7945
leaq -0x60(%rbp), %rax
movq 0x8(%rax), %rdx
testq %rdx, %rdx
cmoveq %rbx, %rdx
leaq 0x2886d(%rip), %rsi     # 0x45f1c
movq %r12, %rdi
xorl %eax, %eax
callq 0x7945
leaq -0x70(%rbp), %rax
movq 0x8(%rax), %rdx
testq %rdx, %rdx
cmoveq %rbx, %rdx
incq %rdx
movq %r12, %rdi
leaq 0x286ca(%rip), %rsi     # 0x45d9f
xorl %eax, %eax
callq 0x7945
leaq -0x250(%rbp), %r15
movq %r15, %rdi
callq 0x19b1c
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq -0x48(%rbp), %r14
movq %r14, %rcx
callq 0x1a9a8
leaq -0x240(%rbp), %rsi
movq %r12, %rdi
callq 0x769e
movq %r12, %rdi
movq %r15, %rsi
callq 0x769e
leaq -0x1d0(%rbp), %rbx
movq %rbx, %rdi
callq 0x19b1c
movq 0x68(%r14), %r8
movq %r13, %rdi
movq %rbx, %rsi
movq -0x38(%rbp), %rdx
movq %r15, %rcx
callq 0x19bc3
leaq -0x1c0(%rbp), %r13
movq %r12, %rdi
movq %r13, %rsi
callq 0x769e
movq %r12, %rdi
movq %rbx, %rsi
callq 0x769e
leaq -0x90(%rbp), %r14
movq 0x8(%r14), %rdx
testq %rdx, %rdx
leaq 0x25795(%rip), %rbx     # 0x42f06
cmoveq %rbx, %rdx
leaq 0x1(%rdx), %rcx
movq %r12, %rdi
leaq 0x28610(%rip), %rsi     # 0x45d93
xorl %eax, %eax
callq 0x7945
leaq -0x60(%rbp), %r15
movq 0x8(%r15), %rdx
testq %rdx, %rdx
cmoveq %rbx, %rdx
movq %r12, %rdi
leaq 0x28779(%rip), %rsi     # 0x45f1c
xorl %eax, %eax
callq 0x7945
movq 0x8(%r15), %rdx
testq %rdx, %rdx
cmoveq %rbx, %rdx
incq %rdx
movq %r12, %rdi
leaq 0x285dd(%rip), %rsi     # 0x45d9f
xorl %eax, %eax
callq 0x7945
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 0x286fd(%rip), %rsi     # 0x45f29
movq -0x50(%rbp), %r13
movq %r13, %rdi
xorl %eax, %eax
pushq %r11
pushq %r10
callq 0x7945
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 0x1def5
leaq -0xa0(%rbp), %rdi
callq 0x7852
leaq -0x80(%rbp), %rdi
callq 0x7852
leaq -0x70(%rbp), %rdi
callq 0x7852
leaq -0x90(%rbp), %rdi
callq 0x7852
leaq -0x60(%rbp), %rdi
callq 0x7852
movq %r15, %rdi
callq 0x7852
leaq -0x350(%rbp), %rdi
callq 0x1a3fd
leaq -0x2d0(%rbp), %rdi
callq 0x1a3fd
leaq -0x150(%rbp), %rdi
callq 0x1a3fd
leaq -0x250(%rbp), %rdi
callq 0x1a3fd
leaq -0x1d0(%rbp), %rdi
callq 0x1a3fd
movq %r12, %rdi
callq 0x7852
leaq -0xb0(%rbp), %rdi
callq 0x7852
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 0x253ba(%rip), %rdi     # 0x42cca
leaq 0x2702d(%rip), %rsi     # 0x44944
leaq 0x2859b(%rip), %rcx     # 0x45eb9
movl $0x1118, %edx           # imm = 0x1118
callq 0x30a0