// File: /workspace/github_c_makefile_star2_O2/saltyJeff[P]uClibcpp/extra/config/./expr.c
// Function: expr_transform
struct expr *expr_transform(struct expr *e)
{
	struct expr *tmp;

	if (!e)
		return NULL;
	switch (e->type) {
	case E_EQUAL:
	case E_UNEQUAL:
	case E_SYMBOL:
	case E_CHOICE:
		break;
	default:
		e->left.expr = expr_transform(e->left.expr);
		e->right.expr = expr_transform(e->right.expr);
	}

	switch (e->type) {
	case E_EQUAL:
		if (e->left.sym->type != S_BOOLEAN)
			break;
		if (e->right.sym == &symbol_no) {
			e->type = E_NOT;
			e->left.expr = expr_alloc_symbol(e->left.sym);
			e->right.sym = NULL;
			break;
		}
		if (e->right.sym == &symbol_mod) {
			printf("boolean symbol %s tested for 'm'? test forced to 'n'\n", e->left.sym->name);
			e->type = E_SYMBOL;
			e->left.sym = &symbol_no;
			e->right.sym = NULL;
			break;
		}
		if (e->right.sym == &symbol_yes) {
			e->type = E_SYMBOL;
			e->right.sym = NULL;
			break;
		}
		break;
	case E_UNEQUAL:
		if (e->left.sym->type != S_BOOLEAN)
			break;
		if (e->right.sym == &symbol_no) {
			e->type = E_SYMBOL;
			e->right.sym = NULL;
			break;
		}
		if (e->right.sym == &symbol_mod) {
			printf("boolean symbol %s tested for 'm'? test forced to 'y'\n", e->left.sym->name);
			e->type = E_SYMBOL;
			e->left.sym = &symbol_yes;
			e->right.sym = NULL;
			break;
		}
		if (e->right.sym == &symbol_yes) {
			e->type = E_NOT;
			e->left.expr = expr_alloc_symbol(e->left.sym);
			e->right.sym = NULL;
			break;
		}
		break;
	case E_NOT:
		switch (e->left.expr->type) {
		case E_NOT:
			// !!a -> a
			tmp = e->left.expr->left.expr;
			free(e->left.expr);
			free(e);
			e = tmp;
			e = expr_transform(e);
			break;
		case E_EQUAL:
		case E_UNEQUAL:
			// !a='x' -> a!='x'
			tmp = e->left.expr;
			free(e);
			e = tmp;
			e->type = e->type == E_EQUAL ? E_UNEQUAL : E_EQUAL;
			break;
		case E_OR:
			// !(a || b) -> !a && !b
			tmp = e->left.expr;
			e->type = E_AND;
			e->right.expr = expr_alloc_one(E_NOT, tmp->right.expr);
			tmp->type = E_NOT;
			tmp->right.expr = NULL;
			e = expr_transform(e);
			break;
		case E_AND:
			// !(a && b) -> !a || !b
			tmp = e->left.expr;
			e->type = E_OR;
			e->right.expr = expr_alloc_one(E_NOT, tmp->right.expr);
			tmp->type = E_NOT;
			tmp->right.expr = NULL;
			e = expr_transform(e);
			break;
		case E_SYMBOL:
			if (e->left.expr->left.sym == &symbol_yes) {
				// !'y' -> 'n'
				tmp = e->left.expr;
				free(e);
				e = tmp;
				e->type = E_SYMBOL;
				e->left.sym = &symbol_no;
				break;
			}
			if (e->left.expr->left.sym == &symbol_mod) {
				// !'m' -> 'm'
				tmp = e->left.expr;
				free(e);
				e = tmp;
				e->type = E_SYMBOL;
				e->left.sym = &symbol_mod;
				break;
			}
			if (e->left.expr->left.sym == &symbol_no) {
				// !'n' -> 'y'
				tmp = e->left.expr;
				free(e);
				e = tmp;
				e->type = E_SYMBOL;
				e->left.sym = &symbol_yes;
				break;
			}
			break;
		default:
			;
		}
		break;
	default:
		;
	}
	return e;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
pushq $0x1
popq %r15
leaq 0x1aa9(%rip), %r12      # 0xa574
pushq $0x2
popq %r13
pushq $0x3
popq %rbp
testq %rbx, %rbx
je 0x8c94
movl (%rbx), %eax
movl %eax, %ecx
andl $-0x4, %ecx
cmpl $0x4, %ecx
je 0x8b03
movq 0x8(%rbx), %rdi
callq 0x8ab2
movq %rax, 0x8(%rbx)
movq 0x10(%rbx), %rdi
callq 0x8ab2
movq %rax, 0x10(%rbx)
movl (%rbx), %eax
cmpl $0x3, %eax
jne 0x8b69
movq 0x8(%rbx), %r14
movl (%r14), %eax
decl %eax
cmpl $0x6, %eax
ja 0x8cde
movslq (%r12,%rax,4), %rcx
addq %r12, %rcx
movl %r15d, %eax
jmpq *%rcx
movl %r13d, %eax
movl %eax, (%rbx)
movq 0x10(%r14), %rsi
movl %ebp, %edi
callq 0x5582
movq %rax, 0x10(%rbx)
movl $0x3, (%r14)
andq $0x0, 0x10(%r14)
jmp 0x8adb
movq 0x8(%r14), %rax
movq %rax, (%rsp)
movq %r14, %rdi
callq 0x2040
movq %rbx, %rdi
callq 0x2040
movq (%rsp), %rbx
jmp 0x8ad2
cmpl $0x5, %eax
je 0x8bba
cmpl $0x4, %eax
jne 0x8cde
movq 0x8(%rbx), %rdi
cmpl $0x1, 0x18(%rdi)
jne 0x8cde
movq 0x10(%rbx), %rax
leaq 0xb698(%rip), %r14      # 0x14228
cmpq %r14, %rax
je 0x8bfc
leaq 0xb76c(%rip), %rcx      # 0x14308
cmpq %rcx, %rax
je 0x8c98
leaq 0xb6ec(%rip), %rcx      # 0x14298
cmpq %rcx, %rax
jne 0x8cde
jmp 0x8c70
movq 0x8(%rbx), %rdi
cmpl $0x1, 0x18(%rdi)
jne 0x8cde
movq 0x10(%rbx), %rax
leaq 0xb655(%rip), %rcx      # 0x14228
cmpq %rcx, %rax
je 0x8c70
leaq 0xb725(%rip), %rcx      # 0x14308
cmpq %rcx, %rax
je 0x8cb6
leaq 0xb6a5(%rip), %rcx      # 0x14298
cmpq %rcx, %rax
jne 0x8cde
movl $0x3, (%rbx)
callq 0x5567
jmp 0x8cd5
movq %rbx, %rdi
callq 0x2040
xorl %eax, %eax
cmpl $0x4, (%r14)
sete %al
orl $0x4, %eax
movl %eax, (%r14)
movq %r14, %rbx
jmp 0x8cde
movq 0x8(%r14), %rax
leaq 0xb662(%rip), %r15      # 0x14298
cmpq %r15, %rax
je 0x8c78
leaq 0xb6c6(%rip), %r12      # 0x14308
cmpq %r12, %rax
je 0x8cf0
leaq 0xb5d6(%rip), %rcx      # 0x14228
cmpq %rcx, %rax
jne 0x8cde
movq %rbx, %rdi
callq 0x2040
movl $0x7, (%r14)
movq %r15, 0x8(%r14)
jmp 0x8c23
movl $0x7, (%rbx)
jmp 0x8cd9
movq %rbx, %rdi
callq 0x2040
movl $0x7, (%r14)
leaq 0xb59a(%rip), %rax      # 0x14228
movq %rax, 0x8(%r14)
jmp 0x8c23
xorl %ebx, %ebx
jmp 0x8cde
movq 0x8(%rdi), %rsi
leaq 0x6ef5(%rip), %rdi      # 0xfb98
xorl %eax, %eax
callq 0x2100
movl $0x7, (%rbx)
movq %r14, 0x8(%rbx)
jmp 0x8cd9
movq 0x8(%rdi), %rsi
leaq 0x6f0d(%rip), %rdi      # 0xfbce
xorl %eax, %eax
callq 0x2100
movl $0x7, (%rbx)
leaq 0xb5c3(%rip), %rax      # 0x14298
movq %rax, 0x8(%rbx)
andq $0x0, 0x10(%rbx)
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
callq 0x2040
movl $0x7, (%r14)
movq %r12, 0x8(%r14)
jmp 0x8c23