// File: /workspace/github_c_makefile_star2_O2/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, 0x34(%rsp)
leaq 0x24640(%rip), %rax     # 0x309d0
movq (%rax), %rax
testq %rax, %rax
je 0xc3a5
movswl (%rax), %ecx
movl %ecx, 0x20(%rsp)
movswl 0x2(%rax), %eax
jmp 0xc3ac
pushq $-0x1
popq %rax
movl %eax, 0x20(%rsp)
movl %eax, 0x1c(%rsp)
leaq 0x21899(%rip), %rax     # 0x2dc50
movl 0x58(%rax), %r14d
movl 0x5c(%rax), %r15d
pushq $0x1
popq %rdi
callq 0x932c
movl %eax, %ebx
leaq 0x21878(%rip), %rax     # 0x2dc48
movq (%rax), %rdi
testq %rdi, %rdi
movb %bl, 0xf(%rsp)
je 0xc3ef
pushq $0x1
popq %rsi
callq 0x12f50
testl %eax, %eax
setne %al
orb %bl, %al
testb $0x1, %al
jmp 0xc3f1
testb %bl, %bl
leaq 0x21858(%rip), %rcx     # 0x2dc50
je 0xc479
leal -0x1(%r14), %ebx
incl %r14d
leal -0x1(%r15), %r13d
incl %r15d
pushq $0x20
popq %rbp
cmpl %r14d, %ebx
jg 0xc479
movl %r13d, %r12d
cmpl %r15d, %r12d
jg 0xc475
cmpl 0x54(%rcx), %r12d
jne 0xc423
cmpl 0x50(%rcx), %ebx
je 0xc470
movl %r12d, %edi
movl %ebx, %esi
callq 0xdabc
leaq 0x2181c(%rip), %rcx     # 0x2dc50
cmpb $0x2e, %al
jne 0xc470
leaq 0x24591(%rip), %rax     # 0x309d0
movq (%rax), %rdi
movl %r12d, %esi
movl %ebx, %edx
callq 0x6470
leaq 0x217fd(%rip), %rcx     # 0x2dc50
cmpl $-0x1, %eax
je 0xc470
leaq 0x24571(%rip), %rax     # 0x309d0
movq (%rax), %rdi
movl %ebp, %esi
callq 0x64a0
leaq 0x217e0(%rip), %rcx     # 0x2dc50
incl %r12d
jmp 0xc413
incl %ebx
jmp 0xc40b
movq 0x70(%rcx), %rax
movq %rax, 0x10(%rsp)
movl 0x50(%rcx), %eax
movl 0x54(%rcx), %edx
leal 0x1(%rdx), %esi
leal 0x1(%rax), %edi
leal -0x1(%rax), %r13d
movl %eax, %r8d
negl %r8d
addl $0x2, %edx
movq %rdx, 0x40(%rsp)
addl $-0x2, %eax
movq 0x1db16(%rip), %r9      # 0x29fc0
leaq 0x2452f(%rip), %rbp     # 0x309e0
movl $0x0, 0x24(%rsp)
movl %esi, 0x8(%rsp)
movl %edi, 0x18(%rsp)
cmpl %edi, %r13d
jg 0xc90b
testl %r13d, %r13d
js 0xc8dc
movq 0x1dac6(%rip), %rdx     # 0x29fa0
cmpl (%rdx), %r13d
jge 0xc8dc
movq %rax, 0x28(%rsp)
movl 0x54(%rcx), %r14d
movq %r8, 0x38(%rsp)
leal (%r14,%r8), %edx
leal -0x1(%r14), %ebx
cmpl %esi, %ebx
jg 0xc8ce
testl %ebx, %ebx
jle 0xc89c
movl (%r9), %eax
addl $-0x2, %eax
cmpl %eax, %ebx
jge 0xc89c
movl %edx, 0x4(%rsp)
callq 0x6590
movq (%rax), %r15
movq (%rbp), %rdi
movl %ebx, %esi
movl %r13d, %edx
callq 0x6470
pushq $-0x1
popq %rcx
cmpl $-0x1, %eax
je 0xc545
movq (%rbp), %rdi
callq 0x6320
movslq %eax, %rcx
testb $0x4, 0x1(%r15,%rcx,2)
je 0xc64f
cmpb $0x0, 0x34(%rsp)
jne 0xc571
cmpq $0x0, 0x10(%rsp)
je 0xc57f
movq 0x10(%rsp), %rdi
pushq $0x4
popq %rsi
callq 0x12f50
testl %eax, %eax
je 0xc57f
movl %ebx, %edi
movl %r13d, %esi
xorl %eax, %eax
callq 0xd185
jmp 0xc589
movl %ebx, %edi
movl %r13d, %esi
callq 0x745e
testq %rax, %rax
movq 0x1d9a5(%rip), %rcx     # 0x29f38
je 0xc5b9
movq 0x10(%rax), %r15
movq (%rcx), %rdi
movl %ebx, %esi
movl %r13d, %edx
movq %rcx, %r12
callq 0x6470
cmpl $-0x1, %eax
je 0xc5e3
movq (%r12), %rdi
callq 0x6320
jmp 0xc5e5
movq (%rcx), %rdi
movl %ebx, %esi
movl %r13d, %edx
callq 0x6470
cmpl $-0x1, %eax
je 0xc64f
movq 0x1d962(%rip), %rax     # 0x29f38
movq (%rax), %rdi
pushq $0x2e
popq %rsi
callq 0x64a0
jmp 0xc64f
movb $-0x1, %al
movb %al, 0x8f(%r15)
movsbl %al, %edi
callq 0xdbbb
testb %al, %al
je 0xc621
movl %ebx, %edi
movl %r13d, %esi
xorl %eax, %eax
callq 0xea05
testq %rax, %rax
je 0xc8e9
movb $0x2e, %cl
testb $0x8, 0x10(%rax)
je 0xc618
movb 0x14(%rax), %cl
movb %cl, 0x8f(%r15)
jmp 0xc628
movb 0x8f(%r15), %cl
cmpb $0x2e, %cl
jne 0xc64f
movq 0x10(%rsp), %rdi
pushq $0x1
popq %rsi
callq 0x12f50
testl %eax, %eax
sete %al
orb 0xf(%rsp), %al
testb $0x1, %al
jne 0xc64f
movb $0x20, 0x8f(%r15)
movl %r13d, %esi
movq %rbp, %r12
movq 0x10(%rsp), %rbp
testq %rbp, %rbp
sete %r15b
movl %ebx, %edi
callq 0xdabc
cmpb $0x26, %al
setne %cl
movzbl %al, %eax
pushq $0x2d
popq %rdx
cmovel %edx, %eax
orb %r15b, %cl
jne 0xc69b
movl 0x4(%rbp), %ecx
movb $0x2d, %al
cmpl %ecx, %ebx
je 0xc69b
movq 0x10(%rsp), %rax
movl 0xc(%rax), %eax
addl %ecx, %eax
decl %eax
cmpl %eax, %ebx
pushq $0x7c
popq %rax
pushq $0x2d
popq %rcx
cmovel %ecx, %eax
movb $0x20, %r15b
cmpb $0x0, 0xf(%rsp)
jne 0xc6cd
movq %r12, %rbp
leaq 0x215a1(%rip), %rcx     # 0x2dc50
cmpl 0x54(%rcx), %ebx
jne 0xc6be
cmpl 0x50(%rcx), %r13d
je 0xc88d
cmpq $0x0, 0x10(%rsp)
je 0xc77d
movl %eax, %r15d
leaq 0x242fc(%rip), %rbp     # 0x309d0
movq (%rbp), %rdi
movl %ebx, %esi
movl %r13d, %edx
callq 0x6470
movq (%rbp), %rdi
movsbl %r15b, %esi
callq 0x64a0
leaq 0x21198(%rip), %rax     # 0x2d88e
cmpb $0x1, (%rax)
jne 0xc763
leaq 0x2118d(%rip), %rax     # 0x2d88f
cmpb $0x0, (%rax)
leaq 0x21544(%rip), %rcx     # 0x2dc50
movq %r12, %rbp
jne 0xc88d
leaq 0x21170(%rip), %rax     # 0x2d88c
cmpb $0x1, (%rax)
jne 0xc88d
leaq 0x21739(%rip), %rax     # 0x2de65
movzbl (%rax), %eax
leal -0x62(%rax), %ecx
cmpl $0xc, %ecx
ja 0xc799
leaq 0x12662(%rip), %rdx     # 0x1eda0
movslq (%rdx,%rcx,4), %rax
addq %rdx, %rax
jmpq *%rax
leaq 0x21502(%rip), %rcx     # 0x2dc50
movl 0x50(%rcx), %eax
subl 0x54(%rcx), %eax
addl 0x4(%rsp), %eax
jns 0xc839
jmp 0xc886
leaq 0x214e6(%rip), %rcx     # 0x2dc50
movl 0x8(%rsp), %esi
movq 0x1d84b(%rip), %r9      # 0x29fc0
movq %r12, %rbp
jmp 0xc898
cmpb $0x2d, %al
je 0xc88d
movzbl %al, %ecx
movl %eax, %r15d
cmpl $0x7c, %ecx
je 0xc886
jmp 0xc6cd
cmpl $0x75, %eax
je 0xc824
cmpl $0x79, %eax
jne 0xc839
movq 0x28(%rsp), %rax
addl %r14d, %eax
leaq 0x21496(%rip), %rdx     # 0x2dc50
movl 0x54(%rdx), %ecx
addl 0x50(%rdx), %ecx
cmpl %ecx, %eax
jle 0xc839
jmp 0xc886
cmpl %r14d, 0x40(%rsp)
jne 0xc839
jmp 0xc886
cmpl 0x18(%rsp), %r13d
jne 0xc839
jmp 0xc886
leaq 0x21468(%rip), %rax     # 0x2dc50
movl 0x50(%rax), %eax
decl %eax
cmpl %eax, %r13d
jne 0xc839
jmp 0xc886
leaq 0x21452(%rip), %rax     # 0x2dc50
movl 0x54(%rax), %eax
decl %eax
cmpl %eax, %ebx
jne 0xc839
jmp 0xc886
movq 0x28(%rsp), %rax
addl %r14d, %eax
leaq 0x21438(%rip), %rdx     # 0x2dc50
movl 0x54(%rdx), %ecx
addl 0x50(%rdx), %ecx
cmpl %ecx, %eax
jge 0xc839
jmp 0xc886
leaq 0x21425(%rip), %rcx     # 0x2dc50
movl 0x50(%rcx), %eax
subl 0x54(%rcx), %eax
addl 0x4(%rsp), %eax
testl %eax, %eax
jg 0xc886
movzbl %r15b, %eax
leal -0x2d(%rax), %ecx
cmpl $0x2, %ecx
jb 0xc886
cmpl $0x20, %eax
movl 0x8(%rsp), %esi
movq 0x1d76d(%rip), %r9      # 0x29fc0
movl 0x4(%rsp), %edx
je 0xc8a6
cmpl $0x23, %eax
leaq 0x213ed(%rip), %rcx     # 0x2dc50
je 0xc8af
cmpl $0x7c, %eax
je 0xc89c
cmpl $0x2b, %eax
jne 0xc87a
cmpl 0x50(%rcx), %r13d
je 0xc87a
cmpl 0x54(%rcx), %ebx
jne 0xc89c
leaq 0x2100b(%rip), %rax     # 0x2d88c
movb $0x0, (%rax)
jmp 0xc89c
leaq 0x213c3(%rip), %rcx     # 0x2dc50
movl 0x8(%rsp), %esi
movq 0x1d728(%rip), %r9      # 0x29fc0
movl 0x4(%rsp), %edx
incl %edx
incl %r14d
jmp 0xc4f5
leaq 0x213a3(%rip), %rcx     # 0x2dc50
jmp 0xc89c
cmpl 0x50(%rcx), %r13d
sete %al
cmpl 0x54(%rcx), %ebx
sete %cl
orb %al, %cl
movzbl %cl, %eax
leaq 0x21388(%rip), %rcx     # 0x2dc50
addl %eax, 0x24(%rsp)
jmp 0xc89c
movq 0x28(%rsp), %rax
movl 0x18(%rsp), %edi
movq 0x38(%rsp), %r8
incl %r13d
decl %r8d
incl %eax
jmp 0xc4c1
leaq 0x21360(%rip), %rcx     # 0x2dc50
movq 0x28(%rsp), %rax
movl 0x8(%rsp), %esi
movl 0x18(%rsp), %edi
movq 0x38(%rsp), %r8
movq 0x1d6b7(%rip), %r9      # 0x29fc0
jmp 0xc8dc
leaq 0x20f7c(%rip), %rax     # 0x2d88e
cmpb $0x1, (%rax)
jne 0xc934
leaq 0x20f71(%rip), %rax     # 0x2d88f
cmpb $0x0, (%rax)
jne 0xc934
cmpl $0x2, 0x24(%rsp)
jl 0xc934
leaq 0x20f5b(%rip), %rax     # 0x2d88c
movb $0x0, (%rax)
leaq 0x24095(%rip), %rbx     # 0x309d0
movq (%rbx), %rdi
movl 0x50(%rcx), %edx
movl 0x54(%rcx), %esi
callq 0x6470
cmpl $-0x1, %eax
movq 0x10(%rsp), %r14
je 0xc95e
movq (%rbx), %rdi
pushq $0x40
popq %rsi
callq 0x64a0
movq (%rbx), %rdi
movl 0x20(%rsp), %esi
movl 0x1c(%rsp), %edx
callq 0x6470
leaq 0x212db(%rip), %rcx     # 0x2dc50
movq 0x50(%rcx), %rax
movq %rax, 0x58(%rcx)
leaq 0x212c4(%rip), %rax     # 0x2dc48
movq %r14, (%rax)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq