// File: /workspace/github_c_makefile_star2_O1/ajpaulson[P]srogue11/move.c
// Function: do_move
int do_move(int dy,int dx)
{
	int ch;
	struct room *rp;

	firstmove = FALSE;
	curprice = -1;
	inpool = FALSE;

	if (player.t_nomove > 0) {
		player.t_nomove -= 1;
		msg("You are still stuck in the bear trap.");
		return 0;
	}
	/*
	 * Do a confused move (maybe)
	 */
	if ((rnd(100) < 80 && pl_on(ISHUH)) ||
	  (iswearing(R_DELUS) && rnd(100) < 25))
		nh = *rndmove(&player);
	else {
		nh.y = hero.y + dy;
		nh.x = hero.x + dx;
	}
	/*
	 * Check if he tried to move off the screen or make
	 *  an illegal diagonal move, and stop him if he did.
	 */
	if (!cordok(nh.y, nh.x) ||
	  (pl_off(ISETHER) && !diag_ok(&hero, &nh))) {
		after = running = FALSE;
		return 0;
	}
	if (running) {
		ch = winat(nh.y, nh.x);
		if (dead_end(ch)) {
			int gox, goy, apsg, whichway;

			gox = goy = apsg = 0;
			if (dy == 0) {
				ch = show(hero.y+1,hero.x);
				if (ch == PASSAGE) {
					apsg += 1;
					goy = 1;
				}
				ch = show(hero.y-1,hero.x);
				if (ch == PASSAGE) {
					apsg += 1;
					goy = -1;
				}
			}
			else if (dx == 0) {
				ch = show(hero.y,hero.x+1);
				if (ch == PASSAGE) {
					gox = 1;
					apsg += 1;
				}
				ch = show(hero.y,hero.x-1);
				if (ch == PASSAGE) {
					gox = -1;
					apsg += 1;
				}
			}
			if (apsg != 1) {
				running = after = FALSE;
				return 0;
			}
			else {			/* can still run here */
				nh.y = hero.y + goy;
				nh.x = hero.x + gox;
				whichway = (goy + 1) * 3 + gox + 1;
				switch(whichway) {
					case 0: runch = 'y';
					when 1: runch = 'k';
					when 2: runch = 'u';
					when 3: runch = 'h';
					when 4: runch = '.';	/* shouldn't do */
					when 5: runch = 'l';
					when 6: runch = 'b';
					when 7: runch = 'j';
					when 8: runch = 'n';
				}
			}
		}
	}
	if (running && ce(hero, nh))
		after = running = FALSE;
	ch = winat(nh.y, nh.x);
	if (pl_on(ISHELD) && ch != 'F' && ch != 'd') {
		msg("You are being held.");
		return 0;
	}
	if (pl_off(ISETHER)) {
		if (isatrap(ch)) {
			ch = be_trapped(&nh, &player);
			if (nlmove) {
				nlmove = FALSE;
				return 0;
			}
			else if (ch == POOL)
				inpool = TRUE;
		}
	 	else if (dead_end(ch)) {
			after = running = FALSE;
			return 0;
		}
		else {
			switch(ch) {
				case GOLD:	case POTION:	case SCROLL:
				case FOOD:	case WEAPON:	case ARMOR:
				case RING:	case AMULET:	case STICK:
					running = FALSE;
					take = ch;
				default:
					if (illeg_ch(ch)) {
						running = FALSE;
						mvaddch(nh.y, nh.x, FLOOR);
						teleport(rndspot, &player);
						light(&nh);
						msg("The spatial warp disappears !");
						return 0;
					}
			}
		}
	}
	rp = roomin(&nh);
	if (ch == DOOR) {		/* just stepped on a door */
		running = FALSE;
		if (rp != NULL && rf_on(rp, ISTREAS)) {
			struct linked_list *item;
			struct thing *tp;

			for (item = mlist; item != NULL; item = next(item)) {
				tp = THINGPTR(item);
				if (tp->t_room == rp)
					runto(&tp->t_pos, &hero);
			}
		}
	}
	else if (ch == STAIRS && pl_off(ISETHER))
		running = FALSE;
	else if (isalpha(ch) && pl_off(ISETHER)) {
		running = FALSE;
		fight(&nh, cur_weapon, FALSE);
		return 0;
	}
	if (rp == NULL && player.t_room != NULL)
		light(&hero);		/* exiting a room */
	else if (rp != NULL && player.t_room == NULL)
		light(&nh);			/* just entering a room */
	if (pl_on(ISBLIND))
		ch = ' ';
	else
		ch = player.t_oldch;
	mvwaddch(cw, hero.y, hero.x, ch);
	mvwaddch(cw, nh.y, nh.x, PLAYER);
	hero = nh;
	player.t_room = rp;
	player.t_oldch = mvinch(hero.y, hero.x);
  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
leaq 0x1fabe(%rip), %rax     # 0x2d89f
xorl %ecx, %ecx
movb %cl, (%rax)
leaq 0x1c508(%rip), %rax     # 0x2a2f4
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
leaq 0x1faa1(%rip), %r14     # 0x2d89a
movb %cl, (%r14)
leaq 0x1fe5d(%rip), %r12     # 0x2dc60
movl 0x84(%r12), %eax
testl %eax, %eax
jle 0xde2c
decl %eax
movl %eax, 0x84(%r12)
leaq 0x13264(%rip), %rdi     # 0x21084
xorl %eax, %eax
callq 0xb6e0
jmp 0xe33b
movl %esi, %ebx
movl %edi, %ebp
movl $0x64, %edi
xorl %eax, %eax
callq 0xc72d
cmpl $0x4f, %eax
jg 0xde4f
movl $0x200, %edi            # imm = 0x200
callq 0x9595
testb %al, %al
jne 0xde6e
movl $0xf, %edi
callq 0x12d9c
testb %al, %al
je 0xde8a
movl $0x64, %edi
xorl %eax, %eax
callq 0xc72d
cmpl $0x18, %eax
jg 0xde8a
leaq 0x1fdeb(%rip), %rdi     # 0x2dc60
callq 0xf524
movq 0x25027(%rip), %rax     # 0x32ea8
movq %rax, 0x25018(%rip)     # 0x32ea0
jmp 0xdea4
movl 0x54(%r12), %eax
addl %ebp, %eax
movl %eax, 0x2500d(%rip)     # 0x32ea4
movl 0x50(%r12), %eax
addl %ebx, %eax
movl %eax, 0x24ffc(%rip)     # 0x32ea0
movl 0x24ffa(%rip), %edi     # 0x32ea4
movl 0x24ff0(%rip), %esi     # 0x32ea0
callq 0x9571
testb %al, %al
je 0xdf22
movl $0x10000, %edi          # imm = 0x10000
callq 0x95a4
testb %al, %al
je 0xdedc
leaq 0x50(%r12), %rdi
leaq 0x24fcd(%rip), %rsi     # 0x32ea0
callq 0x74e2
testb %al, %al
je 0xdf22
leaq 0x1f9b9(%rip), %r15     # 0x2d89c
cmpb $0x1, (%r15)
jne 0xe010
movl 0x24fb1(%rip), %edi     # 0x32ea4
movl 0x24fa7(%rip), %esi     # 0x32ea0
callq 0x9514
movsbl %al, %edi
callq 0xb9da
testb %al, %al
je 0xe010
testl %ebp, %ebp
je 0xdf3b
xorl %r13d, %r13d
testl %ebx, %ebx
je 0xdf7a
xorl %eax, %eax
xorl %ecx, %ecx
jmp 0xdfb3
leaq 0x1f973(%rip), %rax     # 0x2d89c
xorl %ecx, %ecx
movb %cl, (%rax)
leaq 0x1c3d9(%rip), %rax     # 0x2a30d
movb %cl, (%rax)
jmp 0xe33b
movl 0x50(%r12), %esi
movl 0x54(%r12), %edi
incl %edi
callq 0xe3c4
xorl %ebx, %ebx
cmpb $0x23, %al
sete %bl
movl 0x50(%r12), %esi
movl 0x54(%r12), %edi
decl %edi
callq 0xe3c4
cmpb $0x23, %al
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
cmovnel %ebx, %r13d
leal 0x1(%rbx), %ecx
cmovnel %ebx, %ecx
xorl %eax, %eax
jmp 0xdfb3
movl 0x50(%r12), %esi
movl 0x54(%r12), %edi
incl %esi
callq 0xe3c4
xorl %ebx, %ebx
cmpb $0x23, %al
sete %bl
movl 0x50(%r12), %esi
movl 0x54(%r12), %edi
decl %esi
callq 0xe3c4
leal 0x1(%rbx), %ecx
cmpb $0x23, %al
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmovnel %ebx, %eax
cmovnel %ebx, %ecx
cmpl $0x1, %ecx
jne 0xdff9
movl %r13d, %edx
addl 0x54(%r12), %edx
movl %edx, 0x24ede(%rip)     # 0x32ea4
movl %eax, %edx
addl 0x50(%r12), %edx
movl %edx, 0x24ecd(%rip)     # 0x32ea0
leal (%r13,%r13,2), %edx
addl %edx, %eax
addl $0x4, %eax
leaq 0x1307c(%rip), %rdx     # 0x21060
movslq (%rdx,%rax,4), %rax
addq %rdx, %rax
jmpq *%rax
leaq 0x1fe81(%rip), %rax     # 0x2de75
movb $0x79, (%rax)
jmp 0xe007
leaq 0x1c30d(%rip), %rax     # 0x2a30d
xorl %edx, %edx
movb %dl, (%rax)
movb %dl, (%r15)
cmpl $0x1, %ecx
jne 0xe33b
cmpb $0x1, (%r15)
jne 0xe03e
movl 0x50(%r12), %eax
cmpl 0x24e7f(%rip), %eax     # 0x32ea0
jne 0xe03e
movl 0x54(%r12), %eax
cmpl 0x24e76(%rip), %eax     # 0x32ea4
jne 0xe03e
xorl %eax, %eax
movb %al, (%r15)
leaq 0x1c2d1(%rip), %rcx     # 0x2a30d
movb %al, (%rcx)
movl 0x24e60(%rip), %edi     # 0x32ea4
movl 0x24e56(%rip), %esi     # 0x32ea0
callq 0x9514
movl %eax, %ebx
movl $0x100, %edi            # imm = 0x100
callq 0x9595
testb %al, %al
je 0xe06c
cmpb $0x46, %bl
je 0xe06c
movzbl %bl, %eax
cmpl $0x64, %eax
jne 0xe0d5
movsbl %bl, %r13d
movl $0x10000, %edi          # imm = 0x10000
callq 0x95a4
testb %al, %al
je 0xe18c
movsbl %bl, %ebp
movl %ebp, %edi
callq 0xe4fd
testb %al, %al
je 0xe0b7
leaq 0x24e09(%rip), %rdi     # 0x32ea0
leaq 0x1fbc2(%rip), %rsi     # 0x2dc60
callq 0xe528
leaq 0x1f7ef(%rip), %rcx     # 0x2d899
cmpb $0x1, (%rcx)
jne 0xe0e1
movb $0x0, (%rcx)
jmp 0xe33b
movl %ebp, %edi
callq 0xb9da
testb %al, %al
je 0xe0f8
xorl %eax, %eax
movb %al, (%r15)
leaq 0x1c23f(%rip), %rcx     # 0x2a30d
movb %al, (%rcx)
jmp 0xe33b
leaq 0x11499(%rip), %rdi     # 0x1f575
jmp 0xde20
cmpb $0x22, %al
jne 0xe188
movb $0x1, (%r14)
movl $0x22, %r13d
jmp 0xe18c
movzbl %bl, %edi
leal -0x21(%rdi), %eax
cmpl $0x3c, %eax
ja 0xe120
movabsq $0x1000000052004b01, %rcx # imm = 0x1000000052004B01
btq %rax, %rcx
jae 0xe120
movb $0x0, (%r15)
leaq 0x1fd56(%rip), %rax     # 0x2de74
movb %bl, (%rax)
callq 0xbd58
testb %al, %al
je 0xe18c
movb $0x0, (%r15)
movq 0x1bdfc(%rip), %rbx     # 0x29f30
movq (%rbx), %rdi
movl 0x24d67(%rip), %esi     # 0x32ea4
movl 0x24d5d(%rip), %edx     # 0x32ea0
callq 0x6490
cmpl $-0x1, %eax
je 0xe15a
movq (%rbx), %rdi
movl $0x2e, %esi
callq 0x64c0
leaq 0x1c24f(%rip), %rax     # 0x2a3b0
movq (%rax), %rdi
leaq 0x1faf5(%rip), %rsi     # 0x2dc60
callq 0x1d5fa
leaq 0x24d29(%rip), %rdi     # 0x32ea0
callq 0xecbc
leaq 0x12f27(%rip), %rdi     # 0x210aa
jmp 0xde20
movsbl %al, %r13d
leaq 0x24d0d(%rip), %r14     # 0x32ea0
movq %r14, %rdi
callq 0x7052
movq %rax, %rbx
cmpl $0x25, %r13d
je 0xe203
cmpl $0x2b, %r13d
jne 0xe217
movb $0x0, (%r15)
testq %rbx, %rbx
je 0xe258
movl $0x4, %esi
movq %rbx, %rdi
callq 0x13e74
testl %eax, %eax
sete %al
leaq 0x1f670(%rip), %rcx     # 0x2d840
movq (%rcx), %r13
testq %r13, %r13
sete %cl
orb %al, %cl
jne 0xe258
leaq 0x50(%r12), %r15
movq 0x10(%r13), %rdi
cmpq %rbx, 0x70(%rdi)
jne 0xe1f8
addq $0x50, %rdi
movq %r15, %rsi
callq 0x7571
movq (%r13), %r13
testq %r13, %r13
jne 0xe1e2
jmp 0xe258
movl $0x10000, %edi          # imm = 0x10000
callq 0x95a4
testb %al, %al
je 0xe217
movb $0x0, (%r15)
jmp 0xe258
callq 0x65b0
movq (%rax), %rax
movslq %r13d, %rcx
testb $0x4, 0x1(%rax,%rcx,2)
je 0xe258
movl $0x10000, %edi          # imm = 0x10000
callq 0x95a4
testb %al, %al
je 0xe258
movb $0x0, (%r15)
leaq 0x1f60e(%rip), %rax     # 0x2d850
movq (%rax), %rsi
leaq 0x24c54(%rip), %rdi     # 0x32ea0
xorl %edx, %edx
callq 0x99cc
jmp 0xe33b
testq %rbx, %rbx
sete %cl
movq 0x70(%r12), %rax
testq %rax, %rax
setne %dl
testb %dl, %cl
je 0xe274
leaq 0x50(%r12), %r14
jmp 0xe286
testq %rbx, %rbx
setne %cl
testq %rax, %rax
sete %al
andb %cl, %al
cmpb $0x1, %al
jne 0xe28e
movq %r14, %rdi
callq 0xecbc
movl $0x1, %edi
callq 0x9595
movl %eax, %r14d
movsbl 0x8f(%r12), %ebp
leaq 0x22735(%rip), %r15     # 0x309e0
movq (%r15), %rdi
movl 0x50(%r12), %edx
movl 0x54(%r12), %esi
callq 0x6490
cmpl $-0x1, %eax
je 0xe2d7
testb %r14b, %r14b
movl $0x20, %eax
cmovnel %eax, %ebp
movq (%r15), %rdi
movl %ebp, %esi
callq 0x64c0
movq (%r15), %rdi
movl 0x24bc4(%rip), %esi     # 0x32ea4
movl 0x24bba(%rip), %edx     # 0x32ea0
callq 0x6490
cmpl $-0x1, %eax
je 0xe2fd
movq (%r15), %rdi
movl $0x40, %esi
callq 0x64c0
movq 0x24b9c(%rip), %rdx     # 0x32ea0
movq %rdx, 0x50(%r12)
movq %rbx, 0x70(%r12)
movq 0x1bc1b(%rip), %rbx     # 0x29f30
movq (%rbx), %rdi
movl 0x54(%r12), %esi
callq 0x6490
cmpl $-0x1, %eax
je 0xe331
movq (%rbx), %rdi
callq 0x6330
jmp 0xe333
movb $-0x1, %al
movb %al, 0x8f(%r12)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1fb22(%rip), %rax     # 0x2de75
movb $0x2e, (%rax)
jmp 0xe007
leaq 0x1fb13(%rip), %rax     # 0x2de75
movb $0x75, (%rax)
jmp 0xe007
leaq 0x1fb04(%rip), %rax     # 0x2de75
movb $0x68, (%rax)
jmp 0xe007
leaq 0x1faf5(%rip), %rax     # 0x2de75
movb $0x6a, (%rax)
jmp 0xe007
leaq 0x1fae6(%rip), %rax     # 0x2de75
movb $0x6b, (%rax)
jmp 0xe007
leaq 0x1fad7(%rip), %rax     # 0x2de75
movb $0x6c, (%rax)
jmp 0xe007
leaq 0x1fac8(%rip), %rax     # 0x2de75
movb $0x62, (%rax)
jmp 0xe007
leaq 0x1fab9(%rip), %rax     # 0x2de75
movb $0x6e, (%rax)
jmp 0xe007