// File: /workspace/github_c_makefile_star2_O0/Ihsoh[P]ilang/compiler/frontend/irgen.c
// Function: ir_expr_cond
static bool _ir_expr_cond(
	IRGeneratorContext *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);

		_TMP_LABEL_DEF(ctx, expr_true)
		_TMP_LABEL_DEF(ctx, expr_false)
		_TMP_LABEL_DEF(ctx, end)

		ResizableString rstr_result;
		rstr_init(&rstr_result);
		_generate_func_tmp_var(
			ctx,
			ctx->func_symbol,
			&rstr_result,
			node_target_type
		);

		_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,
			"cbr %s, %s, %s;\n",
			RSTR_CSTR(&rstr_expr_cond),
			_TMP_LABEL_CSTR(expr_true),
			_TMP_LABEL_CSTR(expr_false)
		);

		rstr_appendf(
			rstr,
			"%s:\n",
			_TMP_LABEL_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,
			"assign %s, %s;\n",
			RSTR_CSTR(&rstr_result),
			RSTR_CSTR(&(result_expr_true_casted.rstr_result))
		);

		rstr_appendf(
			rstr,
			"br %s;\n",
			_TMP_LABEL_CSTR(end)
		);

		rstr_appendf(
			rstr,
			"%s:\n",
			_TMP_LABEL_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,
			"assign %s, %s;\n",
			RSTR_CSTR(&rstr_result),
			RSTR_CSTR(&(result_expr_false_casted.rstr_result))
		);

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

		_expr_result_set_result(
			expr_result,
			RSTR_CSTR(&rstr_result)
		);

		_TMP_LABEL_FREE(expr_true)
		_TMP_LABEL_FREE(expr_false)
		_TMP_LABEL_FREE(end)

		rstr_free(&rstr_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_expr_cond);

		return true;
	} else {
		return false;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2a0, %rsp            # imm = 0x2A0
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x18de4
jmp 0x18e03
leaq 0x6376b(%rip), %rdi     # 0x7c556
leaq 0x5b5a2(%rip), %rsi     # 0x74394
movl $0xcec, %edx            # imm = 0xCEC
leaq 0x5d060(%rip), %rcx     # 0x75e5e
callq 0x30a0
cmpq $0x0, -0x18(%rbp)
je 0x18e0c
jmp 0x18e2b
leaq 0x59cfb(%rip), %rdi     # 0x72b0e
leaq 0x5b57a(%rip), %rsi     # 0x74394
movl $0xced, %edx            # imm = 0xCED
leaq 0x5d038(%rip), %rcx     # 0x75e5e
callq 0x30a0
cmpq $0x0, -0x20(%rbp)
je 0x18e34
jmp 0x18e53
leaq 0x5bdd8(%rip), %rdi     # 0x74c13
leaq 0x5b552(%rip), %rsi     # 0x74394
movl $0xcee, %edx            # imm = 0xCEE
leaq 0x5d010(%rip), %rcx     # 0x75e5e
callq 0x30a0
cmpq $0x0, -0x28(%rbp)
je 0x18e5c
jmp 0x18e7b
leaq 0x5d170(%rip), %rdi     # 0x75fd3
leaq 0x5b52a(%rip), %rsi     # 0x74394
movl $0xcef, %edx            # imm = 0xCEF
leaq 0x5cfe8(%rip), %rcx     # 0x75e5e
callq 0x30a0
movq -0x28(%rbp), %rax
cmpl $0xecd, (%rax)          # imm = 0xECD
jne 0x194be
movq -0x28(%rbp), %rax
cmpl $0x3, 0x44(%rax)
jne 0x18e97
jmp 0x18eb6
leaq 0x5d01d(%rip), %rdi     # 0x75ebb
leaq 0x5b4ef(%rip), %rsi     # 0x74394
movl $0xcf2, %edx            # imm = 0xCF2
leaq 0x5cfad(%rip), %rcx     # 0x75e5e
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 -0x10(%rbp), %rax
movq 0x40(%rax), %rsi
leaq -0x58(%rbp), %rdx
callq 0x1aa30
leaq -0x68(%rbp), %rdi
callq 0x8c90
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rsi
leaq -0x68(%rbp), %rdx
callq 0x1aa30
leaq -0x78(%rbp), %rdi
callq 0x8c90
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rsi
leaq -0x78(%rbp), %rdx
callq 0x1aa30
leaq -0x88(%rbp), %rdi
callq 0x8c90
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rsi
movq -0x48(%rbp), %rcx
leaq -0x88(%rbp), %rdx
callq 0x1ab00
leaq -0xc8(%rbp), %rdi
callq 0x113b0
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x30(%rbp), %rcx
leaq -0xc8(%rbp), %rdx
callq 0x13d10
movq -0x18(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
addq $0x10, %rsi
callq 0x9100
movq -0x18(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x9100
leaq -0xd8(%rbp), %rdi
callq 0x8c90
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x30(%rbp), %r8
leaq -0xd8(%rbp), %rdx
leaq -0xc8(%rbp), %rcx
callq 0x1d730
movq -0x18(%rbp), %rax
movq %rax, -0x1e0(%rbp)
cmpq $0x0, -0xd0(%rbp)
jne 0x1900b
leaq 0x5e8b3(%rip), %rax     # 0x778b5
movq %rax, -0x1e8(%rbp)
jmp 0x19019
movq -0xd0(%rbp), %rax
movq %rax, -0x1e8(%rbp)
movq -0x1e8(%rbp), %rax
movq %rax, -0x1f0(%rbp)
cmpq $0x0, -0x50(%rbp)
jne 0x1903e
leaq 0x5e880(%rip), %rax     # 0x778b5
movq %rax, -0x1f8(%rbp)
jmp 0x19049
movq -0x50(%rbp), %rax
movq %rax, -0x1f8(%rbp)
movq -0x1f8(%rbp), %rax
movq %rax, -0x200(%rbp)
cmpq $0x0, -0x60(%rbp)
jne 0x1906e
leaq 0x5e850(%rip), %rax     # 0x778b5
movq %rax, -0x208(%rbp)
jmp 0x19079
movq -0x60(%rbp), %rax
movq %rax, -0x208(%rbp)
movq -0x200(%rbp), %rcx
movq -0x1f0(%rbp), %rdx
movq -0x1e0(%rbp), %rdi
movq -0x208(%rbp), %r8
leaq 0x5cca0(%rip), %rsi     # 0x75d3c
movb $0x0, %al
callq 0x94d0
movq -0x18(%rbp), %rax
movq %rax, -0x210(%rbp)
cmpq $0x0, -0x50(%rbp)
jne 0x190c5
leaq 0x5e7f9(%rip), %rax     # 0x778b5
movq %rax, -0x218(%rbp)
jmp 0x190d0
movq -0x50(%rbp), %rax
movq %rax, -0x218(%rbp)
movq -0x210(%rbp), %rdi
movq -0x218(%rbp), %rdx
leaq 0x60577(%rip), %rsi     # 0x7965c
movb $0x0, %al
callq 0x94d0
leaq -0x118(%rbp), %rdi
callq 0x113b0
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x38(%rbp), %rcx
leaq -0x118(%rbp), %rdx
callq 0x13d10
movq -0x18(%rbp), %rdi
leaq -0x118(%rbp), %rsi
addq $0x10, %rsi
callq 0x9100
movq -0x18(%rbp), %rdi
leaq -0x118(%rbp), %rsi
callq 0x9100
leaq -0x158(%rbp), %rdi
callq 0x113b0
movq -0x10(%rbp), %rdi
movq -0x48(%rbp), %rdx
movq -0x38(%rbp), %rax
movq 0x68(%rax), %r8
leaq -0x158(%rbp), %rsi
leaq -0x118(%rbp), %rcx
callq 0x11460
movq -0x18(%rbp), %rdi
leaq -0x158(%rbp), %rsi
addq $0x10, %rsi
callq 0x9100
movq -0x18(%rbp), %rdi
leaq -0x158(%rbp), %rsi
callq 0x9100
movq -0x18(%rbp), %rax
movq %rax, -0x220(%rbp)
cmpq $0x0, -0x80(%rbp)
jne 0x191a9
leaq 0x5e715(%rip), %rax     # 0x778b5
movq %rax, -0x228(%rbp)
jmp 0x191b4
movq -0x80(%rbp), %rax
movq %rax, -0x228(%rbp)
movq -0x228(%rbp), %rax
movq %rax, -0x230(%rbp)
cmpq $0x0, -0x130(%rbp)
jne 0x191dc
leaq 0x5e6e2(%rip), %rax     # 0x778b5
movq %rax, -0x238(%rbp)
jmp 0x191ea
movq -0x130(%rbp), %rax
movq %rax, -0x238(%rbp)
movq -0x230(%rbp), %rdx
movq -0x220(%rbp), %rdi
movq -0x238(%rbp), %rcx
leaq 0x5b460(%rip), %rsi     # 0x74666
movb $0x0, %al
callq 0x94d0
movq -0x18(%rbp), %rax
movq %rax, -0x240(%rbp)
cmpq $0x0, -0x70(%rbp)
jne 0x1922f
leaq 0x5e68f(%rip), %rax     # 0x778b5
movq %rax, -0x248(%rbp)
jmp 0x1923a
movq -0x70(%rbp), %rax
movq %rax, -0x248(%rbp)
movq -0x240(%rbp), %rdi
movq -0x248(%rbp), %rdx
leaq 0x5cafe(%rip), %rsi     # 0x75d4d
movb $0x0, %al
callq 0x94d0
movq -0x18(%rbp), %rax
movq %rax, -0x250(%rbp)
cmpq $0x0, -0x60(%rbp)
jne 0x19278
leaq 0x5e646(%rip), %rax     # 0x778b5
movq %rax, -0x258(%rbp)
jmp 0x19283
movq -0x60(%rbp), %rax
movq %rax, -0x258(%rbp)
movq -0x250(%rbp), %rdi
movq -0x258(%rbp), %rdx
leaq 0x603c4(%rip), %rsi     # 0x7965c
movb $0x0, %al
callq 0x94d0
leaq -0x198(%rbp), %rdi
callq 0x113b0
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x40(%rbp), %rcx
leaq -0x198(%rbp), %rdx
callq 0x13d10
movq -0x18(%rbp), %rdi
leaq -0x198(%rbp), %rsi
addq $0x10, %rsi
callq 0x9100
movq -0x18(%rbp), %rdi
leaq -0x198(%rbp), %rsi
callq 0x9100
leaq -0x1d8(%rbp), %rdi
callq 0x113b0
movq -0x10(%rbp), %rdi
movq -0x48(%rbp), %rdx
movq -0x40(%rbp), %rax
movq 0x68(%rax), %r8
leaq -0x1d8(%rbp), %rsi
leaq -0x198(%rbp), %rcx
callq 0x11460
movq -0x18(%rbp), %rdi
leaq -0x1d8(%rbp), %rsi
addq $0x10, %rsi
callq 0x9100
movq -0x18(%rbp), %rdi
leaq -0x1d8(%rbp), %rsi
callq 0x9100
movq -0x18(%rbp), %rax
movq %rax, -0x260(%rbp)
cmpq $0x0, -0x80(%rbp)
jne 0x1935c
leaq 0x5e562(%rip), %rax     # 0x778b5
movq %rax, -0x268(%rbp)
jmp 0x19367
movq -0x80(%rbp), %rax
movq %rax, -0x268(%rbp)
movq -0x268(%rbp), %rax
movq %rax, -0x270(%rbp)
cmpq $0x0, -0x1b0(%rbp)
jne 0x1938f
leaq 0x5e52f(%rip), %rax     # 0x778b5
movq %rax, -0x278(%rbp)
jmp 0x1939d
movq -0x1b0(%rbp), %rax
movq %rax, -0x278(%rbp)
movq -0x270(%rbp), %rdx
movq -0x260(%rbp), %rdi
movq -0x278(%rbp), %rcx
leaq 0x5b2ad(%rip), %rsi     # 0x74666
movb $0x0, %al
callq 0x94d0
movq -0x18(%rbp), %rax
movq %rax, -0x280(%rbp)
cmpq $0x0, -0x70(%rbp)
jne 0x193e2
leaq 0x5e4dc(%rip), %rax     # 0x778b5
movq %rax, -0x288(%rbp)
jmp 0x193ed
movq -0x70(%rbp), %rax
movq %rax, -0x288(%rbp)
movq -0x280(%rbp), %rdi
movq -0x288(%rbp), %rdx
leaq 0x6025a(%rip), %rsi     # 0x7965c
movb $0x0, %al
callq 0x94d0
movq -0x20(%rbp), %rax
movq %rax, -0x290(%rbp)
cmpq $0x0, -0x80(%rbp)
jne 0x1942b
leaq 0x5e493(%rip), %rax     # 0x778b5
movq %rax, -0x298(%rbp)
jmp 0x19436
movq -0x80(%rbp), %rax
movq %rax, -0x298(%rbp)
movq -0x290(%rbp), %rdi
movq -0x298(%rbp), %rsi
callq 0x1a6c0
leaq -0x58(%rbp), %rdi
callq 0x9310
leaq -0x68(%rbp), %rdi
callq 0x9310
leaq -0x78(%rbp), %rdi
callq 0x9310
leaq -0x88(%rbp), %rdi
callq 0x9310
leaq -0xc8(%rbp), %rdi
callq 0x130a0
leaq -0x118(%rbp), %rdi
callq 0x130a0
leaq -0x158(%rbp), %rdi
callq 0x130a0
leaq -0x198(%rbp), %rdi
callq 0x130a0
leaq -0x1d8(%rbp), %rdi
callq 0x130a0
leaq -0xd8(%rbp), %rdi
callq 0x9310
movb $0x1, -0x1(%rbp)
jmp 0x194c2
movb $0x0, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x2a0, %rsp            # imm = 0x2A0
popq %rbp
retq