// File: /workspace/github_c_makefile_star2_O2/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 0x185df
movq %rdi, %r14
movl 0x1c(%rdi), %eax
cmpl $0x2d, %eax
je 0x18544
cmpl $0x30, %eax
jne 0x1856e
movl 0x40(%r14), %ebx
jmp 0x185df
movq 0x40(%r14), %rax
movq 0x8(%rax), %rdi
leaq 0x1ec65(%rip), %rax     # 0x371b8
movq (%rax), %rsi
callq 0x3190
testl %eax, %eax
jne 0x185d3
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x1a121
movq %rsi, %r15
cmpl $0x3, %eax
jne 0x18598
leaq 0x5692b(%rip), %rcx     # 0x6eea8
cmpq $0x0, (%rcx)
je 0x18598
movq %r14, %rdi
movq %r15, %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x1a141
cmpl $0x28, %eax
jne 0x185d3
movq 0x40(%r14), %rdi
xorl %ebx, %ebx
movl $0x0, %ebp
testq %rdi, %rdi
je 0x185b7
movq %r15, %rsi
callq 0x18519
movl %eax, %ebp
movq 0x48(%r14), %rdi
testq %rdi, %rdi
je 0x185ca
movq %r15, %rsi
callq 0x18519
movl %eax, %ebx
cmpl $0x0, 0x673c7(%rip)     # 0x7f998
je 0x185ec
movl $0x1, 0x673bb(%rip)     # 0x7f998
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 0x18614
leaq 0x16306(%rip), %rcx     # 0x2e908
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
xorl %eax, %eax
cmpl %ebx, %ebp
jmp 0x186d3
cmpl $0x10f, %edi            # imm = 0x10F
je 0x185df
xorl %esi, %esi
callq 0x5da8
movq %rax, %rbx
movq %r14, %rdi
callq 0x4ac7
leaq 0x163e2(%rip), %rdi     # 0x2ea17
movq %rbx, %rsi
movq %rax, %rdx
xorl %eax, %eax
callq 0x3100
jmp 0x185d3
testl %ebx, %ebx
je 0x186f8
movl %ebp, %eax
cltd
idivl %ebx
movl %edx, %ebx
jmp 0x185df
subl %ebx, %ebp
jmp 0x186ea
xorl %eax, %eax
cmpl %ebx, %ebp
setg %al
jmp 0x186df
xorl %ebp, %ebx
jmp 0x185df
imull %ebp, %ebx
jmp 0x185df
movl %ebx, %ecx
shll %cl, %ebp
jmp 0x186ea
testl %ebp, %ebp
setne %al
testl %ebx, %ebx
setne %cl
andb %al, %cl
movzbl %cl, %ebx
jmp 0x185df
xorl %eax, %eax
cmpl %ebx, %ebp
setle %al
jmp 0x186df
orl %ebp, %ebx
jmp 0x185df
xorl %eax, %eax
cmpl %ebx, %ebp
setge %al
jmp 0x186df
xorl %eax, %eax
cmpl %ebx, %ebp
jmp 0x186b8
addl %ebp, %ebx
jmp 0x185df
xorl %eax, %eax
testl %ebx, %ebx
sete %al
jmp 0x186df
andl %ebp, %ebx
jmp 0x185df
testl %ebx, %ebx
je 0x186f8
movl %ebp, %eax
cltd
idivl %ebx
jmp 0x186df
xorl %eax, %eax
orl %ebx, %ebp
setne %al
jmp 0x186df
xorl %eax, %eax
cmpl %ebx, %ebp
setl %al
movl %eax, %ebx
jmp 0x185df
movl %ebx, %ecx
sarl %cl, %ebp
movl %ebp, %ebx
jmp 0x185df
notl %ebx
jmp 0x185df
movq 0x1e8f9(%rip), %rax     # 0x36ff8
movq (%rax), %rdi
movq 0x8(%r14), %rdx
movl 0x10(%r14), %ecx
leaq 0x162e3(%rip), %rsi     # 0x2e9f4
xorl %eax, %eax
callq 0x31a0
jmp 0x185d3