// File: JayWalker512[P]JayParser/main.cpp
// Function: main
int main (int argc, const char *argv[])
{
	Log *log = Log::init();
	
	if (argc != 2)
		log->add(new Error(FATAL + FILEERR + 1, "Invalid argument count. Expecting program file name."));
	else
	{
		std::ifstream inputFile(argv[1], std::ios::binary);
		
		if (!inputFile.is_open())
			log->add(new Error(FATAL + FILEERR + 2, "Can't open the file."));
		else
		{
			// Everything's looking good, starting the VM
			VM vm(&inputFile);
			vm.parse();
		}
	}
	
	Log::init()->displayLastError();
	
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40310, %rsp          # imm = 0x40310
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
callq 0x2770
movq %rax, -0x18(%rbp)
cmpl $0x2, -0x8(%rbp)
je 0x2596
movq -0x18(%rbp), %rax
movq %rax, -0x402e8(%rbp)
movl $0x28, %edi
callq 0x2150
movq %rax, -0x402e0(%rbp)
movb $0x1, -0x4d(%rbp)
leaq -0x39(%rbp), %rdi
movq %rdi, -0x402d8(%rbp)
callq 0x2280
movq -0x402d8(%rbp), %rdx
leaq 0x2b0a(%rip), %rsi      # 0x5004
leaq -0x38(%rbp), %rdi
callq 0x2820
jmp 0x2505
movq -0x402e0(%rbp), %rdi
movl $0x80ffff01, %esi       # imm = 0x80FFFF01
leaq -0x38(%rbp), %rdx
callq 0x28d0
jmp 0x251c
movq -0x402e0(%rbp), %rsi
movq -0x402e8(%rbp), %rdi
movb $0x0, -0x4d(%rbp)
callq 0x27f0
jmp 0x2535
leaq -0x38(%rbp), %rdi
callq 0x20c0
leaq -0x39(%rbp), %rdi
callq 0x2190
jmp 0x2749
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x256f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x20c0
leaq -0x39(%rbp), %rdi
callq 0x2190
testb $0x1, -0x4d(%rbp)
jne 0x2580
jmp 0x2591
movq -0x402e0(%rbp), %rdi
movl $0x28, %esi
callq 0x2160
jmp 0x2761
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
leaq -0x258(%rbp), %rdi
movq %rdi, -0x402f8(%rbp)
movl $0x4, %edx
callq 0x22a0
movq -0x402f8(%rbp), %rdi
callq 0x2240
movb %al, -0x402e9(%rbp)
jmp 0x25ca
movb -0x402e9(%rbp), %al
testb $0x1, %al
jne 0x26e2
jmp 0x25da
movq -0x18(%rbp), %rax
movq %rax, -0x40308(%rbp)
movl $0x28, %edi
callq 0x2150
movq %rax, -0x40300(%rbp)
jmp 0x25f8
movb $0x1, -0x27a(%rbp)
leaq -0x279(%rbp), %rdi
movq %rdi, -0x40310(%rbp)
callq 0x2280
movq -0x40310(%rbp), %rdx
leaq 0x2a19(%rip), %rsi      # 0x5039
leaq -0x278(%rbp), %rdi
callq 0x2820
jmp 0x262e
movq -0x40300(%rbp), %rdi
movl $0x80ffff02, %esi       # imm = 0x80FFFF02
leaq -0x278(%rbp), %rdx
callq 0x28d0
jmp 0x2648
movq -0x40300(%rbp), %rsi
movq -0x40308(%rbp), %rdi
movb $0x0, -0x27a(%rbp)
callq 0x27f0
jmp 0x2664
leaq -0x278(%rbp), %rdi
callq 0x20c0
leaq -0x279(%rbp), %rdi
callq 0x2190
jmp 0x272d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x273b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x26b8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x278(%rbp), %rdi
callq 0x20c0
leaq -0x279(%rbp), %rdi
callq 0x2190
testb $0x1, -0x27a(%rbp)
jne 0x26cf
jmp 0x26e0
movq -0x40300(%rbp), %rdi
movl $0x28, %esi
callq 0x2160
jmp 0x273b
leaq -0x402d0(%rbp), %rdi
leaq -0x258(%rbp), %rsi
callq 0x4040
jmp 0x26f7
leaq -0x402d0(%rbp), %rdi
callq 0x4140
jmp 0x2705
leaq -0x402d0(%rbp), %rdi
callq 0x4130
jmp 0x272d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x402d0(%rbp), %rdi
callq 0x4130
jmp 0x273b
leaq -0x258(%rbp), %rdi
callq 0x2040
jmp 0x2749
leaq -0x258(%rbp), %rdi
callq 0x2040
jmp 0x2761
callq 0x2770
movq %rax, %rdi
callq 0x2910
xorl %eax, %eax
addq $0x40310, %rsp          # imm = 0x40310
popq %rbp
retq
movq -0x48(%rbp), %rdi
callq 0x2270
nopw (%rax,%rax)