// File: /workspace/github_c_makefile_star2_O3/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 0x7502
movq %rax, %rbx
testq %rax, %rax
je 0xdb3e
movq 0x10(%rbx), %r13
movb 0x8d(%r13), %r12b
leaq 0x202ee(%rip), %rax     # 0x2dc60
movq 0x70(%rax), %r14
testq %r14, %r14
je 0xd9b0
movl $0x4, %esi
movq %r14, %rdi
callq 0x13d18
testl %eax, %eax
je 0xd9b0
movq $-0x101, %rax           # imm = 0xFEFF
andq 0x78(%r13), %rax
leaq 0x202c2(%rip), %rcx     # 0x2dc60
addq $0x50, %rcx
movq %rcx, 0x60(%r13)
orq $0x4, %rax
movq %rax, 0x78(%r13)
jmp 0xd9e1
movl $0x64, %edi
xorl %eax, %eax
callq 0xc674
cmpl $0x22, %eax
jl 0xd9e1
movl $0x120, %eax            # imm = 0x120
andl 0x78(%r13), %eax
cmpl $0x20, %eax
jne 0xd9e1
movl $0xc, %edi
callq 0x12c34
testb %al, %al
je 0xdab6
cmpb $0x55, %r12b
jne 0xdadb
movl $0x1, %edi
callq 0x9522
testb %al, %al
je 0xdadb
testq %r14, %r14
je 0xda1f
movl $0x1, %esi
movq %r14, %rdi
callq 0x13d18
testl %eax, %eax
jne 0xda1f
leaq 0x1fe4a(%rip), %rax     # 0x2d864
cmpl $0x2, (%rax)
jne 0xda42
leaq 0x2023a(%rip), %rcx     # 0x2dc60
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 0xdadb
testb $0x8, 0x78(%r13)
jne 0xdad6
movl $0x1, %edi
callq 0xad9d
testl %eax, %eax
jne 0xdad6
movl $0x10, %edi
callq 0x12c34
testb %al, %al
jne 0xdad6
movl $0x8, %edi
callq 0x9522
testb %al, %al
je 0xdad6
leaq 0x13592(%rip), %rdi     # 0x21010
xorl %eax, %eax
callq 0xb620
movl $0x200, %edi            # imm = 0x200
callq 0x9513
movl %eax, %r12d
movl $0x14, %edi
xorl %eax, %eax
callq 0xc674
addl $0x14, %eax
leaq -0x4c3a(%rip), %rdi     # 0x8e6e
testb %r12b, %r12b
je 0xdabf
movl %eax, %esi
callq 0x8bde
jmp 0xdacb
movq 0x78(%r13), %rax
jmp 0xd997
movl $0x1, %esi
movl %eax, %edx
callq 0x8ba7
leaq 0x2018e(%rip), %rax     # 0x2dc60
orb $0x2, 0x79(%rax)
orb $0x8, 0x78(%r13)
testb $0x10, 0x78(%r13)
je 0xdb13
movl $0x1000, %edi           # imm = 0x1000
callq 0x9522
testb %al, %al
je 0xdb13
movq 0x1c439(%rip), %r12     # 0x29f30
movq (%r12), %rdi
movl %r15d, %esi
movl %ebp, %edx
callq 0x6490
cmpl $-0x1, %eax
je 0xdb13
movq (%r12), %rdi
callq 0x6330
movq 0x78(%r13), %rax
testb $0x40, %al
je 0xdb3e
testq %r14, %r14
je 0xdb3e
movl %eax, %ecx
andl $0x4, %ecx
jne 0xdb3e
cmpl $0x0, 0x58(%r14)
je 0xdb3e
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