// File: /workspace/github_c_makefile_star2_O0/lucvoo[P]sparse-dev/linearize.c
// Function: linearize_logical
static pseudo_t linearize_logical(struct entrypoint *ep, struct expression *expr)
{
	struct symbol *ctype = expr->ctype;
	struct basic_block *other, *merge;
	struct instruction *node;
	pseudo_t src1, src2, phi2;

	if (!ep->active || !expr->left || !expr->right)
		return VOID;

	other = alloc_basic_block(ep, expr->right->pos);
	merge = alloc_basic_block(ep, expr->pos);
	node = alloc_phi_node(merge, ctype, NULL);

	// LHS and its shortcut
	if (expr->op == SPECIAL_LOGICAL_OR) {
		linearize_cond_branch(ep, expr->left, merge, other);
		src1 = value_pseudo(1);
	} else {
		linearize_cond_branch(ep, expr->left, other, merge);
		src1 = value_pseudo(0);
	}
	insert_phis(merge, src1, ctype, node);

	// RHS
	set_activeblock(ep, other);
	src2 = linearize_expression_to_bool(ep, expr->right);
	src2 = cast_pseudo(ep, src2, &bool_ctype, ctype);
	phi2 = alloc_phi(ep->active, src2, ctype);
	link_phi(node, phi2);

	// join
	set_activeblock(ep, merge);
	add_instruction(&merge->insns, node);
	return node->target;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x1cd7d
movq -0x18(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x1cd7d
movq -0x18(%rbp), %rax
cmpq $0x0, 0x28(%rax)
jne 0x1cd8d
leaq 0x6f02c(%rip), %rax     # 0x8bdb0
movq %rax, -0x8(%rbp)
jmp 0x1cecf
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rax
movq 0x8(%rax), %rsi
callq 0x1b110
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x1b110
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
movq -0x20(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x1a650
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x10e, 0x4(%rax)       # imm = 0x10E
jne 0x1ce06
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rsi
movq -0x30(%rbp), %rdx
movq -0x28(%rbp), %rcx
callq 0x1e690
movl $0x1, %edi
callq 0x1a390
movq %rax, -0x40(%rbp)
jmp 0x1ce2c
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rsi
movq -0x28(%rbp), %rdx
movq -0x30(%rbp), %rcx
callq 0x1e690
xorl %eax, %eax
movl %eax, %edi
callq 0x1a390
movq %rax, -0x40(%rbp)
movq -0x30(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x38(%rbp), %rcx
callq 0x1fbd0
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x1b170
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rsi
callq 0x1f120
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0x20(%rbp), %rcx
leaq 0x745a2(%rip), %rdx     # 0x91418
callq 0x1f5f0
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x48(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x1a5b0
movq %rax, -0x50(%rbp)
movq -0x38(%rbp), %rdi
movq -0x50(%rbp), %rsi
callq 0x1ef20
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x1b170
movq -0x30(%rbp), %rdi
addq $0x28, %rdi
movq -0x38(%rbp), %rsi
callq 0x1a620
movq -0x38(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)