// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x50, %rsp
movl %edi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
leaq 0x25c8a(%rip), %rax     # 0x36d0f
movb $0x0, (%rax)
leaq 0x22265(%rip), %rax     # 0x332f4
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
leaq 0x25c6e(%rip), %rax     # 0x36d0a
movb $0x0, (%rax)
leaq 0x2602a(%rip), %rax     # 0x370d0
cmpl $0x0, 0x84(%rax)
jle 0x110e6
leaq 0x2601a(%rip), %rax     # 0x370d0
movl 0x84(%rax), %ecx
subl $0x1, %ecx
leaq 0x2600a(%rip), %rax     # 0x370d0
movl %ecx, 0x84(%rax)
leaq 0x1a5b1(%rip), %rdi     # 0x2b684
movb $0x0, %al
callq 0xd8f0
movl $0x0, -0x4(%rbp)
jmp 0x118a9
movl $0x64, %edi
movb $0x0, %al
callq 0xef20
cmpl $0x50, %eax
jge 0x11105
movl $0x200, %edi            # imm = 0x200
callq 0xaa60
testb $0x1, %al
jne 0x11126
movl $0xf, %edi
callq 0x18220
testb $0x1, %al
jne 0x11115
jmp 0x1113e
movl $0x64, %edi
movb $0x0, %al
callq 0xef20
cmpl $0x19, %eax
jge 0x1113e
leaq 0x25fa3(%rip), %rdi     # 0x370d0
callq 0x12f00
movq (%rax), %rax
movq %rax, 0x2b1d4(%rip)     # 0x3c310
jmp 0x11164
leaq 0x25f8b(%rip), %rax     # 0x370d0
movl 0x54(%rax), %eax
addl -0x8(%rbp), %eax
movl %eax, 0x2b1c3(%rip)     # 0x3c314
leaq 0x25f78(%rip), %rax     # 0x370d0
movl 0x50(%rax), %eax
addl -0xc(%rbp), %eax
movl %eax, 0x2b1ac(%rip)     # 0x3c310
movl 0x2b1aa(%rip), %edi     # 0x3c314
movl 0x2b1a0(%rip), %esi     # 0x3c310
callq 0xaa10
testb $0x1, %al
jne 0x1117b
jmp 0x111a6
movl $0x10000, %edi          # imm = 0x10000
callq 0xaa90
testb $0x1, %al
jne 0x1118b
jmp 0x111c6
leaq 0x25f3e(%rip), %rdi     # 0x370d0
addq $0x50, %rdi
leaq 0x2b173(%rip), %rsi     # 0x3c310
callq 0x7b00
testb $0x1, %al
jne 0x111c6
leaq 0x25b5f(%rip), %rax     # 0x36d0c
movb $0x0, (%rax)
leaq 0x22156(%rip), %rax     # 0x3330d
movb $0x0, (%rax)
movl $0x0, -0x4(%rbp)
jmp 0x118a9
leaq 0x25b3f(%rip), %rax     # 0x36d0c
testb $0x1, (%rax)
je 0x113f8
movl 0x2b138(%rip), %edi     # 0x3c314
movl 0x2b12e(%rip), %esi     # 0x3c310
callq 0xa960
movsbl %al, %eax
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %eax
movsbl %al, %edi
callq 0xdca0
testb $0x1, %al
jne 0x11201
jmp 0x113f6
movl $0x0, -0x24(%rbp)
movl $0x0, -0x20(%rbp)
movl $0x0, -0x1c(%rbp)
cmpl $0x0, -0x8(%rbp)
jne 0x1128e
leaq 0x25ead(%rip), %rax     # 0x370d0
movl 0x54(%rax), %edi
addl $0x1, %edi
leaq 0x25ea0(%rip), %rax     # 0x370d0
movl 0x50(%rax), %esi
callq 0x118c0
movsbl %al, %eax
movl %eax, -0x10(%rbp)
cmpl $0x23, -0x10(%rbp)
jne 0x11254
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
movl $0x1, -0x20(%rbp)
leaq 0x25e75(%rip), %rax     # 0x370d0
movl 0x54(%rax), %edi
subl $0x1, %edi
leaq 0x25e68(%rip), %rax     # 0x370d0
movl 0x50(%rax), %esi
callq 0x118c0
movsbl %al, %eax
movl %eax, -0x10(%rbp)
cmpl $0x23, -0x10(%rbp)
jne 0x1128c
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
movl $0xffffffff, -0x20(%rbp) # imm = 0xFFFFFFFF
jmp 0x11308
cmpl $0x0, -0xc(%rbp)
jne 0x11306
leaq 0x25e35(%rip), %rax     # 0x370d0
movl 0x54(%rax), %edi
leaq 0x25e2b(%rip), %rax     # 0x370d0
movl 0x50(%rax), %esi
addl $0x1, %esi
callq 0x118c0
movsbl %al, %eax
movl %eax, -0x10(%rbp)
cmpl $0x23, -0x10(%rbp)
jne 0x112cc
movl $0x1, -0x1c(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
leaq 0x25dfd(%rip), %rax     # 0x370d0
movl 0x54(%rax), %edi
leaq 0x25df3(%rip), %rax     # 0x370d0
movl 0x50(%rax), %esi
subl $0x1, %esi
callq 0x118c0
movsbl %al, %eax
movl %eax, -0x10(%rbp)
cmpl $0x23, -0x10(%rbp)
jne 0x11304
movl $0xffffffff, -0x1c(%rbp) # imm = 0xFFFFFFFF
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x11306
jmp 0x11308
cmpl $0x1, -0x24(%rbp)
je 0x1132e
leaq 0x21ff8(%rip), %rax     # 0x3330d
movb $0x0, (%rax)
leaq 0x259ed(%rip), %rax     # 0x36d0c
movb $0x0, (%rax)
movl $0x0, -0x4(%rbp)
jmp 0x118a9
leaq 0x25d9b(%rip), %rax     # 0x370d0
movl 0x54(%rax), %ecx
movl -0x20(%rbp), %edx
addl %edx, %ecx
movl %ecx, 0x2afd1(%rip)     # 0x3c314
movl 0x50(%rax), %eax
movl -0x1c(%rbp), %ecx
addl %ecx, %eax
movl %eax, 0x2afbf(%rip)     # 0x3c310
movl -0x20(%rbp), %edx
movl -0x1c(%rbp), %ecx
movl %ecx, %eax
movl %edx, %ecx
leal (%rcx,%rcx,2), %edx
movl %edx, %ecx
leal 0x4(%rax,%rcx), %eax
movl %eax, -0x28(%rbp)
movl -0x28(%rbp), %eax
movq %rax, -0x40(%rbp)
subq $0x8, %rax
ja 0x113f2
movq -0x40(%rbp), %rax
leaq 0x1a2e1(%rip), %rcx     # 0x2b660
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x25f56(%rip), %rax     # 0x372e5
movb $0x79, (%rax)
jmp 0x113f2
leaq 0x25f4a(%rip), %rax     # 0x372e5
movb $0x6b, (%rax)
jmp 0x113f2
leaq 0x25f3e(%rip), %rax     # 0x372e5
movb $0x75, (%rax)
jmp 0x113f2
leaq 0x25f32(%rip), %rax     # 0x372e5
movb $0x68, (%rax)
jmp 0x113f2
leaq 0x25f26(%rip), %rax     # 0x372e5
movb $0x2e, (%rax)
jmp 0x113f2
leaq 0x25f1a(%rip), %rax     # 0x372e5
movb $0x6c, (%rax)
jmp 0x113f2
leaq 0x25f0e(%rip), %rax     # 0x372e5
movb $0x62, (%rax)
jmp 0x113f2
leaq 0x25f02(%rip), %rax     # 0x372e5
movb $0x6a, (%rax)
jmp 0x113f2
leaq 0x25ef6(%rip), %rax     # 0x372e5
movb $0x6e, (%rax)
jmp 0x113f4
jmp 0x113f6
jmp 0x113f8
leaq 0x2590d(%rip), %rax     # 0x36d0c
testb $0x1, (%rax)
je 0x1143c
leaq 0x25cc5(%rip), %rax     # 0x370d0
movl 0x50(%rax), %eax
cmpl 0x2aefc(%rip), %eax     # 0x3c310
jne 0x1143c
leaq 0x25cb3(%rip), %rax     # 0x370d0
movl 0x54(%rax), %eax
cmpl 0x2aeee(%rip), %eax     # 0x3c314
jne 0x1143c
leaq 0x258dd(%rip), %rax     # 0x36d0c
movb $0x0, (%rax)
leaq 0x21ed4(%rip), %rax     # 0x3330d
movb $0x0, (%rax)
movl 0x2aed2(%rip), %edi     # 0x3c314
movl 0x2aec8(%rip), %esi     # 0x3c310
callq 0xa960
movsbl %al, %eax
movl %eax, -0x10(%rbp)
movl $0x100, %edi            # imm = 0x100
callq 0xaa60
testb $0x1, %al
jne 0x11463
jmp 0x11489
cmpl $0x46, -0x10(%rbp)
je 0x11489
cmpl $0x64, -0x10(%rbp)
je 0x11489
leaq 0x18457(%rip), %rdi     # 0x298cd
movb $0x0, %al
callq 0xd8f0
movl $0x0, -0x4(%rbp)
jmp 0x118a9
movl $0x10000, %edi          # imm = 0x10000
callq 0xaa90
testb $0x1, %al
jne 0x1149c
jmp 0x11633
movl -0x10(%rbp), %eax
movsbl %al, %edi
callq 0x11a80
testb $0x1, %al
jne 0x114ad
jmp 0x114ff
leaq 0x2ae5c(%rip), %rdi     # 0x3c310
leaq 0x25c15(%rip), %rsi     # 0x370d0
callq 0x11b00
movsbl %al, %eax
movl %eax, -0x10(%rbp)
leaq 0x2583c(%rip), %rax     # 0x36d09
testb $0x1, (%rax)
je 0x114e8
leaq 0x25830(%rip), %rax     # 0x36d09
movb $0x0, (%rax)
movl $0x0, -0x4(%rbp)
jmp 0x118a9
cmpl $0x22, -0x10(%rbp)
jne 0x114f8
leaq 0x25815(%rip), %rax     # 0x36d0a
movb $0x1, (%rax)
jmp 0x114fa
jmp 0x11631
movl -0x10(%rbp), %eax
movsbl %al, %edi
callq 0xdca0
testb $0x1, %al
jne 0x11510
jmp 0x11530
leaq 0x257f5(%rip), %rax     # 0x36d0c
movb $0x0, (%rax)
leaq 0x21dec(%rip), %rax     # 0x3330d
movb $0x0, (%rax)
movl $0x0, -0x4(%rbp)
jmp 0x118a9
movl -0x10(%rbp), %eax
movl %eax, -0x44(%rbp)
subl $0x21, %eax
je 0x11586
jmp 0x1153d
movl -0x44(%rbp), %eax
addl $-0x29, %eax
subl $0x2, %eax
jb 0x11586
jmp 0x1154a
movl -0x44(%rbp), %eax
subl $0x2c, %eax
je 0x11586
jmp 0x11554
movl -0x44(%rbp), %eax
subl $0x2f, %eax
je 0x11586
jmp 0x1155e
movl -0x44(%rbp), %eax
subl $0x3a, %eax
je 0x11586
jmp 0x11568
movl -0x44(%rbp), %eax
subl $0x3d, %eax
je 0x11586
jmp 0x11572
movl -0x44(%rbp), %eax
subl $0x3f, %eax
je 0x11586
jmp 0x1157c
movl -0x44(%rbp), %eax
subl $0x5d, %eax
jne 0x1159e
jmp 0x11586
leaq 0x2577f(%rip), %rax     # 0x36d0c
movb $0x0, (%rax)
movl -0x10(%rbp), %eax
movb %al, %cl
leaq 0x25d48(%rip), %rax     # 0x372e4
movb %cl, (%rax)
movl -0x10(%rbp), %eax
movzbl %al, %edi
callq 0xe220
testb $0x1, %al
jne 0x115af
jmp 0x1162b
leaq 0x25756(%rip), %rax     # 0x36d0c
movb $0x0, (%rax)
movq 0x21a00(%rip), %rax     # 0x32fc0
movq (%rax), %rdi
movl 0x2ad4b(%rip), %esi     # 0x3c314
movl 0x2ad41(%rip), %edx     # 0x3c310
callq 0x6490
cmpl $-0x1, %eax
jne 0x115db
jmp 0x115ef
movq 0x219de(%rip), %rax     # 0x32fc0
movq (%rax), %rdi
movl $0x2e, %esi
callq 0x64c0
leaq 0x21dba(%rip), %rax     # 0x333b0
movq (%rax), %rdi
leaq 0x25ad0(%rip), %rsi     # 0x370d0
callq 0x26c70
leaq 0x2ad04(%rip), %rdi     # 0x3c310
callq 0x123b0
leaq 0x1a092(%rip), %rdi     # 0x2b6aa
movb $0x0, %al
callq 0xd8f0
movl $0x0, -0x4(%rbp)
jmp 0x118a9
jmp 0x1162d
jmp 0x1162f
jmp 0x11631
jmp 0x11633
leaq 0x2acd6(%rip), %rdi     # 0x3c310
callq 0x7560
movq %rax, -0x18(%rbp)
cmpl $0x2b, -0x10(%rbp)
jne 0x116c7
leaq 0x256bc(%rip), %rax     # 0x36d0c
movb $0x0, (%rax)
cmpq $0x0, -0x18(%rbp)
je 0x116c5
movq -0x18(%rbp), %rdi
movl $0x4, %esi
callq 0x19950
cmpl $0x0, %eax
je 0x116c5
leaq 0x2563c(%rip), %rax     # 0x36cb0
movq (%rax), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x116c3
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq 0x70(%rax), %rax
cmpq -0x18(%rbp), %rax
jne 0x116b4
movq -0x38(%rbp), %rdi
addq $0x50, %rdi
leaq 0x25a25(%rip), %rsi     # 0x370d0
addq $0x50, %rsi
callq 0x7bf0
jmp 0x116b6
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
jmp 0x1167b
jmp 0x116c5
jmp 0x11745
cmpl $0x25, -0x10(%rbp)
jne 0x116e9
movl $0x10000, %edi          # imm = 0x10000
callq 0xaa90
testb $0x1, %al
jne 0x116dd
jmp 0x116e9
leaq 0x25628(%rip), %rax     # 0x36d0c
movb $0x0, (%rax)
jmp 0x11743
callq 0x65b0
movq (%rax), %rax
movslq -0x10(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x400, %eax            # imm = 0x400
cmpl $0x0, %eax
je 0x11741
movl $0x10000, %edi          # imm = 0x10000
callq 0xaa90
testb $0x1, %al
jne 0x11713
jmp 0x11741
leaq 0x255f2(%rip), %rax     # 0x36d0c
movb $0x0, (%rax)
leaq 0x2559c(%rip), %rax     # 0x36cc0
movq (%rax), %rsi
leaq 0x2abe2(%rip), %rdi     # 0x3c310
xorl %edx, %edx
callq 0xb220
movl $0x0, -0x4(%rbp)
jmp 0x118a9
jmp 0x11743
jmp 0x11745
cmpq $0x0, -0x18(%rbp)
jne 0x1176c
leaq 0x2597d(%rip), %rax     # 0x370d0
cmpq $0x0, 0x70(%rax)
je 0x1176c
leaq 0x2596f(%rip), %rdi     # 0x370d0
addq $0x50, %rdi
callq 0x123b0
jmp 0x1178f
cmpq $0x0, -0x18(%rbp)
je 0x1178d
leaq 0x25956(%rip), %rax     # 0x370d0
cmpq $0x0, 0x70(%rax)
jne 0x1178d
leaq 0x2ab88(%rip), %rdi     # 0x3c310
callq 0x123b0
jmp 0x1178f
movl $0x1, %edi
callq 0xaa60
testb $0x1, %al
jne 0x1179f
jmp 0x117a8
movl $0x20, -0x10(%rbp)
jmp 0x117b9
leaq 0x25921(%rip), %rax     # 0x370d0
movsbl 0x8f(%rax), %eax
movl %eax, -0x10(%rbp)
leaq 0x28690(%rip), %rax     # 0x39e50
movq (%rax), %rdi
leaq 0x25906(%rip), %rax     # 0x370d0
movl 0x54(%rax), %esi
leaq 0x258fc(%rip), %rax     # 0x370d0
movl 0x50(%rax), %edx
callq 0x6490
cmpl $-0x1, %eax
jne 0x117e3
jmp 0x117f5
leaq 0x28666(%rip), %rax     # 0x39e50
movq (%rax), %rdi
movl -0x10(%rbp), %esi
callq 0x64c0
leaq 0x28654(%rip), %rax     # 0x39e50
movq (%rax), %rdi
movl 0x2ab0f(%rip), %esi     # 0x3c314
movl 0x2ab05(%rip), %edx     # 0x3c310
callq 0x6490
cmpl $-0x1, %eax
jne 0x11817
jmp 0x1182b
leaq 0x28632(%rip), %rax     # 0x39e50
movq (%rax), %rdi
movl $0x40, %esi
callq 0x64c0
leaq 0x2589e(%rip), %rax     # 0x370d0
movq 0x2aad7(%rip), %rcx     # 0x3c310
movq %rcx, 0x50(%rax)
movq -0x18(%rbp), %rcx
leaq 0x25888(%rip), %rax     # 0x370d0
movq %rcx, 0x70(%rax)
movq 0x2176d(%rip), %rax     # 0x32fc0
movq (%rax), %rdi
leaq 0x25873(%rip), %rax     # 0x370d0
movl 0x54(%rax), %esi
leaq 0x25869(%rip), %rax     # 0x370d0
movl 0x50(%rax), %edx
callq 0x6490
cmpl $-0x1, %eax
jne 0x1187e
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0x48(%rbp)
jmp 0x11890
movq 0x2173b(%rip), %rax     # 0x32fc0
movq (%rax), %rdi
callq 0x6340
movl %eax, -0x48(%rbp)
movl -0x48(%rbp), %eax
movb %al, %cl
leaq 0x25834(%rip), %rax     # 0x370d0
movb %cl, 0x8f(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)