// File: /workspace/github_c_makefile_star2_O1/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 0x75c5
testq %rax, %rax
je 0xdb1a
movq %rax, %rbx
movq 0x10(%rax), %r13
movb 0x8d(%r13), %r12b
leaq 0x2027d(%rip), %rax     # 0x2dc60
movq 0x70(%rax), %r14
testq %r14, %r14
je 0xda18
movl $0x4, %esi
movq %r14, %rdi
callq 0x13e74
testl %eax, %eax
je 0xda18
andb $-0x2, 0x79(%r13)
leaq 0x20257(%rip), %rax     # 0x2dc60
addq $0x50, %rax
movq %rax, 0x60(%r13)
orb $0x4, 0x78(%r13)
jmp 0xda45
movl $0x64, %edi
xorl %eax, %eax
callq 0xc72d
cmpl $0x22, %eax
jl 0xda45
movl $0x120, %eax            # imm = 0x120
andl 0x78(%r13), %eax
cmpl $0x20, %eax
jne 0xda45
movl $0xc, %edi
callq 0x12d9c
testb %al, %al
je 0xda02
cmpb $0x55, %r12b
jne 0xdb3a
movl $0x1, %edi
callq 0x95a4
testb %al, %al
je 0xdb3a
testq %r14, %r14
je 0xda83
movl $0x1, %esi
movq %r14, %rdi
callq 0x13e74
testl %eax, %eax
jne 0xda83
leaq 0x1fde6(%rip), %rax     # 0x2d864
cmpl $0x2, (%rax)
jne 0xdaa6
leaq 0x201d6(%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 0xdb3a
testb $0x8, 0x78(%r13)
jne 0xdb35
movl $0x1, %edi
callq 0xae50
testl %eax, %eax
jne 0xdb35
movl $0x10, %edi
callq 0x12d9c
testb %al, %al
jne 0xdb35
movl $0x8, %edi
callq 0x95a4
testb %al, %al
je 0xdb35
leaq 0x13496(%rip), %rdi     # 0x20f78
xorl %eax, %eax
callq 0xb6e0
movl $0x200, %edi            # imm = 0x200
callq 0x9595
movl %eax, %r12d
movl $0x14, %edi
xorl %eax, %eax
callq 0xc72d
addl $0x14, %eax
leaq -0x4be4(%rip), %rdi     # 0x8f28
testb %r12b, %r12b
je 0xdb1e
movl %eax, %esi
callq 0x8ca6
jmp 0xdb2a
xorl %ebx, %ebx
jmp 0xdb9d
movl $0x1, %esi
movl %eax, %edx
callq 0x8c6f
leaq 0x2012f(%rip), %rax     # 0x2dc60
orb $0x2, 0x79(%rax)
orb $0x8, 0x78(%r13)
testb $0x10, 0x78(%r13)
je 0xdb72
movl $0x1000, %edi           # imm = 0x1000
callq 0x95a4
testb %al, %al
je 0xdb72
movq 0x1c3da(%rip), %r12     # 0x29f30
movq (%r12), %rdi
movl %r15d, %esi
movl %ebp, %edx
callq 0x6490
cmpl $-0x1, %eax
je 0xdb72
movq (%r12), %rdi
callq 0x6330
movq 0x78(%r13), %rax
testb $0x40, %al
je 0xdb9d
testq %r14, %r14
je 0xdb9d
movl %eax, %ecx
andl $0x4, %ecx
jne 0xdb9d
cmpl $0x0, 0x58(%r14)
je 0xdb9d
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