// File: /workspace/github_c_makefile_star2_O0/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
subq $0x4a0, %rsp            # imm = 0x4A0
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x33a64
jmp 0x33a83
leaq 0x48aeb(%rip), %rdi     # 0x7c556
leaq 0x4465e(%rip), %rsi     # 0x780d0
movl $0x1112, %edx           # imm = 0x1112
leaq 0x45cf8(%rip), %rcx     # 0x79776
callq 0x30a0
cmpq $0x0, -0x18(%rbp)
je 0x33a8c
jmp 0x33aab
leaq 0x3f07b(%rip), %rdi     # 0x72b0e
leaq 0x44636(%rip), %rsi     # 0x780d0
movl $0x1113, %edx           # imm = 0x1113
leaq 0x45cd0(%rip), %rcx     # 0x79776
callq 0x30a0
cmpq $0x0, -0x20(%rbp)
je 0x33ab4
jmp 0x33ad3
leaq 0x41158(%rip), %rdi     # 0x74c13
leaq 0x4460e(%rip), %rsi     # 0x780d0
movl $0x1114, %edx           # imm = 0x1114
leaq 0x45ca8(%rip), %rcx     # 0x79776
callq 0x30a0
cmpq $0x0, -0x28(%rbp)
je 0x33adc
jmp 0x33afb
leaq 0x424f0(%rip), %rdi     # 0x75fd3
leaq 0x445e6(%rip), %rsi     # 0x780d0
movl $0x1115, %edx           # imm = 0x1115
leaq 0x45c80(%rip), %rcx     # 0x79776
callq 0x30a0
movq -0x28(%rbp), %rax
cmpl $0xecd, (%rax)          # imm = 0xECD
jne 0x343ef
movq -0x28(%rbp), %rax
cmpl $0x3, 0x44(%rax)
jne 0x33b17
jmp 0x33b36
leaq 0x4239d(%rip), %rdi     # 0x75ebb
leaq 0x445ab(%rip), %rsi     # 0x780d0
movl $0x1118, %edx           # imm = 0x1118
leaq 0x45c45(%rip), %rcx     # 0x79776
callq 0x30a0
movq -0x28(%rbp), %rax
movq 0x48(%rax), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rax
movq 0x48(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rax
movq 0x48(%rax), %rax
movq 0x10(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x28(%rbp), %rax
movq 0x68(%rax), %rax
movq %rax, -0x48(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x8c90
movq -0x10(%rbp), %rdi
movq -0x48(%rbp), %rdx
leaq -0x58(%rbp), %rsi
callq 0x299e0
leaq -0x68(%rbp), %rdi
callq 0x8c90
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rsi
leaq -0x68(%rbp), %rdx
callq 0x35980
leaq -0x78(%rbp), %rdi
callq 0x8c90
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rsi
leaq -0x78(%rbp), %rdx
callq 0x35980
leaq -0x88(%rbp), %rdi
callq 0x8c90
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rsi
leaq -0x88(%rbp), %rdx
callq 0x35980
leaq -0x98(%rbp), %rdi
callq 0x8c90
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rsi
leaq -0x98(%rbp), %rdx
callq 0x35980
leaq -0xa8(%rbp), %rdi
callq 0x8c90
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rsi
leaq -0xa8(%rbp), %rdx
callq 0x35980
leaq -0xb8(%rbp), %rdi
callq 0x8c90
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rsi
leaq -0xb8(%rbp), %rdx
callq 0x35980
leaq -0x138(%rbp), %rdi
callq 0x2a260
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x30(%rbp), %rcx
leaq -0x138(%rbp), %rdx
callq 0x2d590
movq -0x18(%rbp), %rdi
leaq -0x138(%rbp), %rsi
addq $0x10, %rsi
callq 0x9100
movq -0x18(%rbp), %rdi
leaq -0x138(%rbp), %rsi
callq 0x9100
leaq -0x148(%rbp), %rdi
callq 0x8c90
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x30(%rbp), %r8
leaq -0x148(%rbp), %rdx
leaq -0x138(%rbp), %rcx
callq 0x39580
movq -0x18(%rbp), %rax
movq %rax, -0x350(%rbp)
cmpq $0x0, -0x140(%rbp)
jne 0x33cef
leaq 0x43bcf(%rip), %rax     # 0x778b5
movq %rax, -0x358(%rbp)
jmp 0x33cfd
movq -0x140(%rbp), %rax
movq %rax, -0x358(%rbp)
movq -0x358(%rbp), %rax
movq %rax, -0x360(%rbp)
cmpq $0x0, -0x60(%rbp)
jne 0x33d22
leaq 0x43b9c(%rip), %rax     # 0x778b5
movq %rax, -0x368(%rbp)
jmp 0x33d2d
movq -0x60(%rbp), %rax
movq %rax, -0x368(%rbp)
movq -0x368(%rbp), %rax
movq %rax, -0x370(%rbp)
cmpq $0x0, -0x80(%rbp)
jne 0x33d52
leaq 0x43b6c(%rip), %rax     # 0x778b5
movq %rax, -0x378(%rbp)
jmp 0x33d5d
movq -0x80(%rbp), %rax
movq %rax, -0x378(%rbp)
movq -0x370(%rbp), %rcx
movq -0x360(%rbp), %rdx
movq -0x350(%rbp), %rdi
movq -0x378(%rbp), %r8
leaq 0x458e1(%rip), %rsi     # 0x79661
movb $0x0, %al
callq 0x94d0
movq -0x18(%rbp), %rax
movq %rax, -0x380(%rbp)
cmpq $0x0, -0x60(%rbp)
jne 0x33da9
leaq 0x43b15(%rip), %rax     # 0x778b5
movq %rax, -0x388(%rbp)
jmp 0x33db4
movq -0x60(%rbp), %rax
movq %rax, -0x388(%rbp)
movq -0x380(%rbp), %rdi
movq -0x388(%rbp), %rdx
addq $0x1, %rdx
leaq 0x4588f(%rip), %rsi     # 0x7965c
movb $0x0, %al
callq 0x94d0
leaq -0x1c8(%rbp), %rdi
callq 0x2a260
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x38(%rbp), %rcx
leaq -0x1c8(%rbp), %rdx
callq 0x2d590
movq -0x18(%rbp), %rdi
leaq -0x1c8(%rbp), %rsi
addq $0x10, %rsi
callq 0x9100
movq -0x18(%rbp), %rdi
leaq -0x1c8(%rbp), %rsi
callq 0x9100
leaq -0x248(%rbp), %rdi
callq 0x2a260
movq -0x10(%rbp), %rdi
movq -0x48(%rbp), %rdx
movq -0x38(%rbp), %rax
movq 0x68(%rax), %r8
leaq -0x248(%rbp), %rsi
leaq -0x1c8(%rbp), %rcx
callq 0x2a360
movq -0x18(%rbp), %rdi
leaq -0x248(%rbp), %rsi
addq $0x10, %rsi
callq 0x9100
movq -0x18(%rbp), %rdi
leaq -0x248(%rbp), %rsi
callq 0x9100
movq -0x18(%rbp), %rax
movq %rax, -0x390(%rbp)
cmpq $0x0, -0x70(%rbp)
jne 0x33e91
leaq 0x43a2d(%rip), %rax     # 0x778b5
movq %rax, -0x398(%rbp)
jmp 0x33e9c
movq -0x70(%rbp), %rax
movq %rax, -0x398(%rbp)
movq -0x398(%rbp), %rax
movq %rax, -0x3a0(%rbp)
cmpq $0x0, -0x70(%rbp)
jne 0x33ec1
leaq 0x439fd(%rip), %rax     # 0x778b5
movq %rax, -0x3a8(%rbp)
jmp 0x33ecc
movq -0x70(%rbp), %rax
movq %rax, -0x3a8(%rbp)
movq -0x3a0(%rbp), %rdx
movq -0x390(%rbp), %rdi
movq -0x3a8(%rbp), %rcx
addq $0x1, %rcx
leaq 0x45764(%rip), %rsi     # 0x79650
movb $0x0, %al
callq 0x94d0
movq -0x18(%rbp), %rax
movq %rax, -0x3b0(%rbp)
cmpq $0x0, -0xa0(%rbp)
jne 0x33f18
leaq 0x439a6(%rip), %rax     # 0x778b5
movq %rax, -0x3b8(%rbp)
jmp 0x33f26
movq -0xa0(%rbp), %rax
movq %rax, -0x3b8(%rbp)
movq -0x3b0(%rbp), %rdi
movq -0x3b8(%rbp), %rdx
leaq 0x4589e(%rip), %rsi     # 0x797d9
movb $0x0, %al
callq 0x94d0
movq -0x18(%rbp), %rax
movq %rax, -0x3c0(%rbp)
cmpq $0x0, -0x80(%rbp)
jne 0x33f64
leaq 0x4395a(%rip), %rax     # 0x778b5
movq %rax, -0x3c8(%rbp)
jmp 0x33f6f
movq -0x80(%rbp), %rax
movq %rax, -0x3c8(%rbp)
movq -0x3c0(%rbp), %rdi
movq -0x3c8(%rbp), %rdx
addq $0x1, %rdx
leaq 0x456d4(%rip), %rsi     # 0x7965c
movb $0x0, %al
callq 0x94d0
leaq -0x2c8(%rbp), %rdi
callq 0x2a260
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x40(%rbp), %rcx
leaq -0x2c8(%rbp), %rdx
callq 0x2d590
movq -0x18(%rbp), %rdi
leaq -0x2c8(%rbp), %rsi
addq $0x10, %rsi
callq 0x9100
movq -0x18(%rbp), %rdi
leaq -0x2c8(%rbp), %rsi
callq 0x9100
leaq -0x348(%rbp), %rdi
callq 0x2a260
movq -0x10(%rbp), %rdi
movq -0x48(%rbp), %rdx
movq -0x40(%rbp), %rax
movq 0x68(%rax), %r8
leaq -0x348(%rbp), %rsi
leaq -0x2c8(%rbp), %rcx
callq 0x2a360
movq -0x18(%rbp), %rdi
leaq -0x348(%rbp), %rsi
addq $0x10, %rsi
callq 0x9100
movq -0x18(%rbp), %rdi
leaq -0x348(%rbp), %rsi
callq 0x9100
movq -0x18(%rbp), %rax
movq %rax, -0x3d0(%rbp)
cmpq $0x0, -0x90(%rbp)
jne 0x3404f
leaq 0x4386f(%rip), %rax     # 0x778b5
movq %rax, -0x3d8(%rbp)
jmp 0x3405d
movq -0x90(%rbp), %rax
movq %rax, -0x3d8(%rbp)
movq -0x3d8(%rbp), %rax
movq %rax, -0x3e0(%rbp)
cmpq $0x0, -0x90(%rbp)
jne 0x34085
leaq 0x43839(%rip), %rax     # 0x778b5
movq %rax, -0x3e8(%rbp)
jmp 0x34093
movq -0x90(%rbp), %rax
movq %rax, -0x3e8(%rbp)
movq -0x3e0(%rbp), %rdx
movq -0x3d0(%rbp), %rdi
movq -0x3e8(%rbp), %rcx
addq $0x1, %rcx
leaq 0x4559d(%rip), %rsi     # 0x79650
movb $0x0, %al
callq 0x94d0
movq -0x18(%rbp), %rax
movq %rax, -0x3f0(%rbp)
cmpq $0x0, -0xa0(%rbp)
jne 0x340df
leaq 0x437df(%rip), %rax     # 0x778b5
movq %rax, -0x3f8(%rbp)
jmp 0x340ed
movq -0xa0(%rbp), %rax
movq %rax, -0x3f8(%rbp)
movq -0x3f0(%rbp), %rdi
movq -0x3f8(%rbp), %rdx
leaq 0x456d7(%rip), %rsi     # 0x797d9
movb $0x0, %al
callq 0x94d0
movq -0x18(%rbp), %rax
movq %rax, -0x400(%rbp)
cmpq $0x0, -0xa0(%rbp)
jne 0x3412e
leaq 0x43790(%rip), %rax     # 0x778b5
movq %rax, -0x408(%rbp)
jmp 0x3413c
movq -0xa0(%rbp), %rax
movq %rax, -0x408(%rbp)
movq -0x400(%rbp), %rdi
movq -0x408(%rbp), %rdx
addq $0x1, %rdx
leaq 0x45507(%rip), %rsi     # 0x7965c
movb $0x0, %al
callq 0x94d0
movq -0x20(%rbp), %rax
movq %rax, -0x410(%rbp)
cmpq $0x0, -0xb0(%rbp)
jne 0x34181
leaq 0x4373d(%rip), %rax     # 0x778b5
movq %rax, -0x418(%rbp)
jmp 0x3418f
movq -0xb0(%rbp), %rax
movq %rax, -0x418(%rbp)
movq -0x418(%rbp), %rax
movq %rax, -0x420(%rbp)
cmpq $0x0, -0x50(%rbp)
jne 0x341b4
leaq 0x4370a(%rip), %rax     # 0x778b5
movq %rax, -0x428(%rbp)
jmp 0x341bf
movq -0x50(%rbp), %rax
movq %rax, -0x428(%rbp)
movq -0x428(%rbp), %rax
movq %rax, -0x430(%rbp)
cmpq $0x0, -0x200(%rbp)
jne 0x341e7
leaq 0x436d7(%rip), %rax     # 0x778b5
movq %rax, -0x438(%rbp)
jmp 0x341f5
movq -0x200(%rbp), %rax
movq %rax, -0x438(%rbp)
movq -0x438(%rbp), %rax
movq %rax, -0x440(%rbp)
cmpq $0x0, -0x70(%rbp)
jne 0x3421a
leaq 0x436a4(%rip), %rax     # 0x778b5
movq %rax, -0x448(%rbp)
jmp 0x34225
movq -0x70(%rbp), %rax
movq %rax, -0x448(%rbp)
movq -0x448(%rbp), %rax
movq %rax, -0x450(%rbp)
cmpq $0x0, -0x300(%rbp)
jne 0x3424d
leaq 0x43671(%rip), %rax     # 0x778b5
movq %rax, -0x458(%rbp)
jmp 0x3425b
movq -0x300(%rbp), %rax
movq %rax, -0x458(%rbp)
movq -0x458(%rbp), %rax
movq %rax, -0x460(%rbp)
cmpq $0x0, -0x90(%rbp)
jne 0x34283
leaq 0x4363b(%rip), %rax     # 0x778b5
movq %rax, -0x468(%rbp)
jmp 0x34291
movq -0x90(%rbp), %rax
movq %rax, -0x468(%rbp)
movq -0x460(%rbp), %r10
movq -0x450(%rbp), %r9
movq -0x440(%rbp), %r8
movq -0x430(%rbp), %rcx
movq -0x420(%rbp), %rdx
movq -0x410(%rbp), %rdi
movq -0x468(%rbp), %rax
leaq 0x4551d(%rip), %rsi     # 0x797e6
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
movb $0x0, %al
callq 0x94d0
movq -0x20(%rbp), %rax
movq %rax, -0x470(%rbp)
cmpq $0x0, -0x50(%rbp)
jne 0x342fb
leaq 0x435c3(%rip), %rax     # 0x778b5
movq %rax, -0x478(%rbp)
jmp 0x34306
movq -0x50(%rbp), %rax
movq %rax, -0x478(%rbp)
movq -0x478(%rbp), %rax
movq %rax, -0x480(%rbp)
cmpq $0x0, -0xb0(%rbp)
jne 0x3432e
leaq 0x43590(%rip), %rax     # 0x778b5
movq %rax, -0x488(%rbp)
jmp 0x3433c
movq -0xb0(%rbp), %rax
movq %rax, -0x488(%rbp)
movq -0x480(%rbp), %rsi
movq -0x470(%rbp), %rdi
movq -0x488(%rbp), %rdx
callq 0x358a0
leaq -0x68(%rbp), %rdi
callq 0x9310
leaq -0x78(%rbp), %rdi
callq 0x9310
leaq -0x88(%rbp), %rdi
callq 0x9310
leaq -0x98(%rbp), %rdi
callq 0x9310
leaq -0xa8(%rbp), %rdi
callq 0x9310
leaq -0xb8(%rbp), %rdi
callq 0x9310
leaq -0x138(%rbp), %rdi
callq 0x2c6a0
leaq -0x1c8(%rbp), %rdi
callq 0x2c6a0
leaq -0x248(%rbp), %rdi
callq 0x2c6a0
leaq -0x2c8(%rbp), %rdi
callq 0x2c6a0
leaq -0x348(%rbp), %rdi
callq 0x2c6a0
leaq -0x58(%rbp), %rdi
callq 0x9310
leaq -0x148(%rbp), %rdi
callq 0x9310
movb $0x1, -0x1(%rbp)
jmp 0x343f3
movb $0x0, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x4a0, %rsp            # imm = 0x4A0
popq %rbp
retq
nopw %cs:(%rax,%rax)