// File: /workspace/github_cpp_makefile_star2_O1/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 -0x260(%rbp), %rbx
movq %rbx, %rdi
movl $0x8, %edx
callq 0x42b0
movq %rbx, %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0x42c0
leaq -0x260(%rbp), %rdi
callq 0x4360
movq %rax, %rbx
leaq -0x260(%rbp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x42c0
leal 0x1(%rbx), %edi
callq 0x4030
movq %rax, %r14
movl %ebx, %ebx
leaq -0x260(%rbp), %rdi
movq %rax, %rsi
movq %rbx, %rdx
callq 0x4260
movb $0x0, (%r14,%rbx)
leaq -0x260(%rbp), %rdi
callq 0x4050
movq %r14, %rdi
callq 0x4c88
movq %rax, %rbx
xorps %xmm0, %xmm0
movaps %xmm0, -0x30(%rbp)
movq $0x0, -0x20(%rbp)
leaq -0x50(%rbp), %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x64d8
movq -0x30(%rbp), %rdi
movq -0x50(%rbp), %rax
movq %rax, -0x30(%rbp)
movups -0x48(%rbp), %xmm0
movups %xmm0, -0x28(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x50(%rbp)
movq $0x0, -0x40(%rbp)
testq %rdi, %rdi
je 0x4af8
callq 0x41e0
movq -0x50(%rbp), %rdi
testq %rdi, %rdi
je 0x4b06
callq 0x41e0
leaq -0x30(%rbp), %rdi
movq %rbx, %rsi
callq 0x1d4c8
movq %rax, %r14
movq (%rax), %r15
xorl %ebx, %ebx
cmpq 0x8(%r14), %r15
je 0x4c32
movq (%r15), %rdi
movq (%rdi), %rax
callq *(%rax)
addq $0x8, %r15
jmp 0x4b1a
movq %rax, %rbx
cmpl $0x1, %edx
jne 0x4c69
movq %rbx, %rdi
callq 0x40d0
movq (%rax), %rcx
movq %rax, %rdi
callq *0x10(%rcx)
movq 0x27472(%rip), %rdi     # 0x2bfc8
movq %rax, %rsi
callq 0x4200
movq %rax, %rdi
callq 0x4100
movl $0x1, %ebx
callq 0x4330
jmp 0x4c32
jmp 0x4c5c
movq %rax, %rbx
callq 0x4330
jmp 0x4c69
movq %rax, %rbx
cmpl $0x1, %edx
jne 0x4c69
movq %rbx, %rdi
callq 0x40d0
movq (%rax), %rcx
movq %rax, %rdi
callq *0x10(%rcx)
movq 0x2741d(%rip), %rdi     # 0x2bfc8
movq %rax, %rsi
callq 0x4200
movq %rax, %rdi
callq 0x4100
movl $0x1, %ebx
callq 0x4330
jmp 0x4c32
jmp 0x4c5c
movq %rax, %rbx
callq 0x4330
jmp 0x4c69
jmp 0x4be1
jmp 0x4be1
jmp 0x4be1
jmp 0x4be1
movq %rax, %rbx
leaq -0x260(%rbp), %rdi
callq 0x4080
movq %rbx, %rdi
callq 0x4380
movq %rax, %rbx
cmpl $0x1, %edx
jne 0x4c69
movq %rbx, %rdi
callq 0x40d0
movq (%rax), %rcx
movq %rax, %rdi
callq *0x10(%rcx)
movq 0x273b0(%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 0x4c40
callq 0x41e0
leaq -0x260(%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 0x4c69
movq %rax, %rbx
callq 0x4330
movq -0x30(%rbp), %rdi
testq %rdi, %rdi
je 0x4be4
callq 0x41e0
jmp 0x4be4
movq %rax, %rdi
callq 0x4dc0