// File: /workspace/github_cpp_makefile_star2_O2/AndrewAlbert[P]Compiler-Theory/SourceCode/parser.cpp
// Function: Parser::TermPrime(int&, int&, bool, bool)
bool Parser::TermPrime(int &inputType, int &inputSize, bool catchTypeError, bool catchSizeError){
	//Next factor type and size.
	int factorType, factorSize;
	
	//get term op to pass to the code generator
	string op = token->ascii;
	
	//Check for '*' or '/' token, otherwise return false ('null').
	if( CheckToken(T_MULTIPLY) );
	else if( CheckToken(T_DIVIDE) );
	else return false;
	
	//Get next factor, otherwise report missing factor error.
	if( Factor(factorType, factorSize) ){
		//Ensure both factors are numbers for arithmetic operators.
		if( !isNumber(inputType) || !isNumber(factorType) ){
			ReportError("Only integer and float factors are defined for arithmetic operations in term.");
			catchTypeError = false;
		}
		if( (inputSize != factorSize) && ( (inputSize != 0) && (factorSize != 0) ) ){
			ReportError("Expected factor of size " + to_string(inputSize) + ", but found one of size " + to_string(factorSize) + ".");
			catchSizeError = false;
		}
		else if(factorSize != 0) inputSize = factorSize;
	}
	else{
		ReportError("Expected factor after arithmetic operator in term.");
		catchTypeError = false;
		catchSizeError = false;
	}
	TermPrime(inputType, inputSize, catchTypeError, catchSizeError);
	
	//evaluate term and push to the code generator expression stack
	generator->evalExpr( op, inputSize, factorSize, inputType, factorType );
	
	return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x178, %rsp            # imm = 0x178
movl %r8d, %r12d
movl %ecx, %ebp
movq %rdx, %r14
movq %rsi, %rbx
movq %rdi, %r15
movq 0x80(%rdi), %rsi
leaq 0x138(%rsp), %rdi
callq 0x2270
movq %r15, %rdi
movl $0x131, %esi            # imm = 0x131
callq 0x49b0
testb %al, %al
jne 0x8b2f
movq %r15, %rdi
movl $0x130, %esi            # imm = 0x130
callq 0x49b0
testb %al, %al
je 0x8d48
leaq 0x14(%rsp), %rsi
leaq 0x10(%rsp), %rdx
movq %r15, %rdi
callq 0x8888
testb %al, %al
je 0x8c9b
movl (%rbx), %eax
andl $-0x2, %eax
cmpl $0x10a, %eax            # imm = 0x10A
jne 0x8b63
movl 0x14(%rsp), %eax
andl $-0x2, %eax
cmpl $0x10a, %eax            # imm = 0x10A
je 0x8b9b
leaq 0x9984(%rip), %rsi      # 0x124ee
leaq 0x118(%rsp), %rdi
leaq 0x18(%rsp), %rdx
callq 0x36b8
leaq 0x118(%rsp), %rsi
movq %r15, %rdi
callq 0x47e0
leaq 0x118(%rsp), %rdi
callq 0x20f0
xorl %ebp, %ebp
movl (%r14), %esi
movl 0x10(%rsp), %r13d
cmpl %r13d, %esi
je 0x8ccf
testl %esi, %esi
sete %al
testl %r13d, %r13d
sete %cl
orb %al, %cl
jne 0x8ccf
leaq 0x98(%rsp), %rdi
callq 0x96b3
leaq 0x9969(%rip), %rsi      # 0x1253c
leaq 0xb8(%rsp), %rdi
leaq 0x98(%rsp), %rdx
callq 0x968f
leaq 0x9799(%rip), %rdx      # 0x12388
leaq 0xd8(%rsp), %rdi
leaq 0xb8(%rsp), %rsi
callq 0x9670
leaq 0x78(%rsp), %rdi
movl %r13d, %esi
callq 0x96b3
leaq 0x18(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
leaq 0x78(%rsp), %rdx
callq 0x9871
leaq 0x987d(%rip), %rdx      # 0x124ac
leaq 0xf8(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x9670
leaq 0xf8(%rsp), %rsi
movq %r15, %rdi
callq 0x47e0
leaq 0xf8(%rsp), %rdi
callq 0x20f0
leaq 0x18(%rsp), %rdi
callq 0x20f0
leaq 0x78(%rsp), %rdi
callq 0x20f0
leaq 0xd8(%rsp), %rdi
callq 0x20f0
leaq 0xb8(%rsp), %rdi
callq 0x20f0
leaq 0x98(%rsp), %rdi
callq 0x20f0
jmp 0x8cca
leaq 0x98b3(%rip), %rsi      # 0x12555
leaq 0x58(%rsp), %rdi
leaq 0x18(%rsp), %rdx
callq 0x36b8
leaq 0x58(%rsp), %rsi
movq %r15, %rdi
callq 0x47e0
leaq 0x58(%rsp), %rdi
callq 0x20f0
xorl %ebp, %ebp
xorl %r12d, %r12d
jmp 0x8cd7
testl %r13d, %r13d
je 0x8cd7
movl %r13d, (%r14)
movzbl %bpl, %ecx
movzbl %r12b, %r8d
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x8ad6
movq 0x98(%r15), %r15
leaq 0x38(%rsp), %rdi
leaq 0x138(%rsp), %rsi
callq 0x2270
movl (%r14), %ecx
movl 0x10(%rsp), %r8d
movl (%rbx), %r9d
movl 0x14(%rsp), %eax
movl %eax, (%rsp)
leaq 0x158(%rsp), %rdi
leaq 0x38(%rsp), %rdx
movq %r15, %rsi
callq 0xcbbe
leaq 0x158(%rsp), %rdi
callq 0x20f0
leaq 0x38(%rsp), %rdi
callq 0x20f0
movb $0x1, %bl
jmp 0x8d4a
xorl %ebx, %ebx
leaq 0x138(%rsp), %rdi
callq 0x20f0
movl %ebx, %eax
addq $0x178, %rsp            # imm = 0x178
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0xf8(%rsp), %rdi
callq 0x20f0
jmp 0x8d80
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x20f0
jmp 0x8d8f
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
callq 0x20f0
jmp 0x8d9e
movq %rax, %rbx
leaq 0xd8(%rsp), %rdi
callq 0x20f0
jmp 0x8db0
movq %rax, %rbx
leaq 0xb8(%rsp), %rdi
callq 0x20f0
leaq 0x98(%rsp), %rdi
jmp 0x8df1
movq %rax, %rbx
jmp 0x8dbd
jmp 0x8df8
movq %rax, %rbx
leaq 0x118(%rsp), %rdi
jmp 0x8df1
jmp 0x8df8
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
jmp 0x8df1
jmp 0x8df8
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x20f0
jmp 0x8dfb
movq %rax, %rbx
leaq 0x138(%rsp), %rdi
callq 0x20f0
movq %rbx, %rdi
callq 0x2310