// File: /workspace/github_c_makefile_star2_O3/ajpaulson[P]srogue11/move.c
// Function: light
int light(struct coord *cp)
{
	struct room *rp;
	int j, k, x, y;
	unsigned long ch, rch;
	struct linked_list *item;

	rp = roomin(cp);
	if (rp == NULL)
		return 0;
	if (pl_on(ISBLIND)) {
		for (j = 0; j < rp->r_max.y; j += 1) {
			for (k = 0; k < rp->r_max.x; k += 1) {
				y = rp->r_pos.y + j;
				x = rp->r_pos.x + k;
				mvwaddch(cw, y, x, ' ');
			}
		}
		look(FALSE);
		return 0;
	}
	if (iswearing(R_LIGHT))
		rp->r_flags &= ~ISDARK;
	for (j = 0; j < rp->r_max.y; j += 1) {
		for (k = 0; k < rp->r_max.x; k += 1) {
			y = rp->r_pos.y + j;
			x = rp->r_pos.x + k;
			if (levtype == MAZELEV && !cansee(y, x))
				continue;
			ch = show(y, x);
			wmove(cw, y, x);
			/*
			 * Figure out how to display a secret door
			 */
			if (ch == SECRETDOOR) {
				if (j == 0 || j == rp->r_max.y - 1)
					ch = '-';
				else
					ch = '|';
			}
			if (isalpha(ch)) {
				struct thing *mit;

				item = wake_monster(y, x);
				if (item == NULL) {
					ch = FLOOR;
					mvaddch(y, x, ch);
				}
				else {
					mit = THINGPTR(item);
					if (mit->t_oldch == ' ')
						if (!rf_on(rp,ISDARK))
							mit->t_oldch = mvinch(y, x);
					if (levtype == MAZELEV)
						ch = mvinch(y, x);
				}
			}
			if (rf_on(rp,ISDARK)) {
				rch = mvwinch(cw, y, x);
				if (isatrap(rch)) {
					ch = rch;			/* if its a trap */
				}
				else {					/* try other things */
					switch (rch) {
						case DOOR:	case STAIRS:	case '|':
						case '-':
							ch = rch;
						otherwise:
							ch = ' ';
					}
				}
			}
			mvwaddch(cw, y, x, ch);
		}
	}
  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
callq 0x701c
testq %rax, %rax
je 0xeeca
movq %rax, %rbx
movl $0x1, %edi
callq 0x9513
testb %al, %al
je 0xec33
movl 0xc(%rbx), %ecx
testl %ecx, %ecx
jle 0xec27
movl 0x8(%rbx), %eax
xorl %ebp, %ebp
leaq 0x21df8(%rip), %r14     # 0x309e0
testl %eax, %eax
jle 0xec21
xorl %r15d, %r15d
movl 0x4(%rbx), %esi
addl %ebp, %esi
movl (%rbx), %edx
addl %r15d, %edx
movq (%r14), %rdi
callq 0x6490
cmpl $-0x1, %eax
je 0xec13
movq (%r14), %rdi
movl $0x20, %esi
callq 0x64c0
incl %r15d
movl 0x8(%rbx), %eax
cmpl %eax, %r15d
jl 0xebef
movl 0xc(%rbx), %ecx
incl %ebp
cmpl %ecx, %ebp
jl 0xebe8
xorl %edi, %edi
callq 0xcae0
jmp 0xeeca
movl $0x16, %edi
callq 0x12c34
testb %al, %al
je 0xec45
andb $-0x2, 0x5c(%rbx)
movl 0xc(%rbx), %eax
testl %eax, %eax
jle 0xeeca
movl 0x8(%rbx), %ecx
leaq 0x21d86(%rip), %r12     # 0x309e0
xorl %ebp, %ebp
testl %ecx, %ecx
jle 0xeec0
xorl %r13d, %r13d
movl %ebp, 0x4(%rsp)
movl 0x4(%rbx), %r14d
addl %ebp, %r14d
movl (%rbx), %r15d
addl %r13d, %r15d
leaq 0x1ebe5(%rip), %rax     # 0x2d864
cmpl $0x2, (%rax)
jne 0xec97
movl %r14d, %edi
movl %r15d, %esi
callq 0x6f96
testb %al, %al
je 0xeeae
movl %r13d, 0xc(%rsp)
movq %rbx, %r13
testl %ebp, %ebp
sete %bl
movl %r14d, %edi
movl %r15d, %esi
callq 0xe2de
movl %r15d, %edx
movl %eax, %r15d
movq (%r12), %rdi
movl %r14d, 0x8(%rsp)
movl %r14d, %esi
movl %edx, (%rsp)
callq 0x6490
cmpb $0x26, %r15b
setne %cl
movzbl %r15b, %eax
movl $0x2d, %edx
cmovel %edx, %eax
orb %bl, %cl
je 0xece9
movsbq %al, %r15
movq %r13, %rbx
jmp 0xed03
movq %r13, %rbx
movl 0xc(%r13), %eax
decl %eax
cmpl %eax, %ebp
movl $0x7c, %r15d
movl $0x2d, %eax
cmoveq %rax, %r15
callq 0x65b0
movq (%rax), %rax
testb $0x4, 0x1(%rax,%r15,2)
leaq 0x21cc8(%rip), %r12     # 0x309e0
movl 0x8(%rsp), %r14d
movl 0xc(%rsp), %r13d
je 0xee28
movl %r14d, %edi
movl %r14d, %r12d
movl (%rsp), %r14d
movl %r14d, %esi
xorl %eax, %eax
callq 0xd93f
testq %rax, %rax
je 0xed91
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
cmpb $0x20, 0x8f(%rax)
movl %r12d, %r14d
jne 0xede3
movl $0x1, %esi
movq %rbx, %rdi
callq 0x13d18
testl %eax, %eax
jne 0xede3
movq 0x1b1be(%rip), %rbp     # 0x29f30
movq (%rbp), %rdi
movl %r14d, %esi
movl (%rsp), %edx
callq 0x6490
cmpl $-0x1, %eax
je 0xedd2
movq (%rbp), %rdi
callq 0x6330
jmp 0xedd4
movq 0x1b198(%rip), %rbp     # 0x29f30
movq (%rbp), %rdi
movl %r12d, %esi
movl %r14d, %edx
callq 0x6490
movl $0x2e, %r15d
cmpl $-0x1, %eax
je 0xedc0
movq (%rbp), %rdi
movl $0x2e, %esi
callq 0x64c0
movl 0x4(%rsp), %ebp
movl 0x8(%rsp), %r14d
leaq 0x21c10(%rip), %r12     # 0x309e0
jmp 0xee28
movb $-0x1, %al
movq 0x10(%rsp), %rcx
movb %al, 0x8f(%rcx)
movl 0x4(%rsp), %ebp
leaq 0x1ea7a(%rip), %rax     # 0x2d864
cmpl $0x2, (%rax)
leaq 0x21bec(%rip), %r12     # 0x309e0
jne 0xee28
movq 0x1b133(%rip), %rax     # 0x29f30
movq (%rax), %rdi
movl %r14d, %esi
movl (%rsp), %edx
callq 0x6490
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
cmpl $-0x1, %eax
je 0xee28
movq 0x1b113(%rip), %rax     # 0x29f30
movq (%rax), %rdi
callq 0x6330
movl %eax, %r15d
movl $0x1, %esi
movq %rbx, %rdi
callq 0x13d18
testl %eax, %eax
je 0xee8e
movq (%r12), %rdi
movl %r14d, %esi
movl (%rsp), %edx
callq 0x6490
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
cmpl $-0x1, %eax
je 0xee5f
movq (%r12), %rdi
callq 0x6330
movl %eax, %r15d
movsbl %r15b, %edi
callq 0xe41e
testb %al, %al
jne 0xee8e
cmpl $0x2d, %r15d
ja 0xee82
movabsq $0x282000000000, %rax   # imm = 0x282000000000
btq %r15, %rax
jb 0xee8e
cmpl $0x7c, %r15d
je 0xee8e
movl $0x20, %r15d
movq (%r12), %rdi
movl %r14d, %esi
movl (%rsp), %edx
callq 0x6490
cmpl $-0x1, %eax
je 0xeeae
movq (%r12), %rdi
movl %r15d, %esi
callq 0x64c0
incl %r13d
movl 0x8(%rbx), %ecx
cmpl %ecx, %r13d
jl 0xec6b
movl 0xc(%rbx), %eax
incl %ebp
cmpl %eax, %ebp
jl 0xec5c
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq