// File: pranavmodx[P]modlang/main.cpp
// Function: main
int main(int argc, char *argv[])
{
	if (argc < 2) {
		std::cout << "error: file name not specified" << std::endl;
		exit(1);
	}

	std::string filename(argv[1]);
	std::string input = readFile(filename);

	if (input.empty())
		return 0;

	Lexer lexer;
	Parser parser;
	Evaluator evaluator;

	Environment *env = new Environment();

	lexer.New(input);
	parser.New(lexer);

	Program *program = parser.ParseProgram();

	if (!parser.Errors().empty())
	{
		std::cout << "error: " << std::endl;

		for (auto error : parser.Errors())
			std::cout << error << std::endl;

		return 0;
	}

	Object *obj = evaluator.Eval(program, env);
	if (obj->type() != NULL_OBJ)
		std::cout << obj->inspect() << std::endl;

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x330, %rsp            # imm = 0x330
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpl $0x2, -0x8(%rbp)
jge 0x144eb
movq 0x51afa(%rip), %rdi     # 0x65fc0
leaq 0x32c3c(%rip), %rsi     # 0x47109
callq 0x62b0
movq %rax, %rdi
movq 0x51abc(%rip), %rsi     # 0x65f98
callq 0x62f0
movl $0x1, %edi
callq 0x6360
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x2e8(%rbp)
leaq -0x31(%rbp), %rdi
movq %rdi, -0x2e0(%rbp)
callq 0x6520
movq -0x2e8(%rbp), %rsi
movq -0x2e0(%rbp), %rdx
leaq -0x30(%rbp), %rdi
callq 0x14960
jmp 0x14523
leaq -0x31(%rbp), %rdi
callq 0x6310
leaq -0x68(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x14160
jmp 0x1453b
leaq -0x68(%rbp), %rdi
callq 0x64d0
testb $0x1, %al
jne 0x1454a
jmp 0x14588
movl $0x0, -0x4(%rbp)
movl $0x1, -0x6c(%rbp)
jmp 0x14926
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x31(%rbp), %rdi
callq 0x6310
jmp 0x1494d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x14944
leaq -0xa0(%rbp), %rdi
callq 0x14b40
leaq -0x210(%rbp), %rdi
callq 0x208a0
jmp 0x145a2
movl $0x40, %edi
callq 0x62c0
movq %rax, -0x2f0(%rbp)
jmp 0x145b5
movq -0x2f0(%rbp), %rdi
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rdi)
movaps %xmm0, 0x20(%rdi)
movaps %xmm0, 0x10(%rdi)
movaps %xmm0, (%rdi)
callq 0x14b60
movq -0x2f0(%rbp), %rax
movq %rax, -0x220(%rbp)
leaq -0xa0(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x194f0
jmp 0x145f3
leaq -0x210(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x20d60
jmp 0x14608
leaq -0x210(%rbp), %rdi
callq 0x23370
movq %rax, -0x2f8(%rbp)
jmp 0x1461d
movq -0x2f8(%rbp), %rax
movq %rax, -0x228(%rbp)
leaq -0x240(%rbp), %rdi
leaq -0x210(%rbp), %rsi
callq 0x240a0
jmp 0x14640
leaq -0x240(%rbp), %rdi
callq 0x14b80
xorb $-0x1, %al
movb %al, -0x2f9(%rbp)
leaq -0x240(%rbp), %rdi
callq 0x14bc0
movb -0x2f9(%rbp), %al
testb $0x1, %al
jne 0x1466f
jmp 0x147ef
movq 0x5194a(%rip), %rdi     # 0x65fc0
leaq 0x32aab(%rip), %rsi     # 0x47128
callq 0x62b0
movq %rax, -0x308(%rbp)
jmp 0x1468b
movq -0x308(%rbp), %rdi
movq 0x518ff(%rip), %rsi     # 0x65f98
callq 0x62f0
jmp 0x146a0
leaq -0x260(%rbp), %rdi
leaq -0x210(%rbp), %rsi
callq 0x240a0
jmp 0x146b5
leaq -0x260(%rbp), %rax
movq %rax, -0x248(%rbp)
movq -0x248(%rbp), %rdi
callq 0x14c20
movq %rax, -0x268(%rbp)
movq -0x248(%rbp), %rdi
callq 0x14c50
movq %rax, -0x270(%rbp)
leaq -0x268(%rbp), %rdi
leaq -0x270(%rbp), %rsi
callq 0x14c80
testb $0x1, %al
jne 0x1473a
movl $0x2, -0x6c(%rbp)
leaq -0x260(%rbp), %rdi
callq 0x14bc0
jmp 0x147dc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x1490f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x14903
leaq -0x268(%rbp), %rdi
callq 0x14cc0
movq %rax, %rsi
leaq -0x290(%rbp), %rdi
callq 0x6140
jmp 0x14757
movq 0x51862(%rip), %rdi     # 0x65fc0
leaq -0x290(%rbp), %rsi
callq 0x6280
movq %rax, -0x310(%rbp)
jmp 0x14773
movq -0x310(%rbp), %rdi
movq 0x51817(%rip), %rsi     # 0x65f98
callq 0x62f0
jmp 0x14788
leaq -0x290(%rbp), %rdi
callq 0x65a8
leaq -0x268(%rbp), %rdi
callq 0x14ce0
jmp 0x146e9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x147cb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x290(%rbp), %rdi
callq 0x65a8
leaq -0x260(%rbp), %rdi
callq 0x14bc0
jmp 0x14903
movl $0x0, -0x4(%rbp)
movl $0x1, -0x6c(%rbp)
jmp 0x148e9
movq -0x228(%rbp), %rsi
movq -0x220(%rbp), %rdx
leaq -0x211(%rbp), %rdi
callq 0x33df0
movq %rax, -0x318(%rbp)
jmp 0x14812
movq -0x318(%rbp), %rax
movq %rax, -0x298(%rbp)
movq -0x298(%rbp), %rsi
movq (%rsi), %rax
movq (%rax), %rax
leaq -0x2b8(%rbp), %rdi
callq *%rax
jmp 0x14838
leaq -0x2b8(%rbp), %rdi
leaq 0x521a2(%rip), %rsi     # 0x669e8
callq 0x14d00
movb %al, -0x319(%rbp)
leaq -0x2b8(%rbp), %rdi
callq 0x65a8
movb -0x319(%rbp), %al
testb $0x1, %al
jne 0x14869
jmp 0x148db
movq -0x298(%rbp), %rsi
movq (%rsi), %rax
movq 0x8(%rax), %rax
leaq -0x2d8(%rbp), %rdi
callq *%rax
jmp 0x14882
movq 0x51737(%rip), %rdi     # 0x65fc0
leaq -0x2d8(%rbp), %rsi
callq 0x6280
movq %rax, -0x328(%rbp)
jmp 0x1489e
movq -0x328(%rbp), %rdi
movq 0x516ec(%rip), %rsi     # 0x65f98
callq 0x62f0
jmp 0x148b3
leaq -0x2d8(%rbp), %rdi
callq 0x65a8
jmp 0x148db
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x2d8(%rbp), %rdi
callq 0x65a8
jmp 0x14903
movl $0x0, -0x4(%rbp)
movl $0x1, -0x6c(%rbp)
leaq -0x210(%rbp), %rdi
callq 0x14d30
leaq -0xa0(%rbp), %rdi
callq 0x14db0
jmp 0x14926
leaq -0x210(%rbp), %rdi
callq 0x14d30
leaq -0xa0(%rbp), %rdi
callq 0x14db0
leaq -0x68(%rbp), %rdi
callq 0x65a8
jmp 0x14944
leaq -0x68(%rbp), %rdi
callq 0x65a8
leaq -0x30(%rbp), %rdi
callq 0x65a8
movl -0x4(%rbp), %eax
addq $0x330, %rsp            # imm = 0x330
popq %rbp
retq
leaq -0x30(%rbp), %rdi
callq 0x65a8
movq -0x40(%rbp), %rdi
callq 0x6510
nopw %cs:(%rax,%rax)