// File: /workspace/github_cpp_makefile_star2_O1/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, 0x4c52(%rip)      # 0x816c
jge 0x3697
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 0x357e
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 0x357e
cmpl $0x3d, %edi
je 0x357e
cmpl $0x7c, %edi
je 0x357e
movq %r14, %rdi
movq %rbx, %rsi
callq 0x39a6
testb %al, %al
je 0x3737
movl 0x4(%rbx), %eax
incl %eax
movl %eax, 0x4(%rbx)
jmp 0x3523
cmpl %esi, %eax
jne 0x3599
cmpl $0x0, 0x4be3(%rip)      # 0x816c
jle 0x3737
callq 0x2550
jmp 0x3737
movslq %eax, %rdi
shlq $0x5, %rdi
movslq (%rbx), %rsi
movq 0x20(%rdx,%rdi), %rdi
cmpb $0x23, (%rdi,%rsi)
jne 0x35b4
cmpb $0x0, 0x10(%rbx)
je 0x3608
movq %r14, %rdi
movq %rbx, %rsi
callq 0x39a6
testb %al, %al
je 0x3737
cmpb $0x1, 0x10(%rbx)
jne 0x3675
movl 0xc(%rbx), %eax
cmpl $0x2, %eax
je 0x36f0
testl %eax, %eax
jne 0x3706
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 0x371e
incl %eax
jmp 0x36f8
testl %eax, %eax
jle 0x3630
movl %eax, %r15d
movl %r15d, %edi
shlq $0x5, %rdi
movq (%rdx,%rdi), %rdi
cmpb $0x22, (%rdi,%rsi)
je 0x36ca
decl %r15d
leal 0x1(%r15), %edi
cmpl $0x1, %edi
jg 0x360f
addl $0x2, %eax
movl %eax, %ebp
cmpl %ecx, %eax
jge 0x365a
movslq %eax, %rdi
shlq $0x5, %rdi
addq %rdi, %rdx
movl %eax, %ebp
movq (%rdx), %rdi
cmpb $0x22, (%rdi,%rsi)
je 0x365a
incl %ebp
addq $0x20, %rdx
cmpl %ebp, %ecx
jne 0x3645
movl %ecx, %ebp
cmpl %ecx, %ebp
jne 0x36a7
cmpl $0x0, 0x4b07(%rip)      # 0x816c
js 0x3737
callq 0x23a3
jmp 0x3737
movb $0x1, %al
cmpb $0x1, 0x4b02(%rip)      # 0x8180
jne 0x36fc
cmpl $0x0, 0x4ae5(%rip)      # 0x816c
jle 0x3737
callq 0x23f7
jmp 0x3737
movq %r14, %rdi
movq %rbx, %rsi
callq 0x22e2
jmp 0x3520
decl %ebp
movl %eax, 0x4(%rbx)
cmpl %ebp, %eax
jge 0x35b4
movq %r14, %rdi
movq %rbx, %rsi
callq 0x39a6
testb %al, %al
je 0x3737
movl 0x4(%rbx), %eax
incl %eax
jmp 0x36a9
leal -0x1(%r15), %ebp
movl 0x4(%rbx), %eax
decl %eax
movl %eax, 0x4(%rbx)
cmpl %r15d, %eax
jle 0x3716
movq %r14, %rdi
movq %rbx, %rsi
callq 0x39a6
movl %eax, %ecx
xorl %eax, %eax
testb %cl, %cl
jne 0x36ce
jmp 0x3739
movl (%rbx), %eax
testl %eax, %eax
jle 0x372e
decl %eax
movl %eax, (%rbx)
xorl %eax, %eax
movb %al, 0x4a7e(%rip)       # 0x8180
movb $0x1, %al
jmp 0x3739
cmpl $0x0, 0x4a5f(%rip)      # 0x816c
js 0x3737
callq 0x24fc
jmp 0x3737
movl %ebp, 0x4(%rbx)
jmp 0x35b4
cmpl $0x0, 0x4a47(%rip)      # 0x816c
jle 0x3737
callq 0x24a5
jmp 0x3737
cmpl $0x0, 0x4a37(%rip)      # 0x816c
jg 0x3744
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
callq 0x244e
jmp 0x3737
nop