// File: /workspace/github_c_makefile_star2_O2/saltyJeff[P]uClibcpp/extra/config/./expr.c
// Function: expr_join_and
struct expr *expr_join_and(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 ((e1->type == E_SYMBOL && e2->type == E_EQUAL && e2->right.sym == &symbol_yes) ||
	    (e2->type == E_SYMBOL && e1->type == E_EQUAL && e1->right.sym == &symbol_yes))
		// (a) && (a='y') -> (a='y')
		return expr_alloc_comp(E_EQUAL, sym1, &symbol_yes);

	if ((e1->type == E_SYMBOL && e2->type == E_UNEQUAL && e2->right.sym == &symbol_no) ||
	    (e2->type == E_SYMBOL && e1->type == E_UNEQUAL && e1->right.sym == &symbol_no))
		// (a) && (a!='n') -> (a)
		return expr_alloc_symbol(sym1);

	if (sym1->type == S_TRISTATE) {
		if (e1->type == E_EQUAL && e2->type == E_UNEQUAL) {
			// (a='b') && (a!='c') -> 'b'='c' ? 'n' : a='b'
			sym2 = e1->right.sym;
			if ((e2->right.sym->flags & SYMBOL_CONST) && (sym2->flags & SYMBOL_CONST))
				return sym2 != e2->right.sym ? expr_alloc_comp(E_EQUAL, sym1, sym2)
							     : expr_alloc_symbol(&symbol_no);
		}
		if (e1->type == E_UNEQUAL && e2->type == E_EQUAL) {
			// (a='b') && (a!='c') -> 'b'='c' ? 'n' : a='b'
			sym2 = e2->right.sym;
			if ((e1->right.sym->flags & SYMBOL_CONST) && (sym2->flags & SYMBOL_CONST))
				return sym2 != e1->right.sym ? expr_alloc_comp(E_EQUAL, sym1, sym2)
							     : expr_alloc_symbol(&symbol_no);
		}
		if (e1->type == E_UNEQUAL && e2->type == E_UNEQUAL &&
			   ((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_EQUAL, sym1, &symbol_mod);

		if (e1->type == E_UNEQUAL && e2->type == E_UNEQUAL &&
			   ((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_EQUAL, sym1, &symbol_no);

		if (e1->type == E_UNEQUAL && e2->type == E_UNEQUAL &&
			   ((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='m')
			return expr_alloc_comp(E_EQUAL, sym1, &symbol_yes);

		if ((e1->type == E_SYMBOL && e2->type == E_EQUAL && e2->right.sym == &symbol_mod) ||
		    (e2->type == E_SYMBOL && e1->type == E_EQUAL && e1->right.sym == &symbol_mod) ||
		    (e1->type == E_SYMBOL && e2->type == E_UNEQUAL && e2->right.sym == &symbol_yes) ||
		    (e2->type == E_SYMBOL && e1->type == E_UNEQUAL && e1->right.sym == &symbol_yes))
			return NULL;
	}
	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, %r14
movq %rdi, %rbx
callq 0x818b
testl %eax, %eax
je 0x84d9
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x7dc5
movl (%rbx), %ecx
cmpl $0x7, %ecx
ja 0x8789
movl $0xb8, %eax
btl %ecx, %eax
jae 0x8789
movl (%r14), %edx
cmpl $0x7, %edx
ja 0x8789
btl %edx, %eax
jae 0x8789
movq %rbx, %rax
cmpl $0x3, %ecx
jne 0x852c
movq 0x8(%rbx), %rax
movl (%rax), %esi
cmpl $0x7, %esi
ja 0x8789
movl $0xb0, %edi
btl %esi, %edi
jae 0x8789
movq 0x8(%rax), %rsi
movq %r14, %rax
cmpl $0x3, %edx
jne 0x8545
movq 0x8(%r14), %rax
cmpl $0x7, (%rax)
jne 0x8789
cmpq 0x8(%rax), %rsi
jne 0x8789
movl 0x18(%rsi), %edi
leal -0x1(%rdi), %eax
cmpl $0x1, %eax
ja 0x8789
cmpl $0x7, %ecx
jne 0x8588
cmpl $0x7, %edx
je 0x8665
cmpl $0x5, %edx
je 0x85c1
cmpl $0x4, %edx
jne 0x85d2
leaq 0xbd1b(%rip), %rax      # 0x14298
cmpq %rax, 0x10(%r14)
jne 0x85d2
jmp 0x8793
cmpl $0x7, %edx
jne 0x85d2
movb $0x1, %al
cmpl $0x5, %ecx
je 0x8673
cmpl $0x4, %ecx
jne 0x85d4
movq 0x10(%rbx), %rax
leaq 0xbcf0(%rip), %rcx      # 0x14298
cmpq %rcx, %rax
je 0x8793
cmpl $0x2, %edi
jne 0x8761
xorl %ecx, %ecx
jmp 0x8744
leaq 0xbc60(%rip), %rax      # 0x14228
cmpq %rax, 0x10(%r14)
je 0x8684
xorl %eax, %eax
cmpl $0x2, %edi
jne 0x8761
cmpl $0x5, %ecx
je 0x860e
cmpl $0x4, %ecx
jne 0x8650
movb $0x1, %dil
cmpl $0x5, %edx
jne 0x866c
movq 0x10(%r14), %rcx
testb $0x7, 0x44(%rcx)
je 0x866c
movq 0x10(%rbx), %rdx
testb $0x7, 0x44(%rdx)
je 0x866c
cmpq %rcx, %rdx
jne 0x879a
jmp 0x8647
cmpl $0x5, %edx
je 0x86b4
cmpl $0x4, %edx
jne 0x86ef
movq 0x10(%rbx), %rdi
movb $0x1, %cl
testb $0x7, 0x44(%rdi)
je 0x8735
movq 0x10(%r14), %rdx
testb $0x7, 0x44(%rdx)
je 0x8735
cmpq %rdi, %rdx
jne 0x879a
leaq 0xbbda(%rip), %rdi      # 0x14228
jmp 0x8687
xorl $0x7, %ecx
movl %edx, %eax
xorl $0x4, %eax
orl %ecx, %eax
jne 0x8693
leaq 0xbca5(%rip), %rax      # 0x14308
jmp 0x86a5
movb $0x1, %al
jmp 0x85d4
xorl %ecx, %ecx
jmp 0x8737
leaq 0xbbae(%rip), %r8       # 0x14228
cmpq %r8, 0x10(%rbx)
jne 0x85d4
movq %rsi, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x5567
xorl $0x5, %edx
orl %edx, %ecx
jne 0x8761
leaq 0xbbf3(%rip), %rax      # 0x14298
cmpq %rax, 0x10(%r14)
jne 0x8761
jmp 0x8789
movq 0x10(%rbx), %r8
leaq 0xbbd9(%rip), %rdx      # 0x14298
cmpq %rdx, %r8
je 0x86f5
leaq 0xbb5d(%rip), %rdi      # 0x14228
cmpq %rdi, %r8
je 0x871c
movb $0x1, %cl
leaq 0xbc2f(%rip), %r9       # 0x14308
cmpq %r9, %r8
jne 0x8735
cmpq %rdx, 0x10(%r14)
je 0x8713
cmpq %rdi, 0x10(%r14)
jne 0x8735
jmp 0x8793
testb %al, %al
jne 0x8754
jmp 0x8761
leaq 0xbb2c(%rip), %rcx      # 0x14228
cmpq %rcx, 0x10(%r14)
je 0x87a9
leaq 0xbbfb(%rip), %rcx      # 0x14308
cmpq %rcx, 0x10(%r14)
jne 0x8733
leaq 0xbb0e(%rip), %rdx      # 0x14228
jmp 0x879a
cmpq %rdx, 0x10(%r14)
je 0x87a9
leaq 0xbbdb(%rip), %rcx      # 0x14308
cmpq %rcx, 0x10(%r14)
je 0x8793
movb $0x1, %cl
xorl %edi, %edi
testb %al, %al
je 0x8761
testb %dil, %dil
je 0x8750
movq 0x10(%rbx), %rax
leaq 0xbbbd(%rip), %rdx      # 0x14308
cmpq %rdx, %rax
je 0x8789
testb %cl, %cl
je 0x8761
leaq 0xbb3d(%rip), %rax      # 0x14298
cmpq %rax, 0x10(%rbx)
je 0x8789
leaq 0x741c(%rip), %rdi      # 0xfb84
xorl %eax, %eax
callq 0x2100
leaq 0x741d(%rip), %rdi      # 0xfb93
xorl %eax, %eax
callq 0x2100
leaq 0x7bd2(%rip), %rdi      # 0x10356
callq 0x20a0
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
leaq 0xbafe(%rip), %rdx      # 0x14298
pushq $0x4
popq %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x5293
leaq 0xbb58(%rip), %rdx      # 0x14308
jmp 0x879a