// File: /workspace/github_c_makefile_star2_O3/ajpaulson[P]srogue11/misc.c
// Function: look
void look(bool wakeup)
{
	char ch;
	int oldx, oldy, y, x;
	struct room *rp;
	int ey, ex, oex, oey;
	int passcount = 0;
	bool inpass, blind;

	getyx(cw, oldy, oldx);
	oex = player.t_oldpos.x;
	oey = player.t_oldpos.y;
	blind = pl_on(ISBLIND);
	if ((oldrp != NULL && rf_on(oldrp,ISDARK)) || blind) {
		for (x = oex - 1; x <= oex + 1; x += 1)
			for (y = oey - 1; y <= oey + 1; y += 1)
				if ((y != hero.y || x != hero.x) && show(y, x) == FLOOR)
					mvwaddch(cw, y, x, ' ');
	}
	rp = player.t_room;
	inpass = (rp == NULL);				/* TRUE when not in a room */
	ey = hero.y + 1;
	ex = hero.x + 1;
	for (x = hero.x - 1; x <= ex; x += 1) {
		if (x >= 0 && x <= COLS - 1) {
			for (y = hero.y - 1; y <= ey; y += 1) {
				if (y <= 0 || y >= LINES - 2)
					continue;
				if (isalpha(mvwinch(mw, y, x))) {
					struct linked_list *it;
					struct thing *tp;

					if (wakeup || (!inpass && rf_on(rp, ISTREAS)))
						it = wake_monster(y, x);
					else
						it = find_mons(y, x);
					if (it == NULL)				/* lost monster */
						mvaddch(y, x, FLOOR);
					else {
						tp = THINGPTR(it);
						if (isatrap(tp->t_oldch = mvinch(y, x))) {
							struct trap *trp;

							if ((trp = trap_at(y,x)) == NULL)
								break;
							if (trp->tr_flags & ISFOUND)
								tp->t_oldch = trp->tr_type;
							else
								tp->t_oldch = FLOOR;
						}
						if (tp->t_oldch == FLOOR && rf_on(rp,ISDARK))
							if (!blind)
								tp->t_oldch = ' ';
					}
				}
				/*
				 * Secret doors show as walls
				 */
				if ((ch = show(y, x)) == SECRETDOOR) {
					if (inpass || y == rp->r_pos.y || y == rp->r_pos.y + rp->r_max.y - 1)
						ch = '-';
					else
						ch = '|';
				}
				/*
				 * Don't show room walls if he is in a passage
				 */
				if (!blind) {
					if ((y == hero.y && x == hero.x) || (inpass && (ch == '-' || ch == '|')))
						continue;
				}
				else
					ch = ' ';
				wmove(cw, y, x);
				waddch(cw, ch);
				if (door_stop && !firstmove && running) {
					switch (runch) {
						case 'h':
							if (x == ex)
								continue;
						when 'j':
							if (y == hero.y - 1)
								continue;
						when 'k':
							if (y == ey)
								continue;
						when 'l':
							if (x == hero.x - 1)
								continue;
						when 'y':
							if ((x + y) - (hero.x + hero.y) >= 1)
								continue;
						when 'u':
							if ((y - x) - (hero.y - hero.x) >= 1)
								continue;
						when 'n':
							if ((x + y) - (hero.x + hero.y) <= -1)
								continue;
						when 'b':
							if ((y - x) - (hero.y - hero.x) <= -1)
								continue;
					}
					switch (ch) {
						case DOOR:
							if (x == hero.x || y == hero.y)
								running = FALSE;
							break;
						case PASSAGE:
							if (x == hero.x || y == hero.y)
								passcount += 1;
							break;
						case FLOOR:
						case '|':
						case '-':
						case ' ':
							break;
						default:
							running = FALSE;
							break;
					}
				}
			}
		}
	}
	if (door_stop && !firstmove && passcount > 1)
		running = FALSE;
	mvwaddch(cw, hero.y, hero.x, PLAYER);
	wmove(cw, oldy, oldx);
	player.t_oldpos = hero;
	oldrp = rp;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %edi, 0x3c(%rsp)
leaq 0x23ee7(%rip), %rax     # 0x309e0
movq (%rax), %rax
testq %rax, %rax
je 0xcb12
movswl (%rax), %ecx
movl %ecx, 0x30(%rsp)
movswl 0x2(%rax), %eax
movl %eax, 0x2c(%rsp)
jmp 0xcb22
movl $0xffffffff, 0x30(%rsp) # imm = 0xFFFFFFFF
movl $0xffffffff, 0x2c(%rsp) # imm = 0xFFFFFFFF
leaq 0x21137(%rip), %r14     # 0x2dc60
movl 0x58(%r14), %r15d
movl 0x5c(%r14), %r13d
movl $0x1, %edi
callq 0x9513
movl %eax, %ebx
leaq 0x21114(%rip), %rax     # 0x2dc58
movq (%rax), %rdi
testq %rdi, %rdi
movb %bl, 0x7(%rsp)
je 0xcb67
movl $0x1, %esi
callq 0x13d18
testl %eax, %eax
setne %al
orb %bl, %al
testb $0x1, %al
jne 0xcb6b
jmp 0xcbcf
testb %bl, %bl
je 0xcbcf
leal -0x1(%r15), %ebx
leal -0x2(%r13), %ebp
movl %ebp, %r12d
incl %r12d
cmpl 0x54(%r14), %r12d
jne 0xcb85
cmpl 0x50(%r14), %ebx
je 0xcbc0
movl %r12d, %edi
movl %ebx, %esi
callq 0xe2de
cmpb $0x2e, %al
jne 0xcbc0
leaq 0x23e46(%rip), %rax     # 0x309e0
movq (%rax), %rdi
movl %r12d, %esi
movl %ebx, %edx
callq 0x6490
cmpl $-0x1, %eax
je 0xcbc0
leaq 0x23e2d(%rip), %rax     # 0x309e0
movq (%rax), %rdi
movl $0x20, %esi
callq 0x64c0
cmpl %r13d, %r12d
jle 0xcb76
leal 0x1(%rbx), %eax
cmpl %r15d, %ebx
movl %eax, %ebx
jle 0xcb73
movq 0x70(%r14), %rax
movq %rax, 0x18(%rsp)
movl 0x50(%r14), %eax
movl 0x54(%r14), %edx
leal 0x1(%rdx), %ecx
movl %ecx, 0x38(%rsp)
leal 0x1(%rax), %ecx
movl %ecx, 0x34(%rsp)
leal -0x1(%rax), %r13d
movl %eax, %ecx
negl %ecx
movl %ecx, 0x24(%rsp)
movq 0x1d3af(%rip), %rsi     # 0x29fb0
leaq 0x23de8(%rip), %r15     # 0x309f0
movq %rax, 0x40(%rsp)
movl %eax, 0x20(%rsp)
movl $0x0, 0x28(%rsp)
movq %rdx, 0x8(%rsp)
testl %r13d, %r13d
js 0xcc3c
movq 0x1d36e(%rip), %rax     # 0x29f98
cmpl (%rax), %r13d
jge 0xcc3c
movl 0x54(%r14), %ebx
leal -0x1(%rbx), %eax
cmpl 0x38(%rsp), %eax
jle 0xcc57
leal 0x1(%r13), %eax
incl 0x20(%rsp)
decl 0x24(%rsp)
cmpl 0x40(%rsp), %r13d
movl %eax, %r13d
jle 0xcc1e
jmp 0xd07c
addl $-0x2, %ebx
movq %r13, 0x10(%rsp)
movl %ebx, %ebp
leal 0x1(%rbp), %ebx
testl %ebx, %ebx
jle 0xcec2
movl (%rsi), %eax
addl $-0x2, %eax
cmpl %eax, %ebx
jge 0xcec2
callq 0x65b0
movq (%rax), %r12
movq (%r15), %rdi
movl %ebx, %esi
movl %r13d, %edx
callq 0x6490
cmpl $-0x1, %eax
je 0xcc9f
movq (%r15), %rdi
callq 0x6330
cltq
jmp 0xcca6
movq $-0x1, %rax
testb $0x4, 0x1(%r12,%rax,2)
je 0xcdc7
cmpb $0x0, 0x3c(%rsp)
jne 0xccd4
cmpq $0x0, 0x18(%rsp)
je 0xcce7
movl $0x4, %esi
movq 0x18(%rsp), %rdi
callq 0x13d18
testl %eax, %eax
je 0xcce7
movl %ebx, %edi
movq 0x10(%rsp), %r13
movl %r13d, %esi
xorl %eax, %eax
callq 0xd93f
jmp 0xccf6
movl %ebx, %edi
movq 0x10(%rsp), %r13
movl %r13d, %esi
callq 0x7502
testq %rax, %rax
movq 0x1d230(%rip), %rcx     # 0x29f30
je 0xcd29
movq 0x10(%rax), %r12
movq (%rcx), %rdi
movl %ebx, %esi
movl %r13d, %edx
callq 0x6490
cmpl $-0x1, %eax
je 0xcd55
movq 0x1d211(%rip), %rax     # 0x29f30
movq (%rax), %rdi
callq 0x6330
jmp 0xcd57
movq (%rcx), %rdi
movl %ebx, %esi
movl %r13d, %edx
callq 0x6490
cmpl $-0x1, %eax
je 0xcdc7
movq 0x1d1ea(%rip), %rax     # 0x29f30
movq (%rax), %rdi
movl $0x2e, %esi
callq 0x64c0
jmp 0xcdc7
movb $-0x1, %al
movb %al, 0x8f(%r12)
movsbl %al, %edi
callq 0xe41e
testb %al, %al
je 0xcd95
movl %ebx, %edi
movl %r13d, %esi
xorl %eax, %eax
callq 0xf3d8
testq %rax, %rax
je 0xd06b
movb $0x2e, %cl
testb $0x8, 0x10(%rax)
je 0xcd8b
movb 0x14(%rax), %cl
movb %cl, 0x8f(%r12)
jmp 0xcd9d
movb 0x8f(%r12), %cl
cmpb $0x2e, %cl
jne 0xcdc7
movl $0x1, %esi
movq 0x18(%rsp), %rdi
callq 0x13d18
testl %eax, %eax
sete %al
orb 0x7(%rsp), %al
testb $0x1, %al
jne 0xcdc7
movb $0x20, 0x8f(%r12)
movq %r14, %r13
movq %r15, %r14
movq 0x18(%rsp), %r15
testq %r15, %r15
sete %r12b
movl %ebx, %edi
movq 0x10(%rsp), %rsi
callq 0xe2de
cmpb $0x26, %al
setne %cl
movzbl %al, %eax
movl $0x2d, %edx
cmovel %edx, %eax
orb %r12b, %cl
jne 0xce1f
movl 0x4(%r15), %ecx
movb $0x2d, %al
cmpl %ecx, %ebx
je 0xce1f
movq 0x18(%rsp), %rax
movl 0xc(%rax), %eax
addl %ecx, %eax
decl %eax
cmpl %eax, %ebx
movl $0x7c, %eax
movl $0x2d, %ecx
cmovel %ecx, %eax
movb $0x20, %r12b
cmpb $0x0, 0x7(%rsp)
jne 0xce60
movq %r14, %r15
cmpl 0x54(%r13), %ebx
jne 0xce51
movq %r13, %rcx
movq 0x10(%rsp), %rdx
cmpl 0x50(%r13), %edx
jne 0xce51
movq 0x8(%rsp), %rdx
movq 0x1d164(%rip), %rsi     # 0x29fb0
movq %rcx, %r14
jmp 0xcebd
cmpq $0x0, 0x18(%rsp)
je 0xcf1d
movl %eax, %r12d
leaq 0x23b79(%rip), %r15     # 0x309e0
movq (%r15), %rdi
movl %ebx, %esi
movq 0x10(%rsp), %rdx
callq 0x6490
movq (%r15), %rdi
movsbl %r12b, %esi
callq 0x64c0
leaq 0x20a15(%rip), %rax     # 0x2d89e
cmpb $0x1, (%rax)
jne 0xceab
leaq 0x20a0a(%rip), %rax     # 0x2d89f
cmpb $0x0, (%rax)
movq %r14, %r15
je 0xcecf
movq 0x8(%rsp), %rdx
movq 0x1d107(%rip), %rsi     # 0x29fb0
jmp 0xceba
movq 0x8(%rsp), %rdx
movq 0x1d0f9(%rip), %rsi     # 0x29fb0
movq %r14, %r15
movq %r13, %r14
movq 0x10(%rsp), %r13
cmpl %edx, %ebx
jle 0xcc5f
jmp 0xcc3c
leaq 0x209c6(%rip), %rax     # 0x2d89c
cmpb $0x1, (%rax)
movq %r13, %r14
jne 0xcf39
leaq 0x20f90(%rip), %rax     # 0x2de75
movzbl (%rax), %eax
leal -0x62(%rax), %ecx
cmpl $0xc, %ecx
movq 0x10(%rsp), %r13
ja 0xcf4a
leaq 0x13ea4(%rip), %rdx     # 0x20da0
movslq (%rdx,%rcx,4), %rax
addq %rdx, %rax
jmpq *%rax
movl 0x50(%r14), %eax
subl 0x54(%r14), %eax
addl 0x24(%rsp), %ebp
addl %eax, %ebp
addl $0x2, %ebp
jns 0xcf77
jmp 0xd03e
cmpb $0x2d, %al
je 0xce9d
movzbl %al, %ecx
movl %eax, %r12d
cmpl $0x7c, %ecx
je 0xce9d
jmp 0xce60
movq 0x8(%rsp), %rdx
movq 0x1d06b(%rip), %rsi     # 0x29fb0
jmp 0xcebd
cmpl $0x75, %eax
je 0xd025
cmpl $0x79, %eax
jne 0xcf77
addl 0x20(%rsp), %ebp
movl 0x54(%r14), %eax
addl 0x50(%r14), %eax
cmpl %eax, %ebp
jle 0xcf77
jmp 0xd03e
cmpl %ebp, 0x8(%rsp)
je 0xd03e
movzbl %r12b, %eax
cmpl $0x2c, %eax
jg 0xcfb5
cmpl $0x20, %eax
movq 0x8(%rsp), %rdx
movq 0x1d021(%rip), %rsi     # 0x29fb0
je 0xcec2
cmpl $0x23, %eax
je 0xd04f
cmpl $0x2b, %eax
jne 0xcfd6
cmpl 0x50(%r14), %r13d
je 0xcfd6
cmpl 0x54(%r14), %ebx
jne 0xcec2
jmp 0xcfd6
leal -0x2d(%rax), %ecx
cmpl $0x2, %ecx
movq 0x8(%rsp), %rdx
movq 0x1cfe9(%rip), %rsi     # 0x29fb0
jb 0xcec2
cmpl $0x7c, %eax
je 0xcec2
leaq 0x208bf(%rip), %rax     # 0x2d89c
movb $0x0, (%rax)
jmp 0xcec2
cmpl 0x34(%rsp), %r13d
jne 0xcf77
jmp 0xd03e
movl 0x50(%r14), %eax
decl %eax
cmpl %eax, %r13d
jne 0xcf77
jmp 0xd03e
movl 0x54(%r14), %eax
decl %eax
cmpl %eax, %ebx
jne 0xcf77
jmp 0xd03e
addl 0x20(%rsp), %ebp
movl 0x54(%r14), %eax
addl 0x50(%r14), %eax
cmpl %eax, %ebp
jge 0xcf77
jmp 0xd03e
movl 0x50(%r14), %eax
subl 0x54(%r14), %eax
addl 0x24(%rsp), %ebp
addl %ebp, %eax
addl $0x2, %eax
testl %eax, %eax
jle 0xcf77
movq 0x8(%rsp), %rdx
movq 0x1cf66(%rip), %rsi     # 0x29fb0
jmp 0xcec2
cmpl 0x50(%r14), %r13d
sete %al
cmpl 0x54(%r14), %ebx
sete %cl
orb %al, %cl
movzbl %cl, %eax
addl %eax, 0x28(%rsp)
jmp 0xcec2
movq 0x8(%rsp), %rdx
movq 0x1cf39(%rip), %rsi     # 0x29fb0
jmp 0xcc3c
leaq 0x2081b(%rip), %rax     # 0x2d89e
cmpb $0x1, (%rax)
leaq 0x23953(%rip), %rbx     # 0x309e0
jne 0xd0ac
leaq 0x20809(%rip), %rax     # 0x2d89f
cmpb $0x0, (%rax)
jne 0xd0ac
cmpl $0x2, 0x28(%rsp)
jl 0xd0ac
leaq 0x207f3(%rip), %rax     # 0x2d89c
movb $0x0, (%rax)
movq (%rbx), %rdi
movl 0x50(%r14), %edx
movl 0x54(%r14), %esi
callq 0x6490
cmpl $-0x1, %eax
movq 0x18(%rsp), %r15
je 0xd0d3
movq (%rbx), %rdi
movl $0x40, %esi
callq 0x64c0
movq (%rbx), %rdi
movl 0x30(%rsp), %esi
movl 0x2c(%rsp), %edx
callq 0x6490
movq 0x50(%r14), %rax
movq %rax, 0x58(%r14)
leaq 0x20b66(%rip), %rax     # 0x2dc58
movq %r15, (%rax)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq