// File: /workspace/github_cpp_makefile_star2_O2/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 %rbx
subq $0x4bf8, %rsp           # imm = 0x4BF8
leaq -0x40(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
xorl %ecx, %ecx
movb %cl, (%rax)
leaq -0x20(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb %cl, (%rax)
movq 0x11c59(%rip), %rdi     # 0x14fc8
leaq 0xbd1c(%rip), %rsi      # 0xf092
callq 0x21a0
movq 0x11c56(%rip), %rdi     # 0x14fd8
leaq -0x50(%rbp), %rsi
callq 0x2220
movq 0x11c36(%rip), %rdi     # 0x14fc8
callq 0x20f0
leaq 0xbd36(%rip), %rsi      # 0xf0d4
movq %rax, %rdi
callq 0x21a0
movq 0x11c2b(%rip), %rdi     # 0x14fd8
leaq -0x30(%rbp), %rsi
callq 0x2220
movq -0x30(%rbp), %rdi
callq 0x22f0
movq 0x11c02(%rip), %rdi     # 0x14fc8
callq 0x20f0
leaq -0xf0(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x2240
leaq -0xd0(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x2240
leaq -0x1b50(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
leaq -0xd0(%rbp), %rdx
callq 0x8914
leaq -0xd0(%rbp), %rdi
callq 0x20d0
leaq -0xf0(%rbp), %rdi
callq 0x20d0
leaq -0xb0(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x2240
leaq -0x90(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x2240
leaq -0x3c40(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
leaq -0x90(%rbp), %rdx
leaq -0x1b50(%rbp), %rcx
callq 0x7f62
leaq -0x90(%rbp), %rdi
callq 0x20d0
leaq -0xb0(%rbp), %rdi
callq 0x20d0
leaq -0x3c40(%rbp), %rdi
callq 0x817c
cmpl $0x1, %eax
jne 0x34f7
movq 0x11b3a(%rip), %rdi     # 0x14fc8
leaq 0xbc6c(%rip), %rsi      # 0xf101
callq 0x21a0
movq %rax, %rdi
callq 0x20f0
movq 0x11b1f(%rip), %rdi     # 0x14fc8
leaq 0xbc5f(%rip), %rsi      # 0xf10f
callq 0x21a0
movq 0x11b0c(%rip), %rdi     # 0x14fc8
callq 0x20f0
leaq 0xbc7d(%rip), %rsi      # 0xf145
movq %rax, %rdi
callq 0x21a0
movq 0x11b01(%rip), %rdi     # 0x14fd8
leaq -0x9(%rbp), %rsi
callq 0x2230
movb -0x9(%rbp), %al
andb $-0x21, %al
cmpb $0x59, %al
jne 0x3512
leaq -0x3c40(%rbp), %rdi
callq 0x816a
jmp 0x3512
movq 0x11aca(%rip), %rdi     # 0x14fc8
leaq 0xbc4c(%rip), %rsi      # 0xf151
callq 0x21a0
movq %rax, %rdi
callq 0x20f0
leaq -0x3c40(%rbp), %rdi
callq 0x8260
cmpb $0x1, -0x3c3f(%rbp)
jne 0x3677
leaq -0x2f8(%rbp), %rdi
callq 0x21d0
leaq 0xbc2d(%rip), %rsi      # 0xf16b
leaq -0x2f8(%rbp), %rdi
pushq $0x8
popq %rdx
callq 0x2140
leaq -0x4f8(%rbp), %rdi
callq 0x22b0
leaq 0xbc14(%rip), %rsi      # 0xf174
leaq -0x4f8(%rbp), %rdi
pushq $0x10
popq %rdx
callq 0x2030
leaq -0xce0(%rbp), %rdi
leaq -0x2f8(%rbp), %rsi
leaq -0x4f8(%rbp), %rdx
callq 0xce24
movq 0x11a38(%rip), %rdi     # 0x14fc8
leaq 0xbbea(%rip), %rsi      # 0xf181
callq 0x21a0
movq %rax, %rdi
callq 0x20f0
leaq -0xce0(%rbp), %rdi
callq 0xce58
leaq -0x2f8(%rbp), %rdi
callq 0x2040
leaq 0xbba8(%rip), %rsi      # 0xf16b
leaq -0x2f8(%rbp), %rdi
pushq $0x8
popq %rdx
callq 0x2140
movq 0x119ef(%rip), %rdi     # 0x14fc8
leaq 0xbbb8(%rip), %rsi      # 0xf198
callq 0x21a0
movq %rax, %rdi
callq 0x20f0
leaq -0xce0(%rbp), %rdi
callq 0xd0d8
movq 0x119c8(%rip), %rdi     # 0x14fc8
leaq 0xbba9(%rip), %rsi      # 0xf1b0
callq 0x21a0
leaq 0xbbd9(%rip), %rsi      # 0xf1ec
movq %rax, %rdi
callq 0x21a0
movq %rax, %rdi
callq 0x20f0
leaq 0xbb4a(%rip), %rsi      # 0xf174
leaq -0x70(%rbp), %rdi
leaq -0xa(%rbp), %rdx
callq 0x20a0
leaq -0x4bf8(%rbp), %rdi
leaq -0x70(%rbp), %rsi
pushq $0x1
popq %rdx
callq 0xd994
leaq -0x70(%rbp), %rdi
callq 0x20d0
leaq -0xce0(%rbp), %rdi
callq 0xce52
leaq -0x4f8(%rbp), %rdi
callq 0x2270
leaq -0x2f8(%rbp), %rdi
callq 0x2050
leaq -0x3c40(%rbp), %rdi
callq 0x377e
leaq -0x1b50(%rbp), %rdi
callq 0x37e2
leaq -0x30(%rbp), %rdi
callq 0x20d0
leaq -0x50(%rbp), %rdi
callq 0x20d0
xorl %eax, %eax
addq $0x4bf8, %rsp           # imm = 0x4BF8
popq %rbx
popq %rbp
retq
movq %rax, %rbx
leaq -0x70(%rbp), %rdi
callq 0x20d0
jmp 0x3722
jmp 0x371f
jmp 0x36bf
movq %rax, %rbx
jmp 0x372e
jmp 0x36c6
movq %rax, %rbx
jmp 0x373a
jmp 0x371a
jmp 0x371a
movq %rax, %rbx
leaq -0x90(%rbp), %rdi
callq 0x20d0
jmp 0x36e3
movq %rax, %rbx
leaq -0xb0(%rbp), %rdi
callq 0x20d0
jmp 0x3752
movq %rax, %rbx
jmp 0x3752
movq %rax, %rbx
leaq -0xd0(%rbp), %rdi
callq 0x20d0
jmp 0x370a
movq %rax, %rbx
leaq -0xf0(%rbp), %rdi
callq 0x20d0
jmp 0x3763
jmp 0x3760
movq %rax, %rbx
jmp 0x3746
movq %rax, %rbx
leaq -0xce0(%rbp), %rdi
callq 0xce52
leaq -0x4f8(%rbp), %rdi
callq 0x2270
leaq -0x2f8(%rbp), %rdi
callq 0x2050
leaq -0x3c40(%rbp), %rdi
callq 0x377e
leaq -0x1b50(%rbp), %rdi
callq 0x37e2
jmp 0x3763
movq %rax, %rbx
leaq -0x30(%rbp), %rdi
callq 0x20d0
leaq -0x50(%rbp), %rdi
callq 0x20d0
movq %rbx, %rdi
callq 0x22e0
nop