// File: /workspace/github_c_makefile_star2_O2/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 0x6f44
testq %rax, %rax
je 0xe562
movq %rax, %rbx
pushq $0x1
popq %rdi
callq 0x932c
testb %al, %al
je 0xe316
xorl %r14d, %r14d
leaq 0x226fc(%rip), %r15     # 0x309d0
pushq $0x20
popq %rbp
cmpl 0xc(%rbx), %r14d
jge 0xe55b
xorl %r12d, %r12d
cmpl 0x8(%rbx), %r12d
jge 0xe311
movl 0x4(%rbx), %esi
addl %r14d, %esi
movl (%rbx), %edx
addl %r12d, %edx
movq (%r15), %rdi
callq 0x6470
cmpl $-0x1, %eax
je 0xe30c
movq (%r15), %rdi
movl %ebp, %esi
callq 0x64a0
incl %r12d
jmp 0xe2e4
incl %r14d
jmp 0xe2d7
pushq $0x16
popq %rdi
callq 0x11fa5
testb %al, %al
je 0xe326
andb $-0x2, 0x5c(%rbx)
leaq 0x226a3(%rip), %rbp     # 0x309d0
movq 0x1bc04(%rip), %r14     # 0x29f38
xorl %ecx, %ecx
movq %rbx, 0x8(%rsp)
cmpl 0xc(%rbx), %ecx
jge 0xe562
xorl %eax, %eax
movl %ecx, 0x4(%rsp)
cmpl 0x8(%rbx), %eax
jge 0xe554
movl 0x4(%rbx), %r15d
addl %ecx, %r15d
movl (%rbx), %r12d
movl %eax, 0x14(%rsp)
addl %eax, %r12d
leaq 0x1f4e9(%rip), %rax     # 0x2d854
cmpl $0x2, (%rax)
jne 0xe387
movl %r15d, %edi
movl %r12d, %esi
callq 0x6ec2
movl 0x4(%rsp), %ecx
testb %al, %al
je 0xe549
movq %r14, %rbx
testl %ecx, %ecx
movq %rbp, %r14
sete %bpl
movl %r15d, %edi
movl %r12d, %esi
callq 0xdabc
movl %eax, %r13d
movq (%r14), %rdi
movl %r15d, %esi
movl %r12d, %edx
callq 0x6470
cmpb $0x26, %r13b
setne %cl
movzbl %r13b, %eax
pushq $0x2d
popq %rdx
cmovel %edx, %eax
orb %bpl, %cl
je 0xe3cb
movsbq %al, %r13
jmp 0xe3e4
movq 0x8(%rsp), %rax
movl 0xc(%rax), %eax
decl %eax
cmpl %eax, 0x4(%rsp)
pushq $0x7c
popq %r13
pushq $0x2d
popq %rax
cmoveq %rax, %r13
movq %rbx, %r14
callq 0x6590
movq (%rax), %rax
testb $0x4, 0x1(%rax,%r13,2)
leaq 0x225d4(%rip), %rbp     # 0x309d0
jne 0xe408
movq 0x8(%rsp), %rbx
jmp 0xe4bf
movl %r15d, %edi
movl %r12d, %esi
xorl %eax, %eax
callq 0xd185
testq %rax, %rax
movq 0x8(%rsp), %rbx
je 0xe458
movq 0x10(%rax), %rbp
cmpb $0x20, 0x8f(%rbp)
jne 0xe488
movq %rbx, %rdi
pushq $0x1
popq %rsi
callq 0x12f50
testl %eax, %eax
jne 0xe488
movq (%r14), %rdi
movl %r15d, %esi
movl %r12d, %edx
callq 0x6470
cmpl $-0x1, %eax
je 0xe480
movq (%r14), %rdi
callq 0x6320
jmp 0xe482
movq (%r14), %rdi
movl %r15d, %esi
movl %r12d, %edx
callq 0x6470
pushq $0x2e
popq %r13
cmpl $-0x1, %eax
je 0xe4bf
movq (%r14), %rdi
pushq $0x2e
popq %rsi
callq 0x64a0
pushq $0x2e
popq %r13
jmp 0xe4bf
movb $-0x1, %al
movb %al, 0x8f(%rbp)
leaq 0x1f3c5(%rip), %rax     # 0x2d854
cmpl $0x2, (%rax)
leaq 0x22537(%rip), %rbp     # 0x309d0
jne 0xe4bf
movq (%r14), %rdi
movl %r15d, %esi
movl %r12d, %edx
callq 0x6470
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
cmpl $-0x1, %eax
je 0xe4bf
movq (%r14), %rdi
callq 0x6320
movl %eax, %r13d
movq %rbx, %rdi
pushq $0x1
popq %rsi
callq 0x12f50
testl %eax, %eax
je 0xe521
movq (%rbp), %rdi
movl %r15d, %esi
movl %r12d, %edx
callq 0x6470
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
cmpl $-0x1, %eax
je 0xe4f4
movq (%rbp), %rdi
callq 0x6320
movl %eax, %r13d
movsbl %r13b, %edi
callq 0xdbbb
testb %al, %al
jne 0xe521
cmpl $0x2d, %r13d
ja 0xe517
movabsq $0x282000000000, %rax   # imm = 0x282000000000
btq %r13, %rax
jb 0xe521
cmpl $0x7c, %r13d
je 0xe521
pushq $0x20
popq %r13
movq (%rbp), %rdi
movl %r15d, %esi
movl %r12d, %edx
callq 0x6470
cmpl $-0x1, %eax
movl 0x4(%rsp), %ecx
je 0xe549
movq (%rbp), %rdi
movl %r13d, %esi
callq 0x64a0
movl 0x4(%rsp), %ecx
movl 0x14(%rsp), %eax
incl %eax
jmp 0xe34a
incl %ecx
jmp 0xe33b
xorl %edi, %edi
callq 0xc377
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq