// File: /workspace/github_cpp_makefile_star2_O3/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
leaq -0x68(%rbp), %r12
movq %rbx, %rdi
callq 0x10c0
movq %rbx, %rdi
callq 0x1070
movl %eax, %r15d
shll $0x18, %r15d
cmpl $0x5e000000, %r15d      # imm = 0x5E000000
je 0x1557
cmpl $0x25000000, %r15d      # imm = 0x25000000
je 0x1557
movl %eax, %ecx
andl $0xfe, %ecx
cmpl $0x2a, %ecx
je 0x1557
andl $0xfd, %eax
cmpl $0x2d, %eax
je 0x1557
sarl $0x18, %r15d
movl %r15d, %edi
callq 0x1180
testl %eax, %eax
je 0x1736
movq %rbx, %rdi
leaq -0x88(%rbp), %rsi
callq 0x1140
movq (%rbx), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x20(%rbx,%rax)
jne 0x18c2
leaq -0x88(%rbp), %rdi
leaq 0xba7(%rip), %rsi       # 0x2041
callq 0x1060
testl %eax, %eax
jne 0x17a2
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 0x18da
cmpb $0x3d, -0x2a(%rbp)
jne 0x18f2
movq -0x58(%rbp), %rdi
testq %rdi, %rdi
je 0x1533
movb -0x29(%rbp), %al
leaq -0x60(%rbp), %r8
movq %r8, %rcx
movq %rdi, %rdx
movb 0x20(%rdi), %sil
xorl %edi, %edi
cmpb %al, %sil
setl %dil
movq %rdx, %r8
cmovlq %rcx, %r8
movq 0x10(%rdx,%rdi,8), %rdi
testq %rdi, %rdi
jne 0x14f6
leaq -0x60(%rbp), %rdi
cmpq %rdi, %r8
je 0x1533
cmpb %al, %sil
cmovlq %rcx, %rdx
cmpb 0x20(%rdx), %al
jge 0x1994
movl -0x30(%rbp), %r15d
cmpl $0x100, %r15d           # imm = 0x100
jae 0x190a
movq %r12, %rdi
movq %r13, %rsi
callq 0x1a70
movl %r15d, (%rax)
jmp 0x1407
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 0x1630
movq %rbx, %rdi
movq %r13, %rsi
callq 0x1150
movq (%rbx), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x20(%rbx,%rax)
jne 0x1922
movq -0x58(%rbp), %rdi
testq %rdi, %rdi
je 0x18aa
movb -0x29(%rbp), %al
leaq -0x60(%rbp), %r8
movq %r8, %rcx
movq %rdi, %rdx
movb 0x20(%rdi), %sil
xorl %edi, %edi
cmpb %al, %sil
setl %dil
movq %rdx, %r8
cmovlq %rcx, %r8
movq 0x10(%rdx,%rdi,8), %rdi
testq %rdi, %rdi
jne 0x15b8
leaq -0x60(%rbp), %rdi
cmpq %rdi, %r8
je 0x18aa
cmpb %al, %sil
cmovlq %rcx, %rdx
cmpb 0x20(%rdx), %al
jl 0x18aa
movq %r12, %rdi
movq %r13, %rsi
callq 0x1a70
movl (%rax), %r15d
movl %r15d, -0x34(%rbp)
movq %r12, %rdi
movq %r13, %rsi
callq 0x1a70
incl (%rax)
movq %r12, %rdi
movq %r13, %rsi
callq 0x1a70
cmpl $0x100, (%rax)          # imm = 0x100
jl 0x1660
jmp 0x193a
addl $-0x30, %r15d
cmpl $0x9, %r15d
ja 0x197f
movq %rbx, %rdi
leaq -0x34(%rbp), %rsi
callq 0x1090
movq (%rbx), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x20(%rbx,%rax)
jne 0x196a
movl -0x34(%rbp), %r15d
movzbl -0x2b(%rbp), %eax
leal -0x25(%rax), %ecx
cmpl $0xa, %ecx
ja 0x168c
leaq 0x991(%rip), %rdx       # 0x2004
movslq (%rdx,%rcx,4), %rax
addq %rdx, %rax
jmpq *%rax
movl %r14d, %edi
movl %r15d, %esi
callq 0x1339
movl %eax, %r14d
jmp 0x16e8
cmpl $0x5e, %eax
jne 0x1952
movl %r14d, %eax
orl %r15d, %eax
je 0x19a9
xorps %xmm0, %xmm0
cvtsi2sd %r14d, %xmm0
xorps %xmm1, %xmm1
cvtsi2sd %r15d, %xmm1
callq 0x11b0
cvtsd2ss %xmm0, %xmm0
jmp 0x16d3
testl %r15d, %r15d
je 0x1952
movl %r14d, %eax
cltd
idivl %r15d
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
cvttss2si %xmm0, %r14d
jmp 0x16e8
imull %r15d, %r14d
jmp 0x16e8
subl %r15d, %r14d
jmp 0x16e8
addl %r15d, %r14d
movq %rbx, %rdi
callq 0x1070
cmpb $0xa, %al
jne 0x1557
movq 0x28d1(%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 0x1407
addl $-0x30, %r15d
cmpl $0x9, %r15d
ja 0x19fb
movq %rbx, %rdi
leaq -0x30(%rbp), %rsi
callq 0x1090
movl -0x30(%rbp), %r14d
movq %rbx, %rdi
callq 0x1070
cmpb $0xa, %al
jne 0x1407
movq 0x2865(%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 0x1407
leaq -0x88(%rbp), %rdi
leaq 0x895(%rip), %rsi       # 0x2045
callq 0x1060
testl %eax, %eax
je 0x19fb
cmpq $0x1, -0x80(%rbp)
jne 0x19d3
movq -0x88(%rbp), %rax
movb (%rax), %al
movb %al, -0x29(%rbp)
movq -0x58(%rbp), %rdi
testq %rdi, %rdi
je 0x19be
leaq -0x60(%rbp), %r8
movq %r8, %rcx
movq %rdi, %rdx
movb 0x20(%rdi), %sil
xorl %edi, %edi
cmpb %al, %sil
setl %dil
movq %rdx, %r8
cmovlq %rcx, %r8
movq 0x10(%rdx,%rdi,8), %rdi
testq %rdi, %rdi
jne 0x17e5
leaq -0x60(%rbp), %rdi
cmpq %rdi, %r8
je 0x19be
cmpb %al, %sil
cmovlq %rcx, %rdx
cmpb 0x20(%rdx), %al
jl 0x19be
movq %r12, %rdi
movq %r13, %rsi
callq 0x1a70
movl (%rax), %r14d
movl %r14d, -0x30(%rbp)
movq %r12, %rdi
movq %r13, %rsi
callq 0x1a70
incl (%rax)
movq %r12, %rdi
movq %r13, %rsi
callq 0x1a70
cmpl $0x100, (%rax)          # imm = 0x100
jge 0x19e8
movq %rbx, %rdi
callq 0x1070
cmpb $0xa, %al
jne 0x1407
movq 0x275d(%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 0x1407
movq 0x271f(%rip), %rdi      # 0x3fd0
leaq 0x779(%rip), %rsi       # 0x2031
callq 0x1100
jmp 0x19fb
movq 0x2707(%rip), %rdi      # 0x3fd0
leaq 0x761(%rip), %rsi       # 0x2031
callq 0x1100
jmp 0x19fb
movq 0x26ef(%rip), %rdi      # 0x3fd0
leaq 0x749(%rip), %rsi       # 0x2031
callq 0x1100
jmp 0x19fb
movq 0x26d7(%rip), %rdi      # 0x3fd0
leaq 0x731(%rip), %rsi       # 0x2031
callq 0x1100
jmp 0x19fb
movq 0x26bf(%rip), %rdi      # 0x3fd0
leaq 0x719(%rip), %rsi       # 0x2031
callq 0x1100
jmp 0x19fb
movq 0x26a7(%rip), %rdi      # 0x3fd0
leaq 0x701(%rip), %rsi       # 0x2031
callq 0x1100
jmp 0x19fb
movq 0x268f(%rip), %rdi      # 0x3fd0
leaq 0x6e9(%rip), %rsi       # 0x2031
callq 0x1100
jmp 0x19fb
movq 0x2677(%rip), %rdi      # 0x3fd0
leaq 0x6d1(%rip), %rsi       # 0x2031
callq 0x1100
jmp 0x19fb
movq 0x265f(%rip), %rdi      # 0x3fd0
leaq 0x6b9(%rip), %rsi       # 0x2031
callq 0x1100
jmp 0x19fb
movq 0x264a(%rip), %rdi      # 0x3fd0
leaq 0x6a4(%rip), %rsi       # 0x2031
callq 0x1100
jmp 0x19fb
movq 0x2635(%rip), %rdi      # 0x3fd0
leaq 0x68f(%rip), %rsi       # 0x2031
callq 0x1100
jmp 0x19fb
movq 0x2620(%rip), %rdi      # 0x3fd0
leaq 0x67a(%rip), %rsi       # 0x2031
callq 0x1100
jmp 0x19fb
movq 0x260b(%rip), %rdi      # 0x3fd0
leaq 0x665(%rip), %rsi       # 0x2031
callq 0x1100
jmp 0x19fb
movq 0x25f6(%rip), %rdi      # 0x3fd0
leaq 0x650(%rip), %rsi       # 0x2031
callq 0x1100
jmp 0x19fb
movq 0x25e1(%rip), %rdi      # 0x3fd0
leaq 0x63b(%rip), %rsi       # 0x2031
callq 0x1100
xorl %edi, %edi
callq 0x1130
jmp 0x1a16
jmp 0x1a16
jmp 0x1a16
jmp 0x1a16
jmp 0x1a16
jmp 0x1a16
jmp 0x1a16
jmp 0x1a16
jmp 0x1a16
jmp 0x1a16
movq %rax, %rbx
leaq -0x68(%rbp), %rdi
callq 0x1ae6
movq -0xa8(%rbp), %rdi
leaq -0x98(%rbp), %rax
cmpq %rax, %rdi
je 0x1a3a
callq 0x10e0
movq -0xc8(%rbp), %rdi
leaq -0xb8(%rbp), %rax
cmpq %rax, %rdi
je 0x1a52
callq 0x10e0
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
je 0x1a67
callq 0x10e0
movq %rbx, %rdi
callq 0x11c0
nop