// File: /workspace/github_cpp_makefile_star2_O3/ssubrandon[P]460Project2/SyntacticalAnalyzer.cpp
// Function: SyntacticalAnalyzer::stmt()
int SyntacticalAnalyzer::stmt(){
  //This function deals with the stmt rules (7-9) and will check for syntactical correctness,
  //this function will then, depending on the token seen, send the program to literal, action, or will return. 
	ruleFile << "Entering stmt function; Current token is: " << lex ->GetTokenName(token) << ", lexeme: " << lex->GetLexeme() << endl;

	int errors = 0;

	switch(token){
		case IDENT_T:
			ruleFile << "Using Rule 8" << endl;
			token = lex->GetToken();
			break;


		case LPAREN_T:
			ruleFile << "Using Rule 9" << endl;
			//ruleFile << "stmt function complete. Current token is: " << lex->GetTokenName(token) << endl;
			token = lex->GetToken();
			errors += action();
			//returned token should be a RPAREN?
			if(token == RPAREN_T){
			  token=lex->GetToken();
			}
			else{
			  ReportError(string("RPAREN_T expected in stmt function, current token is: " + lex->GetTokenName(token)));
			  token=lex->GetToken();
			}
			break;


		case NUMLIT_T: 
			ruleFile << "stmt function complete. Current token is: " << lex->GetTokenName(token) << endl;
			ruleFile << "Using Rule 7"  << endl;
			errors += literal();
			break;

		case STRLIT_T:
			//ruleFile << "stmt function complete. Current token is: " << lex->GetTokenName(token) << endl;
			ruleFile << "Using Rule 7"  << endl;
			errors += literal();
			break;

		case SQUOTE_T:
			//ruleFile << "stmt function complete. Current token is: " << lex->GetTokenName(token) << endl;
			ruleFile << "Using Rule 7"  << endl;
			errors += literal();
			break;

			
		default: //no rule found
			errors++;
			ReportError(string("No rule found in stmt function, current token is: " + lex->GetTokenName(token)));
			break;

	}
	ruleFile << "Exiting stmt function; current token is: " << lex ->GetTokenName (token) << endl;
	return errors;	
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %r14
leaq 0x420(%rdi), %rbx
leaq 0x508a(%rip), %rsi      # 0xbc24
movl $0x2a, %edx
movq %rbx, %rdi
callq 0x2260
movq 0x8(%r14), %rsi
movl 0x10(%r14), %edx
leaq -0x48(%rbp), %r15
movq %r15, %rdi
callq 0x499a
movq (%r15), %rsi
movq 0x8(%r15), %rdx
movq %rbx, %rdi
callq 0x2260
movq %rax, %r15
leaq 0x4cc4(%rip), %rsi      # 0xb898
movl $0xa, %edx
movq %rax, %rdi
callq 0x2260
movq 0x8(%r14), %rsi
leaq -0x68(%rbp), %rdi
callq 0x49d4
movq -0x68(%rbp), %rsi
movq -0x60(%rbp), %rdx
movq %r15, %rdi
callq 0x2260
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x21e0
movsbl %al, %esi
movq %r15, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2170
leaq -0x58(%rbp), %r12
movq -0x10(%r12), %rdi
cmpq %r12, %rdi
je 0x6c42
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x2210
leaq -0x38(%rbp), %r13
movq -0x10(%r13), %rdi
cmpq %r13, %rdi
je 0x6c5b
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2210
movl 0x10(%r14), %edx
cmpl $0x2, %edx
jle 0x6c84
cmpl $0x3, %edx
je 0x6d0c
cmpl $0x1f, %edx
je 0x6d5b
cmpl $0x21, %edx
je 0x6d0c
jmp 0x6e61
cmpl $0x1, %edx
je 0x6e0d
cmpl $0x2, %edx
jne 0x6e61
leaq 0x5003(%rip), %rsi      # 0xbca0
movl $0x2a, %edx
movq %rbx, %rdi
callq 0x2260
movq 0x8(%r14), %rsi
movl 0x10(%r14), %edx
leaq -0x48(%rbp), %r15
movq %r15, %rdi
callq 0x499a
movq (%r15), %rsi
movq 0x8(%r15), %rdx
movq %rbx, %rdi
callq 0x2260
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x21e0
movsbl %al, %esi
movq %r15, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2170
movq -0x48(%rbp), %rdi
cmpq %r13, %rdi
je 0x6d0c
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2210
leaq 0x4fb8(%rip), %rsi      # 0xbccb
movl $0xc, %edx
movq %rbx, %rdi
callq 0x2260
movq 0x420(%r14), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21e0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2170
movq %r14, %rdi
callq 0x87be
movl %eax, %r15d
jmp 0x6f69
leaq 0x4efa(%rip), %rsi      # 0xbc5c
movl $0xc, %edx
movq %rbx, %rdi
callq 0x2260
movq 0x420(%r14), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21e0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2170
movq 0x8(%r14), %rdi
callq 0x3e8e
movl %eax, 0x10(%r14)
movq %r14, %rdi
callq 0x7076
movl %eax, %r15d
movl 0x10(%r14), %edx
cmpl $0x20, %edx
je 0x6f5c
movq 0x8(%r14), %rsi
leaq -0x68(%rbp), %rdi
callq 0x499a
leaq 0x4e96(%rip), %rcx      # 0xbc69
movl $0x36, %r8d
leaq -0x68(%rbp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2240
movq %r13, -0x48(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x6f07
movq %rdx, -0x48(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x38(%rbp)
jmp 0x6f0f
leaq 0x4e3b(%rip), %rsi      # 0xbc4f
movl $0xc, %edx
movq %rbx, %rdi
callq 0x2260
movq 0x420(%r14), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21e0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2170
movq 0x8(%r14), %rdi
callq 0x3e8e
movl %eax, 0x10(%r14)
xorl %r15d, %r15d
jmp 0x6f69
movq 0x8(%r14), %rsi
leaq -0x68(%rbp), %r15
movq %r15, %rdi
callq 0x499a
leaq 0x4e60(%rip), %rcx      # 0xbcd8
movl $0x32, %r8d
movq %r15, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2240
movq %r13, -0x48(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x6eaa
movq %rdx, -0x48(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x38(%rbp)
jmp 0x6eb2
movups (%rcx), %xmm0
movups %xmm0, (%r13)
movq 0x8(%rax), %rdx
leaq -0x48(%rbp), %rsi
movq %rdx, 0x8(%rsi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq %r14, %rdi
callq 0x56f4
movq -0x48(%rbp), %rdi
cmpq %r13, %rdi
je 0x6eea
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2210
movq -0x68(%rbp), %rdi
cmpq %r12, %rdi
je 0x6eff
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x2210
movl $0x1, %r15d
jmp 0x6f69
movups (%rcx), %xmm0
movups %xmm0, (%r13)
movq 0x8(%rax), %rdx
leaq -0x48(%rbp), %rsi
movq %rdx, 0x8(%rsi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq %r14, %rdi
callq 0x56f4
movq -0x48(%rbp), %rdi
cmpq %r13, %rdi
je 0x6f47
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2210
movq -0x68(%rbp), %rdi
cmpq %r12, %rdi
je 0x6f5c
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x2210
movq 0x8(%r14), %rdi
callq 0x3e8e
movl %eax, 0x10(%r14)
leaq 0x4d9b(%rip), %rsi      # 0xbd0b
movl $0x29, %edx
movq %rbx, %rdi
callq 0x2260
movq 0x8(%r14), %rsi
movl 0x10(%r14), %edx
leaq -0x48(%rbp), %r14
movq %r14, %rdi
callq 0x499a
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq %rbx, %rdi
callq 0x2260
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21e0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2170
movq -0x48(%rbp), %rdi
cmpq %r13, %rdi
je 0x6fdf
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2210
movl %r15d, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x6ff5
jmp 0x700f
movq %rax, %rbx
movq -0x48(%rbp), %rdi
cmpq %r13, %rdi
je 0x7012
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2210
jmp 0x7012
movq %rax, %rbx
movq -0x68(%rbp), %rdi
cmpq %r12, %rdi
je 0x706d
movq -0x58(%rbp), %rsi
jmp 0x7065
jmp 0x702a
jmp 0x7025
movq %rax, %rbx
jmp 0x7054
movq %rax, %rbx
movq -0x48(%rbp), %rdi
cmpq %r13, %rdi
jne 0x7061
jmp 0x706d
movq %rax, %rbx
leaq -0x58(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x7054
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x2210
leaq -0x38(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x706d
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2210
movq %rbx, %rdi
callq 0x2340
nop