// File: /workspace/github_cpp_makefile_star2_O2/toxemicsquire4[P]csci41_calc/main.cc
// Function: main
int main() {		
  string str, command, check; //basic things needed for calculator
  map <char, int> var; //keeps track of variables
	char var_name, operation, equal;
	int a, b;
	Number x, y;	//objects we will pass to functions

while (true) {
	cin >> ws;
	char input = cin.peek();  // Checks the next char
	if ( input == '+' || input == '-' || input == '*' || input == '/' || input == '%' || input == '^' ) { // If char is an operation, enters solution loop
		while (true) {	
			cin >> operation;
			cin >> ws;
			input = cin.peek();
			if ( isalpha(input) ) {	 // If variable, will set y.
				cin >> var_name;
				if (!cin) die();
				auto search = var.find(var_name);
				if ( search == var.end() ) die(); // If variable doesn't exist, run ERROR.
				else {
					b = var[var_name];
					y.set_value(b);
					var[var_name]+= 1; // Increments value
					if ( var[var_name] > 255 ) die();
				}
			}
			else if ( isdigit(input) ) {
				cin >> b; 
				if (!cin) die(); 
					y.set_value(b);
			}
			else die();
			if ( operation == '+' ) x.set_value(add(x, y));
			else if ( operation == '-' ) x.set_value(subtract(x, y));
			else if ( operation == '*' ) x.set_value(multiply(x, y));
			else if ( operation == '/' && y.get_value() != 0 ) x.set_value(division(x, y));
			else if ( operation == '%' ) x.set_value(modulate(x, y));
			else if ( operation == '^' ) {
				if ( x.get_value() == 0 && y.get_value() == 0 ) die();
				else x.set_value(exponate(x, y));
			}
			else die();  // No other operations possible
			input = cin.peek(); // Checks for end of input... if end, output answer
			if ( input == '\n' ) {
				cout << x.get_value() << endl;
				break;
			}
		}
	}
	else if ( isalpha(input) ) { // If given a letter, will check for either setting variable or starting equation
		cin >> str;
		if ( !cin ) die();
		if ( str == "LET" ) { // If LET, set variable
			cin >> var_name >> equal >> a;
			if ( !cin ) die();
			if ( equal != '=' ) die();
			auto search = var.find(var_name);
			if ( search != var.end() ) die();
			if ( a < 0 || a > 255 ) die();
			else var[var_name] = a;
		}
		else if ( str == "QUIT" ) exit(0); // QUIT
		else if ( str.size() == 1 ) {	// If variable, will set x.
			var_name = str.at(0);
			auto search = var.find(var_name);
			if ( search == var.end() ) die(); // If variable does not exist, ERROR
			else {
				a = var[var_name];
				x.set_value(a);
				var[var_name]++;
				if ( var[var_name] > 255 ) die();
				input = cin.peek(); // Checks for end of input... if end, output answer
				if ( input == '\n' ) {
					cout << x.get_value() << endl;
				}
			}
		}
		else die();
	}
	else if ( isdigit(input) ) { // If given a digit, will set x.
		cin >> a;
		x.set_value(a);
		input = cin.peek(); // Checks for end of input... if end, output answer
		if ( input == '\n' ) {
			cout << x.get_value() << endl;
		}
	}
	else exit(0);
}

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
leaq -0x48(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
xorl %ecx, %ecx
leaq -0xb8(%rbp), %rdx
movq %rdx, -0x10(%rdx)
andq $0x0, -0x8(%rdx)
movb %cl, (%rax)
movb %cl, (%rdx)
leaq -0x98(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb %cl, (%rax)
leaq -0x80(%rbp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
movq 0x2bbf(%rip), %rbx      # 0x4fe0
leaq -0x2b(%rbp), %r13
leaq -0x88(%rbp), %r12
movq %rbx, %rdi
callq 0x20e0
movq %rbx, %rdi
callq 0x2070
movl %eax, %r15d
shll $0x18, %r15d
cmpl $0x5e000000, %r15d      # imm = 0x5E000000
je 0x2541
cmpl $0x25000000, %r15d      # imm = 0x25000000
je 0x2541
movl %eax, %ecx
andl $0xfe, %ecx
cmpl $0x2a, %ecx
je 0x2541
andl $0xfd, %eax
cmpl $0x2d, %eax
je 0x2541
sarl $0x18, %r15d
movl %r15d, %edi
callq 0x2190
testl %eax, %eax
je 0x26b4
movq %rbx, %rdi
leaq -0x58(%rbp), %rsi
callq 0x2150
movq (%rbx), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x20(%rbx,%rax)
jne 0x27a3
leaq -0x58(%rbp), %rdi
leaq 0xb88(%rip), %rsi       # 0x3041
callq 0x285b
testb %al, %al
je 0x26fe
movq %rbx, %rdi
movq %r13, %rsi
callq 0x2160
movq %rax, %rdi
leaq -0x29(%rbp), %rsi
callq 0x2160
movq %rax, %rdi
leaq -0x30(%rbp), %rsi
callq 0x20b0
movq (%rbx), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x20(%rbx,%rax)
jne 0x27a3
cmpb $0x3d, -0x29(%rbp)
jne 0x27a3
movq %r12, %rdi
movq %r13, %rsi
callq 0x28d0
leaq -0x80(%rbp), %rcx
cmpq %rcx, %rax
jne 0x27a8
movl -0x30(%rbp), %r15d
cmpl $0xff, %r15d
ja 0x27a8
movq %r12, %rdi
movq %r13, %rsi
callq 0x280a
movl %r15d, (%rax)
jmp 0x242c
movq %rbx, %rdi
leaq -0x2a(%rbp), %rsi
callq 0x2160
movq %rbx, %rdi
callq 0x20e0
movq %rbx, %rdi
callq 0x2070
movsbl %al, %r15d
movl %r15d, %edi
callq 0x2190
testl %eax, %eax
je 0x25d9
movq %rbx, %rdi
movq %r13, %rsi
callq 0x2160
movq (%rbx), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x20(%rbx,%rax)
jne 0x27a3
movq %r12, %rdi
movq %r13, %rsi
callq 0x28d0
leaq -0x80(%rbp), %rcx
cmpq %rcx, %rax
je 0x27ad
movq %r12, %rdi
movq %r13, %rsi
callq 0x280a
movl (%rax), %r15d
movl %r15d, -0x34(%rbp)
movq %r12, %rdi
movq %r13, %rsi
callq 0x280a
incl (%rax)
movq %r12, %rdi
movq %r13, %rsi
callq 0x280a
cmpl $0xff, (%rax)
jle 0x2609
jmp 0x27ad
addl $-0x30, %r15d
cmpl $0x9, %r15d
ja 0x27a3
movq %rbx, %rdi
leaq -0x34(%rbp), %rsi
callq 0x20b0
movq (%rbx), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x20(%rbx,%rax)
jne 0x27a3
movl -0x34(%rbp), %r15d
movzbl -0x2a(%rbp), %eax
leal -0x25(%rax), %ecx
cmpl $0xa, %ecx
ja 0x2635
leaq 0x9e8(%rip), %rdx       # 0x3004
movslq (%rdx,%rcx,4), %rax
addq %rdx, %rax
jmpq *%rax
movl %r14d, %edi
movl %r15d, %esi
callq 0x2359
movl %eax, %r14d
jmp 0x2688
cmpl $0x5e, %eax
jne 0x27a3
movl %r14d, %eax
orl %r15d, %eax
je 0x27a3
cvtsi2sd %r14d, %xmm0
cvtsi2sd %r15d, %xmm1
callq 0x21c0
cvtsd2ss %xmm0, %xmm0
jmp 0x2673
testl %r15d, %r15d
je 0x27a3
movl %r14d, %eax
cltd
idivl %r15d
cvtsi2ss %eax, %xmm0
cvttss2si %xmm0, %r14d
jmp 0x2688
imull %r15d, %r14d
jmp 0x2688
subl %r15d, %r14d
jmp 0x2688
addl %r15d, %r14d
movq %rbx, %rdi
callq 0x2070
cmpb $0xa, %al
jne 0x2541
movq 0x2931(%rip), %rdi      # 0x4fd0
movl %r14d, %esi
callq 0x21b0
movq %rax, %rdi
callq 0x20a0
jmp 0x242c
addl $-0x30, %r15d
cmpl $0x9, %r15d
ja 0x27b2
movq %rbx, %rdi
leaq -0x30(%rbp), %rsi
callq 0x20b0
movl -0x30(%rbp), %r14d
movq %rbx, %rdi
callq 0x2070
cmpb $0xa, %al
jne 0x242c
movq 0x28e7(%rip), %rdi      # 0x4fd0
movl %r14d, %esi
callq 0x21b0
movq %rax, %rdi
callq 0x20a0
jmp 0x242c
leaq -0x58(%rbp), %rdi
leaq 0x93c(%rip), %rsi       # 0x3045
callq 0x285b
testb %al, %al
jne 0x27b2
cmpq $0x1, -0x50(%rbp)
jne 0x27a3
leaq -0x58(%rbp), %rdi
xorl %esi, %esi
callq 0x21e0
movb (%rax), %al
movb %al, -0x2b(%rbp)
movq %r12, %rdi
movq %r13, %rsi
callq 0x28d0
leaq -0x80(%rbp), %rcx
cmpq %rcx, %rax
je 0x27b9
movq %r12, %rdi
movq %r13, %rsi
callq 0x280a
movl (%rax), %r14d
movl %r14d, -0x30(%rbp)
movq %r12, %rdi
movq %r13, %rsi
callq 0x280a
incl (%rax)
movq %r12, %rdi
movq %r13, %rsi
callq 0x280a
cmpl $0xff, (%rax)
jg 0x27b9
movq %rbx, %rdi
callq 0x2070
cmpb $0xa, %al
jne 0x242c
movq 0x2842(%rip), %rdi      # 0x4fd0
movl %r14d, %esi
callq 0x21b0
movq %rax, %rdi
callq 0x20a0
jmp 0x242c
callq 0x239a
callq 0x239a
callq 0x239a
xorl %edi, %edi
callq 0x2140
callq 0x239a
jmp 0x27d2
jmp 0x27d2
jmp 0x27d2
jmp 0x27d2
jmp 0x27d2
jmp 0x27d2
jmp 0x27d2
jmp 0x27d2
jmp 0x27d2
jmp 0x27d2
movq %rax, %rbx
leaq -0x88(%rbp), %rdi
callq 0x287a
leaq -0xa8(%rbp), %rdi
callq 0x2090
leaq -0xc8(%rbp), %rdi
callq 0x2090
leaq -0x58(%rbp), %rdi
callq 0x2090
movq %rbx, %rdi
callq 0x21d0