// File: /workspace/github_cpp_makefile_star2_O1/AndrewAlbert[P]Compiler-Theory/SourceCode/parser.cpp
// Function: Parser::RelationPrime(int&, int&, bool, bool)
bool Parser::RelationPrime(int &inputType, int &inputSize, bool catchTypeError, bool catchSizeError){
	//Type and size of relation being compared to.
	int termType, termSize;

	//get relationsal op to pass to the codegenerator evaluation stack
	string op = token->ascii;
	
	if (CheckToken(T_COMPARE)){
		//Get next term, otherwise report missing term error.
		if( Term(termType, termSize) ){
			if(catchTypeError){
				//Ensure both terms are of type integer or bool. The two types can be compared against each other.
				if( ((inputType != TYPE_BOOL) && (inputType != TYPE_INTEGER)) || ((termType != TYPE_BOOL) && (termType != TYPE_INTEGER)) ){
					ReportError("Relational operators are only valid for terms of type bool or integers '0' and '1'.");
					catchTypeError = false;
				}
			}
			if(catchSizeError){
				//Ensure compatible sizes are used.
				if( (inputSize != termSize) && ( (inputSize != 0) && (termSize != 0) ) ){
					ReportError("Expected term of size " + to_string(inputSize) + ", but found one of size " + to_string(termSize) + ".");
					catchSizeError = false;
				}
				//Assign termSize to inputSize if termSize is non-zero.
				else if(termSize != 0) inputSize = termSize;
			}
		}
		else{
			ReportError("Expected term after relational operator.");
			catchTypeError = false;
			catchSizeError = false;
		}
		//Check for another relational operator and term.
		RelationPrime(inputType, inputSize, catchTypeError, catchSizeError);
		
		//evaluate relation expression and push to the codegenerator evaluation stack
		generator->evalExpr( op, inputSize, termSize, inputType, termType );
		
		return true;
	}
	else return false;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x188, %rsp            # imm = 0x188
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 $0x139, %esi            # imm = 0x139
callq 0x5c0a
movl %eax, %ebx
testb %al, %al
je 0xc056
leaq 0x1c(%rsp), %rsi
leaq 0x18(%rsp), %rdx
movq %r12, %rdi
callq 0xbd70
testb %al, %al
je 0xbf43
testb %bpl, %bpl
je 0xbeb0
movq 0x20(%rsp), %rax
movl (%rax), %eax
cmpl $0x10c, %eax            # imm = 0x10C
je 0xbe48
cmpl $0x10a, %eax            # imm = 0x10A
jne 0xbe5a
movl 0x1c(%rsp), %eax
cmpl $0x10a, %eax            # imm = 0x10A
je 0xbeb0
cmpl $0x10c, %eax            # imm = 0x10C
je 0xbeb0
leaq 0x158(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0xe5ed(%rip), %rsi      # 0x1a45a
leaq 0xe639(%rip), %rdx      # 0x1a4ad
leaq 0x148(%rsp), %rdi
callq 0x3c34
leaq 0x148(%rsp), %rsi
movq %r12, %rdi
callq 0x5696
movq 0x148(%rsp), %rdi
cmpq %r14, %rdi
je 0xbeae
movq 0x158(%rsp), %rsi
incq %rsi
callq 0x2200
xorl %ebp, %ebp
testb %r13b, %r13b
je 0xbf9c
movl (%r15), %r14d
movl 0x18(%rsp), %eax
cmpl %eax, %r14d
je 0xc08f
testq %r14, %r14
sete %cl
testl %eax, %eax
sete %dl
orb %cl, %dl
jne 0xc08f
movl %r14d, %esi
negl %esi
cmovsl %r14d, %esi
movl $0x1, %r13d
cmpl $0xa, %esi
jb 0xc0a8
movl $0x4, %r13d
movl $0xd1b71759, %eax       # imm = 0xD1B71759
movl %esi, %ecx
cmpl $0x63, %ecx
jbe 0xc09f
cmpl $0x3e7, %ecx            # imm = 0x3E7
jbe 0xc0a5
cmpl $0x2710, %ecx           # imm = 0x2710
jb 0xc0a8
movl %ecx, %edx
imulq %rax, %rdx
shrq $0x2d, %rdx
addl $0x4, %r13d
cmpl $0x1869f, %ecx          # imm = 0x1869F
movl %edx, %ecx
ja 0xbf01
addl $-0x3, %r13d
jmp 0xc0a8
leaq 0x138(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0xe56f(%rip), %rsi      # 0x1a4c5
leaq 0xe590(%rip), %rdx      # 0x1a4ed
leaq 0x128(%rsp), %rdi
callq 0x3c34
leaq 0x128(%rsp), %rsi
movq %r12, %rdi
callq 0x5696
movq 0x128(%rsp), %rdi
cmpq %r14, %rdi
je 0xbf97
movq 0x138(%rsp), %rsi
incq %rsi
callq 0x2200
xorl %ebp, %ebp
xorl %r13d, %r13d
movzbl %bpl, %ecx
movzbl %r13b, %r8d
movq %r12, %rdi
movq 0x20(%rsp), %rsi
movq %r15, %rdx
callq 0xbdb2
movq 0x98(%r12), %r14
leaq 0x118(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0xc8(%rsp), %rsi
movq 0xd0(%rsp), %rdx
addq %rsi, %rdx
leaq 0x108(%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 0x168(%rsp), %rdi
leaq 0x108(%rsp), %rdx
movq %r14, %rsi
callq 0x11eb8
leaq 0x178(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xc039
movq 0x178(%rsp), %rsi
incq %rsi
callq 0x2200
movq 0x108(%rsp), %rdi
cmpq %r12, %rdi
je 0xc056
movq 0x118(%rsp), %rsi
incq %rsi
callq 0x2200
movq 0xc8(%rsp), %rdi
leaq 0xd8(%rsp), %rax
cmpq %rax, %rdi
je 0xc07b
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x2200
movl %ebx, %eax
addq $0x188, %rsp            # imm = 0x188
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testl %eax, %eax
je 0xbf9c
movl %eax, (%r15)
jmp 0xbf9c
addl $-0x2, %r13d
jmp 0xc0a8
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 0xe3bb(%rip), %rcx      # 0x1a4ae
movl $0x16, %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 0xc13a
movq %rdx, 0xa8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0xb8(%rsp)
jmp 0xc140
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 0xe222(%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 0xc192
movq %rdx, 0x48(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x58(%rsp)
jmp 0xc198
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 0xc212
movl $0x4, %r13d
movl $0xd1b71759, %eax       # imm = 0xD1B71759
movl %esi, %ecx
cmpl $0x63, %ecx
jbe 0xc209
cmpl $0x3e7, %ecx            # imm = 0x3E7
jbe 0xc20f
cmpl $0x2710, %ecx           # imm = 0x2710
jb 0xc212
movl %ecx, %edx
imulq %rax, %rdx
shrq $0x2d, %rdx
addl $0x4, %r13d
cmpl $0x1869f, %ecx          # imm = 0x1869F
movl %edx, %ecx
ja 0xc1d6
addl $-0x3, %r13d
jmp 0xc212
addl $-0x2, %r13d
jmp 0xc212
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 0xc271
movq 0x58(%rsp), %rsi
cmpq %rsi, %rax
jbe 0xc291
movl $0xf, %esi
leaq 0x38(%rsp), %rdi
cmpq %rdi, 0x28(%rsp)
je 0xc28c
movq 0x38(%rsp), %rsi
cmpq %rsi, %rax
jbe 0xc2a2
movq 0x28(%rsp), %rsi
leaq 0x48(%rsp), %rdi
callq 0x20c0
jmp 0xc2b0
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 0xc2d4
movq %rsi, 0x68(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x78(%rsp)
jmp 0xc2da
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 0xe1ae(%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 0xc338
movq %rdx, 0xe8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0xf8(%rsp)
jmp 0xc33f
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 0xc383
movq 0xf8(%rsp), %rsi
incq %rsi
callq 0x2200
leaq 0x78(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
leaq 0xb8(%rsp), %r14
je 0xc3a6
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x2200
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0xc3c2
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x2200
movq 0x48(%rsp), %rdi
cmpq %r13, %rdi
je 0xc3d9
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x2200
movq 0xa8(%rsp), %rdi
cmpq %r14, %rdi
je 0xc3f6
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x2200
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
je 0xbf99
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x2200
jmp 0xbf99
movq %rax, %rbx
movq 0xe8(%rsp), %rdi
cmpq %r14, %rdi
je 0xc449
movq 0xf8(%rsp), %rsi
incq %rsi
callq 0x2200
jmp 0xc449
movq %rax, %rbx
leaq 0x78(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xc469
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x2200
jmp 0xc469
movq %rax, %rbx
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0xc48a
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x2200
jmp 0xc48a
movq %rax, %rbx
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0xc4ab
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x2200
jmp 0xc4ab
movq %rax, %rbx
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0xc4d5
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x2200
jmp 0xc4d5
movq %rax, %rbx
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
je 0xc553
movq 0x98(%rsp), %rsi
jmp 0xc546
jmp 0xc550
movq %rax, %rbx
movq 0x148(%rsp), %rdi
cmpq %r14, %rdi
je 0xc553
movq 0x158(%rsp), %rsi
jmp 0xc546
jmp 0xc550
movq %rax, %rbx
movq 0x128(%rsp), %rdi
cmpq %r14, %rdi
je 0xc553
movq 0x138(%rsp), %rsi
jmp 0xc546
jmp 0xc550
movq %rax, %rbx
movq 0x108(%rsp), %rdi
cmpq %r12, %rdi
je 0xc553
movq 0x118(%rsp), %rsi
incq %rsi
callq 0x2200
jmp 0xc553
movq %rax, %rbx
movq 0xc8(%rsp), %rdi
leaq 0xd8(%rsp), %rax
cmpq %rax, %rdi
je 0xc578
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x2200
movq %rbx, %rdi
callq 0x2330