// File: /workspace/github_c_makefile_star2_O1/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 0x28a27
movq %r14, %rdi
movq %r13, %rsi
movq %r15, %rdx
movq %rbp, %rcx
callq 0x28bec
movl $0x1, %ebx
testl %eax, %eax
jne 0x28bb9
movl 0x4(%rbp), %eax
cmpl $0x6, %eax
je 0x28a58
cmpl $0x3, %eax
jne 0x28bb7
movq %r14, %rdi
movq %r13, %rsi
movq %rbp, %rdx
movq %r15, %rcx
callq 0x28bec
movl %eax, %ebx
testl %eax, %eax
jne 0x28bb9
jmp 0x28bb7
movq 0x18(%rbp), %rax
movq %rax, %rbx
andq %r13, %rbx
je 0x28b16
cmpq %r13, %rbx
jne 0x28ba0
leaq 0x30(%r14), %r15
movq %r13, %rdi
callq 0x136d3
movq 0x30(%r14), %r12
movq %rax, 0x30(%r14)
testq %rax, %rax
je 0x28abc
movq %rax, %rbx
movl 0x4(%rax), %eax
cmpl $0x6, %eax
ja 0x28a9f
movl $0x43, %ecx
btl %eax, %ecx
jb 0x28abc
xorl %edi, %edi
callq 0x12220
movq %r15, 0x8(%rax)
movq %r14, (%rax)
addq $0x8, %rbx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x2285b
movl $0x1, %ebx
testq %r12, %r12
je 0x28bb9
movl 0x4(%r12), %eax
cmpl $0x6, %eax
ja 0x28ae2
movl $0x43, %ecx
btl %eax, %ecx
jb 0x28bb9
leaq 0x8(%r12), %rdi
movq %r15, %rsi
callq 0x2830b
cmpq $0x0, 0x8(%r12)
jne 0x28bb9
movl 0x4(%r12), %eax
andl $-0x2, %eax
cmpl $0x2, %eax
jne 0x28bb9
movq 0x18(%r12), %rdi
jmp 0x28b97
leaq 0x30(%r14), %r12
movq 0x30(%r14), %r13
movq %r15, 0x30(%r14)
testq %r15, %r15
je 0x28b57
movl 0x4(%r15), %eax
cmpl $0x6, %eax
ja 0x28b3a
movl $0x43, %ecx
btl %eax, %ecx
jb 0x28b57
xorl %edi, %edi
callq 0x12220
movq %r12, 0x8(%rax)
movq %r14, (%rax)
addq $0x8, %r15
movq %r15, %rdi
movq %rax, %rsi
callq 0x2285b
movl $0x1, %ebx
testq %r13, %r13
je 0x28bb9
movl 0x4(%r13), %eax
cmpl $0x6, %eax
ja 0x28b74
movl $0x43, %ecx
btl %eax, %ecx
jb 0x28bb9
leaq 0x8(%r13), %rdi
movq %r12, %rsi
callq 0x2830b
cmpq $0x0, 0x8(%r13)
jne 0x28bb9
movl 0x4(%r13), %eax
andl $-0x2, %eax
cmpl $0x2, %eax
jne 0x28bb9
movq 0x18(%r13), %rdi
xorl %esi, %esi
callq 0x24adf
jmp 0x28bb9
cmpq %rax, %rbx
je 0x28bb7
movq 0x20(%r12), %rax
movq 0x8(%rax), %rdi
callq 0x22603
testb %al, %al
je 0x28bca
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 0x136d3
movq %r12, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x28833
movl $0x1, %ebx
jmp 0x28bb9