// File: /workspace/github_c_makefile_star2_O3/hsjoihs[P]c-compiler/parse_expression.c
// Function: parse_conditional_expression
static struct UntypedExpr
parse_conditional_expression(const struct Token **ptr_tokvec)
{
	const struct Token *tokvec = *ptr_tokvec;
	struct UntypedExpr expr = parse_logical_OR_expression(&tokvec);
	if (tokvec[0].kind == QUESTION) {

		++tokvec;
		*ptr_tokvec = tokvec;
		struct UntypedExpr true_branch = parse_expression(&tokvec);

		expect_and_consume(&tokvec, COLON, "colon of the conditional operator");

		*ptr_tokvec = tokvec;
		struct UntypedExpr false_branch = parse_conditional_expression(&tokvec);

		*ptr_tokvec = tokvec;

		struct UntypedExpr *ptr_expr1 = calloc(1, sizeof(struct UntypedExpr));
		struct UntypedExpr *ptr_expr2 = calloc(1, sizeof(struct UntypedExpr));
		struct UntypedExpr *ptr_expr3 = calloc(1, sizeof(struct UntypedExpr));
		*ptr_expr1 = expr;
		*ptr_expr2 = true_branch;
		*ptr_expr3 = false_branch;

		struct UntypedExpr new_expr;
		new_expr.category = CONDITIONAL;
		new_expr.ptr1 = ptr_expr1;
		new_expr.ptr2 = ptr_expr2;
		new_expr.ptr3 = ptr_expr3;

		return new_expr;
	}
	*ptr_tokvec = tokvec;
	return expr;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1f8, %rsp            # imm = 0x1F8
movq %rdi, -0x38(%rbp)
movq %rsi, -0x30(%rbp)
movq (%rsi), %rax
leaq -0x180(%rbp), %r15
movq %rax, (%r15)
leaq -0xe0(%rbp), %rdi
movq %r15, %rsi
callq 0x8cce
movq (%r15), %r14
movl (%r14), %eax
cmpl $0x21, %eax
jne 0x89b7
leaq -0x220(%rbp), %r15
leaq -0x180(%rbp), %r12
leaq -0xe0(%rbp), %r13
addq $0x20, %r14
movq %r14, -0x180(%rbp)
movq %r15, %rdi
movq %r12, %rsi
callq 0x8cce
movl $0x1, %edi
movl $0xa0, %esi
callq 0x10d0
movq %rax, %r14
movl $0x1, %edi
movl $0xa0, %esi
callq 0x10d0
movq %rax, %rbx
movl $0xa0, %edx
movq %r14, %rdi
movq %r13, %rsi
callq 0x1100
movl $0xa0, %edx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x1100
movq $0x21, -0xe0(%rbp)
movq %r14, -0xd8(%rbp)
movq %rbx, -0xd0(%rbp)
movq $0x0, -0xc8(%rbp)
movq -0x180(%rbp), %r14
movl (%r14), %eax
cmpl $0x21, %eax
je 0x8926
cmpl $0x1c, %eax
jne 0x8a9f
addq $0x20, %r14
leaq -0x40(%rbp), %rbx
movq %r14, (%rbx)
movq -0x30(%rbp), %rax
movq %r14, (%rax)
movq %rax, %r14
leaq -0x220(%rbp), %rdi
movq %rbx, %rsi
callq 0x8ae5
leaq 0x779b(%rip), %rdx      # 0x10186
movq %rbx, %rdi
movl $0x1d, %esi
callq 0x9563
movq (%rbx), %rax
movq %rax, (%r14)
leaq -0x180(%rbp), %rdi
movq %rbx, %rsi
callq 0x88ca
movq (%rbx), %r14
movl $0x1, %edi
movl $0xa0, %esi
callq 0x10d0
movq %rax, %r13
movl $0x1, %edi
movl $0xa0, %esi
callq 0x10d0
movq %rax, %r15
movl $0x1, %edi
movl $0xa0, %esi
callq 0x10d0
movq %rax, %r12
leaq -0xe0(%rbp), %rsi
movl $0xa0, %edx
movq %r13, %rdi
callq 0x1100
movl $0xa0, %edx
movq %r15, %rdi
leaq -0x220(%rbp), %rsi
callq 0x1100
movl $0xa0, %edx
movq %r12, %rdi
leaq -0x180(%rbp), %rsi
callq 0x1100
movq -0x38(%rbp), %rcx
movl $0x2, 0x4(%rcx)
movq %r13, 0x8(%rcx)
movq %r15, 0x10(%rcx)
movq -0x30(%rbp), %rax
movq %r12, 0x18(%rcx)
jmp 0x8ab8
leaq -0xe0(%rbp), %rsi
movl $0xa0, %edx
movq -0x38(%rbp), %rdi
callq 0x1100
movq -0x30(%rbp), %rax
movq %r14, (%rax)
addq $0x1f8, %rsp            # imm = 0x1F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq