// File: /workspace/github_c_makefile_star2_O0/Ihsoh[P]ilang/compiler/frontend/semantics.c
// Function: expr_cond
static void _expr_cond(
	ParserContext *ctx,
	ParserASTNode *node
) {
	assert(ctx);
	assert(node);

	uint32_t node_type = node->type;

	switch (node_type) {
		case FE_NODE_EXPR_COND: {
			assert(node->nchilds == 3);

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

			_expr_or(ctx, node_expr);
			_expr(ctx, node_expr_true);
			_expr(ctx, node_expr_false);

			ParserASTNode *node_expr_true_type = FE_EXPR_AST_NODE_GET_TYPE_NODE(node_expr_true);
			ParserASTNode *node_expr_false_type = FE_EXPR_AST_NODE_GET_TYPE_NODE(node_expr_false);

			if (!_is_integer_type_node(ctx, node_expr)
					&& !_is_pointer_type_node(ctx, node_expr)) {
				_SYNERR_NODE(
					ctx,
					node,
					"conditional operator condexpr type must be primitive type or pointer type."
				);
			}

			if (_is_primitive_type_node(ctx, node_expr_true)
					&& _is_compatible_type(ctx, node_expr_true_type, node_expr_false_type, false)) {
				int32_t weight_node_expr_true = _get_primitive_type_weight_by_expr_node(ctx, node_expr_true);
				int32_t weight_node_expr_false = _get_primitive_type_weight_by_expr_node(ctx, node_expr_false);
				if (weight_node_expr_true > weight_node_expr_false) {
					FE_EXPR_AST_NODE_COPY(node, node_expr_true);
				} else {
					FE_EXPR_AST_NODE_COPY(node, node_expr_false);
				}
			} else if (_is_pointer_type_node(ctx, node_expr_true)
					&& _is_compatible_type(ctx, node_expr_true_type, node_expr_false_type, true)) {
				FE_EXPR_AST_NODE_COPY(node, node_expr_true);
			} else {
				_SYNERR_NODE(
					ctx,
					node,
					"conditional operator do not support this operand combination."
				);
			}

			FE_EXPR_AST_NODE_COPY_CONSTANT3(
				node,
				node_expr,
				node_expr_true,
				node_expr_false
			);
			if (FE_EXPR_AST_NODE_GET_CONSTANT(node)) {
				_calc_cond_constexpr(ctx, node, node_expr, node_expr_true, node_expr_false);
			}

			break;
		}
		default: {
			_expr_or(ctx, node);
			break;
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x860, %rsp            # imm = 0x860
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x511cc
jmp 0x511eb
leaq 0x2b383(%rip), %rdi     # 0x7c556
leaq 0x2d070(%rip), %rsi     # 0x7e24a
movl $0x1292, %edx           # imm = 0x1292
leaq 0x2d707(%rip), %rcx     # 0x7e8ed
callq 0x30a0
cmpq $0x0, -0x10(%rbp)
je 0x511f4
jmp 0x51213
leaq 0x24dd8(%rip), %rdi     # 0x75fd3
leaq 0x2d048(%rip), %rsi     # 0x7e24a
movl $0x1293, %edx           # imm = 0x1293
leaq 0x2d6df(%rip), %rcx     # 0x7e8ed
callq 0x30a0
movq -0x10(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %eax
subl $0xecd, %eax            # imm = 0xECD
jne 0x51491
jmp 0x5122c
movq -0x10(%rbp), %rax
cmpl $0x3, 0x44(%rax)
jne 0x51238
jmp 0x51257
leaq 0x24c7c(%rip), %rdi     # 0x75ebb
leaq 0x2d004(%rip), %rsi     # 0x7e24a
movl $0x1299, %edx           # imm = 0x1299
leaq 0x2d69b(%rip), %rcx     # 0x7e8ed
callq 0x30a0
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq 0x10(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x52490
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x4f4b0
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x4f4b0
movq -0x28(%rbp), %rax
movq 0x68(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rax
movq 0x68(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x526c0
testb $0x1, %al
jne 0x51315
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x52770
testb $0x1, %al
jne 0x51315
leaq -0x440(%rbp), %rdi
leaq 0x2d62a(%rip), %rsi     # 0x7e91f
movb $0x0, %al
callq 0x3160
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
leaq -0x440(%rbp), %rdx
callq *%rax
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x52820
testb $0x1, %al
jne 0x5132b
jmp 0x513b0
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x40(%rbp), %rdx
xorl %ecx, %ecx
callq 0x4d570
testb $0x1, %al
jne 0x51344
jmp 0x513b0
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x528d0
movl %eax, -0x444(%rbp)
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x528d0
movl %eax, -0x448(%rbp)
movl -0x444(%rbp), %eax
cmpl -0x448(%rbp), %eax
jle 0x51394
movq -0x10(%rbp), %rdi
addq $0x60, %rdi
movq -0x28(%rbp), %rsi
addq $0x60, %rsi
movl $0x30, %edx
callq 0x3110
jmp 0x513ae
movq -0x10(%rbp), %rdi
addq $0x60, %rdi
movq -0x30(%rbp), %rsi
addq $0x60, %rsi
movl $0x30, %edx
callq 0x3110
jmp 0x5142b
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x52770
testb $0x1, %al
jne 0x513c3
jmp 0x513fb
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x40(%rbp), %rdx
movl $0x1, %ecx
callq 0x4d570
testb $0x1, %al
jne 0x513df
jmp 0x513fb
movq -0x10(%rbp), %rdi
addq $0x60, %rdi
movq -0x28(%rbp), %rsi
addq $0x60, %rsi
movl $0x30, %edx
callq 0x3110
jmp 0x51429
leaq -0x850(%rbp), %rdi
leaq 0x2d561(%rip), %rsi     # 0x7e96a
movb $0x0, %al
callq 0x3160
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
leaq -0x850(%rbp), %rdx
callq *%rax
jmp 0x5142b
movq -0x20(%rbp), %rcx
xorl %eax, %eax
testb $0x1, 0x70(%rcx)
movb %al, -0x851(%rbp)
je 0x5145c
movq -0x28(%rbp), %rcx
xorl %eax, %eax
testb $0x1, 0x70(%rcx)
movb %al, -0x851(%rbp)
je 0x5145c
movq -0x30(%rbp), %rax
movb 0x70(%rax), %al
movb %al, -0x851(%rbp)
movb -0x851(%rbp), %cl
movq -0x10(%rbp), %rax
andb $0x1, %cl
movb %cl, 0x70(%rax)
movq -0x10(%rbp), %rax
testb $0x1, 0x70(%rax)
je 0x5148f
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %r8
callq 0x52950
jmp 0x5149e
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x52490
addq $0x860, %rsp            # imm = 0x860
popq %rbp
retq
nopw (%rax,%rax)