// File: RuiDGPires[P]CrimLang/src/main.cpp
// Function: main
int main(int argc, char *argv[]){
	if (argc < 3) {std::cout << "Invalid number of command line arguments\n"; return 0;}

	crl::Pproc_lib p;
	p.libc = argc - 3;
	if (argc > 3)
		p.libv = &argv[3];
	else
		p.libv = NULL;
	
	
	try{
		std::vector<crl::Token> vec = crl::tokenize(argv[1]);
		crl::preprocess(vec, p);
		//print_token_vec(vec);
		crl::Ast *ast = crl::generate_ast(vec);
		//std::cout << ast->to_string() << std::endl;
		crl::semantic_check(ast);
		generate_cas(ast, argv[2]);
		delete ast;
	}catch(std::string &e){
		std::cout << e << std::endl;
		return 1;
	}catch(crl::CL_Exception &e){
		std::cout << e.what() << std::endl;
		return 1;
	}
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x150, %rsp            # imm = 0x150
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpl $0x3, -0x8(%rbp)
jge 0x1800e
movq 0x21fe2(%rip), %rdi     # 0x39fd8
leaq 0x136bd(%rip), %rsi     # 0x2b6ba
callq 0x42e0
movl $0x0, -0x4(%rbp)
jmp 0x1835b
movl -0x8(%rbp), %eax
subl $0x3, %eax
cltq
movq %rax, -0x20(%rbp)
cmpl $0x3, -0x8(%rbp)
jle 0x1802e
movq -0x10(%rbp), %rax
addq $0x18, %rax
movq %rax, -0x18(%rbp)
jmp 0x18036
movq $0x0, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x108(%rbp)
leaq -0x59(%rbp), %rdi
movq %rdi, -0x100(%rbp)
callq 0x4590
movq -0x108(%rbp), %rsi
movq -0x100(%rbp), %rdx
leaq -0x58(%rbp), %rdi
callq 0x52e0
jmp 0x1806e
leaq -0x38(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x2a180
jmp 0x1807d
leaq -0x58(%rbp), %rdi
callq 0x41e0
leaq -0x59(%rbp), %rdi
callq 0x4360
movups -0x20(%rbp), %xmm0
movaps %xmm0, -0x80(%rbp)
movq -0x80(%rbp), %rsi
movq -0x78(%rbp), %rdx
leaq -0x38(%rbp), %rdi
callq 0x1de20
jmp 0x180aa
leaq -0xa0(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x18380
jmp 0x180bc
leaq -0xa0(%rbp), %rdi
callq 0x1bed0
movq %rax, -0x110(%rbp)
jmp 0x180d1
leaq -0xa0(%rbp), %rdi
callq 0x18470
movq -0x110(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rdi
callq 0x25c30
jmp 0x180f9
movq -0x88(%rbp), %rax
movq %rax, -0x128(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x120(%rbp)
leaq -0xc1(%rbp), %rdi
movq %rdi, -0x118(%rbp)
callq 0x4590
movq -0x120(%rbp), %rsi
movq -0x118(%rbp), %rdx
leaq -0xc0(%rbp), %rdi
callq 0x52e0
jmp 0x18145
movq -0x128(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x12be0
jmp 0x1815a
leaq -0xc0(%rbp), %rdi
callq 0x41e0
leaq -0xc1(%rbp), %rdi
callq 0x4360
movq -0x88(%rbp), %rax
movq %rax, -0x130(%rbp)
cmpq $0x0, %rax
je 0x18193
movq -0x130(%rbp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
leaq -0x38(%rbp), %rdi
callq 0x18470
jmp 0x18354
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x181c4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x41e0
leaq -0x59(%rbp), %rdi
callq 0x4360
jmp 0x18232
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x18229
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x18470
jmp 0x18229
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x1821d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x41e0
leaq -0xc1(%rbp), %rdi
callq 0x4360
leaq -0x38(%rbp), %rdi
callq 0x18470
movl -0x6c(%rbp), %eax
movl %eax, -0x134(%rbp)
movl $0x2, %ecx
cmpl %ecx, %eax
jne 0x18296
movq -0x68(%rbp), %rdi
callq 0x4130
movq %rax, -0xf8(%rbp)
movq -0xf8(%rbp), %rsi
movq 0x21d76(%rip), %rdi     # 0x39fd8
callq 0x42c0
movq %rax, -0x140(%rbp)
jmp 0x18270
movq -0x140(%rbp), %rdi
movq 0x21d42(%rip), %rsi     # 0x39fc0
callq 0x4330
jmp 0x18285
movl $0x1, -0x4(%rbp)
callq 0x4500
jmp 0x1835b
movl -0x134(%rbp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0x18367
movq -0x68(%rbp), %rdi
callq 0x4130
movq %rax, -0xd0(%rbp)
movq -0xd0(%rbp), %rsi
leaq -0xf0(%rbp), %rdi
movq %rdi, -0x150(%rbp)
callq 0x8ee0
movq -0x150(%rbp), %rsi
movq 0x21cf7(%rip), %rdi     # 0x39fd8
callq 0x42c0
movq %rax, -0x148(%rbp)
jmp 0x182ef
movq -0x148(%rbp), %rdi
movq 0x21cc3(%rip), %rsi     # 0x39fc0
callq 0x4330
jmp 0x18304
leaq -0xf0(%rbp), %rdi
callq 0x41e0
movl $0x1, -0x4(%rbp)
callq 0x4500
jmp 0x1835b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x41e0
callq 0x4500
jmp 0x1833d
jmp 0x18367
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
callq 0x4500
jmp 0x18352
jmp 0x18367
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x150, %rsp            # imm = 0x150
popq %rbp
retq
movq -0x68(%rbp), %rdi
callq 0x4580
movq %rax, %rdi
callq 0x5bd0
nopl (%rax,%rax)