// File: /workspace/github_c_makefile_star2_O2/ajpaulson[P]srogue11/monsters.c
// Function: wake_monster
struct linked_list *wake_monster(int y,int x)
{
	struct thing *tp;
	struct linked_list *it;
	struct room *rp;
	char ch;
	bool treas = FALSE;

	if ((it = find_mons(y, x)) == NULL)
		return NULL;
	tp = THINGPTR(it);
	ch = tp->t_type;
	/*
	 * Every time he sees mean monster, it might start chasing him
	 */
	rp = player.t_room;
	if (rp != NULL && rf_on(rp,ISTREAS)) {
		tp->t_flags &= ~ISHELD;
		treas = TRUE;
	}
	if (treas || (rnd(100) > 33 && on(*tp,ISMEAN) && off(*tp,ISHELD) &&
	  !iswearing(R_STEALTH))) {
		tp->t_dest = &hero;
		tp->t_flags |= ISRUN;
	}
	if (ch == 'U' && pl_off(ISBLIND)) {
		if ((rp != NULL && !rf_on(rp,ISDARK) && levtype != MAZELEV)
		  || DISTANCE(y, x, hero.y, hero.x) < 3) {
			if (off(*tp,ISFOUND) && !save(VS_PETRIFICATION)
			  && !iswearing(R_SUSAB) && pl_off(ISINVINC)) {
				msg("The umber hulk's gaze has confused you.");
				if (pl_on(ISHUH))
					lengthen(unconfuse,rnd(20)+HUHDURATION);
				else
					fuse(unconfuse,TRUE,rnd(20)+HUHDURATION);
				player.t_flags |= ISHUH;
			}
			tp->t_flags |= ISFOUND;
		}
	}
	/*
	 * Hide invisible monsters
	 */
	if ((tp->t_flags & ISINVIS) && pl_off(CANSEE))
		ch = mvinch(y, x);
	/*
	 * Let greedy ones guard gold
	 */
	if (on(*tp, ISGREED) && off(*tp, ISRUN)) {
		if (rp != NULL && rp->r_goldval) {
			tp->t_dest = &rp->r_gold;
			tp->t_flags |= ISRUN;
		}
	}
	return it;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %esi, %ebp
movl %edi, %r15d
callq 0x745e
movq %rax, %rbx
testq %rax, %rax
je 0xd36c
movq 0x10(%rbx), %r13
movb 0x8d(%r13), %r12b
leaq 0x20a98(%rip), %rax     # 0x2dc50
movq 0x70(%rax), %r14
testq %r14, %r14
je 0xd1f4
pushq $0x4
popq %rsi
movq %r14, %rdi
callq 0x12f50
testl %eax, %eax
je 0xd1f4
movq $-0x101, %rax           # imm = 0xFEFF
andq 0x78(%r13), %rax
leaq 0x20a6e(%rip), %rcx     # 0x2dc50
addq $0x50, %rcx
movq %rcx, 0x60(%r13)
orq $0x4, %rax
movq %rax, 0x78(%r13)
jmp 0xd221
pushq $0x64
popq %rdi
xorl %eax, %eax
callq 0xc004
cmpl $0x22, %eax
jl 0xd221
movl $0x120, %eax            # imm = 0x120
andl 0x78(%r13), %eax
cmpl $0x20, %eax
jne 0xd221
pushq $0xc
popq %rdi
callq 0x11fa5
testb %al, %al
je 0xd2e6
cmpb $0x55, %r12b
jne 0xd309
pushq $0x1
popq %rdi
callq 0x933b
testb %al, %al
je 0xd309
testq %r14, %r14
je 0xd25b
pushq $0x1
popq %rsi
movq %r14, %rdi
callq 0x12f50
testl %eax, %eax
jne 0xd25b
leaq 0x205fe(%rip), %rax     # 0x2d854
cmpl $0x2, (%rax)
jne 0xd27e
leaq 0x209ee(%rip), %rcx     # 0x2dc50
movl 0x50(%rcx), %eax
movl 0x54(%rcx), %ecx
subl %ebp, %eax
imull %eax, %eax
subl %r15d, %ecx
imull %ecx, %ecx
addl %eax, %ecx
cmpl $0x2, %ecx
ja 0xd309
testb $0x8, 0x78(%r13)
jne 0xd304
pushq $0x1
popq %rdi
callq 0xa933
testl %eax, %eax
jne 0xd304
pushq $0x10
popq %rdi
callq 0x11fa5
testb %al, %al
jne 0xd304
pushq $0x8
popq %rdi
callq 0x933b
testb %al, %al
je 0xd304
leaq 0x11d60(%rip), %rdi     # 0x1f010
xorl %eax, %eax
callq 0xb178
movl $0x200, %edi            # imm = 0x200
callq 0x932c
movl %eax, %r12d
pushq $0x14
popq %rdi
xorl %eax, %eax
callq 0xc004
addl $0x14, %eax
leaq -0x45f1(%rip), %rdi     # 0x8ce7
testb %r12b, %r12b
je 0xd2ef
movl %eax, %esi
callq 0x8a7d
jmp 0xd2f9
movq 0x78(%r13), %rax
jmp 0xd1db
pushq $0x1
popq %rsi
movl %eax, %edx
callq 0x8a46
leaq 0x20950(%rip), %rax     # 0x2dc50
orb $0x2, 0x79(%rax)
orb $0x8, 0x78(%r13)
testb $0x10, 0x78(%r13)
je 0xd341
movl $0x1000, %edi           # imm = 0x1000
callq 0x933b
testb %al, %al
je 0xd341
movq 0x1cc13(%rip), %r12     # 0x29f38
movq (%r12), %rdi
movl %r15d, %esi
movl %ebp, %edx
callq 0x6470
cmpl $-0x1, %eax
je 0xd341
movq (%r12), %rdi
callq 0x6320
movq 0x78(%r13), %rax
testb $0x40, %al
je 0xd36c
testq %r14, %r14
je 0xd36c
movl %eax, %ecx
andl $0x4, %ecx
jne 0xd36c
cmpl $0x0, 0x58(%r14)
je 0xd36c
addq $0x10, %r14
movq %r14, 0x60(%r13)
orq $0x4, %rax
movq %rax, 0x78(%r13)
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq