// File: 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
movq %rsp, %rbp
subq $0x1f0, %rsp            # imm = 0x1F0
movb %r8b, %al
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
andb $0x1, %cl
movb %cl, -0x21(%rbp)
andb $0x1, %al
movb %al, -0x22(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x1c0(%rbp)
movq 0x80(%rax), %rsi
leaq -0x50(%rbp), %rdi
callq 0x3130
movq -0x1c0(%rbp), %rdi
movl $0x131, %esi            # imm = 0x131
callq 0x9300
movb %al, -0x1b1(%rbp)
jmp 0x10f19
movb -0x1b1(%rbp), %al
testb $0x1, %al
jne 0x10f25
jmp 0x10f38
jmp 0x10f71
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x113c3
movq -0x1c0(%rbp), %rdi
movl $0x130, %esi            # imm = 0x130
callq 0x9300
movb %al, -0x1c1(%rbp)
jmp 0x10f51
movb -0x1c1(%rbp), %al
testb $0x1, %al
jne 0x10f5d
jmp 0x10f5f
jmp 0x10f6f
movb $0x0, -0x1(%rbp)
movl $0x1, -0x60(%rbp)
jmp 0x113ac
jmp 0x10f71
movq -0x1c0(%rbp), %rdi
leaq -0x28(%rbp), %rsi
leaq -0x2c(%rbp), %rdx
callq 0x10a30
movb %al, -0x1c2(%rbp)
jmp 0x10f8d
movb -0x1c2(%rbp), %al
testb $0x1, %al
jne 0x10f9c
jmp 0x1124e
movq -0x1c0(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0xf850
movb %al, -0x1c3(%rbp)
jmp 0x10fb4
movb -0x1c3(%rbp), %al
testb $0x1, %al
jne 0x10fc0
jmp 0x10fe8
movq -0x1c0(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0xf850
movb %al, -0x1c4(%rbp)
jmp 0x10fd8
movb -0x1c4(%rbp), %al
testb $0x1, %al
jne 0x11075
jmp 0x10fe8
leaq -0x81(%rbp), %rdi
movq %rdi, -0x1d0(%rbp)
callq 0x3430
movq -0x1d0(%rbp), %rdx
leaq 0x157ab(%rip), %rsi     # 0x267b4
leaq -0x80(%rbp), %rdi
callq 0x62d0
jmp 0x11014
movq -0x1c0(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x9060
jmp 0x11026
leaq -0x80(%rbp), %rdi
callq 0x31a0
leaq -0x81(%rbp), %rdi
callq 0x32e0
movb $0x0, -0x21(%rbp)
jmp 0x11075
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x11064
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x31a0
leaq -0x81(%rbp), %rdi
callq 0x32e0
jmp 0x113c3
movq -0x20(%rbp), %rax
movl (%rax), %eax
cmpl -0x2c(%rbp), %eax
je 0x11238
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x11238
cmpl $0x0, -0x2c(%rbp)
je 0x11238
movq -0x20(%rbp), %rax
movl (%rax), %esi
leaq -0x128(%rbp), %rdi
callq 0x123d0
jmp 0x110af
leaq 0x1574c(%rip), %rsi     # 0x26802
leaq -0x108(%rbp), %rdi
leaq -0x128(%rbp), %rdx
callq 0x12380
jmp 0x110cb
leaq 0x1557c(%rip), %rdx     # 0x2664e
leaq -0xe8(%rbp), %rdi
leaq -0x108(%rbp), %rsi
callq 0x12330
jmp 0x110e7
movl -0x2c(%rbp), %esi
leaq -0x148(%rbp), %rdi
callq 0x123d0
jmp 0x110f8
leaq -0xc8(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
leaq -0x148(%rbp), %rdx
callq 0x12990
jmp 0x11114
leaq 0x15657(%rip), %rdx     # 0x26772
leaq -0xa8(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x12330
jmp 0x11130
movq -0x1c0(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x9060
jmp 0x11145
leaq -0xa8(%rbp), %rdi
callq 0x31a0
leaq -0xc8(%rbp), %rdi
callq 0x31a0
leaq -0x148(%rbp), %rdi
callq 0x31a0
leaq -0xe8(%rbp), %rdi
callq 0x31a0
leaq -0x108(%rbp), %rdi
callq 0x31a0
leaq -0x128(%rbp), %rdi
callq 0x31a0
movb $0x0, -0x22(%rbp)
jmp 0x11249
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x11227
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x1121b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x1120f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x11203
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x111f7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x31a0
leaq -0xc8(%rbp), %rdi
callq 0x31a0
leaq -0x148(%rbp), %rdi
callq 0x31a0
leaq -0xe8(%rbp), %rdi
callq 0x31a0
leaq -0x108(%rbp), %rdi
callq 0x31a0
leaq -0x128(%rbp), %rdi
callq 0x31a0
jmp 0x113c3
cmpl $0x0, -0x2c(%rbp)
je 0x11247
movl -0x2c(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
jmp 0x11249
jmp 0x112eb
leaq -0x169(%rbp), %rdi
movq %rdi, -0x1d8(%rbp)
callq 0x3430
movq -0x1d8(%rbp), %rdx
leaq 0x155ac(%rip), %rsi     # 0x2681b
leaq -0x168(%rbp), %rdi
callq 0x62d0
jmp 0x1127d
movq -0x1c0(%rbp), %rdi
leaq -0x168(%rbp), %rsi
callq 0x9060
jmp 0x11292
leaq -0x168(%rbp), %rdi
callq 0x31a0
leaq -0x169(%rbp), %rdi
callq 0x32e0
movb $0x0, -0x21(%rbp)
movb $0x0, -0x22(%rbp)
jmp 0x112eb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x112da
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x168(%rbp), %rdi
callq 0x31a0
leaq -0x169(%rbp), %rdi
callq 0x32e0
jmp 0x113c3
movq -0x1c0(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movzbl -0x22(%rbp), %r8d
movzbl -0x21(%rbp), %ecx
andl $0x1, %ecx
andl $0x1, %r8d
callq 0x10ec0
jmp 0x11311
movq -0x1c0(%rbp), %rax
movq 0x98(%rax), %rax
movq %rax, -0x1e0(%rbp)
leaq -0x1b0(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x3130
jmp 0x11338
movq -0x1e0(%rbp), %rsi
movq -0x20(%rbp), %rax
movl (%rax), %ecx
movl -0x2c(%rbp), %r8d
movq -0x18(%rbp), %rax
movl (%rax), %r9d
movl -0x28(%rbp), %edx
movq %rsp, %rax
movl %edx, (%rax)
leaq -0x190(%rbp), %rdi
leaq -0x1b0(%rbp), %rdx
callq 0x1abf0
jmp 0x1136d
leaq -0x190(%rbp), %rdi
callq 0x31a0
leaq -0x1b0(%rbp), %rdi
callq 0x31a0
movb $0x1, -0x1(%rbp)
movl $0x1, -0x60(%rbp)
jmp 0x113ac
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x1b0(%rbp), %rdi
callq 0x31a0
jmp 0x113c3
leaq -0x50(%rbp), %rdi
callq 0x31a0
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x1f0, %rsp            # imm = 0x1F0
popq %rbp
retq
leaq -0x50(%rbp), %rdi
callq 0x31a0
movq -0x58(%rbp), %rdi
callq 0x3420
nopw %cs:(%rax,%rax)