// File: /workspace/github_cpp_makefile_star2_O3/AndrewAlbert[P]Compiler-Theory/SourceCode/parser.cpp
// Function: Parser::ExpressionPrime(int&, int&, bool, bool)
bool Parser::ExpressionPrime(int &inputType, int &inputSize, bool catchTypeError, bool catchSizeError){
	int arithOpType, arithOpSize;
	
	// Get the operator to pass to the codegenerator evaluation stack
	string op = token->ascii;
	
	if( CheckToken(T_BITWISE) ){
		CheckToken(T_NOT); //'NOT' is always optional and will be good for both integer-bitwise and boolean-boolean expressions.
		if( ArithOp(arithOpType, arithOpSize) ){
			if( catchTypeError ){
				if(inputType == TYPE_INTEGER){
					if(arithOpType != TYPE_INTEGER){
						ReportError("Only integer ArithOps can be used for bitwise operators '&' and '|'.");
						catchTypeError = false;
					}
				}
				else if(inputType == TYPE_BOOL){
					if(arithOpType != TYPE_BOOL){
						ReportError("Only boolean ArithOps can be used for boolean operators '&' and '|'.");
						catchTypeError = false;
					}
				}
				else ReportError("Only integer / boolean ArithOps can be used for bitwise / boolean operators '&' and '|'.");
			}
			if( catchSizeError ){
				//Ensure compatible sizes are used.
				if( (inputSize != arithOpSize) && (inputSize != 0) && (arithOpSize != 0) ){
					ReportError("Expected ArithOp of size " + to_string(inputSize) + ", but found one of size " + to_string(arithOpSize) + ".");
					catchSizeError = false;
				}
				//Set new inputSize if the next ArithOp's size was non-zero and inputSize was zero.
				else if(arithOpSize != 0) inputSize = arithOpSize;
			}
		}
		else{
			ReportError("Expected ArithOp after '&' or '|' operator.");
			catchTypeError = false;
			catchSizeError = false;
		}
		ExpressionPrime(inputType, inputSize, catchTypeError, catchSizeError);
		
		// GEN: Evaluate expression and push register onto the stack to pass to upper expression
		// Do not need resulting string since expression result is pushed back onto the stack
		generator->evalExpr( op, inputSize, arithOpSize, inputType, arithOpType );
		
		return true;
	}
	else return false;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1b8, %rsp            # imm = 0x1B8
movl %r8d, %ebp
movl %ecx, %r13d
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %r12
movq 0x80(%rdi), %rax
leaq 0xc8(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq 0xb8(%rsp), %rdi
callq 0x3bac
movq %r12, %rdi
movl $0x13b, %esi            # imm = 0x13B
callq 0x5c08
movl %eax, %ebx
testb %al, %al
je 0xaf1f
movq %r12, %rdi
movl $0x10f, %esi            # imm = 0x10F
callq 0x5c08
leaq 0x10(%rsp), %rsi
leaq 0xc(%rsp), %rdx
movq %r12, %rdi
callq 0xab8e
testb %al, %al
je 0xaccb
testb %r13b, %r13b
je 0xad26
movl (%r14), %eax
cmpl $0x10c, %eax            # imm = 0x10C
je 0xad2d
cmpl $0x10a, %eax            # imm = 0x10A
jne 0xad81
movb $0x1, %sil
cmpl $0x10a, 0x10(%rsp)      # imm = 0x10A
je 0xaddc
leaq 0x188(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0xf5f1(%rip), %rsi      # 0x1a28b
leaq 0xf62e(%rip), %rdx      # 0x1a2cf
leaq 0x178(%rsp), %rdi
callq 0x3c42
leaq 0x178(%rsp), %rsi
movq %r12, %rdi
callq 0x5694
movq 0x178(%rsp), %rdi
jmp 0xad7d
leaq 0x128(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0xf6c3(%rip), %rsi      # 0x1a3a1
leaq 0xf6e7(%rip), %rdx      # 0x1a3cc
leaq 0x118(%rsp), %rdi
callq 0x3c42
leaq 0x118(%rsp), %rsi
movq %r12, %rdi
callq 0x5694
movq 0x118(%rsp), %rdi
cmpq %r13, %rdi
je 0xad1f
movq 0x128(%rsp), %rsi
incq %rsi
callq 0x2200
xorl %esi, %esi
jmp 0xae6b
xorl %esi, %esi
jmp 0xaddc
movb $0x1, %sil
cmpl $0x10c, 0x10(%rsp)      # imm = 0x10C
je 0xaddc
leaq 0x168(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0xf57f(%rip), %rsi      # 0x1a2d0
leaq 0xf5bc(%rip), %rdx      # 0x1a314
leaq 0x158(%rsp), %rdi
callq 0x3c42
leaq 0x158(%rsp), %rsi
movq %r12, %rdi
callq 0x5694
movq 0x158(%rsp), %rdi
xorl %esi, %esi
jmp 0xadc3
leaq 0x148(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0xf581(%rip), %rsi      # 0x1a315
leaq 0xf5d2(%rip), %rdx      # 0x1a36d
leaq 0x138(%rsp), %rdi
callq 0x3c42
leaq 0x138(%rsp), %rsi
movq %r12, %rdi
callq 0x5694
movq 0x138(%rsp), %rdi
movb $0x1, %sil
cmpq %r13, %rdi
je 0xaddc
movq %r13, %rax
movl %esi, %r13d
movq (%rax), %rsi
incq %rsi
callq 0x2200
movl %r13d, %esi
testb %bpl, %bpl
je 0xae6b
movl (%r15), %r13d
movl 0xc(%rsp), %ecx
cmpl %ecx, %r13d
je 0xaf58
testq %r13, %r13
sete %al
testl %ecx, %ecx
sete %dl
orb %al, %dl
jne 0xaf58
movl %r13d, %edi
negl %edi
cmovsl %r13d, %edi
movl $0x1, %ebp
cmpl $0xa, %edi
jb 0xaf71
movl $0x4, %ebp
movl $0xd1b71759, %eax       # imm = 0xD1B71759
movl %edi, %ecx
cmpl $0x63, %ecx
jbe 0xaf6a
cmpl $0x3e7, %ecx            # imm = 0x3E7
jbe 0xaf6f
cmpl $0x2710, %ecx           # imm = 0x2710
jb 0xaf71
movl %ecx, %edx
imulq %rax, %rdx
shrq $0x2d, %rdx
addl $0x4, %ebp
cmpl $0x1869f, %ecx          # imm = 0x1869F
movl %edx, %ecx
ja 0xae2b
addl $-0x3, %ebp
jmp 0xaf71
xorl %eax, %eax
movzbl %sil, %ecx
movzbl %al, %r8d
movq %r12, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0xabd0
movq 0x98(%r12), %r12
leaq 0x108(%rsp), %r13
movq %r13, -0x10(%r13)
movq 0xb8(%rsp), %rsi
movq 0xc0(%rsp), %rdx
addq %rsi, %rdx
leaq 0xf8(%rsp), %rdi
callq 0x3bac
movl (%r15), %ecx
movl 0xc(%rsp), %r8d
movl (%r14), %r9d
movl 0x10(%rsp), %eax
movl %eax, (%rsp)
leaq 0x198(%rsp), %rdi
leaq 0xf8(%rsp), %rdx
movq %r12, %rsi
callq 0x11dd6
leaq 0x1a8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xaf02
movq 0x1a8(%rsp), %rsi
incq %rsi
callq 0x2200
movq 0xf8(%rsp), %rdi
cmpq %r13, %rdi
je 0xaf1f
movq 0x108(%rsp), %rsi
incq %rsi
callq 0x2200
movq 0xb8(%rsp), %rdi
leaq 0xc8(%rsp), %rax
cmpq %rax, %rdi
je 0xaf44
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x2200
movl %ebx, %eax
addq $0x1b8, %rsp            # imm = 0x1B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movb $0x1, %al
testl %ecx, %ecx
je 0xae6d
movl %ecx, (%r15)
jmp 0xae6d
addl $-0x2, %ebp
jmp 0xaf71
decl %ebp
movl %edi, 0x8(%rsp)
movl %esi, 0x14(%rsp)
shrl $0x1f, %r13d
leal (%rbp,%r13), %esi
leaq 0x88(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x78(%rsp), %rdi
movl $0x2d, %edx
callq 0x2240
leaq 0x78(%rsp), %rax
addq (%rax), %r13
movq %r13, %rdi
movl %ebp, %esi
movl 0x8(%rsp), %edx
callq 0xdf80
leaq 0xf3b4(%rip), %rcx      # 0x1a36e
movl $0x19, %r8d
leaq 0x78(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2220
leaq 0xa8(%rsp), %rsi
movq %rsi, -0x10(%rsi)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0xaffe
movq %rdx, 0x98(%rsp)
movq (%rcx), %rdx
movq %rdx, 0xa8(%rsp)
jmp 0xb004
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq 0x8(%rax), %rdx
leaq 0x98(%rsp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0xf35e(%rip), %rsi      # 0x1a388
callq 0x2380
leaq 0x48(%rsp), %rsi
movq %rsi, -0x10(%rsi)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0xb056
movq %rdx, 0x38(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x48(%rsp)
jmp 0xb05c
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq 0x8(%rax), %rdx
movq %rdx, 0x40(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movl 0xc(%rsp), %r13d
movl %r13d, %esi
negl %esi
cmovsl %r13d, %esi
movl $0x1, %ebp
cmpl $0xa, %esi
jb 0xb0d0
movl $0x4, %ebp
movl $0xd1b71759, %eax       # imm = 0xD1B71759
movl %esi, %ecx
cmpl $0x63, %ecx
jbe 0xb0c9
cmpl $0x3e7, %ecx            # imm = 0x3E7
jbe 0xb0ce
cmpl $0x2710, %ecx           # imm = 0x2710
jb 0xb0d0
movl %ecx, %edx
imulq %rax, %rdx
shrq $0x2d, %rdx
addl $0x4, %ebp
cmpl $0x1869f, %ecx          # imm = 0x1869F
movl %edx, %ecx
ja 0xb098
addl $-0x3, %ebp
jmp 0xb0d0
addl $-0x2, %ebp
jmp 0xb0d0
decl %ebp
movl %esi, 0x8(%rsp)
shrl $0x1f, %r13d
leal (%rbp,%r13), %esi
leaq 0x28(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x18(%rsp), %rdi
movl $0x2d, %edx
callq 0x2240
addq 0x18(%rsp), %r13
movq %r13, %rdi
movl %ebp, %esi
movl 0x8(%rsp), %edx
callq 0xdf80
movq 0x38(%rsp), %rcx
movq 0x40(%rsp), %r8
movq 0x20(%rsp), %rdx
leaq (%rdx,%r8), %rax
movl $0xf, %edi
leaq 0x48(%rsp), %rbp
cmpq %rbp, %rcx
je 0xb12f
movq 0x48(%rsp), %rdi
movq 0x18(%rsp), %rsi
cmpq %rdi, %rax
jbe 0xb152
movl $0xf, %edi
leaq 0x28(%rsp), %r9
cmpq %r9, %rsi
je 0xb14d
movq 0x28(%rsp), %rdi
cmpq %rdi, %rax
jbe 0xb15e
leaq 0x38(%rsp), %rdi
callq 0x20c0
jmp 0xb16c
leaq 0x18(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2220
leaq 0x68(%rsp), %rdx
movq %rdx, -0x10(%rdx)
movq (%rax), %rsi
leaq 0x10(%rax), %rcx
cmpq %rcx, %rsi
je 0xb190
movq %rsi, 0x58(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x68(%rsp)
jmp 0xb196
movups (%rcx), %xmm0
movups %xmm0, (%rdx)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, 0x60(%rsp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
leaq 0xf2f2(%rip), %rsi      # 0x1a4ac
leaq 0x58(%rsp), %rdi
callq 0x2380
leaq 0xe8(%rsp), %r13
movq %r13, -0x10(%r13)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0xb1f4
movq %rdx, 0xd8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0xe8(%rsp)
jmp 0xb1fc
movups (%rcx), %xmm0
movups %xmm0, (%r13)
movq 0x8(%rax), %rdx
leaq 0xd8(%rsp), %rsi
movq %rdx, 0x8(%rsi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq %r12, %rdi
callq 0x5694
movq 0xd8(%rsp), %rdi
cmpq %r13, %rdi
je 0xb240
movq 0xe8(%rsp), %rsi
incq %rsi
callq 0x2200
leaq 0x68(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
leaq 0xa8(%rsp), %r13
je 0xb263
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x2200
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0xb27f
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x2200
movq 0x38(%rsp), %rdi
cmpq %rbp, %rdi
je 0xb296
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x2200
movq 0x98(%rsp), %rdi
cmpq %r13, %rdi
je 0xb2b3
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x2200
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0xb2d5
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x2200
xorl %eax, %eax
movl 0x14(%rsp), %esi
jmp 0xae6d
movq %rax, %rbx
movq 0x158(%rsp), %rdi
cmpq %r13, %rdi
je 0xb458
movq 0x168(%rsp), %rsi
jmp 0xb44b
movq %rax, %rbx
movq 0x178(%rsp), %rdi
cmpq %r13, %rdi
je 0xb458
movq 0x188(%rsp), %rsi
jmp 0xb44b
jmp 0xb455
jmp 0xb455
movq %rax, %rbx
movq 0xd8(%rsp), %rdi
cmpq %r13, %rdi
je 0xb351
movq 0xe8(%rsp), %rsi
incq %rsi
callq 0x2200
jmp 0xb351
movq %rax, %rbx
leaq 0x68(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xb371
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x2200
jmp 0xb371
movq %rax, %rbx
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0xb392
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x2200
jmp 0xb392
movq %rax, %rbx
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0xb3b3
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x2200
jmp 0xb3b3
movq %rax, %rbx
movq 0x98(%rsp), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
je 0xb3dd
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x2200
jmp 0xb3dd
movq %rax, %rbx
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0xb458
movq 0x88(%rsp), %rsi
jmp 0xb44b
jmp 0xb455
movq %rax, %rbx
movq 0x138(%rsp), %rdi
cmpq %r13, %rdi
je 0xb458
movq 0x148(%rsp), %rsi
jmp 0xb44b
jmp 0xb455
movq %rax, %rbx
movq 0x118(%rsp), %rdi
cmpq %r13, %rdi
je 0xb458
movq 0x128(%rsp), %rsi
jmp 0xb44b
jmp 0xb455
movq %rax, %rbx
movq 0xf8(%rsp), %rdi
cmpq %r13, %rdi
je 0xb458
movq 0x108(%rsp), %rsi
incq %rsi
callq 0x2200
jmp 0xb458
movq %rax, %rbx
movq 0xb8(%rsp), %rdi
leaq 0xc8(%rsp), %rax
cmpq %rax, %rdi
je 0xb47d
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x2200
movq %rbx, %rdi
callq 0x2330
nop