// File: ssubrandon[P]460Project2/SyntacticalAnalyzer.cpp
// Function: SyntacticalAnalyzer::program()
int SyntacticalAnalyzer::program(){
  //This is the program function and is also rule one of our language this will check for
  //correct syntax and send the program off to the next rule using recursion.

	ruleFile  << "Entering Program function; current token is: " << lex ->GetTokenName (token) << ", lexeme: " << lex->GetLexeme() <<  endl; 
	int errors = 0;
	ruleFile << "Using Rule 1" << endl;

	if(token != LPAREN_T){
		errors++;
		ReportError(string("expected a LPAREN_T, currently in program, but found  " + lex->GetTokenName(token)));
	}
	token = lex->GetToken();

	errors += define();

	if(token != LPAREN_T){
		errors++;
		ReportError(string("expected a LPAREN_T in program, but found  " + lex->GetTokenName(token)));
	}

	token = lex->GetToken();
	errors += more_defines();
	if (token != EOF_T) {
		errors ++;		
		ReportError(string("expected a EOF_T in program, but found  " + lex->GetTokenName(token)));
	} // end of if EOF
	ruleFile << "Exiting Program function; current token is: " << lex ->GetTokenName (token) << endl;

	return errors;

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1a0, %rsp            # imm = 0x1A0
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x160(%rbp)
addq $0x420, %rdi            # imm = 0x420
leaq 0x77fe(%rip), %rsi      # 0x10426
callq 0x3270
movq %rax, %rcx
movq -0x160(%rbp), %rax
movq %rcx, -0x158(%rbp)
movq 0x8(%rax), %rsi
movl 0x10(%rax), %edx
leaq -0x28(%rbp), %rdi
movq %rdi, -0x150(%rbp)
callq 0x6f40
movq -0x158(%rbp), %rdi
movq -0x150(%rbp), %rsi
callq 0x3240
movq %rax, -0x148(%rbp)
jmp 0x8c71
movq -0x148(%rbp), %rdi
leaq 0x77d5(%rip), %rsi      # 0x10454
callq 0x3270
movq %rax, -0x168(%rbp)
jmp 0x8c8d
movq -0x160(%rbp), %rax
movq 0x8(%rax), %rsi
leaq -0x58(%rbp), %rdi
callq 0x6f80
jmp 0x8ca3
movq -0x168(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x3240
movq %rax, -0x170(%rbp)
jmp 0x8cbc
movq -0x170(%rbp), %rdi
movq 0xc2f6(%rip), %rsi      # 0x14fc0
callq 0x32c0
jmp 0x8cd1
leaq -0x58(%rbp), %rdi
callq 0x34b8
leaq -0x28(%rbp), %rdi
callq 0x34b8
movq -0x160(%rbp), %rdi
movl $0x0, -0x5c(%rbp)
addq $0x420, %rdi            # imm = 0x420
leaq 0x7760(%rip), %rsi      # 0x1045f
callq 0x3270
movq %rax, %rdi
movq 0xc2b2(%rip), %rsi      # 0x14fc0
callq 0x32c0
movq -0x160(%rbp), %rax
cmpl $0x1f, 0x10(%rax)
je 0x8df4
movq -0x160(%rbp), %rax
movl -0x5c(%rbp), %ecx
incl %ecx
movl %ecx, -0x5c(%rbp)
movq 0x8(%rax), %rsi
movl 0x10(%rax), %edx
leaq -0xa0(%rbp), %rdi
movq %rdi, -0x178(%rbp)
callq 0x6f40
movq -0x178(%rbp), %rdx
leaq 0x7711(%rip), %rsi      # 0x1046c
leaq -0x80(%rbp), %rdi
callq 0xf1b0
jmp 0x8d66
movq -0x160(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x91a0
jmp 0x8d78
leaq -0x80(%rbp), %rdi
callq 0x34b8
leaq -0xa0(%rbp), %rdi
callq 0x34b8
jmp 0x8df4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x8db2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x34b8
leaq -0x28(%rbp), %rdi
callq 0x34b8
jmp 0x9060
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x8de3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x34b8
leaq -0xa0(%rbp), %rdi
callq 0x34b8
jmp 0x9060
movq -0x160(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x5fd0
movq -0x160(%rbp), %rdi
movl %eax, 0x10(%rdi)
callq 0x92e0
movl %eax, %ecx
movq -0x160(%rbp), %rax
addl -0x5c(%rbp), %ecx
movl %ecx, -0x5c(%rbp)
cmpl $0x1f, 0x10(%rax)
je 0x8ed7
movq -0x160(%rbp), %rax
movl -0x5c(%rbp), %ecx
incl %ecx
movl %ecx, -0x5c(%rbp)
movq 0x8(%rax), %rsi
movl 0x10(%rax), %edx
leaq -0xe0(%rbp), %rdi
movq %rdi, -0x180(%rbp)
callq 0x6f40
movq -0x180(%rbp), %rdx
leaq 0x7640(%rip), %rsi      # 0x104a3
leaq -0xc0(%rbp), %rdi
callq 0xf1b0
jmp 0x8e71
movq -0x160(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x91a0
jmp 0x8e86
leaq -0xc0(%rbp), %rdi
callq 0x34b8
leaq -0xe0(%rbp), %rdi
callq 0x34b8
jmp 0x8ed7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x8ec6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x34b8
leaq -0xe0(%rbp), %rdi
callq 0x34b8
jmp 0x9060
movq -0x160(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x5fd0
movq -0x160(%rbp), %rdi
movl %eax, 0x10(%rdi)
callq 0x9930
movl %eax, %ecx
movq -0x160(%rbp), %rax
addl -0x5c(%rbp), %ecx
movl %ecx, -0x5c(%rbp)
cmpl $0x23, 0x10(%rax)
je 0x8fba
movq -0x160(%rbp), %rax
movl -0x5c(%rbp), %ecx
incl %ecx
movl %ecx, -0x5c(%rbp)
movq 0x8(%rax), %rsi
movl 0x10(%rax), %edx
leaq -0x120(%rbp), %rdi
movq %rdi, -0x188(%rbp)
callq 0x6f40
movq -0x188(%rbp), %rdx
leaq 0x7589(%rip), %rsi      # 0x104cf
leaq -0x100(%rbp), %rdi
callq 0xf1b0
jmp 0x8f54
movq -0x160(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0x91a0
jmp 0x8f69
leaq -0x100(%rbp), %rdi
callq 0x34b8
leaq -0x120(%rbp), %rdi
callq 0x34b8
jmp 0x8fba
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x8fa9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x100(%rbp), %rdi
callq 0x34b8
leaq -0x120(%rbp), %rdi
callq 0x34b8
jmp 0x9060
movq -0x160(%rbp), %rdi
addq $0x420, %rdi            # imm = 0x420
leaq 0x7529(%rip), %rsi      # 0x104f8
callq 0x3270
movq %rax, %rcx
movq -0x160(%rbp), %rax
movq %rcx, -0x1a0(%rbp)
movq 0x8(%rax), %rsi
movl 0x10(%rax), %edx
leaq -0x140(%rbp), %rdi
movq %rdi, -0x198(%rbp)
callq 0x6f40
movq -0x1a0(%rbp), %rdi
movq -0x198(%rbp), %rsi
callq 0x3240
movq %rax, -0x190(%rbp)
jmp 0x901b
movq -0x190(%rbp), %rdi
movq 0xbf97(%rip), %rsi      # 0x14fc0
callq 0x32c0
jmp 0x9030
leaq -0x140(%rbp), %rdi
callq 0x34b8
movl -0x5c(%rbp), %eax
addq $0x1a0, %rsp            # imm = 0x1A0
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x140(%rbp), %rdi
callq 0x34b8
movq -0x30(%rbp), %rdi
callq 0x3430
nopl (%rax)