// File: /workspace/github_c_makefile_star2_O1/ajpaulson[P]srogue11/fight.c
// Function: fight
bool fight(struct coord *mp,struct object *weap,bool thrown)
{

	struct thing *tp;
	struct stats *st;
	struct linked_list *item;
	bool did_hit = TRUE;

	if (pl_on(ISETHER))			/* cant fight when ethereal */
		return 0;

	if ((item = find_mons(mp->y, mp->x)) == NULL) {
		mvaddch(mp->y, mp->x, FLOOR);
		mvwaddch(mw, mp->y, mp->x, ' ');
		look(FALSE);
		msg("That monster must have been an illusion.");
		return 0;
	}
	tp = THINGPTR(item);
	st = &tp->t_stats;
	/*
	 * Since we are fighting, things are not quiet so
	 * no healing takes place.
	 */
	quiet = 0;
	isfight = TRUE;
	runto(mp, &hero);
	/*
	 * Let him know it was really a mimic (if it was one).
	 */
	if(tp->t_type == 'M' && tp->t_disguise != 'M' && pl_off(ISBLIND)) {
		msg("Wait! That's a mimic!");
		tp->t_disguise = 'M';
		did_hit = thrown;
	}
	if (did_hit) {
		char *mname;

		did_hit = FALSE;
		if (pl_on(ISBLIND))
			mname = "it";
		else
			mname = monsters[tp->t_indx].m_name;
		/*
		 * If the hero can see the invisibles, then
		 * make it easier to hit.
		 */
		if (pl_on(CANSEE) && on(*tp, ISINVIS) && off(*tp, WASHIT)) {
			tp->t_flags |= WASHIT;
			st->s_arm += 3;
		}
		if (roll_em(him, st, weap, thrown)) {
			did_hit = TRUE;
			if (thrown)
				thunk(weap, mname);
			else
				hit(NULL);
			if (pl_on(CANHUH)) {
				msg("Your hands stop glowing red");
				msg("The %s appears confused.", mname);
				tp->t_flags |= ISHUH;
				player.t_flags &= ~CANHUH;
				/*
				 * If our hero was stuck by a bone devil,
				 * release him now because the devil is
				 * confused.
				 */
				if (pl_on(ISHELD))
					unhold(tp->t_type);
			}
			if (st->s_hpt <= 0)
				killed(item, TRUE);
			else if (monhurt(tp) && off(*tp, ISWOUND)) {
				if (levtype != MAZELEV && tp->t_room != NULL &&
				  !rf_on(tp->t_room, ISTREAS)) {
					tp->t_flags |= ISWOUND;
					msg("You wounded %s.",prname(mname,FALSE));
					unhold(tp->t_type);
				}
			}
		}
		else {
			if (thrown)
				bounce(weap, mname);
			else
				miss(NULL);
		}
	}
	count = 0;
	return did_hit;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %ebp
movq %rsi, %r12
movq %rdi, %r15
movl $0x10000, %edi          # imm = 0x10000
callq 0x9595
testb %al, %al
je 0x99f5
xorl %r13d, %r13d
jmp 0x9d06
movl (%r15), %esi
movl 0x4(%r15), %edi
callq 0x75c5
testq %rax, %rax
je 0x9a99
movq %rax, %r14
movq 0x10(%rax), %rbx
leaq 0x23e74(%rip), %rax     # 0x2d88c
movl $0x0, (%rax)
leaq 0x23e73(%rip), %rax     # 0x2d898
movb $0x1, (%rax)
leaq 0x24231(%rip), %rax     # 0x2dc60
leaq 0x50(%rax), %rsi
movq %r15, %rdi
callq 0x7571
movb $0x1, %r13b
cmpb $0x4d, 0x8d(%rbx)
jne 0x9a76
cmpb $0x4d, 0x8e(%rbx)
je 0x9a76
movl $0x1, %edi
callq 0x95a4
testb %al, %al
je 0x9a76
leaq 0x15e58(%rip), %rdi     # 0x1f8bd
xorl %eax, %eax
callq 0xb6e0
movb $0x4d, 0x8e(%rbx)
movl %ebp, %r13d
testb %r13b, %r13b
je 0x9cf9
movl $0x1, %edi
callq 0x9595
testb %al, %al
je 0x9b06
leaq 0x1722d(%rip), %r15     # 0x20cc1
jmp 0x9b1c
movq 0x20490(%rip), %rbx     # 0x29f30
movq (%rbx), %rdi
movl (%r15), %edx
movl 0x4(%r15), %esi
callq 0x6490
cmpl $-0x1, %eax
je 0x9ac1
movq (%rbx), %rdi
movl $0x2e, %esi
callq 0x64c0
leaq 0x26f28(%rip), %rbx     # 0x309f0
movq (%rbx), %rdi
movl (%r15), %edx
movl 0x4(%r15), %esi
callq 0x6490
cmpl $-0x1, %eax
je 0x9ae9
movq (%rbx), %rdi
movl $0x20, %esi
callq 0x64c0
xorl %r13d, %r13d
xorl %edi, %edi
callq 0xcb98
leaq 0x15d9a(%rip), %rdi     # 0x1f894
xorl %eax, %eax
callq 0xb6e0
jmp 0x9d06
movslq 0x80(%rbx), %rax
imulq $0x70, %rax, %rax
leaq 0x208a8(%rip), %rcx     # 0x2a3c0
movq (%rcx,%rax), %r15
movl $0x1000, %edi           # imm = 0x1000
callq 0x9595
testb %al, %al
je 0x9b49
movq 0x78(%rbx), %rax
movl %eax, %ecx
andl $0x1010, %ecx           # imm = 0x1010
cmpl $0x10, %ecx
jne 0x9b49
orq $0x1000, %rax           # imm = 0x1000
movq %rax, 0x78(%rbx)
addl $0x3, 0x2c(%rbx)
leaq 0x24210(%rip), %rax     # 0x2dd60
movq (%rax), %rdi
movzbl %bpl, %ecx
movq %rbx, %rsi
movq %r12, %rdx
callq 0x9d18
testb %al, %al
je 0x9b78
testb %bpl, %bpl
je 0x9b94
movq %r12, %rdi
movq %r15, %rsi
callq 0xa0ad
jmp 0x9bca
testb %bpl, %bpl
je 0x9ca7
movq %r12, %rdi
movq %r15, %rsi
callq 0xa440
xorl %r13d, %r13d
jmp 0x9cf9
leaq 0x23c55(%rip), %r12     # 0x2d7f0
movl $0x756f79, 0x23c4b(%rip) # imm = 0x756F79
callq 0x6030
movq (%rax), %rax
movb 0x1e4(%rax), %al
movb %al, 0x23c37(%rip)      # 0x2d7f0
leaq 0x15efb(%rip), %rdi     # 0x1fabb
movq %r12, %rsi
xorl %eax, %eax
callq 0xb6e0
movl $0x800, %edi            # imm = 0x800
callq 0x9595
testb %al, %al
je 0x9c20
leaq 0x15cf4(%rip), %rdi     # 0x1f8d3
xorl %eax, %eax
callq 0xb6e0
leaq 0x15d02(%rip), %rdi     # 0x1f8ef
movq %r15, %rsi
xorl %eax, %eax
callq 0xb6e0
orb $0x2, 0x79(%rbx)
leaq 0x2405e(%rip), %rax     # 0x2dc60
andb $-0x9, 0x79(%rax)
movl $0x100, %edi            # imm = 0x100
callq 0x9595
testb %al, %al
je 0x9c20
movsbl 0x8d(%rbx), %edi
callq 0xdd01
cmpl $0x0, 0x30(%rbx)
jle 0x9ce9
movq %rbx, %rdi
callq 0xdd69
movb $0x1, %r13b
testb %al, %al
je 0x9cf9
testb $-0x80, 0x78(%rbx)
jne 0x9cf9
leaq 0x23c16(%rip), %rax     # 0x2d864
cmpl $0x2, (%rax)
je 0x9cf9
movq 0x70(%rbx), %rdi
testq %rdi, %rdi
je 0x9cf9
movl $0x4, %esi
callq 0x13e74
testl %eax, %eax
jne 0x9cf9
orb $-0x80, 0x78(%rbx)
movq %r15, %rdi
xorl %esi, %esi
callq 0xa3b3
leaq 0x15c7d(%rip), %rdi     # 0x1f908
leaq 0x23b5e(%rip), %rsi     # 0x2d7f0
xorl %eax, %eax
callq 0xb6e0
movsbl 0x8d(%rbx), %edi
callq 0xdd01
jmp 0x9cf9
leaq 0x23b42(%rip), %rbx     # 0x2d7f0
movl $0x756f79, 0x23b38(%rip) # imm = 0x756F79
callq 0x6030
movq (%rax), %rax
movb 0x1e4(%rax), %al
movb %al, 0x23b24(%rip)      # 0x2d7f0
leaq 0x15df0(%rip), %rdi     # 0x1fac3
leaq 0x19c37(%rip), %rdx     # 0x23911
xorl %r13d, %r13d
movq %rbx, %rsi
xorl %eax, %eax
callq 0xb6e0
jmp 0x9cf9
movq %r14, %rdi
movl $0x1, %esi
callq 0xa109
movb $0x1, %r13b
leaq 0x23b84(%rip), %rax     # 0x2d884
movl $0x0, (%rax)
movl %r13d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq