// File: /workspace/github_cpp_makefile_star2_O3/AshOlogn[P]ash-language-interpreter/src/main.cpp
// Function: main
int main(int argc, char** argv) {
  
  //read in source code
  char* sourceFile = argv[1];
  fstream in(sourceFile, fstream::in);

  in.seekg(0, in.end);
  uint32_t length = in.tellg();
  in.seekg(0, in.beg);
  
  char* sourceCode = new char[length+1];
  in.read(sourceCode, length);
  sourceCode[length] = 0;
  in.close();

  //convert source code into array of lines
  vector<char*>* codeLines = getLines(sourceCode);
  
  //generate array of Tokens from source code 
  vector<Token> tokens;
  
  try {
    tokens = lex(sourceCode, codeLines);
  } catch(exception& e) {
    cout << e.what() << endl;
    return 1;
  }
	
  //get list of statements from list of tokens (parse)
  vector<AbstractStatementNode*>* statements;
  
  try {
    statements = parse(&tokens, codeLines); 
  } catch(exception& e) {
    cout << e.what() << endl;
    return 1;
  }
  
  vector<AbstractStatementNode*>::iterator it2;
	
  //execute statements
  for(it2 = statements->begin(); it2 != statements->end(); it2++) {

		try {
			(*it2)->execute();
		}	catch(exception& e) {
			cout << e.what() << endl;
			return 1;
		}	
  }

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x248, %rsp            # imm = 0x248
movq 0x8(%rsi), %rsi
leaq -0x258(%rbp), %rbx
movq %rbx, %rdi
movl $0x8, %edx
callq 0x42b0
movq %rbx, %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0x42c0
leaq -0x258(%rbp), %rdi
callq 0x4360
movq %rax, %r14
leaq -0x258(%rbp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x42c0
leal 0x1(%r14), %edi
callq 0x4030
movq %rax, %rbx
movl %r14d, %r14d
leaq -0x258(%rbp), %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x4260
movb $0x0, (%rbx,%r14)
leaq -0x258(%rbp), %rdi
callq 0x4050
movq %rbx, %rdi
callq 0x4c5e
movq %rax, %r14
xorps %xmm0, %xmm0
movaps %xmm0, -0x30(%rbp)
movq $0x0, -0x20(%rbp)
leaq -0x48(%rbp), %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x64ab
movq -0x48(%rbp), %rax
leaq -0x30(%rbp), %rdi
movq %rax, (%rdi)
movups -0x40(%rbp), %xmm0
movups %xmm0, 0x8(%rdi)
movq %r14, %rsi
callq 0x1d479
movq %rax, %r14
movq (%rax), %r15
xorl %ebx, %ebx
cmpq 0x8(%r14), %r15
je 0x4c08
movq (%r15), %rdi
movq (%rdi), %rax
callq *(%rax)
addq $0x8, %r15
jmp 0x4af0
movq %rax, %rbx
cmpl $0x1, %edx
jne 0x4c3f
movq %rbx, %rdi
callq 0x40d0
movq (%rax), %rcx
movq %rax, %rdi
callq *0x10(%rcx)
movq 0x2749c(%rip), %rdi     # 0x2bfc8
movq %rax, %rsi
callq 0x4200
movq %rax, %rdi
callq 0x4100
movl $0x1, %ebx
callq 0x4330
jmp 0x4c08
jmp 0x4c32
movq %rax, %rbx
callq 0x4330
jmp 0x4c3f
movq %rax, %rbx
cmpl $0x1, %edx
jne 0x4c3f
movq %rbx, %rdi
callq 0x40d0
movq (%rax), %rcx
movq %rax, %rdi
callq *0x10(%rcx)
movq 0x27447(%rip), %rdi     # 0x2bfc8
movq %rax, %rsi
callq 0x4200
movq %rax, %rdi
callq 0x4100
movl $0x1, %ebx
callq 0x4330
jmp 0x4c08
jmp 0x4c32
movq %rax, %rbx
callq 0x4330
jmp 0x4c3f
jmp 0x4bb7
jmp 0x4bb7
jmp 0x4bb7
jmp 0x4bb7
movq %rax, %rbx
leaq -0x258(%rbp), %rdi
callq 0x4080
movq %rbx, %rdi
callq 0x4380
movq %rax, %rbx
cmpl $0x1, %edx
jne 0x4c3f
movq %rbx, %rdi
callq 0x40d0
movq (%rax), %rcx
movq %rax, %rdi
callq *0x10(%rcx)
movq 0x273da(%rip), %rdi     # 0x2bfc8
movq %rax, %rsi
callq 0x4200
movq %rax, %rdi
callq 0x4100
movl $0x1, %ebx
callq 0x4330
movq -0x30(%rbp), %rdi
testq %rdi, %rdi
je 0x4c16
callq 0x41e0
leaq -0x258(%rbp), %rdi
callq 0x4080
movl %ebx, %eax
addq $0x248, %rsp            # imm = 0x248
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x4c3f
movq %rax, %rbx
callq 0x4330
movq -0x30(%rbp), %rdi
testq %rdi, %rdi
je 0x4bba
callq 0x41e0
jmp 0x4bba
movq %rax, %rdi
callq 0x4d92