// File: /workspace/github_cpp_makefile_star2_O1/navrajsaini[P]PL_Compiler_design_project/plc.cpp
// Function: main
int main ()
{
   // variables for file names
   /*remove testLang.txt when project complete*/
   string codeFileName /*= "testLang.txt"*/, tokenFileName /* = "tokenFile"*/;
   //string codeFileName = "./testfiles/testLang.txt",
   //      tokenFileName  = "./testfiles/tokenFile";
   //get the file name for input and then declare and open file
   cout<<"Welcome to compiler4600, please enter your code input file name: ";
   cin>>codeFileName;
   //get the file name for output and then declare and open file
   cout<<endl<< "Now, please enter your scanner output file: ";
   cin>>tokenFileName;
   
   remove(tokenFileName.c_str()); 

   cout<<endl;
   
   //creating a scanner 
   Scanner scan(codeFileName, tokenFileName);

   //run the compiler
   Admin compiler(codeFileName, tokenFileName, scan);

   //calls the scanner function.
   int stat = compiler.scan();
   char answer;
   //result msg
   if(stat == 1)
   {
	cout<< "Scan Complete" << endl;
	cout<<"would you like us to output the completed syboltable?";
	cout<<endl<<"Y(y)/N(n): ";
	cin>>answer;

	if(answer=='y'||answer=='Y')
	   compiler.print();//printing token list
   }
   else
      cout << "Scan errors have occoured" <<endl;
   
   //Time to parse
   compiler.parse();
   if (compiler.ctd)
   {
      //--------------------------assembler-------------------
      //open the psudogen and create the output file for the interpreter
      ifstream infile;//psudogen is given to the assembler
      infile.open ("psudogen");

      //psudogen.Out file is given to the assember then passed to the interpreter
      ofstream outfile;
      outfile.open ("psudogen.Out");
   
      Assembler assemble(infile, outfile);

      cout << "Assembler first pass: "<<endl;
      assemble.firstPass();

      infile.close();
      infile.open ("psudogen");

      cout << "Assembler second pass: " << endl;
      assemble.secondPass();
      cout << "Assembler output file is: psudogen.Out. This will be passed"
	   << " to the interpreter now." << endl;
      Interpreter interp("psudogen.Out", true);
   }
   return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x4bf8, %rsp           # imm = 0x4BF8
leaq -0x60(%rbp), %r14
movq %r14, -0x10(%r14)
xorl %eax, %eax
movq %rax, -0x8(%r14)
movb %al, (%r14)
leaq -0x40(%rbp), %r15
movq %r15, -0x10(%r15)
movq %rax, -0x8(%r15)
movb %al, (%r15)
movq 0x15591(%rip), %rbx     # 0x18fc8
leaq 0xf627(%rip), %rsi      # 0x13065
movl $0x41, %edx
movq %rbx, %rdi
callq 0x2210
movq 0x15586(%rip), %rdi     # 0x18fd8
leaq -0x70(%rbp), %rsi
callq 0x2250
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x21c0
movsbl %al, %esi
movq 0x1554f(%rip), %rbx     # 0x18fc8
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2140
leaq 0xf617(%rip), %rsi      # 0x130a7
movl $0x2c, %edx
movq %rax, %rdi
callq 0x2210
movq 0x15534(%rip), %rdi     # 0x18fd8
leaq -0x50(%rbp), %rsi
callq 0x2250
movq -0x50(%rbp), %rdi
callq 0x2330
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x21c0
movsbl %al, %esi
movq 0x154f4(%rip), %rdi     # 0x18fc8
callq 0x2030
movq %rax, %rdi
callq 0x2140
leaq -0x100(%rbp), %r12
movq %r12, -0x10(%r12)
movq -0x70(%rbp), %rsi
movq -0x68(%rbp), %rdx
addq %rsi, %rdx
leaq -0x110(%rbp), %rdi
callq 0x4242
leaq -0xe0(%rbp), %r13
movq %r13, -0x10(%r13)
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
addq %rsi, %rdx
leaq -0xf0(%rbp), %rdi
callq 0x4242
leaq -0x1b70(%rbp), %rdi
leaq -0x110(%rbp), %rsi
leaq -0xf0(%rbp), %rdx
callq 0xaf40
movq -0xf0(%rbp), %rdi
cmpq %r13, %rdi
je 0x3b51
callq 0x21b0
movq -0x110(%rbp), %rdi
cmpq %r12, %rdi
je 0x3b62
callq 0x21b0
leaq -0xc0(%rbp), %r12
movq %r12, -0x10(%r12)
movq -0x70(%rbp), %rsi
movq -0x68(%rbp), %rdx
addq %rsi, %rdx
leaq -0xd0(%rbp), %rdi
callq 0x4242
leaq -0xa0(%rbp), %r13
movq %r13, -0x10(%r13)
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
addq %rsi, %rdx
leaq -0xb0(%rbp), %rdi
callq 0x4242
leaq -0x3c60(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
leaq -0xb0(%rbp), %rdx
leaq -0x1b70(%rbp), %rcx
callq 0xa30c
movq -0xb0(%rbp), %rdi
cmpq %r13, %rdi
je 0x3bd9
callq 0x21b0
movq -0xd0(%rbp), %rdi
cmpq %r12, %rdi
je 0x3bea
callq 0x21b0
leaq -0x3c60(%rbp), %rdi
callq 0xa5b0
cmpl $0x1, %eax
jne 0x3cc6
movq 0x153c2(%rip), %rbx     # 0x18fc8
leaq 0xf4c7(%rip), %rsi      # 0x130d4
movl $0xd, %edx
movq %rbx, %rdi
callq 0x2210
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x21c0
movsbl %al, %esi
movq 0x15390(%rip), %rdi     # 0x18fc8
callq 0x2030
movq %rax, %rdi
callq 0x2140
movq 0x1537c(%rip), %rbx     # 0x18fc8
leaq 0xf48f(%rip), %rsi      # 0x130e2
movl $0x35, %edx
movq %rbx, %rdi
callq 0x2210
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x21c0
movsbl %al, %esi
movq 0x1534a(%rip), %rdi     # 0x18fc8
callq 0x2030
movq %rax, %rdi
callq 0x2140
leaq 0xf486(%rip), %rsi      # 0x13118
movl $0xb, %edx
movq %rax, %rdi
callq 0x2210
movq 0x15332(%rip), %rdi     # 0x18fd8
leaq -0x29(%rbp), %rsi
callq 0x2260
movb -0x29(%rbp), %al
andb $-0x21, %al
cmpb $0x59, %al
jne 0x3d0c
leaq -0x3c60(%rbp), %rdi
callq 0xa59e
jmp 0x3d0c
movq 0x152fb(%rip), %rbx     # 0x18fc8
leaq 0xf450(%rip), %rsi      # 0x13124
movl $0x19, %edx
movq %rbx, %rdi
callq 0x2210
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x21c0
movsbl %al, %esi
movq 0x152c9(%rip), %rdi     # 0x18fc8
callq 0x2030
movq %rax, %rdi
callq 0x2140
leaq -0x3c60(%rbp), %rdi
callq 0xa6a4
cmpb $0x1, -0x3c5f(%rbp)
jne 0x3f47
leaq -0x518(%rbp), %rdi
callq 0x2200
leaq 0xf406(%rip), %rsi      # 0x1313e
leaq -0x518(%rbp), %rdi
movl $0x8, %edx
callq 0x2130
leaq -0x310(%rbp), %rdi
callq 0x22e0
leaq 0xf3eb(%rip), %rsi      # 0x13147
leaq -0x310(%rbp), %rdi
movl $0x10, %edx
callq 0x2040
leaq -0xd00(%rbp), %rdi
leaq -0x518(%rbp), %rsi
leaq -0x310(%rbp), %rdx
callq 0x10c38
movq 0x1523a(%rip), %rbx     # 0x18fc8
leaq 0xf3bf(%rip), %rsi      # 0x13154
movl $0x16, %edx
movq %rbx, %rdi
callq 0x2210
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x21c0
movsbl %al, %esi
movq 0x15208(%rip), %rdi     # 0x18fc8
callq 0x2030
movq %rax, %rdi
callq 0x2140
leaq -0xd00(%rbp), %rdi
callq 0x10c76
leaq -0x518(%rbp), %rdi
callq 0x2050
leaq 0xf352(%rip), %rsi      # 0x1313e
leaq -0x518(%rbp), %rdi
movl $0x8, %edx
callq 0x2130
movq 0x151c4(%rip), %rbx     # 0x18fc8
leaq 0xf360(%rip), %rsi      # 0x1316b
movl $0x17, %edx
movq %rbx, %rdi
callq 0x2210
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x21c0
movsbl %al, %esi
movq 0x15192(%rip), %rdi     # 0x18fc8
callq 0x2030
movq %rax, %rdi
callq 0x2140
leaq -0xd00(%rbp), %rdi
callq 0x10f48
movq 0x15172(%rip), %rdi     # 0x18fc8
leaq 0xf326(%rip), %rsi      # 0x13183
movl $0x3b, %edx
callq 0x2210
movq 0x1515a(%rip), %rbx     # 0x18fc8
leaq 0xf34a(%rip), %rsi      # 0x131bf
movl $0x18, %edx
movq %rbx, %rdi
callq 0x2210
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x21c0
movsbl %al, %esi
movq 0x15128(%rip), %rdi     # 0x18fc8
callq 0x2030
movq %rax, %rdi
callq 0x2140
leaq -0x80(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0xf28a(%rip), %rsi      # 0x13147
leaq 0xf28f(%rip), %rdx      # 0x13153
leaq -0x90(%rbp), %rdi
callq 0x42dc
leaq -0x4c18(%rbp), %rdi
leaq -0x90(%rbp), %rsi
movl $0x1, %edx
callq 0x11cb4
movq -0x90(%rbp), %rdi
cmpq %r12, %rdi
je 0x3ef9
callq 0x21b0
leaq -0xd00(%rbp), %rdi
callq 0x10c70
movq 0x150b4(%rip), %rax     # 0x18fc0
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq -0x308(%rbp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, -0x310(%rbp,%rcx)
callq 0x2180
leaq -0x218(%rbp), %rdi
callq 0x2090
leaq -0x518(%rbp), %rdi
callq 0x2060
leaq -0x3c60(%rbp), %rdi
callq 0x4092
leaq -0x1b70(%rbp), %rdi
callq 0x416e
movq -0x50(%rbp), %rdi
cmpq %r15, %rdi
je 0x3f6d
callq 0x21b0
movq -0x70(%rbp), %rdi
cmpq %r14, %rdi
je 0x3f7b
callq 0x21b0
xorl %eax, %eax
addq $0x4bf8, %rsp           # imm = 0x4BF8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq -0x90(%rbp), %rdi
cmpq %r12, %rdi
je 0x402d
callq 0x21b0
jmp 0x402d
jmp 0x402a
jmp 0x3fb0
movq %rax, %rbx
jmp 0x4039
jmp 0x3fba
movq %rax, %rbx
jmp 0x4045
jmp 0x4025
jmp 0x4025
movq %rax, %rbx
movq -0xb0(%rbp), %rdi
cmpq %r13, %rdi
je 0x3fdf
callq 0x21b0
jmp 0x3fdf
movq %rax, %rbx
movq -0xd0(%rbp), %rdi
cmpq %r12, %rdi
je 0x405d
callq 0x21b0
jmp 0x405d
movq %rax, %rbx
jmp 0x405d
movq %rax, %rbx
movq -0xf0(%rbp), %rdi
cmpq %r13, %rdi
je 0x4010
callq 0x21b0
jmp 0x4010
movq %rax, %rbx
movq -0x110(%rbp), %rdi
cmpq %r12, %rdi
je 0x406e
callq 0x21b0
jmp 0x406e
jmp 0x406b
movq %rax, %rbx
jmp 0x4051
movq %rax, %rbx
leaq -0xd00(%rbp), %rdi
callq 0x10c70
leaq -0x310(%rbp), %rdi
callq 0x2290
leaq -0x518(%rbp), %rdi
callq 0x2060
leaq -0x3c60(%rbp), %rdi
callq 0x4092
leaq -0x1b70(%rbp), %rdi
callq 0x416e
jmp 0x406e
movq %rax, %rbx
movq -0x50(%rbp), %rdi
cmpq %r15, %rdi
je 0x407c
callq 0x21b0
movq -0x70(%rbp), %rdi
cmpq %r14, %rdi
je 0x408a
callq 0x21b0
movq %rbx, %rdi
callq 0x2310