// File: /workspace/github_c_makefile_star2_O1/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
xorl %r15d, %r15d
leaq 0x2614(%rip), %r12      # 0xc578
movl $0x3, %ebp
testq %rbx, %rbx
je 0xa062
movl (%rbx), %eax
andl $-0x4, %eax
cmpl $0x4, %eax
je 0x9f96
movq 0x8(%rbx), %rdi
callq 0x9f4c
movq %rax, 0x8(%rbx)
movq 0x10(%rbx), %rdi
callq 0x9f4c
movq %rax, 0x10(%rbx)
movl (%rbx), %eax
cmpl $0x3, %eax
jne 0xa010
movq 0x8(%rbx), %r14
movl (%r14), %eax
decl %eax
cmpl $0x6, %eax
ja 0xa1b0
movslq (%r12,%rax,4), %rax
addq %r12, %rax
jmpq *%rax
movl $0x2, (%rbx)
jmp 0x9fc6
movl $0x1, (%rbx)
movq 0x10(%r14), %r13
movl $0x18, %edi
callq 0x2220
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq %r15, 0x10(%rax)
movl %ebp, (%rax)
movq %r13, 0x8(%rax)
movq %rax, 0x10(%rbx)
movl %ebp, (%r14)
movq %r15, 0x10(%r14)
jmp 0x9f69
movq 0x8(%r14), %r13
movq %r14, %rdi
callq 0x2040
movq %rbx, %rdi
callq 0x2040
movq %r13, %rbx
jmp 0x9f69
cmpl $0x5, %eax
je 0xa069
cmpl $0x4, %eax
jne 0xa1b0
movq 0x8(%rbx), %r14
cmpl $0x1, 0x18(%r14)
jne 0xa1b0
movq 0x10(%rbx), %rax
leaq 0xc1e0(%rip), %r15      # 0x16218
cmpq %r15, %rax
je 0xa0ac
leaq 0xc2b4(%rip), %rcx      # 0x162f8
cmpq %rcx, %rax
je 0xa167
leaq 0xc234(%rip), %rcx      # 0x16288
cmpq %rcx, %rax
jne 0xa1b0
jmp 0xa143
xorl %ebx, %ebx
jmp 0xa1b0
movq 0x8(%rbx), %r14
cmpl $0x1, 0x18(%r14)
jne 0xa1b0
movq 0x10(%rbx), %rax
leaq 0xc195(%rip), %rcx      # 0x16218
cmpq %rcx, %rax
je 0xa143
leaq 0xc265(%rip), %rcx      # 0x162f8
cmpq %rcx, %rax
je 0xa185
leaq 0xc1e5(%rip), %rcx      # 0x16288
cmpq %rcx, %rax
jne 0xa1b0
movl $0x3, (%rbx)
movl $0x18, %edi
callq 0x2220
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
xorl %ecx, %ecx
movq %rcx, 0x10(%rax)
movl $0x7, (%rax)
movq %r14, 0x8(%rax)
movq %rax, 0x8(%rbx)
movq %rcx, 0x10(%rbx)
jmp 0xa1b0
movq %rbx, %rdi
callq 0x2040
xorl %eax, %eax
cmpl $0x4, (%r14)
sete %al
orl $0x4, %eax
movl %eax, (%r14)
movq %r14, %rbx
jmp 0xa1b0
movq 0x8(%r14), %rax
leaq 0xc17f(%rip), %r15      # 0x16288
cmpq %r15, %rax
je 0xa14b
leaq 0xc1e3(%rip), %r12      # 0x162f8
cmpq %r12, %rax
je 0xa1c2
leaq 0xc0f3(%rip), %rcx      # 0x16218
cmpq %rcx, %rax
jne 0xa1b0
movq %rbx, %rdi
callq 0x2040
movl $0x7, (%r14)
movq %r15, 0x8(%r14)
jmp 0xa0f6
movl $0x7, (%rbx)
jmp 0xa1a8
movq %rbx, %rdi
callq 0x2040
movl $0x7, (%r14)
leaq 0xc0b7(%rip), %rax      # 0x16218
movq %rax, 0x8(%r14)
jmp 0xa0f6
movq 0x8(%r14), %rsi
leaq 0x7a12(%rip), %rdi      # 0x11b84
xorl %eax, %eax
callq 0x2100
movl $0x7, (%rbx)
movq %r15, 0x8(%rbx)
jmp 0xa1a8
movq 0x8(%r14), %rsi
leaq 0x7a2a(%rip), %rdi      # 0x11bba
xorl %eax, %eax
callq 0x2100
movl $0x7, (%rbx)
leaq 0xc0e4(%rip), %rax      # 0x16288
movq %rax, 0x8(%rbx)
movq $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 0xa0f6