// File: /workspace/github_cpp_makefile_star2_O3/tomsmeding[P]MarioLANG/mariolang.cpp
// Function: main
int main(int argc,char **argv){
	if(argc==1){
		printf(
		 "Usage: %s [-a] [-d level] <file>\n"
		 "\t-a        Turn on \x1B[46ma\x1B[0mnimation mode.\n"
		 "\t-d level  Set \x1B[46md\x1B[0mebug level to 'level', where 'level' can be:\n"
		 "\t            -1: No fatal errors.\n"
		 "\t             0: No debug output. Default.\n"
		 "\t             1: Show errors.\n"
		 "\t             2: Plus one debug line per command.\n"
		 "\t             3: Frantic. Useless. Adds even more shit per executed command.\n"
		 "\t-T        Show the \x1B[46mT\x1B[0mape in animation mode.\n"
		 "\t-w msecs  Sets the time to \x1B[46mw\x1B[0mait between commands in milliseconds if animating. Useless otherwise.\n"
		 ,argv[0]);
		return 0;
	}
	signal(SIGINT,signalhandler);
	signal(SIGUSR1,signalhandler);
	debuglevel=0;
	animatedelay=250000;
	animate=false;
	animateShowTape=false;
	int i,j;
	bool skipNextArg=false;
	for(i=1;i<argc-1;i++){
		if(skipNextArg){skipNextArg=false;continue;}
		if(argv[i][0]=='-'){
			for(j=1;argv[i][j]!='\0';j++){
				if(argv[i][j]=='a')animate=true;
				else if(argv[i][j]=='d'){debuglevel=strtol(argv[i+1],NULL,10);skipNextArg=true;}
				else if(argv[i][j]=='T')animateShowTape=true;
				else if(argv[i][j]=='w'){animatedelay=strtol(argv[i+1],NULL,10)*1000;skipNextArg=true;}
				else {fprintf(stderr,"Unrecognised option %c\n",argv[i][j]);return 0;}
			}
		} else {
			fprintf(stderr,"Unrecognised argument %s\n",argv[i]);
			return 0;
		}
	}
	if(strcmp(argv[argc-1],"-")==0){
		L=new Level();
	} else {
		ifstream cf; //CodeFile
		cf.open(argv[argc-1]);
		if(!cf.is_open()){
			fprintf(stderr,"Could not open file '%s'\n",argv[argc-1]);
			fprintf(stderr,"Run %s without arguments for usage information.\n",argv[0]);
			return 0;
		}
		L=new Level(cf);
	}
	L->play();
	delete L;
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x210, %rsp            # imm = 0x210
movq %rsi, %rbx
cmpl $0x1, %edi
jne 0x2cbc
movq (%rbx), %rsi
leaq 0x245f(%rip), %rdi      # 0x510f
xorl %eax, %eax
callq 0x2030
jmp 0x2eb2
movl %edi, %r14d
leaq -0x73(%rip), %r15       # 0x2c53
movl $0x2, %edi
movq %r15, %rsi
callq 0x2170
movl $0xa, %edi
movq %r15, %rsi
callq 0x2170
movl $0x0, 0x547a(%rip)      # 0x8164
movl $0x3d090, 0x5474(%rip)  # imm = 0x3D090
xorl %eax, %eax
movb %al, 0x5470(%rip)       # 0x816c
movb %al, 0x546b(%rip)       # 0x816d
leal -0x1(%r14), %ebp
cmpl $0x3, %r14d
jl 0x2dc4
movl %ebp, %r14d
movl $0x1, %r15d
xorl %eax, %eax
testb $0x1, %al
je 0x2d26
xorl %eax, %eax
jmp 0x2db8
movq (%rbx,%r15,8), %rdx
cmpb $0x2d, (%rdx)
jne 0x2ef7
movl $0x1, %r12d
xorl %eax, %eax
movzbl (%rdx,%r12), %ecx
cmpl $0x63, %ecx
jg 0x2d58
cmpl $0x54, %ecx
je 0x2da0
cmpl $0x61, %ecx
jne 0x2db0
movb $0x1, 0x5416(%rip)      # 0x816c
jmp 0x2da7
cmpl $0x64, %ecx
je 0x2d85
cmpl $0x77, %ecx
jne 0x2e97
movq 0x8(%rbx,%r15,8), %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x21c0
imull $0x3e8, %eax, %eax      # imm = 0x3E8
movl %eax, 0x53e5(%rip)      # 0x8168
jmp 0x2d9c
movq 0x8(%rbx,%r15,8), %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x21c0
movl %eax, 0x53c8(%rip)      # 0x8164
movb $0x1, %al
jmp 0x2da7
movb $0x1, 0x53c6(%rip)      # 0x816d
incq %r12
movq (%rbx,%r15,8), %rdx
jmp 0x2d3b
testl %ecx, %ecx
jne 0x2e97
incq %r15
cmpq %r14, %r15
jne 0x2d1b
movslq %ebp, %rax
movq (%rbx,%rax,8), %rcx
cmpb $0x2d, (%rcx)
jne 0x2dda
cmpb $0x0, 0x1(%rcx)
je 0x2ec4
leaq (%rbx,%rax,8), %r14
leaq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0x2140
movq (%r14), %rsi
movq %r15, %rdi
movl $0x8, %edx
callq 0x20b0
leaq 0x80(%rsp), %rdi
callq 0x2050
testb %al, %al
je 0x2ee5
movl $0x58, %edi
callq 0x2100
movq %rax, %r14
leaq 0x8(%rsp), %rsi
movq %rax, %rdi
callq 0x2fd4
movq %r14, 0x533f(%rip)      # 0x8170
leaq 0x8(%rsp), %rdi
callq 0x2060
movq 0x532e(%rip), %r14      # 0x8170
movq %r14, %rdi
callq 0x3146
movq 0x531f(%rip), %rbx      # 0x8170
testq %rbx, %rbx
je 0x2e88
leaq 0x30(%rbx), %rdi
callq 0x3296
movq 0x18(%rbx), %rdi
testq %rdi, %rdi
je 0x2e74
movq 0x28(%rbx), %rsi
subq %rdi, %rsi
callq 0x2110
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x2e88
movq 0x10(%rbx), %rsi
subq %rdi, %rsi
callq 0x2110
movl $0x58, %esi
movq %rbx, %rdi
callq 0x2110
jmp 0x2eb2
movsbl %cl, %edx
movq 0x512f(%rip), %rax      # 0x7fd0
movq (%rax), %rdi
leaq 0x2483(%rip), %rsi      # 0x532e
xorl %eax, %eax
callq 0x21e0
xorl %eax, %eax
addq $0x210, %rsp            # imm = 0x210
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl $0x58, %edi
callq 0x2100
movq %rax, %r14
movq %rax, %rdi
callq 0x2f4a
movq %r14, 0x5290(%rip)      # 0x8170
jmp 0x2e42
leaq 0x8(%rsp), %rdx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2280
jmp 0x2eb2
movq 0x50d2(%rip), %rax      # 0x7fd0
movq (%rax), %rdi
leaq 0x243e(%rip), %rsi      # 0x5346
xorl %eax, %eax
callq 0x21e0
jmp 0x2eb2
movq %rax, %rbx
movl $0x58, %esi
movq %r14, %rdi
callq 0x2110
jmp 0x2f42
movq %rax, %rbx
movl $0x58, %esi
movq %r14, %rdi
callq 0x2110
jmp 0x2f38
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x2060
movq %rbx, %rdi
callq 0x2240