// File: /workspace/github_cpp_makefile_star2_O3/hobbitsyfeet[P]Turn/turn.cc
// Function: Turn::movePlayer(Unit&, Chart&)
void Turn::movePlayer(Unit& player, Chart& world){
	string option;
			bool spawning;
			int dist;
			cout<<"which way>>";
			cin>>option;
			cout<<"how much>>"<<endl;

			cin>>dist;
			world.setCanEnter(player.getPosX(),player.getPosY(),false);
			if(option == "north" || option == "up"){
				for(int i =0; i<dist;i++){
					//cout<<i;
					if( world.canEnter(player.getPosX(), player.getPosY()+1 ) ==false ){
						///increment Y
					player.posY += 1;
					world.isPortal(player.getPosX(),player.getPosY(),spawning);
						if(spawning == true){
							world.setSpawn('O',player.posX,player.posY);
							spawning = false;
							break;
						}
					}
					else{
						break;
					}
				}
				world.setCanEnter(player.getPosX(),player.getPosY(),true);
			}

			else if(option == "east" || option == "right"){
				for(int i =0; i<dist;i++){
					if( world.canEnter(player.getPosX()+1, player.getPosY() ) ==false ){
						//increment X
						player.posX += 1;
						world.isPortal(player.getPosX(),player.getPosY(),spawning);
						if(spawning == true){
							world.setSpawn('O',player.posX,player.posY);
							spawning = false;
							break;
						}
					}
					else{
						break;
						}
				}
				world.setCanEnter(player.getPosX(),player.getPosY(),true);
			}

			else if(option == "south" || option == "down"){
				for(int i =0; i<dist;i++){
					if( world.canEnter(player.getPosX(), player.getPosY()-1 ) ==false ){
						//decrement Y
					player.posY -=1;
					world.isPortal(player.getPosX(),player.getPosY(),spawning);
						if(spawning == true){
							world.setSpawn('O',player.posX,player.posY);
							spawning = false;
							break;
						}
					}
					else{
						break;
						}
				}
				world.setCanEnter(player.getPosX(),player.getPosY(),true);
			}

			else if(option == "west" || option == "left"){
				for(int i =0; i<dist;i++){
					if( world.canEnter(player.getPosX()-1, player.getPosY() ) ==false ){
						//decrement X
						player.posX -=1;
						world.isPortal(player.getPosX(),player.getPosY(),spawning);
						if(spawning == true){
							world.setSpawn('O',player.posX,player.posY);
							spawning = false;
							break;
						}
					}
					else{
						break;
						return;
					}
				}
				world.setCanEnter(player.getPosX(),player.getPosY(),true);
			}
			cout<<world.getChartName()<<endl;
			world.displayRange(player.getPosX(),player.getPosY(),5);
			player.setCurrentWorld(world.getChartName());
			//cout<<"you are at:"<<player.getCurrentWorld();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rdx, %r14
movq %rsi, %rbx
leaq -0x48(%rbp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq 0x7b79(%rip), %rdi      # 0xefd0
leaq 0x423a(%rip), %rsi      # 0xb698
movl $0xb, %edx
callq 0x2230
movq 0x7b71(%rip), %rdi      # 0xefe0
leaq -0x58(%rbp), %rsi
callq 0x2250
movq 0x7b51(%rip), %r15      # 0xefd0
leaq 0x421e(%rip), %rsi      # 0xb6a4
movl $0xa, %edx
movq %r15, %rdi
callq 0x2230
movq (%r15), %rax
addq -0x18(%rax), %r15
movq %r15, %rdi
movl $0xa, %esi
callq 0x21e0
movsbl %al, %esi
movq 0x7b1f(%rip), %rdi      # 0xefd0
callq 0x2040
movq %rax, %rdi
callq 0x2170
movq 0x7b1b(%rip), %rdi      # 0xefe0
leaq -0x30(%rbp), %rsi
callq 0x2150
movq %rbx, %rdi
callq 0x37d6
movl %eax, %r15d
movq %rbx, %rdi
callq 0x37cc
movq %r14, %rdi
movl %r15d, %esi
movl %eax, %edx
xorl %ecx, %ecx
callq 0x86ea
leaq 0x41b8(%rip), %rsi      # 0xb6af
leaq -0x58(%rbp), %rdi
callq 0x20c0
testl %eax, %eax
je 0x762e
leaq 0x41a6(%rip), %rsi      # 0xb6b5
leaq -0x58(%rbp), %rdi
callq 0x20c0
testl %eax, %eax
je 0x762e
leaq 0x4191(%rip), %rsi      # 0xb6b8
leaq -0x58(%rbp), %rdi
callq 0x20c0
testl %eax, %eax
je 0x76af
leaq 0x417e(%rip), %rsi      # 0xb6bd
leaq -0x58(%rbp), %rdi
callq 0x20c0
testl %eax, %eax
je 0x76af
leaq 0x416c(%rip), %rsi      # 0xb6c3
leaq -0x58(%rbp), %rdi
callq 0x20c0
testl %eax, %eax
je 0x7762
leaq 0x415a(%rip), %rsi      # 0xb6c9
leaq -0x58(%rbp), %rdi
callq 0x20c0
testl %eax, %eax
je 0x7762
leaq 0x4147(%rip), %rsi      # 0xb6ce
leaq -0x58(%rbp), %rdi
callq 0x20c0
testl %eax, %eax
je 0x75ac
leaq 0x4138(%rip), %rsi      # 0xb6d3
leaq -0x58(%rbp), %rdi
callq 0x20c0
testl %eax, %eax
jne 0x7872
cmpl $0x0, -0x30(%rbp)
jle 0x784d
leaq 0x78(%rbx), %rax
movq %rax, -0x38(%rbp)
xorl %r15d, %r15d
leaq -0x29(%rbp), %r12
movq %rbx, %rdi
callq 0x37d6
movl %eax, %r13d
movq %rbx, %rdi
callq 0x37cc
decl %r13d
movq %r14, %rdi
movl %r13d, %esi
movl %eax, %edx
callq 0x86b8
testb %al, %al
jne 0x784d
decl 0x78(%rbx)
movq %rbx, %rdi
callq 0x37d6
movl %eax, %r13d
movq %rbx, %rdi
callq 0x37cc
movq %r14, %rdi
movl %r13d, %esi
movl %eax, %edx
movq %r12, %rcx
callq 0x8762
cmpb $0x1, -0x29(%rbp)
je 0x7834
incl %r15d
cmpl -0x30(%rbp), %r15d
jl 0x75c5
jmp 0x784d
cmpl $0x0, -0x30(%rbp)
jle 0x774a
leaq 0x7c(%rbx), %rax
movq %rax, -0x38(%rbp)
xorl %r15d, %r15d
leaq -0x29(%rbp), %r12
movq %rbx, %rdi
callq 0x37d6
movl %eax, %r13d
movq %rbx, %rdi
callq 0x37cc
incl %eax
movq %r14, %rdi
movl %r13d, %esi
movl %eax, %edx
callq 0x86b8
testb %al, %al
jne 0x774a
incl 0x7c(%rbx)
movq %rbx, %rdi
callq 0x37d6
movl %eax, %r13d
movq %rbx, %rdi
callq 0x37cc
movq %r14, %rdi
movl %r13d, %esi
movl %eax, %edx
movq %r12, %rcx
callq 0x8762
cmpb $0x1, -0x29(%rbp)
je 0x7731
incl %r15d
cmpl -0x30(%rbp), %r15d
jl 0x7647
jmp 0x774a
cmpl $0x0, -0x30(%rbp)
jle 0x77f1
leaq 0x78(%rbx), %rax
movq %rax, -0x38(%rbp)
xorl %r15d, %r15d
leaq -0x29(%rbp), %r12
movq %rbx, %rdi
callq 0x37d6
movl %eax, %r13d
movq %rbx, %rdi
callq 0x37cc
incl %r13d
movq %r14, %rdi
movl %r13d, %esi
movl %eax, %edx
callq 0x86b8
testb %al, %al
jne 0x77f1
incl 0x78(%rbx)
movq %rbx, %rdi
callq 0x37d6
movl %eax, %r13d
movq %rbx, %rdi
callq 0x37cc
movq %r14, %rdi
movl %r13d, %esi
movl %eax, %edx
movq %r12, %rcx
callq 0x8762
cmpb $0x1, -0x29(%rbp)
je 0x77d8
incl %r15d
cmpl -0x30(%rbp), %r15d
jl 0x76c8
jmp 0x77f1
leaq 0x78(%rbx), %rdx
movq %r14, %rdi
movl $0x4f, %esi
movq -0x38(%rbp), %rcx
callq 0x871c
movb $0x0, -0x29(%rbp)
movq %rbx, %rdi
callq 0x37d6
movl %eax, %r15d
movq %rbx, %rdi
callq 0x37cc
jmp 0x7860
cmpl $0x0, -0x30(%rbp)
jle 0x781f
leaq 0x7c(%rbx), %rax
movq %rax, -0x38(%rbp)
xorl %r15d, %r15d
leaq -0x29(%rbp), %r12
movq %rbx, %rdi
callq 0x37d6
movl %eax, %r13d
movq %rbx, %rdi
callq 0x37cc
decl %eax
movq %r14, %rdi
movl %r13d, %esi
movl %eax, %edx
callq 0x86b8
testb %al, %al
jne 0x781f
decl 0x7c(%rbx)
movq %rbx, %rdi
callq 0x37d6
movl %eax, %r13d
movq %rbx, %rdi
callq 0x37cc
movq %r14, %rdi
movl %r13d, %esi
movl %eax, %edx
movq %r12, %rcx
callq 0x8762
cmpb $0x1, -0x29(%rbp)
je 0x7806
incl %r15d
cmpl -0x30(%rbp), %r15d
jl 0x777b
jmp 0x781f
leaq 0x7c(%rbx), %rcx
movq %r14, %rdi
movl $0x4f, %esi
movq -0x38(%rbp), %rdx
callq 0x871c
movb $0x0, -0x29(%rbp)
movq %rbx, %rdi
callq 0x37d6
movl %eax, %r15d
movq %rbx, %rdi
callq 0x37cc
jmp 0x7860
leaq 0x78(%rbx), %rdx
movq %r14, %rdi
movl $0x4f, %esi
movq -0x38(%rbp), %rcx
callq 0x871c
movb $0x0, -0x29(%rbp)
movq %rbx, %rdi
callq 0x37d6
movl %eax, %r15d
movq %rbx, %rdi
callq 0x37cc
jmp 0x7860
leaq 0x7c(%rbx), %rcx
movq %r14, %rdi
movl $0x4f, %esi
movq -0x38(%rbp), %rdx
callq 0x871c
movb $0x0, -0x29(%rbp)
movq %rbx, %rdi
callq 0x37d6
movl %eax, %r15d
movq %rbx, %rdi
callq 0x37cc
movq %r14, %rdi
movl %r15d, %esi
movl %eax, %edx
movl $0x1, %ecx
callq 0x86ea
leaq -0x78(%rbp), %rdi
movq %r14, %rsi
callq 0x88d6
movq -0x78(%rbp), %rsi
movq -0x70(%rbp), %rdx
movq 0x7743(%rip), %rdi      # 0xefd0
callq 0x2230
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x21e0
movsbl %al, %esi
movq %r15, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
leaq -0x68(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x78d5
movq -0x68(%rbp), %rsi
incq %rsi
callq 0x2200
movq %rbx, %rdi
callq 0x37d6
movl %eax, %r15d
movq %rbx, %rdi
callq 0x37cc
movq %r14, %rdi
movl %r15d, %esi
movl %eax, %edx
movl $0x5, %ecx
callq 0x8480
leaq -0x98(%rbp), %rdi
movq %r14, %rsi
callq 0x88d6
leaq -0x98(%rbp), %rsi
movq %rbx, %rdi
callq 0x380e
leaq -0x88(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x7937
movq -0x88(%rbp), %rsi
incq %rsi
callq 0x2200
movq -0x58(%rbp), %rdi
leaq -0x48(%rbp), %rax
cmpq %rax, %rdi
je 0x7950
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x2200
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x79ab
jmp 0x79ab
jmp 0x79ab
jmp 0x79ab
movq %rax, %rbx
leaq -0x88(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x79ae
movq -0x88(%rbp), %rsi
jmp 0x799d
jmp 0x79ab
jmp 0x79ab
jmp 0x79ab
movq %rax, %rbx
leaq -0x68(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x79ae
movq -0x68(%rbp), %rsi
incq %rsi
callq 0x2200
jmp 0x79ae
jmp 0x79ab
jmp 0x79ab
movq %rax, %rbx
movq -0x58(%rbp), %rdi
leaq -0x48(%rbp), %rax
cmpq %rax, %rdi
je 0x79c7
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x2200
movq %rbx, %rdi
callq 0x2310
nop