// File: /workspace/github_c_makefile_star2_O0/mist64[P]cbm6502asm/src/express.c
// Function: evaluate
int evaluate(char *str, long *value) {
	int i;
	char c;

	expdef = TRUE; /* assume expression will be defined */
	lastval = FALSE;
	lp = str;
	osp = vsp = MAXESTK;
	opstk[--osp] = '$';
	while ((c = *lp)) {
		if (isspace(c) || c == ';') break;
		if (osp <= 0 || vsp <= 0)
			error_msg("evaluation stack overflow ", str, 4);
		if (osp > MAXESTK || vsp > MAXESTK)
			error_msg("evaluation stack underflow ", str, 4);
		lp++; /* point to next character */

		if (isalpha(c) || c == '.' ||
		    c == '_') { /* it must be a symbol */
			pushval(evalsym());
			continue;
		}
		if (c == '\"' || c == '\'') { /* it is a character constant */
			pushval(evalchar(c));
			continue;
		}
		if (isdigit(c)) { /* it is a decimal number */
			lp--;     /* point to the digit again */
			pushval(evalocal());
			continue;
		}
		if (c == RADIX2) { /* it is a binary constant */
			pushval(evalcon(2));
			continue;
		}
		if (c == RADIX8) { /* it is an octal constant */
			pushval(evalcon(8));
			continue;
		}
		if (c == RADIX16) { /* it is a hexidecimal constant */
			pushval(evalcon(16));
			continue;
		}

		if (c == '!') {           /* start of 2 character operator */
			c = toupper(*lp); /* get the rest of the operator */
			lp++;
			if (!(c == 'N' || c == '.' || c == '+' || c == 'X'))
				display_error(error = 'E');
			else {
				if (c == 'N') c = '~';
				if (c == '.') c = '&';
				if (c == '+') c = '|';
				if (c == 'X') c = '^';
				eval(c);
			}
			continue;
		}
		if (c == '*') { /* multiply or location counter */
			/* if preceded by nothing or an operator then it is the
			 * location counter */
			if (!lastval)
				pushval(loc_cntr);
			else
				/* if preceded by a constant or symbol then it
				 * is the multiply operator */
				eval(c);
			continue;
		}
		if (c == '>' || c == '<' || c == '/') {
			eval(c);
			continue;
		}
		if (c == '+') { /* unary or binary operator */
			/* if preceded by nothing or an operator then it is a
			 * unary +, ignore it */
			/* if preceded by a constant or symbol then it is a
			 * binary operator */
			if (lastval) eval(c);
			continue;
		}
		if (c == '-') { /* unary or binary operator */
			/* if preceded by nothing or an operator then it is a
			 * unary operator */
			if (!lastval) c = '_';
			/* if preceded by a constant or symbol then it is a
			 * binary operator */
			eval(c);
			continue;
		}
		if (c == '(') {
			eval(c);
			continue;
		}
		if (c == ')') {
			int more = TRUE;
			while (more)
				if (opstk[osp] == '(') {
					more = FALSE;
					osp++;
					pushval(stack[vsp++]);
				} else if (opstk[osp] == '$') {
					display_error(error = 'B');
					more = FALSE;
				} else
					do_oper();
			continue;
		}
		display_error(error = 'C'); /* no valid state if we get here */
	}
	while (opstk[osp] != '$') do_oper();
	for (i = osp; i < MAXESTK; i++)
		if (opstk[i] == '(')
			display_error(
			        error = 'B'); /* too many ( in expression */
	if (vsp != MAXESTK - 1)
		display_error(error = 'E'); /* stack was messed up */
	if (error) stack[vsp] = 0;
	*value = stack[vsp];
	return (expdef);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq 0xa721(%rip), %rax      # 0x10dc8
movl $0x1, (%rax)
movl $0x0, 0xadb1(%rip)      # 0x11468
movq -0x8(%rbp), %rax
movq %rax, 0xabfe(%rip)      # 0x112c0
movl $0x32, 0xad94(%rip)     # 0x11460
movl $0x32, 0xad8e(%rip)     # 0x11464
movl 0xad88(%rip), %eax      # 0x11464
addl $-0x1, %eax
movl %eax, 0xad7f(%rip)      # 0x11464
movslq %eax, %rcx
leaq 0xad81(%rip), %rax      # 0x11470
movb $0x24, (%rax,%rcx)
movq 0xabc6(%rip), %rax      # 0x112c0
movb (%rax), %al
movb %al, -0x15(%rbp)
cmpb $0x0, %al
je 0x6acd
callq 0x1200
movq (%rax), %rax
movsbl -0x15(%rbp), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
jne 0x672d
movsbl -0x15(%rbp), %eax
cmpl $0x3b, %eax
jne 0x6732
jmp 0x6acd
cmpl $0x0, 0xad2b(%rip)      # 0x11464
jle 0x6744
cmpl $0x0, 0xad1e(%rip)      # 0x11460
jg 0x6759
movq -0x8(%rbp), %rsi
leaq 0x6d75(%rip), %rdi      # 0xd4c4
movl $0x4, %edx
callq 0x22f0
cmpl $0x32, 0xad04(%rip)     # 0x11464
jg 0x676b
cmpl $0x32, 0xacf7(%rip)     # 0x11460
jle 0x6780
movq -0x8(%rbp), %rsi
leaq 0x6d69(%rip), %rdi      # 0xd4df
movl $0x4, %edx
callq 0x22f0
movq 0xab39(%rip), %rax      # 0x112c0
addq $0x1, %rax
movq %rax, 0xab2e(%rip)      # 0x112c0
callq 0x1200
movq (%rax), %rax
movsbl -0x15(%rbp), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x400, %eax            # imm = 0x400
cmpl $0x0, %eax
jne 0x67c1
movsbl -0x15(%rbp), %eax
cmpl $0x2e, %eax
je 0x67c1
movsbl -0x15(%rbp), %eax
cmpl $0x5f, %eax
jne 0x67d3
callq 0x5b80
movq %rax, %rdi
callq 0x61f0
jmp 0x66f3
movsbl -0x15(%rbp), %eax
cmpl $0x22, %eax
je 0x67e5
movsbl -0x15(%rbp), %eax
cmpl $0x27, %eax
jne 0x67fb
movsbl -0x15(%rbp), %edi
callq 0x6060
movq %rax, %rdi
callq 0x61f0
jmp 0x66f3
callq 0x1200
movq (%rax), %rax
movsbl -0x15(%rbp), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
je 0x683c
movq 0xaaa1(%rip), %rax      # 0x112c0
addq $-0x1, %rax
movq %rax, 0xaa96(%rip)      # 0x112c0
callq 0x5e80
movq %rax, %rdi
callq 0x61f0
jmp 0x66f3
movsbl -0x15(%rbp), %eax
cmpl $0x25, %eax
jne 0x685c
movl $0x2, %edi
callq 0x5dc0
movq %rax, %rdi
callq 0x61f0
jmp 0x66f3
movsbl -0x15(%rbp), %eax
cmpl $0x40, %eax
jne 0x687c
movl $0x8, %edi
callq 0x5dc0
movq %rax, %rdi
callq 0x61f0
jmp 0x66f3
movsbl -0x15(%rbp), %eax
cmpl $0x24, %eax
jne 0x689c
movl $0x10, %edi
callq 0x5dc0
movq %rax, %rdi
callq 0x61f0
jmp 0x66f3
movsbl -0x15(%rbp), %eax
cmpl $0x21, %eax
jne 0x6949
movq 0xaa10(%rip), %rax      # 0x112c0
movsbl (%rax), %edi
callq 0x1080
movb %al, -0x15(%rbp)
movq 0xa9fe(%rip), %rax      # 0x112c0
addq $0x1, %rax
movq %rax, 0xa9f3(%rip)      # 0x112c0
movsbl -0x15(%rbp), %eax
cmpl $0x4e, %eax
je 0x6907
movsbl -0x15(%rbp), %eax
cmpl $0x2e, %eax
je 0x6907
movsbl -0x15(%rbp), %eax
cmpl $0x2b, %eax
je 0x6907
movsbl -0x15(%rbp), %eax
cmpl $0x58, %eax
je 0x6907
leaq 0xa4e8(%rip), %rax      # 0x10de0
movb $0x45, (%rax)
movl $0x45, %edi
callq 0x2350
jmp 0x6944
movsbl -0x15(%rbp), %eax
cmpl $0x4e, %eax
jne 0x6914
movb $0x7e, -0x15(%rbp)
movsbl -0x15(%rbp), %eax
cmpl $0x2e, %eax
jne 0x6921
movb $0x26, -0x15(%rbp)
movsbl -0x15(%rbp), %eax
cmpl $0x2b, %eax
jne 0x692e
movb $0x7c, -0x15(%rbp)
movsbl -0x15(%rbp), %eax
cmpl $0x58, %eax
jne 0x693b
movb $0x5e, -0x15(%rbp)
movsbl -0x15(%rbp), %edi
callq 0x65a0
jmp 0x66f3
movsbl -0x15(%rbp), %eax
cmpl $0x2a, %eax
jne 0x697a
cmpl $0x0, 0xab0f(%rip)      # 0x11468
jne 0x696c
leaq 0x9e9e(%rip), %rax      # 0x10800
movq (%rax), %rdi
callq 0x61f0
jmp 0x6975
movsbl -0x15(%rbp), %edi
callq 0x65a0
jmp 0x66f3
movsbl -0x15(%rbp), %eax
cmpl $0x3e, %eax
je 0x6995
movsbl -0x15(%rbp), %eax
cmpl $0x3c, %eax
je 0x6995
movsbl -0x15(%rbp), %eax
cmpl $0x2f, %eax
jne 0x69a3
movsbl -0x15(%rbp), %edi
callq 0x65a0
jmp 0x66f3
movsbl -0x15(%rbp), %eax
cmpl $0x2b, %eax
jne 0x69c3
cmpl $0x0, 0xaab5(%rip)      # 0x11468
je 0x69be
movsbl -0x15(%rbp), %edi
callq 0x65a0
jmp 0x66f3
movsbl -0x15(%rbp), %eax
cmpl $0x2d, %eax
jne 0x69e7
cmpl $0x0, 0xaa95(%rip)      # 0x11468
jne 0x69d9
movb $0x5f, -0x15(%rbp)
movsbl -0x15(%rbp), %edi
callq 0x65a0
jmp 0x66f3
movsbl -0x15(%rbp), %eax
cmpl $0x28, %eax
jne 0x69fe
movsbl -0x15(%rbp), %edi
callq 0x65a0
jmp 0x66f3
movsbl -0x15(%rbp), %eax
cmpl $0x29, %eax
jne 0x6ab4
movl $0x1, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x6aaf
movslq 0xaa41(%rip), %rcx      # 0x11464
leaq 0xaa46(%rip), %rax      # 0x11470
movsbl (%rax,%rcx), %eax
cmpl $0x28, %eax
jne 0x6a6f
movl $0x0, -0x1c(%rbp)
movl 0xaa24(%rip), %eax      # 0x11464
addl $0x1, %eax
movl %eax, 0xaa1b(%rip)      # 0x11464
movl 0xaa11(%rip), %eax      # 0x11460
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, 0xaa06(%rip)      # 0x11460
movslq %eax, %rcx
leaq 0xa86c(%rip), %rax      # 0x112d0
movq (%rax,%rcx,8), %rdi
callq 0x61f0
jmp 0x6aaa
movslq 0xa9ee(%rip), %rcx      # 0x11464
leaq 0xa9f3(%rip), %rax      # 0x11470
movsbl (%rax,%rcx), %eax
cmpl $0x24, %eax
jne 0x6aa3
leaq 0xa353(%rip), %rax      # 0x10de0
movb $0x42, (%rax)
movl $0x42, %edi
callq 0x2350
movl $0x0, -0x1c(%rbp)
jmp 0x6aa8
callq 0x6350
jmp 0x6aaa
jmp 0x6a12
jmp 0x66f3
leaq 0xa325(%rip), %rax      # 0x10de0
movb $0x43, (%rax)
movl $0x43, %edi
callq 0x2350
jmp 0x66f3
jmp 0x6acf
movslq 0xa98e(%rip), %rcx      # 0x11464
leaq 0xa993(%rip), %rax      # 0x11470
movsbl (%rax,%rcx), %eax
cmpl $0x24, %eax
je 0x6aed
callq 0x6350
jmp 0x6acf
movl 0xa971(%rip), %eax      # 0x11464
movl %eax, -0x14(%rbp)
cmpl $0x32, -0x14(%rbp)
jge 0x6b31
movslq -0x14(%rbp), %rcx
leaq 0xa969(%rip), %rax      # 0x11470
movsbl (%rax,%rcx), %eax
cmpl $0x28, %eax
jne 0x6b24
leaq 0xa2c9(%rip), %rax      # 0x10de0
movb $0x42, (%rax)
movl $0x42, %edi
callq 0x2350
jmp 0x6b26
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x6af6
cmpl $0x31, 0xa928(%rip)     # 0x11460
je 0x6b4e
leaq 0xa29f(%rip), %rax      # 0x10de0
movb $0x45, (%rax)
movl $0x45, %edi
callq 0x2350
leaq 0xa28b(%rip), %rax      # 0x10de0
cmpb $0x0, (%rax)
je 0x6b70
movslq 0xa8ff(%rip), %rcx      # 0x11460
leaq 0xa768(%rip), %rax      # 0x112d0
movq $0x0, (%rax,%rcx,8)
movslq 0xa8e9(%rip), %rcx      # 0x11460
leaq 0xa752(%rip), %rax      # 0x112d0
movq (%rax,%rcx,8), %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
leaq 0xa238(%rip), %rax      # 0x10dc8
movl (%rax), %eax
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax,%rax)