// File: /workspace/github_cpp_makefile_star2_O3/tomsmeding[P]MarioLANG/mariolang.cpp
// Function: Level::execcommandStep(mario*)
bool execcommandStep(mario *m){
		static bool lastTurnWasStanding=false;
		SHOW_MESSAGE("EC\tinstr=%c\tip=%d,%d\tmemp=%d\tmem[memp]=%d\tdir=%d\twalking=%d\tskip=%d",code[m->ipy][m->ipx],m->ipx,m->ipy,m->memp,memory[m->memp],m->dir,m->walking,m->skip);
		/*if(m->ipx<0||m->ipx>=code[m->ipy].size()){
			ERROR_FALSE("Mario walked out of the world.");
		}*/
		while(m->ipy<(int)code.size()-1
			&&code[m->ipy+1][m->ipx]!='='
			&&code[m->ipy+1][m->ipx]!='|'
			&&code[m->ipy+1][m->ipx]!='#'
			&&code[m->ipy+1][m->ipx]!='"'){
			if(!execcommandSingle(m))return false;
			m->ipy++;
		}
		if(m->ipy==(int)code.size()-1)ERROR_FALSE("Mario fell out of the world.");
		if(code[m->ipy+1][m->ipx]=='#'&&!m->walking){
			int newipy=m->ipy;
			while(newipy>0&&code[newipy][m->ipx]!='"')newipy--;
			if(newipy>0){
				newipy--;
				for(m->ipy-=1;m->ipy>newipy+1;m->ipy--)if(!execcommandSingle(m))return false;
				m->ipy=newipy;
			} else {
				newipy=m->ipy+2;
				while(newipy<(int)code.size()&&code[newipy][m->ipx]!='"')newipy++;
				if(newipy==(int)code.size())FATAL_FALSE("Elevator without ending.");
				newipy--;
				for(m->ipy+=2;m->ipy<newipy;m->ipy++)if(!execcommandSingle(m))return false;
				//now m->ipy == newipy
			}
		}
		if(!execcommandSingle(m))return false;
		if(m->walking){
			if(m->dir==DIRRIGHT){
				if(m->ipx<(int)code[m->ipy].size()-1)m->ipx++;
				else ERROR_FALSE("Mario walked out of the world.");
			} else if(m->dir==DIRLEFT){
				if(m->ipx>0)m->ipx--;
				else ERROR_FALSE("Mario walked out of the world.");
			} else FATAL_FALSE("The world glitched!");
			lastTurnWasStanding=false;
		} else {
			if(!lastTurnWasStanding)lastTurnWasStanding=true;
			else ERROR_FALSE("Mario got tired of standing still.");
		}
		return true;
	}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
cmpl $0x2, 0x4bfc(%rip)      # 0x8164
jge 0x36e5
movl 0x4(%rbx), %eax
movq 0x30(%r14), %rdx
movq 0x38(%r14), %rcx
subq %rdx, %rcx
shrq $0x5, %rcx
leal -0x1(%rcx), %esi
cmpl %esi, %eax
jge 0x35cc
movslq %eax, %rdi
shlq $0x5, %rdi
movslq (%rbx), %r8
movq 0x20(%rdx,%rdi), %rdi
movzbl (%rdi,%r8), %edi
leal -0x22(%rdi), %r8d
cmpl $0x2, %r8d
jb 0x35cc
cmpl $0x3d, %edi
je 0x35cc
cmpl $0x7c, %edi
je 0x35cc
movq %r14, %rdi
movq %rbx, %rsi
callq 0x3db2
testb %al, %al
je 0x3785
movl 0x4(%rbx), %eax
incl %eax
movl %eax, 0x4(%rbx)
jmp 0x3571
cmpl %esi, %eax
jne 0x35e7
cmpl $0x0, 0x4b8d(%rip)      # 0x8164
jle 0x3785
callq 0x254a
jmp 0x3785
movslq %eax, %rdi
shlq $0x5, %rdi
movslq (%rbx), %rsi
movq 0x20(%rdx,%rdi), %rdi
cmpb $0x23, (%rdi,%rsi)
jne 0x3602
cmpb $0x0, 0x10(%rbx)
je 0x3656
movq %r14, %rdi
movq %rbx, %rsi
callq 0x3db2
testb %al, %al
je 0x3785
cmpb $0x1, 0x10(%rbx)
jne 0x36a8
movl 0xc(%rbx), %eax
cmpl $0x2, %eax
je 0x371b
testl %eax, %eax
jne 0x3731
movl (%rbx), %eax
movslq 0x4(%rbx), %rcx
movq 0x30(%r14), %rdx
shlq $0x5, %rcx
movl 0x8(%rdx,%rcx), %ecx
decl %ecx
cmpl %ecx, %eax
jge 0x376c
incl %eax
jmp 0x3723
testl %eax, %eax
jle 0x367e
movl %eax, %r15d
movl %r15d, %edi
shlq $0x5, %rdi
movq (%rdx,%rdi), %rdi
cmpb $0x22, (%rdi,%rsi)
je 0x36f5
decl %r15d
leal 0x1(%r15), %edi
cmpl $0x1, %edi
jg 0x365d
addl $0x2, %eax
movl %eax, %ebp
cmpl %ecx, %eax
jge 0x36ca
movslq %eax, %rdi
shlq $0x5, %rdi
addq %rdi, %rdx
movl %eax, %ebp
movq (%rdx), %rdi
cmpb $0x22, (%rdi,%rsi)
je 0x36ca
incl %ebp
addq $0x20, %rdx
cmpl %ebp, %ecx
jne 0x3693
jmp 0x36ce
movb $0x1, %al
cmpb $0x1, 0x4ac7(%rip)      # 0x8178
jne 0x3727
cmpl $0x0, 0x4aaa(%rip)      # 0x8164
jle 0x3785
callq 0x23f1
jmp 0x3785
cmpl %ecx, %ebp
jne 0x3741
cmpl $0x0, 0x4a8f(%rip)      # 0x8164
js 0x3785
callq 0x239d
jmp 0x3785
movq %r14, %rdi
movq %rbx, %rsi
callq 0x22dc
jmp 0x356e
leal -0x1(%r15), %ebp
movl 0x4(%rbx), %eax
decl %eax
movl %eax, 0x4(%rbx)
cmpl %r15d, %eax
jle 0x3764
movq %r14, %rdi
movq %rbx, %rsi
callq 0x3db2
movl %eax, %ecx
xorl %eax, %eax
testb %cl, %cl
jne 0x36f9
jmp 0x3787
movl (%rbx), %eax
testl %eax, %eax
jle 0x377c
decl %eax
movl %eax, (%rbx)
xorl %eax, %eax
movb %al, 0x4a4b(%rip)       # 0x8178
movb $0x1, %al
jmp 0x3787
cmpl $0x0, 0x4a2c(%rip)      # 0x8164
js 0x3785
callq 0x24f6
jmp 0x3785
decl %ebp
movl %eax, 0x4(%rbx)
cmpl %ebp, %eax
jge 0x3602
movq %r14, %rdi
movq %rbx, %rsi
callq 0x3db2
testb %al, %al
je 0x3785
movl 0x4(%rbx), %eax
incl %eax
jmp 0x3743
movl %ebp, 0x4(%rbx)
jmp 0x3602
cmpl $0x0, 0x49f1(%rip)      # 0x8164
jle 0x3785
callq 0x249f
jmp 0x3785
cmpl $0x0, 0x49e1(%rip)      # 0x8164
jg 0x3792
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
callq 0x2448
jmp 0x3785
nop