// File: /workspace/github_c_makefile_star2_O0/lucvoo[P]sparse-dev/expand.c
// Function: expand_logical
static int expand_logical(struct expression *expr)
{
	struct expression *left = expr->left;
	struct expression *right;
	int cost, rcost;

	/* Do immediate short-circuiting ... */
	cost = expand_expression(left);
	if (left->type == EXPR_VALUE) {
		if (expr->op == SPECIAL_LOGICAL_AND) {
			if (!left->value) {
				expr->type = EXPR_VALUE;
				expr->value = 0;
				expr->taint = left->taint;
				return 0;
			}
		} else {
			if (left->value) {
				expr->type = EXPR_VALUE;
				expr->value = 1;
				expr->taint = left->taint;
				return 0;
			}
		}
	}

	right = expr->right;
	rcost = expand_expression(right);
	if (left->type == EXPR_VALUE && right->type == EXPR_VALUE) {
		/*
		 * We know the left value doesn't matter, since
		 * otherwise we would have short-circuited it..
		 */
		expr->type = EXPR_VALUE;
		expr->value = right->value != 0;
		expr->taint = left->taint | right->taint;
		return 0;
	}

	/*
	 * If the right side is safe and cheaper than a branch,
	 * just avoid the branch and turn it into a regular binop
	 * style SAFELOGICAL.
	 */
	if (rcost < BRANCH_COST) {
		expr->type = EXPR_BINOP;
		rcost -= BRANCH_COST - 1;
	}

	return cost + BRANCH_COST + rcost;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
callq 0x11b30
movl %eax, -0x24(%rbp)
movq -0x18(%rbp), %rax
movl (%rax), %eax
andl $0xff, %eax
cmpl $0x1, %eax
jne 0x1253f
movq -0x10(%rbp), %rax
cmpl $0x10c, 0x4(%rax)       # imm = 0x10C
jne 0x124f9
movq -0x18(%rbp), %rax
cmpq $0x0, 0x20(%rax)
jne 0x124f7
movq -0x10(%rbp), %rax
movl (%rax), %ecx
andl $0xffffff00, %ecx       # imm = 0xFFFFFF00
orl $0x1, %ecx
movl %ecx, (%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x20(%rax)
movq -0x18(%rbp), %rax
movl 0x28(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x28(%rax)
movl $0x0, -0x4(%rbp)
jmp 0x125ee
jmp 0x1253d
movq -0x18(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x1253b
movq -0x10(%rbp), %rax
movl (%rax), %ecx
andl $0xffffff00, %ecx       # imm = 0xFFFFFF00
orl $0x1, %ecx
movl %ecx, (%rax)
movq -0x10(%rbp), %rax
movq $0x1, 0x20(%rax)
movq -0x18(%rbp), %rax
movl 0x28(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x28(%rax)
movl $0x0, -0x4(%rbp)
jmp 0x125ee
jmp 0x1253d
jmp 0x1253f
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
callq 0x11b30
movl %eax, -0x28(%rbp)
movq -0x18(%rbp), %rax
movl (%rax), %eax
andl $0xff, %eax
cmpl $0x1, %eax
jne 0x125c2
movq -0x20(%rbp), %rax
movl (%rax), %eax
andl $0xff, %eax
cmpl $0x1, %eax
jne 0x125c2
movq -0x10(%rbp), %rax
movl (%rax), %ecx
andl $0xffffff00, %ecx       # imm = 0xFFFFFF00
orl $0x1, %ecx
movl %ecx, (%rax)
movq -0x20(%rbp), %rax
cmpq $0x0, 0x20(%rax)
setne %al
andb $0x1, %al
movzbl %al, %eax
movslq %eax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x18(%rbp), %rax
movl 0x28(%rax), %ecx
movq -0x20(%rbp), %rax
orl 0x28(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x28(%rax)
movl $0x0, -0x4(%rbp)
jmp 0x125ee
cmpl $0xa, -0x28(%rbp)
jge 0x125e2
movq -0x10(%rbp), %rax
movl (%rax), %ecx
andl $0xffffff00, %ecx       # imm = 0xFFFFFF00
orl $0x5, %ecx
movl %ecx, (%rax)
movl -0x28(%rbp), %eax
subl $0x9, %eax
movl %eax, -0x28(%rbp)
movl -0x24(%rbp), %eax
addl $0xa, %eax
addl -0x28(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw (%rax,%rax)