// File: /workspace/github_c_makefile_star2_O1/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 0x23e2f(%rip), %rax     # 0x309e0
movq (%rax), %rax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
testq %rax, %rax
je 0xcbc6
movswl (%rax), %edx
movl %edx, 0x30(%rsp)
testq %rax, %rax
je 0xcbd3
movswl 0x2(%rax), %ecx
movl %ecx, 0x34(%rsp)
leaq 0x21082(%rip), %r14     # 0x2dc60
movl 0x58(%r14), %r15d
movl 0x5c(%r14), %r13d
movl $0x1, %edi
callq 0x9595
movl %eax, %ebx
leaq 0x2105f(%rip), %rax     # 0x2dc58
movq (%rax), %rdi
testq %rdi, %rdi
movb %bl, 0x7(%rsp)
je 0xcc1c
movl $0x1, %esi
callq 0x13e74
testl %eax, %eax
setne %al
orb %bl, %al
testb $0x1, %al
jne 0xcc20
jmp 0xcc84
testb %bl, %bl
je 0xcc84
leal -0x1(%r15), %ebx
leal -0x2(%r13), %ebp
movl %ebp, %r12d
incl %r12d
cmpl 0x54(%r14), %r12d
jne 0xcc3a
cmpl 0x50(%r14), %ebx
je 0xcc75
movl %r12d, %edi
movl %ebx, %esi
callq 0xe3c4
cmpb $0x2e, %al
jne 0xcc75
leaq 0x23d91(%rip), %rax     # 0x309e0
movq (%rax), %rdi
movl %r12d, %esi
movl %ebx, %edx
callq 0x6490
cmpl $-0x1, %eax
je 0xcc75
leaq 0x23d78(%rip), %rax     # 0x309e0
movq (%rax), %rdi
movl $0x20, %esi
callq 0x64c0
cmpl %r13d, %r12d
jle 0xcc2b
leal 0x1(%rbx), %eax
cmpl %r15d, %ebx
movl %eax, %ebx
jle 0xcc28
movq 0x70(%r14), %r12
movl 0x50(%r14), %eax
movl 0x54(%r14), %ecx
leal 0x1(%rcx), %edx
movl %edx, 0x38(%rsp)
leal 0x1(%rax), %edx
movl %edx, 0x2c(%rsp)
leal -0x1(%rax), %ebp
movl %eax, %edx
negl %edx
movl %edx, 0x1c(%rsp)
movq %rax, 0x40(%rsp)
movl %eax, 0x18(%rsp)
movl $0x0, 0x28(%rsp)
movq %r12, 0x8(%rsp)
movq %rcx, 0x10(%rsp)
testl %ebp, %ebp
js 0xcce0
movq 0x1d2c9(%rip), %rax     # 0x29f98
cmpl (%rax), %ebp
jge 0xcce0
movl 0x54(%r14), %ebx
leal -0x1(%rbx), %eax
cmpl 0x38(%rsp), %eax
jle 0xccf8
leal 0x1(%rbp), %eax
incl 0x18(%rsp)
decl 0x1c(%rsp)
cmpl 0x40(%rsp), %ebp
movl %eax, %ebp
jle 0xccc4
jmp 0xd0db
addl $-0x2, %ebx
movl %ebx, %edx
leal 0x1(%rdx), %ebx
testl %ebx, %ebx
jle 0xd0a6
movq 0x1d2a1(%rip), %rax     # 0x29fb0
movl (%rax), %eax
addl $-0x2, %eax
cmpl %eax, %ebx
jge 0xd0a6
movq %rdx, 0x20(%rsp)
movq %rbp, %r13
movq %r14, %r12
callq 0x65b0
movq (%rax), %r15
leaq 0x23cba(%rip), %r14     # 0x309f0
movq (%r14), %rdi
movl %ebx, %esi
movl %r13d, %edx
callq 0x6490
cmpl $-0x1, %eax
je 0xcd54
movq (%r14), %rdi
callq 0x6330
cltq
jmp 0xcd5b
movq $-0x1, %rax
testb $0x4, 0x1(%r15,%rax,2)
movq %r12, %r14
movq 0x8(%rsp), %r12
je 0xce85
cmpb $0x0, 0x3c(%rsp)
jne 0xcd8c
testq %r12, %r12
je 0xcd99
movl $0x4, %esi
movq %r12, %rdi
callq 0x13e74
testl %eax, %eax
je 0xcd99
movl %ebx, %edi
movl %ebp, %esi
xorl %eax, %eax
callq 0xd9b0
jmp 0xcda2
movl %ebx, %edi
movl %ebp, %esi
callq 0x75c5
testq %rax, %rax
movq 0x1d184(%rip), %rcx     # 0x29f30
je 0xcdd0
movq 0x10(%rax), %r12
movq (%rcx), %rdi
movl %ebx, %esi
movl %ebp, %edx
movq %rcx, %r15
callq 0x6490
cmpl $-0x1, %eax
je 0xcdfb
movq (%r15), %rdi
callq 0x6330
jmp 0xcdfd
movq (%rcx), %rdi
movl %ebx, %esi
movl %ebp, %edx
movq %rcx, %r12
callq 0x6490
xorl %r15d, %r15d
cmpl $-0x1, %eax
je 0xce77
movq (%r12), %rdi
movl $0x2e, %esi
callq 0x64c0
jmp 0xce77
movb $-0x1, %al
movb %al, 0x8f(%r12)
movsbl %al, %edi
callq 0xe4fd
testb %al, %al
je 0xce44
movl %ebx, %edi
movl %ebp, %esi
xorl %eax, %eax
callq 0xf4ea
testq %rax, %rax
je 0xce39
movb $0x2e, %cl
testb $0x8, 0x10(%rax)
je 0xce2c
movb 0x14(%rax), %cl
movb %cl, 0x8f(%r12)
xorl %r15d, %r15d
jmp 0xce3f
movl $0xb, %r15d
testq %rax, %rax
je 0xce77
xorl %r15d, %r15d
cmpb $0x2e, 0x8f(%r12)
jne 0xce77
movl $0x1, %esi
movq 0x8(%rsp), %rdi
callq 0x13e74
testl %eax, %eax
sete %al
orb 0x7(%rsp), %al
testb $0x1, %al
jne 0xce77
movb $0x20, 0x8f(%r12)
testl %r15d, %r15d
movq 0x8(%rsp), %r12
jne 0xd0d1
testq %r12, %r12
sete %r15b
movl %ebx, %edi
movl %ebp, %esi
callq 0xe3c4
cmpb $0x26, %al
setne %cl
movzbl %al, %eax
movl $0x2d, %edx
cmovel %edx, %eax
orb %r15b, %cl
jne 0xcecd
movl 0x4(%r12), %ecx
movb $0x2d, %al
cmpl %ecx, %ebx
je 0xcecd
movl 0xc(%r12), %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 0xcef8
cmpl 0x54(%r14), %ebx
jne 0xcee7
cmpl 0x50(%r14), %ebp
je 0xcf9f
movq 0x8(%rsp), %r12
testq %r12, %r12
je 0xcf8c
movl %eax, %r12d
leaq 0x23ae1(%rip), %r15     # 0x309e0
movq (%r15), %rdi
movl %ebx, %esi
movl %ebp, %edx
callq 0x6490
movq (%r15), %rdi
movsbl %r12b, %esi
callq 0x64c0
leaq 0x20980(%rip), %rax     # 0x2d89e
cmpb $0x1, (%rax)
jne 0xcf9f
leaq 0x20975(%rip), %rax     # 0x2d89f
cmpb $0x0, (%rax)
movq 0x10(%rsp), %rcx
jne 0xd0a1
leaq 0x2095d(%rip), %rax     # 0x2d89c
cmpb $0x1, (%rax)
jne 0xd0a1
leaq 0x20f26(%rip), %rax     # 0x2de75
movzbl (%rax), %eax
leal -0x62(%rax), %ecx
cmpl $0xc, %ecx
ja 0xcfae
leaq 0x13e2b(%rip), %rdx     # 0x20d8c
movslq (%rdx,%rcx,4), %rax
addq %rdx, %rax
movq 0x10(%rsp), %rcx
jmpq *%rax
movl 0x50(%r14), %eax
subl 0x54(%r14), %eax
movq 0x20(%rsp), %rdx
addl 0x1c(%rsp), %edx
addl %eax, %edx
addl $0x2, %edx
jns 0xcfe5
jmp 0xd0a1
cmpb $0x2d, %al
je 0xcfa4
movzbl %al, %ecx
movl %eax, %r12d
cmpl $0x7c, %ecx
jne 0xcef8
movq 0x8(%rsp), %r12
movq 0x10(%rsp), %rcx
jmp 0xd0a6
cmpl $0x75, %eax
je 0xd07e
cmpl $0x79, %eax
movq 0x10(%rsp), %rcx
jne 0xcfe5
movq 0x20(%rsp), %rdx
addl 0x18(%rsp), %edx
movl 0x54(%r14), %eax
addl 0x50(%r14), %eax
cmpl %eax, %edx
jle 0xcfe5
jmp 0xd0a1
cmpl 0x20(%rsp), %ecx
je 0xd0a1
movzbl %r12b, %eax
cmpl $0x2c, %eax
jg 0xd01c
cmpl $0x20, %eax
movq 0x8(%rsp), %r12
je 0xd0a6
cmpl $0x23, %eax
je 0xd0b3
cmpl $0x2b, %eax
jne 0xd037
cmpl 0x50(%r14), %ebp
je 0xd037
cmpl 0x54(%r14), %ebx
jne 0xd0a6
jmp 0xd037
leal -0x2d(%rax), %ecx
cmpl $0x2, %ecx
movq 0x8(%rsp), %r12
jb 0xcfa4
cmpl $0x7c, %eax
movq 0x10(%rsp), %rcx
je 0xd0a6
leaq 0x2085e(%rip), %rax     # 0x2d89c
movb $0x0, (%rax)
jmp 0xd0a6
cmpl 0x2c(%rsp), %ebp
jne 0xcfe5
jmp 0xd0a1
movl 0x50(%r14), %eax
decl %eax
cmpl %eax, %ebp
jne 0xcfe5
jmp 0xd0a1
movl 0x54(%r14), %eax
decl %eax
cmpl %eax, %ebx
jne 0xcfe5
jmp 0xd0a1
movq 0x20(%rsp), %rdx
addl 0x18(%rsp), %edx
movl 0x54(%r14), %eax
addl 0x50(%r14), %eax
cmpl %eax, %edx
jge 0xcfe5
jmp 0xd0a1
movl 0x50(%r14), %eax
subl 0x54(%r14), %eax
movq 0x20(%rsp), %rcx
addl 0x1c(%rsp), %ecx
addl %ecx, %eax
addl $0x2, %eax
testl %eax, %eax
movq 0x10(%rsp), %rcx
jle 0xcfe5
movq 0x8(%rsp), %r12
cmpl %ecx, %ebx
jle 0xccfb
jmp 0xcce0
cmpl 0x50(%r14), %ebp
sete %al
cmpl 0x54(%r14), %ebx
sete %cl
orb %al, %cl
movzbl %cl, %eax
movq 0x10(%rsp), %rcx
addl %eax, 0x28(%rsp)
jmp 0xd0a6
movq 0x10(%rsp), %rcx
jmp 0xcce0
leaq 0x207bc(%rip), %rax     # 0x2d89e
cmpb $0x1, (%rax)
leaq 0x238f4(%rip), %rbx     # 0x309e0
jne 0xd10b
leaq 0x207aa(%rip), %rax     # 0x2d89f
cmpb $0x0, (%rax)
jne 0xd10b
cmpl $0x2, 0x28(%rsp)
jl 0xd10b
leaq 0x20794(%rip), %rax     # 0x2d89c
movb $0x0, (%rax)
movq (%rbx), %rdi
movl 0x50(%r14), %edx
movl 0x54(%r14), %esi
callq 0x6490
cmpl $-0x1, %eax
je 0xd12d
movq (%rbx), %rdi
movl $0x40, %esi
callq 0x64c0
movq (%rbx), %rdi
movl 0x30(%rsp), %esi
movl 0x34(%rsp), %edx
callq 0x6490
movq 0x50(%r14), %rax
movq %rax, 0x58(%r14)
leaq 0x20b0c(%rip), %rax     # 0x2dc58
movq %r12, (%rax)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq