// File: /workspace/github_c_makefile_star2_O3/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 %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
callq 0x8cbb
testl %eax, %eax
je 0x9097
movq %rbx, %rdi
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x88c5
movl (%rbx), %ecx
xorl %r15d, %r15d
cmpl $0x7, %ecx
ja 0x940a
movl $0xb8, %eax
btl %ecx, %eax
jae 0x940a
movl (%r14), %edx
xorl %r15d, %r15d
cmpl $0x7, %edx
ja 0x940a
btl %edx, %eax
jae 0x940a
movq %rbx, %rax
cmpl $0x3, %ecx
jne 0x90f3
movq 0x8(%rbx), %rax
movl (%rax), %esi
xorl %r15d, %r15d
cmpl $0x7, %esi
ja 0x940a
movl $0xb0, %edi
btl %esi, %edi
jae 0x940a
movq 0x8(%rax), %r12
movq %r14, %rax
cmpl $0x3, %edx
jne 0x910c
movq 0x8(%r14), %rax
cmpl $0x7, (%rax)
jne 0x9407
cmpq 0x8(%rax), %r12
jne 0x9407
movl 0x18(%r12), %esi
leal -0x1(%rsi), %eax
cmpl $0x1, %eax
ja 0x9407
cmpl $0x7, %ecx
jne 0x9151
cmpl $0x7, %edx
je 0x927a
cmpl $0x5, %edx
je 0x918a
cmpl $0x4, %edx
jne 0x919b
leaq 0xc142(%rip), %rax      # 0x15288
cmpq %rax, 0x10(%r14)
jne 0x919b
jmp 0x92ba
cmpl $0x7, %edx
jne 0x919b
movb $0x1, %al
cmpl $0x5, %ecx
je 0x9288
cmpl $0x4, %ecx
jne 0x919d
movq 0x10(%rbx), %rax
leaq 0xc117(%rip), %rcx      # 0x15288
cmpq %rcx, %rax
je 0x92ba
cmpl $0x2, %esi
jne 0x93da
xorl %ecx, %ecx
jmp 0x93bd
leaq 0xc087(%rip), %rax      # 0x15218
cmpq %rax, 0x10(%r14)
je 0x9299
xorl %eax, %eax
cmpl $0x2, %esi
jne 0x93da
cmpl $0x5, %ecx
je 0x9207
cmpl $0x4, %ecx
jne 0x9265
movb $0x1, %sil
cmpl $0x5, %edx
jne 0x9281
movq 0x10(%r14), %rcx
testb $0x7, 0x44(%rcx)
je 0x9281
movq 0x10(%rbx), %r14
testb $0x7, 0x44(%r14)
je 0x9281
cmpq %rcx, %r14
je 0x923d
movl $0x1, %edi
movl $0x18, %esi
callq 0x2180
movq %rax, %r15
movl $0x4, (%rax)
movq %r12, 0x8(%rax)
movq %r14, 0x10(%rax)
jmp 0x940a
cmpl $0x5, %edx
je 0x9307
cmpl $0x4, %edx
jne 0x9342
movq 0x10(%rbx), %rdx
movb $0x1, %cl
testb $0x7, 0x44(%rdx)
je 0x93ae
movq 0x10(%r14), %r14
testb $0x7, 0x44(%r14)
je 0x93ae
cmpq %rdx, %r14
jne 0x91e2
movl $0x1, %edi
movl $0x18, %esi
callq 0x2180
movq %rax, %r15
movl $0x7, (%rax)
leaq 0xbfbc(%rip), %rax      # 0x15218
movq %rax, 0x8(%r15)
jmp 0x940a
xorl $0x7, %ecx
movl %edx, %eax
xorl $0x4, %eax
orl %ecx, %eax
jne 0x92e6
leaq 0xc080(%rip), %rax      # 0x152f8
jmp 0x92f8
movb $0x1, %al
jmp 0x919d
xorl %ecx, %ecx
jmp 0x93b0
leaq 0xbf89(%rip), %rdi      # 0x15218
cmpq %rdi, 0x10(%rbx)
jne 0x919d
movl $0x1, %edi
movl $0x18, %esi
callq 0x2180
movq %rax, %r15
movl $0x7, (%rax)
movq %r12, 0x8(%rax)
jmp 0x940a
movl $0x1, %edi
movl $0x18, %esi
callq 0x2180
movq %rax, %r15
movl $0x4, (%rax)
movq %r12, 0x8(%rax)
leaq 0xbfab(%rip), %rax      # 0x15288
movq %rax, 0x10(%r15)
jmp 0x940a
xorl $0x5, %edx
orl %edx, %ecx
jne 0x93da
leaq 0xbf90(%rip), %rax      # 0x15288
cmpq %rax, 0x10(%r14)
jne 0x93da
jmp 0x9407
movq 0x10(%rbx), %rsi
leaq 0xbf76(%rip), %r13      # 0x15288
cmpq %r13, %rsi
je 0x934f
leaq 0xbefa(%rip), %rdx      # 0x15218
cmpq %rdx, %rsi
je 0x9395
movb $0x1, %cl
leaq 0xbfcc(%rip), %rdi      # 0x152f8
cmpq %rdi, %rsi
jne 0x93ae
cmpq %r13, 0x10(%r14)
je 0x936d
cmpq %rdx, 0x10(%r14)
jne 0x93ae
jmp 0x943f
testb %al, %al
jne 0x93cd
jmp 0x93da
leaq 0xbec2(%rip), %rcx      # 0x15218
cmpq %rcx, 0x10(%r14)
je 0x9417
leaq 0xbf91(%rip), %rcx      # 0x152f8
cmpq %rcx, 0x10(%r14)
jne 0x93ac
movl $0x1, %edi
movl $0x18, %esi
callq 0x2180
movq %rax, %r15
movl $0x4, (%rax)
movq %r12, 0x8(%rax)
leaq 0xbe88(%rip), %rax      # 0x15218
jmp 0x92dd
cmpq %r13, 0x10(%r14)
je 0x9417
leaq 0xbf56(%rip), %rcx      # 0x152f8
cmpq %rcx, 0x10(%r14)
je 0x943f
movb $0x1, %cl
xorl %esi, %esi
testb %al, %al
je 0x93da
testb %sil, %sil
je 0x93c9
movq 0x10(%rbx), %rax
leaq 0xbf34(%rip), %rdx      # 0x152f8
cmpq %rdx, %rax
je 0x9407
testb %cl, %cl
je 0x93da
leaq 0xbeb4(%rip), %rax      # 0x15288
cmpq %rax, 0x10(%rbx)
je 0x9407
leaq 0x776f(%rip), %rdi      # 0x10b50
xorl %r15d, %r15d
xorl %eax, %eax
callq 0x2100
leaq 0x776d(%rip), %rdi      # 0x10b5f
xorl %eax, %eax
callq 0x2100
leaq 0x7f22(%rip), %rdi      # 0x11322
callq 0x20a0
jmp 0x940a
xorl %r15d, %r15d
movq %r15, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movl $0x1, %edi
movl $0x18, %esi
callq 0x2180
movq %rax, %r15
movl $0x4, (%rax)
movq %r12, 0x8(%rax)
leaq 0xbebe(%rip), %rax      # 0x152f8
jmp 0x92dd
movl $0x1, %edi
movl $0x18, %esi
callq 0x2180
movq %rax, %r15
movl $0x4, (%rax)
movq %r12, 0x8(%rax)
movq %r13, 0x10(%rax)
jmp 0x940a