// File: /workspace/github_c_makefile_star2_O1/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 0x7052
testq %rax, %rax
je 0xefc8
movq %rax, %rbx
movl $0x1, %edi
callq 0x9595
testb %al, %al
je 0xed41
cmpl $0x0, 0xc(%rbx)
jle 0xed35
xorl %ebp, %ebp
leaq 0x21ce8(%rip), %r14     # 0x309e0
cmpl $0x0, 0x8(%rbx)
jle 0xed2e
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 0xed25
movq (%r14), %rdi
movl $0x20, %esi
callq 0x64c0
incl %r15d
cmpl 0x8(%rbx), %r15d
jl 0xed01
incl %ebp
cmpl 0xc(%rbx), %ebp
jl 0xecf8
xorl %edi, %edi
callq 0xcb98
jmp 0xefc8
movl $0x16, %edi
callq 0x12d9c
testb %al, %al
je 0xed53
andb $-0x2, 0x5c(%rbx)
cmpl $0x0, 0xc(%rbx)
jle 0xefc8
leaq 0x21c7c(%rip), %r12     # 0x309e0
xorl %ebp, %ebp
cmpl $0x0, 0x8(%rbx)
jle 0xefbd
xorl %r13d, %r13d
movl %ebp, 0xc(%rsp)
movl 0x4(%rbx), %r14d
addl %ebp, %r14d
movl (%rbx), %r15d
addl %r13d, %r15d
leaq 0x1ead9(%rip), %rax     # 0x2d864
cmpl $0x2, (%rax)
jne 0xeda3
movl %r14d, %edi
movl %r15d, %esi
callq 0x6fcc
testb %al, %al
je 0xefb0
movl %r13d, 0x10(%rsp)
movq %rbx, %r13
testl %ebp, %ebp
sete %bl
movl %r14d, %edi
movl %r15d, %esi
callq 0xe3c4
movl %r15d, %edx
movl %eax, %r15d
movq (%r12), %rdi
movl %r14d, 0x14(%rsp)
movl %r14d, %esi
movl %edx, 0x8(%rsp)
callq 0x6490
cmpb $0x26, %r15b
setne %cl
movzbl %r15b, %eax
movl $0x2d, %edx
cmovel %edx, %eax
orb %bl, %cl
je 0xedf6
movsbq %al, %r15
movq %r13, %rbx
jmp 0xee10
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 0x21bbb(%rip), %r12     # 0x309e0
movq 0x1b104(%rip), %rbp     # 0x29f30
movl 0x14(%rsp), %r14d
movl 0x10(%rsp), %r13d
je 0xef24
movl %r14d, %edi
movl %r14d, %r12d
movl 0x8(%rsp), %r14d
movl %r14d, %esi
xorl %eax, %eax
callq 0xd9b0
testq %rax, %rax
je 0xee9e
movq 0x10(%rax), %rbp
cmpb $0x20, 0x8f(%rbp)
movl %r12d, %r14d
jne 0xeee3
movl $0x1, %esi
movq %rbx, %rdi
callq 0x13e74
testl %eax, %eax
jne 0xeee3
movq 0x1b0b2(%rip), %r12     # 0x29f30
movq (%r12), %rdi
movl %r14d, %esi
movl 0x8(%rsp), %edx
callq 0x6490
cmpl $-0x1, %eax
je 0xeedb
movq (%r12), %rdi
callq 0x6330
jmp 0xeedd
movq (%rbp), %rdi
movl %r12d, %ebp
movl %r12d, %esi
movl %r14d, %edx
callq 0x6490
movl $0x2e, %r15d
cmpl $-0x1, %eax
je 0xeecf
movq 0x1b06e(%rip), %rax     # 0x29f30
movq (%rax), %rdi
movl $0x2e, %esi
callq 0x64c0
movl %ebp, %r14d
leaq 0x21b07(%rip), %r12     # 0x309e0
jmp 0xef24
movb $-0x1, %al
movb %al, 0x8f(%rbp)
leaq 0x1e97a(%rip), %rax     # 0x2d864
cmpl $0x2, (%rax)
leaq 0x21aec(%rip), %r12     # 0x309e0
movq 0x1b035(%rip), %rbp     # 0x29f30
jne 0xef24
movq (%rbp), %rdi
movl %r14d, %esi
movl 0x8(%rsp), %edx
callq 0x6490
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
cmpl $-0x1, %eax
je 0xef24
movq (%rbp), %rdi
callq 0x6330
movl %eax, %r15d
movl $0x1, %esi
movq %rbx, %rdi
callq 0x13e74
testl %eax, %eax
movl 0xc(%rsp), %ebp
je 0xef8f
movq (%r12), %rdi
movl %r14d, %esi
movl 0x8(%rsp), %edx
callq 0x6490
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
cmpl $-0x1, %eax
je 0xef60
movq (%r12), %rdi
callq 0x6330
movl %eax, %r15d
movsbl %r15b, %edi
callq 0xe4fd
testb %al, %al
jne 0xef8f
cmpl $0x2d, %r15d
ja 0xef83
movabsq $0x282000000000, %rax   # imm = 0x282000000000
btq %r15, %rax
jb 0xef8f
cmpl $0x7c, %r15d
je 0xef8f
movl $0x20, %r15d
movq (%r12), %rdi
movl %r14d, %esi
movl 0x8(%rsp), %edx
callq 0x6490
cmpl $-0x1, %eax
je 0xefb0
movq (%r12), %rdi
movl %r15d, %esi
callq 0x64c0
incl %r13d
cmpl 0x8(%rbx), %r13d
jl 0xed77
incl %ebp
cmpl 0xc(%rbx), %ebp
jl 0xed66
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq