// File: /workspace/github_cpp_makefile_star2_O1/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 -0x78(%rbp), %rcx
movq %rcx, -0x10(%rcx)
xorl %eax, %eax
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq -0xb8(%rbp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq -0x98(%rbp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq -0x60(%rbp), %rcx
movl $0x0, (%rcx)
movq %rax, 0x8(%rcx)
movq %rcx, 0x10(%rcx)
movq %rcx, 0x18(%rcx)
movq %rax, 0x20(%rcx)
movq 0x2be1(%rip), %rbx      # 0x3fe0
leaq -0x29(%rbp), %r13
movq %rbx, %rdi
callq 0x10c0
movq %rbx, %rdi
callq 0x1070
movl %eax, %r15d
shll $0x18, %r15d
cmpl $0x5e000000, %r15d      # imm = 0x5E000000
je 0x1550
cmpl $0x25000000, %r15d      # imm = 0x25000000
je 0x1550
movl %eax, %ecx
andl $0xfe, %ecx
cmpl $0x2a, %ecx
je 0x1550
andl $0xfd, %eax
cmpl $0x2d, %eax
je 0x1550
sarl $0x18, %r15d
movl %r15d, %edi
callq 0x1180
testl %eax, %eax
je 0x173e
movq %rbx, %rdi
leaq -0x88(%rbp), %rsi
callq 0x1140
movq (%rbx), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x20(%rbx,%rax)
jne 0x18a4
leaq -0x88(%rbp), %rdi
leaq 0xbab(%rip), %rsi       # 0x2041
callq 0x1060
testl %eax, %eax
jne 0x17aa
movq %rbx, %rdi
movq %r13, %rsi
callq 0x1150
movq %rax, %rdi
leaq -0x2a(%rbp), %rsi
callq 0x1150
movq %rax, %rdi
leaq -0x30(%rbp), %rsi
callq 0x1090
movq (%rbx), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x20(%rbx,%rax)
jne 0x18bc
cmpb $0x3d, -0x2a(%rbp)
jne 0x18d4
movq -0x58(%rbp), %rcx
leaq -0x60(%rbp), %rax
testq %rcx, %rcx
je 0x1509
movb -0x29(%rbp), %dl
xorl %esi, %esi
cmpb %dl, 0x20(%rcx)
setl %sil
cmovgeq %rcx, %rax
movq 0x10(%rcx,%rsi,8), %rcx
testq %rcx, %rcx
jne 0x14f2
leaq -0x60(%rbp), %rdx
movq %rdx, %rcx
cmpq %rdx, %rax
je 0x1522
movb -0x29(%rbp), %cl
cmpb 0x20(%rax), %cl
cmovlq %rdx, %rax
movq %rax, %rcx
cmpq %rdx, %rcx
leaq -0x68(%rbp), %rdi
jne 0x18ec
movl -0x30(%rbp), %r15d
cmpl $0x100, %r15d           # imm = 0x100
jae 0x1904
movq %r13, %rsi
callq 0x1a60
movl %r15d, (%rax)
jmp 0x1403
movl %r14d, %r12d
movq %rbx, %rdi
leaq -0x2b(%rbp), %rsi
callq 0x1150
movq %rbx, %rdi
callq 0x10c0
movq %rbx, %rdi
callq 0x1070
movsbl %al, %r15d
movl %r15d, %edi
callq 0x1180
testl %eax, %eax
je 0x1624
movq %rbx, %rdi
movq %r13, %rsi
callq 0x1150
movq (%rbx), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x20(%rbx,%rax)
jne 0x1931
movq -0x58(%rbp), %rcx
leaq -0x60(%rbp), %rax
testq %rcx, %rcx
je 0x15c7
movb -0x29(%rbp), %dl
xorl %esi, %esi
cmpb %dl, 0x20(%rcx)
setl %sil
cmovgeq %rcx, %rax
movq 0x10(%rcx,%rsi,8), %rcx
testq %rcx, %rcx
jne 0x15b0
leaq -0x60(%rbp), %rdx
movq %rdx, %rcx
cmpq %rdx, %rax
je 0x15e0
movb -0x29(%rbp), %cl
cmpb 0x20(%rax), %cl
cmovlq %rdx, %rax
movq %rax, %rcx
cmpq %rdx, %rcx
leaq -0x68(%rbp), %rdi
je 0x191c
movq %r13, %rsi
movq %rdi, %r14
callq 0x1a60
movl (%rax), %r15d
movl %r15d, -0x34(%rbp)
movq %r14, %rdi
movq %r13, %rsi
callq 0x1a60
incl (%rax)
movq %r14, %rdi
movq %r13, %rsi
callq 0x1a60
cmpl $0x100, (%rax)          # imm = 0x100
jl 0x1654
jmp 0x1946
addl $-0x30, %r15d
cmpl $0x9, %r15d
ja 0x1970
movq %rbx, %rdi
leaq -0x34(%rbp), %rsi
callq 0x1090
movq (%rbx), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x20(%rbx,%rax)
jne 0x195b
movl -0x34(%rbp), %r15d
movzbl -0x2b(%rbp), %eax
leal -0x25(%rax), %ecx
cmpl $0xa, %ecx
ja 0x1680
leaq 0x99d(%rip), %rdx       # 0x2004
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
movl %r12d, %edi
movl %r15d, %esi
callq 0x1339
movl %eax, %r12d
jmp 0x16d8
cmpl $0x5e, %eax
jne 0x1985
movl %r12d, %eax
orl %r15d, %eax
je 0x199a
xorps %xmm0, %xmm0
cvtsi2sd %r12d, %xmm0
xorps %xmm1, %xmm1
cvtsi2sd %r15d, %xmm1
callq 0x11b0
cvtsd2ss %xmm0, %xmm0
jmp 0x16c3
testl %r15d, %r15d
je 0x16ea
movl %r12d, %eax
cltd
idivl %r15d
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
cvttss2si %xmm0, %r12d
jmp 0x16d8
imull %r15d, %r12d
jmp 0x16d8
subl %r15d, %r12d
jmp 0x16d8
addl %r15d, %r12d
movq %rbx, %rdi
callq 0x1070
cmpb $0xa, %al
jne 0x1553
jmp 0x16fd
cmpl $0x5e, %eax
je 0x1689
cmpl $0x25, %eax
je 0x1670
jmp 0x1985
movq 0x28cc(%rip), %rdi      # 0x3fd0
movl %r12d, %r14d
movl %r12d, %esi
callq 0x11a0
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x10f0
movsbl %al, %esi
movq %r15, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x10a0
jmp 0x1403
addl $-0x30, %r15d
cmpl $0x9, %r15d
ja 0x19ad
movq %rbx, %rdi
leaq -0x30(%rbp), %rsi
callq 0x1090
movl -0x30(%rbp), %r14d
movq %rbx, %rdi
callq 0x1070
cmpb $0xa, %al
jne 0x1403
movq 0x285d(%rip), %rdi      # 0x3fd0
movl %r14d, %esi
callq 0x11a0
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x10f0
movsbl %al, %esi
movq %r15, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x10a0
jmp 0x1403
leaq -0x88(%rbp), %rdi
leaq 0x88d(%rip), %rsi       # 0x2045
callq 0x1060
testl %eax, %eax
je 0x19ad
cmpq $0x1, -0x80(%rbp)
jne 0x19b4
movq -0x88(%rbp), %rax
movb (%rax), %al
movb %al, -0x29(%rbp)
movq -0x58(%rbp), %rdx
leaq -0x60(%rbp), %rcx
testq %rdx, %rdx
je 0x17fd
xorl %esi, %esi
cmpb %al, 0x20(%rdx)
setl %sil
cmovgeq %rdx, %rcx
movq 0x10(%rdx,%rsi,8), %rdx
jmp 0x17e4
leaq -0x60(%rbp), %rsi
movq %rsi, %rdx
cmpq %rsi, %rcx
je 0x1813
cmpb 0x20(%rcx), %al
cmovlq %rsi, %rcx
movq %rcx, %rdx
cmpq %rsi, %rdx
je 0x19c9
leaq -0x68(%rbp), %rdi
movq %r13, %rsi
callq 0x1a60
movl (%rax), %eax
movl %eax, %r14d
movl %eax, -0x30(%rbp)
leaq -0x68(%rbp), %rdi
movq %r13, %rsi
callq 0x1a60
incl (%rax)
leaq -0x68(%rbp), %rdi
movq %r13, %rsi
callq 0x1a60
cmpl $0x100, (%rax)          # imm = 0x100
jge 0x19de
movq %rbx, %rdi
callq 0x1070
cmpb $0xa, %al
jne 0x1403
movq 0x2763(%rip), %rdi      # 0x3fd0
movl %r14d, %esi
callq 0x11a0
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x10f0
movsbl %al, %esi
movq %r15, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x10a0
jmp 0x1403
movq 0x2725(%rip), %rdi      # 0x3fd0
leaq 0x77f(%rip), %rsi       # 0x2031
callq 0x1100
jmp 0x19ad
movq 0x270d(%rip), %rdi      # 0x3fd0
leaq 0x767(%rip), %rsi       # 0x2031
callq 0x1100
jmp 0x19ad
movq 0x26f5(%rip), %rdi      # 0x3fd0
leaq 0x74f(%rip), %rsi       # 0x2031
callq 0x1100
jmp 0x19ad
movq 0x26dd(%rip), %rdi      # 0x3fd0
leaq 0x737(%rip), %rsi       # 0x2031
callq 0x1100
jmp 0x19ad
movq 0x26c5(%rip), %rdi      # 0x3fd0
leaq 0x71f(%rip), %rsi       # 0x2031
callq 0x1100
jmp 0x19ad
movq 0x26ad(%rip), %rdi      # 0x3fd0
leaq 0x707(%rip), %rsi       # 0x2031
callq 0x1100
jmp 0x19ad
movq 0x2698(%rip), %rdi      # 0x3fd0
leaq 0x6f2(%rip), %rsi       # 0x2031
callq 0x1100
jmp 0x19ad
movq 0x2683(%rip), %rdi      # 0x3fd0
leaq 0x6dd(%rip), %rsi       # 0x2031
callq 0x1100
jmp 0x19ad
movq 0x266e(%rip), %rdi      # 0x3fd0
leaq 0x6c8(%rip), %rsi       # 0x2031
callq 0x1100
jmp 0x19ad
movq 0x2659(%rip), %rdi      # 0x3fd0
leaq 0x6b3(%rip), %rsi       # 0x2031
callq 0x1100
jmp 0x19ad
movq 0x2644(%rip), %rdi      # 0x3fd0
leaq 0x69e(%rip), %rsi       # 0x2031
callq 0x1100
jmp 0x19ad
movq 0x262f(%rip), %rdi      # 0x3fd0
leaq 0x689(%rip), %rsi       # 0x2031
callq 0x1100
xorl %edi, %edi
callq 0x1130
movq 0x2615(%rip), %rdi      # 0x3fd0
leaq 0x66f(%rip), %rsi       # 0x2031
callq 0x1100
jmp 0x19ad
movq 0x2600(%rip), %rdi      # 0x3fd0
leaq 0x65a(%rip), %rsi       # 0x2031
callq 0x1100
jmp 0x19ad
movq 0x25eb(%rip), %rdi      # 0x3fd0
leaq 0x645(%rip), %rsi       # 0x2031
callq 0x1100
jmp 0x19ad
jmp 0x1a07
jmp 0x1a07
jmp 0x1a07
jmp 0x1a07
jmp 0x1a07
jmp 0x1a07
jmp 0x1a07
jmp 0x1a07
jmp 0x1a07
jmp 0x1a07
movq %rax, %rbx
leaq -0x68(%rbp), %rdi
callq 0x1ad6
movq -0xa8(%rbp), %rdi
leaq -0x98(%rbp), %rax
cmpq %rax, %rdi
je 0x1a2b
callq 0x10e0
movq -0xc8(%rbp), %rdi
leaq -0xb8(%rbp), %rax
cmpq %rax, %rdi
je 0x1a43
callq 0x10e0
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
je 0x1a58
callq 0x10e0
movq %rbx, %rdi
callq 0x11c0