// File: /workspace/github_c_makefile_star2_O3/nimble-code[P]Uno/Src/uno_bounds.c
// Function: eval_const_expr
int
eval_const_expr(treenode *n, treenode *m)
{	int a=0, b=0;

	if (!n) return 0;

	if (n->hdr.type == TN_INT)
		return ((leafnode *)n)->data.ival;

	if (n->hdr.type == TN_IDENT)
	{	if (strcmp(((leafnode *)n)->data.sval->str, statename) == 0)
			return get_state_val();
	}

	if (uno_prop
	&&  n->hdr.type == TN_FUNC_CALL)
	{
		return eval_fct(n, m);
	}

	if (n->hdr.type == TN_EXPR)
	{
		if (n->lnode)
			a = eval_const_expr(n->lnode, m);
		if (n->rnode)
			b = eval_const_expr(n->rnode, m);

		if (!nogood)
		switch (n->hdr.tok) {
		case NOT:	return !b;
		case B_NOT:	return ~b;
		case CASE:	return b;

		case PLUS:	return a+b;
		case MINUS:	return a-b;
		case STAR:	return a*b;
		case DIV:	if (b == 0)
				{	fprintf(stderr, "uno: %s:%d division by zero error\n",
						n->hdr.fnm, n->hdr.line);
					break;
				}
				return a/b;
		case MOD:	if (b == 0)
				{	fprintf(stderr, "uno: %s:%d division by zero error\n",
						n->hdr.fnm, n->hdr.line);
					break;
				}
				return a%b;

		case EQUAL:	return (a == b);
		case LESS:	return (a < b);
		case LESS_EQ:	return (a <= b);
		case GRTR:	return (a > b);
		case GRTR_EQ:	return (a >= b);
		case NOT_EQ:	return (a != b);

		case AND:	return (a && b);
		case OR:	return (a || b);
		case B_OR:	return (a | b);
		case B_AND:	return (a & b);
		case B_XOR:	return (a ^ b);
		case B_NOT_EQ:	return (a != b);
		case L_SHIFT:	return (a << b);
		case R_SHIFT:	return (a >> b);

		default:
				printf("saw token type: %s (%s)\n",
					(char *) toksym(n->hdr.tok,0),
					x_stmnt(n));
				break;
		}
	}
	nogood = 1;
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
xorl %ebx, %ebx
testq %rdi, %rdi
je 0x1a816
movq %rdi, %r14
movl 0x1c(%rdi), %eax
cmpl $0x2d, %eax
je 0x1a77b
cmpl $0x30, %eax
jne 0x1a7a5
movl 0x40(%r14), %ebx
jmp 0x1a816
movq 0x40(%r14), %rax
movq 0x8(%rax), %rdi
leaq 0x1da26(%rip), %rax     # 0x381b0
movq (%rax), %rsi
callq 0x3190
testl %eax, %eax
jne 0x1a80a
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x1c416
movq %rsi, %r15
cmpl $0x3, %eax
jne 0x1a7cf
leaq 0x556f4(%rip), %rcx     # 0x6fea8
cmpq $0x0, (%rcx)
je 0x1a7cf
movq %r14, %rdi
movq %r15, %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x1c436
cmpl $0x28, %eax
jne 0x1a80a
movq 0x40(%r14), %rdi
xorl %ebx, %ebx
movl $0x0, %ebp
testq %rdi, %rdi
je 0x1a7ee
movq %r15, %rsi
callq 0x1a750
movl %eax, %ebp
movq 0x48(%r14), %rdi
testq %rdi, %rdi
je 0x1a801
movq %r15, %rsi
callq 0x1a750
movl %eax, %ebx
cmpl $0x0, 0x66190(%rip)     # 0x80998
je 0x1a823
movl $0x1, 0x66184(%rip)     # 0x80998
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movl 0x18(%r14), %edi
leal -0x131(%rdi), %eax
cmpl $0x32, %eax
ja 0x1a84b
leaq 0x1609b(%rip), %rcx     # 0x308d4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
xorl %eax, %eax
cmpl %ebx, %ebp
jmp 0x1a90a
cmpl $0x10f, %edi            # imm = 0x10F
je 0x1a816
xorl %esi, %esi
callq 0x71b4
movq %rax, %rbx
movq %r14, %rdi
callq 0x5cbe
leaq 0x16177(%rip), %rdi     # 0x309e3
movq %rbx, %rsi
movq %rax, %rdx
xorl %eax, %eax
callq 0x3100
jmp 0x1a80a
testl %ebx, %ebx
je 0x1a92f
movl %ebp, %eax
cltd
idivl %ebx
movl %edx, %ebx
jmp 0x1a816
subl %ebx, %ebp
jmp 0x1a921
xorl %eax, %eax
cmpl %ebx, %ebp
setg %al
jmp 0x1a916
xorl %ebp, %ebx
jmp 0x1a816
imull %ebp, %ebx
jmp 0x1a816
movl %ebx, %ecx
shll %cl, %ebp
jmp 0x1a921
testl %ebp, %ebp
setne %al
testl %ebx, %ebx
setne %cl
andb %al, %cl
movzbl %cl, %ebx
jmp 0x1a816
xorl %eax, %eax
cmpl %ebx, %ebp
setle %al
jmp 0x1a916
orl %ebp, %ebx
jmp 0x1a816
xorl %eax, %eax
cmpl %ebx, %ebp
setge %al
jmp 0x1a916
xorl %eax, %eax
cmpl %ebx, %ebp
jmp 0x1a8ef
addl %ebp, %ebx
jmp 0x1a816
xorl %eax, %eax
testl %ebx, %ebx
sete %al
jmp 0x1a916
andl %ebp, %ebx
jmp 0x1a816
testl %ebx, %ebx
je 0x1a93c
movl %ebp, %eax
cltd
idivl %ebx
jmp 0x1a916
xorl %eax, %eax
orl %ebx, %ebp
setne %al
jmp 0x1a916
xorl %eax, %eax
cmpl %ebx, %ebp
setl %al
movl %eax, %ebx
jmp 0x1a816
movl %ebx, %ecx
sarl %cl, %ebp
movl %ebp, %ebx
jmp 0x1a816
notl %ebx
jmp 0x1a816
movq %r14, %rdi
callq 0x415b
jmp 0x1a80a
movq %r14, %rdi
callq 0x417d
jmp 0x1a80a