// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movl $0x0, -0x20(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x2b521
movl $0x0, -0x4(%rbp)
jmp 0x2b867
movq -0x10(%rbp), %rax
cmpl $0x30, 0x1c(%rax)
jne 0x2b53a
movq -0x10(%rbp), %rax
movl 0x40(%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x2b867
movq -0x10(%rbp), %rax
cmpl $0x2d, 0x1c(%rax)
jne 0x2b573
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movq 0x8(%rax), %rdi
leaq 0x22c91(%rip), %rax     # 0x4e1e8
movq (%rax), %rsi
callq 0x3160
cmpl $0x0, %eax
jne 0x2b571
callq 0x2f500
movl %eax, -0x4(%rbp)
jmp 0x2b867
jmp 0x2b573
leaq 0x5aa86(%rip), %rax     # 0x86000
cmpq $0x0, (%rax)
je 0x2b59f
movq -0x10(%rbp), %rax
cmpl $0x3, 0x1c(%rax)
jne 0x2b59f
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x2f540
movl %eax, -0x4(%rbp)
jmp 0x2b867
movq -0x10(%rbp), %rax
cmpl $0x28, 0x1c(%rax)
jne 0x2b856
movq -0x10(%rbp), %rax
cmpq $0x0, 0x40(%rax)
je 0x2b5cc
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x2b4f0
movl %eax, -0x1c(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x48(%rax)
je 0x2b5eb
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x2b4f0
movl %eax, -0x20(%rbp)
cmpl $0x0, 0x6b506(%rip)     # 0x96af8
jne 0x2b854
movq -0x10(%rbp), %rax
movl 0x18(%rax), %eax
addl $0xfffffef1, %eax       # imm = 0xFFFFFEF1
movl %eax, %ecx
movq %rcx, -0x28(%rbp)
subl $0x54, %eax
ja 0x2b822
movq -0x28(%rbp), %rax
leaq 0x1ab96(%rip), %rcx     # 0x461b4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpl $0x0, -0x20(%rbp)
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x4(%rbp)
jmp 0x2b867
movl -0x20(%rbp), %eax
xorl $-0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0x2b867
movl -0x20(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x2b867
movl -0x1c(%rbp), %eax
addl -0x20(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x2b867
movl -0x1c(%rbp), %eax
subl -0x20(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x2b867
movl -0x1c(%rbp), %eax
imull -0x20(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x2b867
cmpl $0x0, -0x20(%rbp)
jne 0x2b6b3
movq 0x2296a(%rip), %rax     # 0x4dff8
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdx
movq -0x10(%rbp), %rax
movl 0x10(%rax), %ecx
leaq 0x1acf9(%rip), %rsi     # 0x463a0
movb $0x0, %al
callq 0x3170
jmp 0x2b852
movl -0x1c(%rbp), %eax
cltd
idivl -0x20(%rbp)
movl %eax, -0x4(%rbp)
jmp 0x2b867
cmpl $0x0, -0x20(%rbp)
jne 0x2b6f4
movq 0x22929(%rip), %rax     # 0x4dff8
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdx
movq -0x10(%rbp), %rax
movl 0x10(%rax), %ecx
leaq 0x1acb8(%rip), %rsi     # 0x463a0
movb $0x0, %al
callq 0x3170
jmp 0x2b852
movl -0x1c(%rbp), %eax
cltd
idivl -0x20(%rbp)
movl %edx, -0x4(%rbp)
jmp 0x2b867
movl -0x1c(%rbp), %eax
cmpl -0x20(%rbp), %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x4(%rbp)
jmp 0x2b867
movl -0x1c(%rbp), %eax
cmpl -0x20(%rbp), %eax
setl %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x4(%rbp)
jmp 0x2b867
movl -0x1c(%rbp), %eax
cmpl -0x20(%rbp), %eax
setle %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x4(%rbp)
jmp 0x2b867
movl -0x1c(%rbp), %eax
cmpl -0x20(%rbp), %eax
setg %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x4(%rbp)
jmp 0x2b867
movl -0x1c(%rbp), %eax
cmpl -0x20(%rbp), %eax
setge %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x4(%rbp)
jmp 0x2b867
movl -0x1c(%rbp), %eax
cmpl -0x20(%rbp), %eax
setne %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x4(%rbp)
jmp 0x2b867
xorl %eax, %eax
cmpl $0x0, -0x1c(%rbp)
movb %al, -0x29(%rbp)
je 0x2b79c
cmpl $0x0, -0x20(%rbp)
setne %al
movb %al, -0x29(%rbp)
movb -0x29(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x4(%rbp)
jmp 0x2b867
movb $0x1, %al
cmpl $0x0, -0x1c(%rbp)
movb %al, -0x2a(%rbp)
jne 0x2b7c1
cmpl $0x0, -0x20(%rbp)
setne %al
movb %al, -0x2a(%rbp)
movb -0x2a(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x4(%rbp)
jmp 0x2b867
movl -0x1c(%rbp), %eax
orl -0x20(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x2b867
movl -0x1c(%rbp), %eax
andl -0x20(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x2b867
movl -0x1c(%rbp), %eax
xorl -0x20(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x2b867
movl -0x1c(%rbp), %eax
cmpl -0x20(%rbp), %eax
setne %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x4(%rbp)
jmp 0x2b867
movl -0x1c(%rbp), %eax
movl -0x20(%rbp), %ecx
shll %cl, %eax
movl %eax, -0x4(%rbp)
jmp 0x2b867
movl -0x1c(%rbp), %eax
movl -0x20(%rbp), %ecx
sarl %cl, %eax
movl %eax, -0x4(%rbp)
jmp 0x2b867
movq -0x10(%rbp), %rax
movl 0x18(%rax), %edi
xorl %esi, %esi
callq 0x7120
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rdi
callq 0x4ec0
movq -0x38(%rbp), %rsi
movq %rax, %rdx
leaq 0x1ab78(%rip), %rdi     # 0x463c3
movb $0x0, %al
callq 0x30f0
jmp 0x2b854
jmp 0x2b856
movl $0x1, 0x6b298(%rip)     # 0x96af8
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq