// File: /workspace/github_c_makefile_star2_O3/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
testq %rdi, %rdi
je 0x990c
movq %rdi, %rbx
leaq 0x1d49(%rip), %r12      # 0xb558
movl $0x3, %ebp
xorl %r14d, %r14d
movl (%rbx), %eax
movl %eax, %ecx
andl $-0x4, %ecx
cmpl $0x4, %ecx
je 0x983f
movq 0x8(%rbx), %rdi
callq 0x97f1
movq %rax, 0x8(%rbx)
movq 0x10(%rbx), %rdi
callq 0x97f1
movq %rax, 0x10(%rbx)
movl (%rbx), %eax
cmpl $0x3, %eax
jne 0x98ba
movq 0x8(%rbx), %r15
movl (%r15), %ecx
decl %ecx
cmpl $0x6, %ecx
ja 0x9a4c
movl $0x1, %eax
movslq (%r12,%rcx,4), %rcx
addq %r12, %rcx
jmpq *%rcx
movl $0x2, %eax
movl %eax, (%rbx)
movq 0x10(%r15), %r13
movl $0x1, %edi
movl $0x18, %esi
callq 0x2180
movl %ebp, (%rax)
movq %r13, 0x8(%rax)
movq %rax, 0x10(%rbx)
movl %ebp, (%r15)
movq $0x0, 0x10(%r15)
jmp 0x9817
movq 0x8(%r15), %r13
movq %r15, %rdi
callq 0x2040
movq %rbx, %rdi
callq 0x2040
movq %r13, %rbx
testq %r13, %r13
jne 0x9817
jmp 0x9a4f
cmpl $0x5, %eax
je 0x9914
cmpl $0x4, %eax
jne 0x9a4c
movq 0x8(%rbx), %r14
cmpl $0x1, 0x18(%r14)
jne 0x9a4c
movq 0x10(%rbx), %rax
leaq 0xb936(%rip), %r15      # 0x15218
cmpq %r15, %rax
je 0x9957
leaq 0xba0a(%rip), %rcx      # 0x152f8
cmpq %rcx, %rax
je 0x9a03
leaq 0xb98a(%rip), %rcx      # 0x15288
cmpq %rcx, %rax
jne 0x9a4c
jmp 0x99df
xorl %r14d, %r14d
jmp 0x9a4f
movq 0x8(%rbx), %r14
cmpl $0x1, 0x18(%r14)
jne 0x9a4c
movq 0x10(%rbx), %rax
leaq 0xb8ea(%rip), %rcx      # 0x15218
cmpq %rcx, %rax
je 0x99df
leaq 0xb9ba(%rip), %rcx      # 0x152f8
cmpq %rcx, %rax
je 0x9a21
leaq 0xb93a(%rip), %rcx      # 0x15288
cmpq %rcx, %rax
jne 0x9a4c
movl $0x3, (%rbx)
movl $0x1, %edi
movl $0x18, %esi
callq 0x2180
movl $0x7, (%rax)
movq %r14, 0x8(%rax)
jmp 0x9a40
movq %rbx, %rdi
callq 0x2040
xorl %eax, %eax
cmpl $0x4, (%r15)
sete %al
orl $0x4, %eax
movl %eax, (%r15)
movq %r15, %r14
jmp 0x9a4f
movq 0x8(%r15), %rax
leaq 0xb8e3(%rip), %r14      # 0x15288
cmpq %r14, %rax
je 0x99e7
leaq 0xb947(%rip), %r12      # 0x152f8
cmpq %r12, %rax
je 0x9a61
leaq 0xb857(%rip), %rcx      # 0x15218
cmpq %rcx, %rax
jne 0x9a4c
movq %rbx, %rdi
callq 0x2040
movl $0x7, (%r15)
movq %r14, 0x8(%r15)
jmp 0x9992
movl $0x7, (%rbx)
jmp 0x9a44
movq %rbx, %rdi
callq 0x2040
movl $0x7, (%r15)
leaq 0xb81b(%rip), %rax      # 0x15218
movq %rax, 0x8(%r15)
jmp 0x9992
movq 0x8(%r14), %rsi
leaq 0x7156(%rip), %rdi      # 0x10b64
xorl %eax, %eax
callq 0x2100
movl $0x7, (%rbx)
movq %r15, 0x8(%rbx)
jmp 0x9a44
movq 0x8(%r14), %rsi
leaq 0x716e(%rip), %rdi      # 0x10b9a
xorl %eax, %eax
callq 0x2100
movl $0x7, (%rbx)
leaq 0xb848(%rip), %rax      # 0x15288
movq %rax, 0x8(%rbx)
movq $0x0, 0x10(%rbx)
movq %rbx, %r14
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
callq 0x2040
movl $0x7, (%r15)
movq %r12, 0x8(%r15)
jmp 0x9992