// File: /workspace/github_cpp_makefile_star2_O1/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 $0x1c8, %rsp            # imm = 0x1C8
movl %r8d, %r13d
movl %ecx, %ebp
movq %rdx, %r15
movq %rsi, 0x20(%rsp)
movq %rdi, %r12
movq 0x80(%rdi), %rax
leaq 0xd8(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq 0xc8(%rsp), %rdi
callq 0x3ba4
movq %r12, %rdi
movl $0x13b, %esi            # imm = 0x13B
callq 0x5c0a
movl %eax, %ebx
testb %al, %al
je 0xafcd
movq %r12, %rdi
movl $0x10f, %esi            # imm = 0x10F
callq 0x5c0a
leaq 0x1c(%rsp), %rsi
leaq 0x18(%rsp), %rdx
movq %r12, %rdi
callq 0xac14
testb %al, %al
je 0xad67
testb %bpl, %bpl
je 0xae81
movq 0x20(%rsp), %rax
movl (%rax), %eax
cmpl $0x10c, %eax            # imm = 0x10C
je 0xadc5
cmpl $0x10a, %eax            # imm = 0x10A
jne 0xae24
cmpl $0x10a, 0x1c(%rsp)      # imm = 0x10A
je 0xae81
leaq 0x158(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0xf565(%rip), %rsi      # 0x1a28b
leaq 0xf5a2(%rip), %rdx      # 0x1a2cf
leaq 0x148(%rsp), %rdi
callq 0x3c34
leaq 0x148(%rsp), %rsi
movq %r12, %rdi
callq 0x5696
movq 0x148(%rsp), %rdi
xorl %r14d, %r14d
movl $0x0, %ebp
leaq 0x158(%rsp), %rax
jmp 0xae6e
leaq 0x198(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0xf627(%rip), %rsi      # 0x1a3a1
leaq 0xf64b(%rip), %rdx      # 0x1a3cc
leaq 0x188(%rsp), %rdi
callq 0x3c34
leaq 0x188(%rsp), %rsi
movq %r12, %rdi
callq 0x5696
movq 0x188(%rsp), %rdi
cmpq %r14, %rdi
je 0xadbb
movq 0x198(%rsp), %rsi
incq %rsi
callq 0x2200
xorl %ebp, %ebp
xorl %r13d, %r13d
jmp 0xaf13
cmpl $0x10c, 0x1c(%rsp)      # imm = 0x10C
je 0xae81
leaq 0x138(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0xf4ea(%rip), %rsi      # 0x1a2d0
leaq 0xf527(%rip), %rdx      # 0x1a314
leaq 0x128(%rsp), %rdi
callq 0x3c34
leaq 0x128(%rsp), %rsi
movq %r12, %rdi
callq 0x5696
movq 0x128(%rsp), %rdi
xorl %r14d, %r14d
movl $0x0, %ebp
leaq 0x138(%rsp), %rax
jmp 0xae6e
leaq 0x118(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0xf4de(%rip), %rsi      # 0x1a315
leaq 0xf52f(%rip), %rdx      # 0x1a36d
leaq 0x108(%rsp), %rdi
callq 0x3c34
leaq 0x108(%rsp), %rsi
movq %r12, %rdi
callq 0x5696
movq 0x108(%rsp), %rdi
movl %ebp, %r14d
leaq 0x118(%rsp), %rax
cmpq %rax, %rdi
je 0xae81
movq (%rax), %rsi
incq %rsi
callq 0x2200
movl %r14d, %ebp
testb %r13b, %r13b
je 0xaf13
movl (%r15), %r14d
movl 0x18(%rsp), %eax
cmpl %eax, %r14d
je 0xaf0c
testq %r14, %r14
sete %cl
testl %eax, %eax
sete %dl
orb %cl, %dl
jne 0xaf0c
movl %r14d, %esi
negl %esi
cmovsl %r14d, %esi
movl $0x1, %r13d
cmpl $0xa, %esi
jb 0xb00f
movl $0x4, %r13d
movl $0xd1b71759, %eax       # imm = 0xD1B71759
movl %esi, %ecx
cmpl $0x63, %ecx
jbe 0xb006
cmpl $0x3e7, %ecx            # imm = 0x3E7
jbe 0xb00c
cmpl $0x2710, %ecx           # imm = 0x2710
jb 0xb00f
movl %ecx, %edx
imulq %rax, %rdx
shrq $0x2d, %rdx
addl $0x4, %r13d
cmpl $0x1869f, %ecx          # imm = 0x1869F
movl %edx, %ecx
ja 0xaeca
addl $-0x3, %r13d
jmp 0xb00f
testl %eax, %eax
je 0xaf13
movl %eax, (%r15)
movzbl %bpl, %ecx
movzbl %r13b, %r8d
movq %r12, %rdi
movq 0x20(%rsp), %rsi
movq %r15, %rdx
callq 0xac56
movq 0x98(%r12), %r14
leaq 0x178(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0xc8(%rsp), %rsi
movq 0xd0(%rsp), %rdx
addq %rsi, %rdx
leaq 0x168(%rsp), %rdi
callq 0x3ba4
movl (%r15), %ecx
movl 0x18(%rsp), %r8d
movq 0x20(%rsp), %rax
movl (%rax), %r9d
movl 0x1c(%rsp), %eax
movl %eax, (%rsp)
leaq 0x1a8(%rsp), %rdi
leaq 0x168(%rsp), %rdx
movq %r14, %rsi
callq 0x11eb8
leaq 0x1b8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xafb0
movq 0x1b8(%rsp), %rsi
incq %rsi
callq 0x2200
movq 0x168(%rsp), %rdi
cmpq %r12, %rdi
je 0xafcd
movq 0x178(%rsp), %rsi
incq %rsi
callq 0x2200
movq 0xc8(%rsp), %rdi
leaq 0xd8(%rsp), %rax
cmpq %rax, %rdi
je 0xaff2
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x2200
movl %ebx, %eax
addq $0x1c8, %rsp            # imm = 0x1C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
addl $-0x2, %r13d
jmp 0xb00f
decl %r13d
movl %esi, 0x14(%rsp)
shrl $0x1f, %r14d
leal (%r14,%r13), %esi
leaq 0x98(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x88(%rsp), %rdi
movl $0x2d, %edx
callq 0x2240
leaq 0x88(%rsp), %rax
addq (%rax), %r14
movq %r14, %rdi
movl %r13d, %esi
movl 0x14(%rsp), %edx
callq 0xe072
leaq 0xf314(%rip), %rcx      # 0x1a36e
movl $0x19, %r8d
leaq 0x88(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2220
leaq 0xb8(%rsp), %rsi
movq %rsi, -0x10(%rsi)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0xb0a1
movq %rdx, 0xa8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0xb8(%rsp)
jmp 0xb0a7
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq 0x8(%rax), %rdx
leaq 0xa8(%rsp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0xf2bb(%rip), %rsi      # 0x1a388
callq 0x2380
leaq 0x58(%rsp), %rsi
movq %rsi, -0x10(%rsi)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0xb0f9
movq %rdx, 0x48(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x58(%rsp)
jmp 0xb0ff
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq 0x8(%rax), %rdx
movq %rdx, 0x50(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movl 0x18(%rsp), %r14d
movl %r14d, %esi
negl %esi
cmovsl %r14d, %esi
movl $0x1, %r13d
cmpl $0xa, %esi
jb 0xb179
movl $0x4, %r13d
movl $0xd1b71759, %eax       # imm = 0xD1B71759
movl %esi, %ecx
cmpl $0x63, %ecx
jbe 0xb170
cmpl $0x3e7, %ecx            # imm = 0x3E7
jbe 0xb176
cmpl $0x2710, %ecx           # imm = 0x2710
jb 0xb179
movl %ecx, %edx
imulq %rax, %rdx
shrq $0x2d, %rdx
addl $0x4, %r13d
cmpl $0x1869f, %ecx          # imm = 0x1869F
movl %edx, %ecx
ja 0xb13d
addl $-0x3, %r13d
jmp 0xb179
addl $-0x2, %r13d
jmp 0xb179
decl %r13d
movl %esi, 0x14(%rsp)
shrl $0x1f, %r14d
leal (%r14,%r13), %esi
leaq 0x38(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x28(%rsp), %rdi
movl $0x2d, %edx
callq 0x2240
addq 0x28(%rsp), %r14
movq %r14, %rdi
movl %r13d, %esi
movl 0x14(%rsp), %edx
callq 0xe072
movq 0x48(%rsp), %rcx
movq 0x50(%rsp), %r8
movq 0x30(%rsp), %rdx
leaq (%rdx,%r8), %rax
movl $0xf, %esi
leaq 0x58(%rsp), %r13
cmpq %r13, %rcx
je 0xb1d8
movq 0x58(%rsp), %rsi
cmpq %rsi, %rax
jbe 0xb1f8
movl $0xf, %esi
leaq 0x38(%rsp), %rdi
cmpq %rdi, 0x28(%rsp)
je 0xb1f3
movq 0x38(%rsp), %rsi
cmpq %rsi, %rax
jbe 0xb209
movq 0x28(%rsp), %rsi
leaq 0x48(%rsp), %rdi
callq 0x20c0
jmp 0xb217
leaq 0x28(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2220
leaq 0x78(%rsp), %rdx
movq %rdx, -0x10(%rdx)
movq (%rax), %rsi
leaq 0x10(%rax), %rcx
cmpq %rcx, %rsi
je 0xb23b
movq %rsi, 0x68(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x78(%rsp)
jmp 0xb241
movups (%rcx), %xmm0
movups %xmm0, (%rdx)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, 0x70(%rsp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
leaq 0xf247(%rip), %rsi      # 0x1a4ac
leaq 0x68(%rsp), %rdi
callq 0x2380
leaq 0xf8(%rsp), %r14
movq %r14, -0x10(%r14)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0xb29f
movq %rdx, 0xe8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0xf8(%rsp)
jmp 0xb2a6
movups (%rcx), %xmm0
movups %xmm0, (%r14)
movq 0x8(%rax), %rdx
leaq 0xe8(%rsp), %rsi
movq %rdx, 0x8(%rsi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq %r12, %rdi
callq 0x5696
movq 0xe8(%rsp), %rdi
cmpq %r14, %rdi
je 0xb2ea
movq 0xf8(%rsp), %rsi
incq %rsi
callq 0x2200
leaq 0x78(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
leaq 0xb8(%rsp), %r14
je 0xb30d
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x2200
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0xb329
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x2200
movq 0x48(%rsp), %rdi
cmpq %r13, %rdi
je 0xb340
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x2200
movq 0xa8(%rsp), %rdi
cmpq %r14, %rdi
je 0xb35d
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x2200
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
je 0xadbd
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x2200
jmp 0xadbd
movq %rax, %rbx
movq 0x128(%rsp), %rdi
leaq 0x138(%rsp), %rax
cmpq %rax, %rdi
je 0xb51e
movq 0x138(%rsp), %rsi
jmp 0xb511
movq %rax, %rbx
movq 0x148(%rsp), %rdi
leaq 0x158(%rsp), %rax
cmpq %rax, %rdi
je 0xb51e
movq 0x158(%rsp), %rsi
jmp 0xb511
jmp 0xb51b
jmp 0xb51b
movq %rax, %rbx
movq 0xe8(%rsp), %rdi
cmpq %r14, %rdi
je 0xb40c
movq 0xf8(%rsp), %rsi
incq %rsi
callq 0x2200
jmp 0xb40c
movq %rax, %rbx
leaq 0x78(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xb42c
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x2200
jmp 0xb42c
movq %rax, %rbx
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0xb44d
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x2200
jmp 0xb44d
movq %rax, %rbx
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0xb46e
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x2200
jmp 0xb46e
movq %rax, %rbx
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0xb498
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x2200
jmp 0xb498
movq %rax, %rbx
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
je 0xb51e
movq 0x98(%rsp), %rsi
jmp 0xb511
jmp 0xb51b
movq %rax, %rbx
movq 0x108(%rsp), %rdi
leaq 0x118(%rsp), %rax
cmpq %rax, %rdi
je 0xb51e
movq 0x118(%rsp), %rsi
jmp 0xb511
jmp 0xb51b
movq %rax, %rbx
movq 0x188(%rsp), %rdi
cmpq %r14, %rdi
je 0xb51e
movq 0x198(%rsp), %rsi
jmp 0xb511
jmp 0xb51b
movq %rax, %rbx
movq 0x168(%rsp), %rdi
cmpq %r12, %rdi
je 0xb51e
movq 0x178(%rsp), %rsi
incq %rsi
callq 0x2200
jmp 0xb51e
movq %rax, %rbx
movq 0xc8(%rsp), %rdi
leaq 0xd8(%rsp), %rax
cmpq %rax, %rdi
je 0xb543
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x2200
movq %rbx, %rdi
callq 0x2330
nop