// File: /workspace/github_c_makefile_star2_O0/Ihsoh[P]ilang/compiler/backend/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 BE_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 = BE_EXPR_AST_NODE_GET_TYPE_NODE(node_expr_true);
			ParserASTNode *node_expr_false_type = BE_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) {
					BE_EXPR_AST_NODE_COPY(node, node_expr_true);
				} else {
					BE_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)) {
				BE_EXPR_AST_NODE_COPY(node, node_expr_true);
			} else {
				_SYNERR_NODE(
					ctx,
					node,
					"conditional operator do not support this operand combination."
				);
			}

			BE_EXPR_AST_NODE_COPY_CONSTANT3(
				node,
				node_expr,
				node_expr_true,
				node_expr_false
			);
			if (BE_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 0x5056c
jmp 0x5058b
leaq 0x2fbee(%rip), %rdi     # 0x80161
leaq 0x32306(%rip), %rsi     # 0x82880
movl $0xe11, %edx            # imm = 0xE11
leaq 0x32a21(%rip), %rcx     # 0x82fa7
callq 0x30a0
cmpq $0x0, -0x10(%rbp)
je 0x50594
jmp 0x505b3
leaq 0x25fc1(%rip), %rdi     # 0x7655c
leaq 0x322de(%rip), %rsi     # 0x82880
movl $0xe12, %edx            # imm = 0xE12
leaq 0x329f9(%rip), %rcx     # 0x82fa7
callq 0x30a0
movq -0x10(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %eax
subl $0xecd, %eax            # imm = 0xECD
jne 0x50831
jmp 0x505cc
movq -0x10(%rbp), %rax
cmpl $0x3, 0x44(%rax)
jne 0x505d8
jmp 0x505f7
leaq 0x26b5f(%rip), %rdi     # 0x7713e
leaq 0x3229a(%rip), %rsi     # 0x82880
movl $0xe18, %edx            # imm = 0xE18
leaq 0x329b5(%rip), %rcx     # 0x82fa7
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 0x50850
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x4f400
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x4f400
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 0x50a80
testb $0x1, %al
jne 0x506b5
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x50b30
testb $0x1, %al
jne 0x506b5
leaq -0x440(%rbp), %rdi
leaq 0x32944(%rip), %rsi     # 0x82fd9
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 0x50be0
testb $0x1, %al
jne 0x506cb
jmp 0x50750
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x40(%rbp), %rdx
xorl %ecx, %ecx
callq 0x50c90
testb $0x1, %al
jne 0x506e4
jmp 0x50750
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x50e40
movl %eax, -0x444(%rbp)
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x50e40
movl %eax, -0x448(%rbp)
movl -0x444(%rbp), %eax
cmpl -0x448(%rbp), %eax
jle 0x50734
movq -0x10(%rbp), %rdi
addq $0x60, %rdi
movq -0x28(%rbp), %rsi
addq $0x60, %rsi
movl $0x30, %edx
callq 0x3110
jmp 0x5074e
movq -0x10(%rbp), %rdi
addq $0x60, %rdi
movq -0x30(%rbp), %rsi
addq $0x60, %rsi
movl $0x30, %edx
callq 0x3110
jmp 0x507cb
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x50b30
testb $0x1, %al
jne 0x50763
jmp 0x5079b
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x40(%rbp), %rdx
movl $0x1, %ecx
callq 0x50c90
testb $0x1, %al
jne 0x5077f
jmp 0x5079b
movq -0x10(%rbp), %rdi
addq $0x60, %rdi
movq -0x28(%rbp), %rsi
addq $0x60, %rsi
movl $0x30, %edx
callq 0x3110
jmp 0x507c9
leaq -0x850(%rbp), %rdi
leaq 0x3287b(%rip), %rsi     # 0x83024
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 0x507cb
movq -0x20(%rbp), %rcx
xorl %eax, %eax
testb $0x1, 0x70(%rcx)
movb %al, -0x851(%rbp)
je 0x507fc
movq -0x28(%rbp), %rcx
xorl %eax, %eax
testb $0x1, 0x70(%rcx)
movb %al, -0x851(%rbp)
je 0x507fc
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 0x5082f
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %r8
callq 0x50ec0
jmp 0x5083e
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x50850
addq $0x860, %rsp            # imm = 0x860
popq %rbp
retq
nopw (%rax,%rax)