// File: /workspace/github_c_makefile_star2_O2/saltyJeff[P]uClibcpp/extra/config/./expr.c
// Function: expr_join_or
struct expr *expr_join_or(struct expr *e1, struct expr *e2)
{
	struct expr *tmp;
	struct symbol *sym1, *sym2;

	if (expr_eq(e1, e2))
		return expr_copy(e1);
	if (e1->type != E_EQUAL && e1->type != E_UNEQUAL && e1->type != E_SYMBOL && e1->type != E_NOT)
		return NULL;
	if (e2->type != E_EQUAL && e2->type != E_UNEQUAL && e2->type != E_SYMBOL && e2->type != E_NOT)
		return NULL;
	if (e1->type == E_NOT) {
		tmp = e1->left.expr;
		if (tmp->type != E_EQUAL && tmp->type != E_UNEQUAL && tmp->type != E_SYMBOL)
			return NULL;
		sym1 = tmp->left.sym;
	} else
		sym1 = e1->left.sym;
	if (e2->type == E_NOT) {
		if (e2->left.expr->type != E_SYMBOL)
			return NULL;
		sym2 = e2->left.expr->left.sym;
	} else
		sym2 = e2->left.sym;
	if (sym1 != sym2)
		return NULL;
	if (sym1->type != S_BOOLEAN && sym1->type != S_TRISTATE)
		return NULL;
	if (sym1->type == S_TRISTATE) {
		if (e1->type == E_EQUAL && e2->type == E_EQUAL &&
		    ((e1->right.sym == &symbol_yes && e2->right.sym == &symbol_mod) ||
		     (e1->right.sym == &symbol_mod && e2->right.sym == &symbol_yes))) {
			// (a='y') || (a='m') -> (a!='n')
			return expr_alloc_comp(E_UNEQUAL, sym1, &symbol_no);
		}
		if (e1->type == E_EQUAL && e2->type == E_EQUAL &&
		    ((e1->right.sym == &symbol_yes && e2->right.sym == &symbol_no) ||
		     (e1->right.sym == &symbol_no && e2->right.sym == &symbol_yes))) {
			// (a='y') || (a='n') -> (a!='m')
			return expr_alloc_comp(E_UNEQUAL, sym1, &symbol_mod);
		}
		if (e1->type == E_EQUAL && e2->type == E_EQUAL &&
		    ((e1->right.sym == &symbol_mod && e2->right.sym == &symbol_no) ||
		     (e1->right.sym == &symbol_no && e2->right.sym == &symbol_mod))) {
			// (a='m') || (a='n') -> (a!='y')
			return expr_alloc_comp(E_UNEQUAL, sym1, &symbol_yes);
		}
	}
	if (sym1->type == S_BOOLEAN && sym1 == sym2) {
		if ((e1->type == E_NOT && e1->left.expr->type == E_SYMBOL && e2->type == E_SYMBOL) ||
		    (e2->type == E_NOT && e2->left.expr->type == E_SYMBOL && e1->type == E_SYMBOL))
			return expr_alloc_symbol(&symbol_yes);
	}

	printf("optimize ");
	print_expr(0, e1, 0);
	printf(" || ");
	print_expr(0, e2, 0);
	printf(" ?\n");
	return NULL;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
callq 0x818b
testl %eax, %eax
je 0x831d
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x7dc5
movl (%r14), %eax
cmpl $0x7, %eax
ja 0x848e
movl $0xb8, %ecx
btl %eax, %ecx
jae 0x848e
movl (%rbx), %ecx
cmpl $0x7, %ecx
ja 0x848e
movl $0xb8, %edx
btl %ecx, %edx
jae 0x848e
movq %r14, %rdx
cmpl $0x3, %eax
jne 0x8375
movq 0x8(%r14), %rdx
movl (%rdx), %esi
cmpl $0x7, %esi
ja 0x848e
movl $0xb0, %edi
btl %esi, %edi
jae 0x848e
movq 0x8(%rdx), %rsi
movq %rbx, %rdx
cmpl $0x3, %ecx
jne 0x838e
movq 0x8(%rbx), %rdx
cmpl $0x7, (%rdx)
jne 0x848e
cmpq 0x8(%rdx), %rsi
jne 0x848e
movl 0x18(%rsi), %edx
leal -0x1(%rdx), %edi
cmpl $0x1, %edi
ja 0x848e
cmpl $0x2, %edx
jne 0x83f7
xorl $0x4, %eax
xorl $0x4, %ecx
orl %eax, %ecx
jne 0x8466
movq 0x10(%r14), %rdx
leaq 0xbed3(%rip), %rax      # 0x14298
cmpq %rax, %rdx
je 0x8430
leaq 0xbf37(%rip), %rcx      # 0x14308
cmpq %rcx, %rdx
je 0x8453
leaq 0xbe4b(%rip), %rdi      # 0x14228
cmpq %rdi, %rdx
jne 0x8466
cmpq %rax, 0x10(%rbx)
je 0x844a
cmpq %rcx, 0x10(%rbx)
jne 0x8466
jmp 0x84a1
cmpl $0x3, %eax
jne 0x840a
cmpl $0x7, %ecx
jne 0x840a
movq 0x8(%r14), %rdx
cmpl $0x7, (%rdx)
je 0x841d
cmpl $0x3, %ecx
jne 0x8466
cmpl $0x7, %eax
jne 0x8466
movq 0x8(%rbx), %rax
cmpl $0x7, (%rax)
jne 0x8466
leaq 0xbe74(%rip), %rdi      # 0x14298
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x5567
leaq 0xbed1(%rip), %rax      # 0x14308
cmpq %rax, 0x10(%rbx)
je 0x8498
leaq 0xbde4(%rip), %rax      # 0x14228
cmpq %rax, 0x10(%rbx)
jne 0x8466
leaq 0xbeb7(%rip), %rdx      # 0x14308
jmp 0x84a8
cmpq %rax, 0x10(%rbx)
je 0x8498
leaq 0xbdc8(%rip), %rax      # 0x14228
cmpq %rax, 0x10(%rbx)
je 0x84a1
leaq 0x7717(%rip), %rdi      # 0xfb84
xorl %eax, %eax
callq 0x2100
leaq 0x7713(%rip), %rdi      # 0xfb8e
xorl %eax, %eax
callq 0x2100
leaq 0x7ecd(%rip), %rdi      # 0x10356
callq 0x20a0
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
leaq 0xbd89(%rip), %rdx      # 0x14228
jmp 0x84a8
leaq 0xbdf0(%rip), %rdx      # 0x14298
pushq $0x5
popq %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x5293