// File: /workspace/github_c_makefile_star2_O3/lucvoo[P]sparse-dev/simplify.c
// Function: simplify_mask_or
static int simplify_mask_or(struct instruction *insn, unsigned long long mask, struct instruction *or)
{
	pseudo_t src1 = or->src1;
	pseudo_t src2 = or->src2;
	int rc;

	if (src1->type == PSEUDO_REG) {
		if ((rc = simplify_mask_or_and(insn, mask, src1, src2)))
			return rc;
	}
	if (src2->type == PSEUDO_REG) {
		if ((rc = simplify_mask_or_and(insn, mask, src2, src1)))
			return rc;
	} else if (src2->type == PSEUDO_VAL) {
		unsigned long long oval = src2->value;
		unsigned long long nval = oval & mask;
		// Try to simplify:
		//	MASK(OR(x, C), M)
		if (nval == 0) {
			// if (C & M) == 0: OR(x, C) -> x
			return replace_pseudo(insn, &insn->src1, src1);
		}
		if (nval == mask) {
			// if (C & M) == M: OR(x, C) -> M
			return replace_pseudo(insn, &insn->src1, value_pseudo(mask));
		}
		if (nval != oval && one_use(or->target)) {
			// if (C & M) != C: OR(x, C) -> OR(x, (C & M))
			return replace_pseudo(or, &or->src2, value_pseudo(nval));
		}
	}
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r12
movq %rsi, %r13
movq %rdi, %r14
movq 0x30(%rdx), %r15
movq 0x38(%rdx), %rbp
cmpl $0x3, 0x4(%r15)
jne 0x2874a
movq %r14, %rdi
movq %r13, %rsi
movq %r15, %rdx
movq %rbp, %rcx
callq 0x2890a
movl $0x1, %ebx
testl %eax, %eax
jne 0x288d7
movl 0x4(%rbp), %eax
cmpl $0x6, %eax
je 0x2877e
cmpl $0x3, %eax
jne 0x288d5
movq %r14, %rdi
movq %r13, %rsi
movq %rbp, %rdx
movq %r15, %rcx
callq 0x2890a
movl $0x1, %ebx
testl %eax, %eax
jne 0x288d7
jmp 0x288d5
movq 0x18(%rbp), %rax
movq %rax, %rbx
andq %r13, %rbx
je 0x28839
cmpq %r13, %rbx
jne 0x288be
leaq 0x30(%r14), %r15
movq %r13, %rdi
callq 0x13745
movq 0x30(%r14), %r12
movq %rax, 0x30(%r14)
testq %rax, %rax
je 0x287e2
movq %rax, %rbx
movl 0x4(%rax), %eax
cmpl $0x6, %eax
ja 0x287c5
movl $0x43, %ecx
btl %eax, %ecx
jb 0x287e2
xorl %edi, %edi
callq 0x12264
movq %r15, 0x8(%rax)
movq %r14, (%rax)
addq $0x8, %rbx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x227b4
movl $0x1, %ebx
testq %r12, %r12
je 0x288d7
movl 0x4(%r12), %eax
cmpl $0x6, %eax
ja 0x28808
movl $0x43, %ecx
btl %eax, %ecx
jb 0x288d7
leaq 0x8(%r12), %rdi
movq %r15, %rsi
callq 0x2806f
cmpq $0x0, 0x8(%r12)
jne 0x288d7
movl 0x4(%r12), %eax
andl $-0x2, %eax
cmpl $0x2, %eax
jne 0x288d7
movq 0x18(%r12), %rdi
jmp 0x288b5
leaq 0x30(%r14), %r12
movq 0x30(%r14), %r13
movq %r15, 0x30(%r14)
movl 0x4(%r15), %eax
cmpl $0x6, %eax
ja 0x28858
movl $0x43, %ecx
btl %eax, %ecx
jb 0x28875
xorl %edi, %edi
callq 0x12264
movq %r12, 0x8(%rax)
movq %r14, (%rax)
addq $0x8, %r15
movq %r15, %rdi
movq %rax, %rsi
callq 0x227b4
movl $0x1, %ebx
testq %r13, %r13
je 0x288d7
movl 0x4(%r13), %eax
cmpl $0x6, %eax
ja 0x28892
movl $0x43, %ecx
btl %eax, %ecx
jb 0x288d7
leaq 0x8(%r13), %rdi
movq %r12, %rsi
callq 0x2806f
cmpq $0x0, 0x8(%r13)
jne 0x288d7
movl 0x4(%r13), %eax
andl $-0x2, %eax
cmpl $0x2, %eax
jne 0x288d7
movq 0x18(%r13), %rdi
xorl %esi, %esi
callq 0x24a3f
jmp 0x288d7
cmpq %rax, %rbx
je 0x288d5
movq 0x20(%r12), %rax
movq 0x8(%rax), %rdi
callq 0x2257f
testb %al, %al
je 0x288e8
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x38(%r12), %r14
movq %rbx, %rdi
callq 0x13745
movq %r12, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x28562
movl $0x1, %ebx
jmp 0x288d7