// File: /workspace/github_c_makefile_star2_O2/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 0x932c
testb %al, %al
je 0x9719
xorl %r13d, %r13d
jmp 0x9995
movl (%r15), %esi
movl 0x4(%r15), %edi
callq 0x745e
testq %rax, %rax
je 0x97b0
movq %rax, %r14
movq 0x10(%rax), %rbx
leaq 0x24140(%rip), %rax     # 0x2d87c
andl $0x0, (%rax)
leaq 0x24142(%rip), %rax     # 0x2d888
movb $0x1, (%rax)
leaq 0x24500(%rip), %rax     # 0x2dc50
leaq 0x50(%rax), %rsi
movq %r15, %rdi
callq 0x7427
cmpb $0x4d, 0x8d(%rbx)
jne 0x979b
cmpb $0x4d, 0x8e(%rbx)
je 0x979b
pushq $0x1
popq %rdi
callq 0x933b
testb %al, %al
je 0x979b
leaq 0x1413c(%rip), %rdi     # 0x1d8bd
xorl %r13d, %r13d
xorl %eax, %eax
callq 0xb178
movb $0x4d, 0x8e(%rbx)
testb %bpl, %bpl
je 0x998b
pushq $0x1
popq %rdi
callq 0x932c
testb %al, %al
je 0x9819
leaq 0x15524(%rip), %r15     # 0x1ecd2
jmp 0x982f
movq 0x20781(%rip), %rbx     # 0x29f38
movq (%rbx), %rdi
movl (%r15), %edx
movl 0x4(%r15), %esi
callq 0x6470
cmpl $-0x1, %eax
je 0x97d6
movq (%rbx), %rdi
pushq $0x2e
popq %rsi
callq 0x64a0
leaq 0x27203(%rip), %rbx     # 0x309e0
movq (%rbx), %rdi
movl (%r15), %edx
movl 0x4(%r15), %esi
callq 0x6470
cmpl $-0x1, %eax
je 0x97fc
movq (%rbx), %rdi
pushq $0x20
popq %rsi
callq 0x64a0
xorl %r13d, %r13d
xorl %edi, %edi
callq 0xc377
leaq 0x14087(%rip), %rdi     # 0x1d894
xorl %eax, %eax
callq 0xb178
jmp 0x9995
movslq 0x80(%rbx), %rax
imulq $0x70, %rax, %rax
leaq 0x20b85(%rip), %rcx     # 0x2a3b0
movq (%rcx,%rax), %r15
movl $0x1000, %edi           # imm = 0x1000
callq 0x932c
testb %al, %al
je 0x985c
movq 0x78(%rbx), %rax
movl %eax, %ecx
andl $0x1010, %ecx           # imm = 0x1010
cmpl $0x10, %ecx
jne 0x985c
orq $0x1000, %rax           # imm = 0x1000
movq %rax, 0x78(%rbx)
addl $0x3, 0x2c(%rbx)
leaq 0x244ed(%rip), %rax     # 0x2dd50
movq (%rax), %rdi
movzbl %bpl, %ecx
movq %rbx, %rsi
movq %r12, %rdx
callq 0x99a7
testb %al, %al
je 0x988b
testb %bpl, %bpl
je 0x98a7
movq %r12, %rdi
movq %r15, %rsi
callq 0x9ce7
jmp 0x98ae
testb %bpl, %bpl
je 0x9971
movq %r12, %rdi
movq %r15, %rsi
callq 0xa01f
xorl %r13d, %r13d
jmp 0x998b
xorl %edi, %edi
callq 0x9d22
movl $0x800, %edi            # imm = 0x800
callq 0x932c
testb %al, %al
je 0x9904
leaq 0x14010(%rip), %rdi     # 0x1d8d3
xorl %eax, %eax
callq 0xb178
leaq 0x1401e(%rip), %rdi     # 0x1d8ef
movq %r15, %rsi
xorl %eax, %eax
callq 0xb178
orb $0x2, 0x79(%rbx)
leaq 0x2436a(%rip), %rax     # 0x2dc50
andb $-0x9, 0x79(%rax)
movl $0x100, %edi            # imm = 0x100
callq 0x932c
testb %al, %al
je 0x9904
movsbl 0x8d(%rbx), %edi
callq 0xd4b0
cmpl $0x0, 0x30(%rbx)
jle 0x997d
movq %rbx, %rdi
callq 0xd4f6
movb $0x1, %r13b
testb %al, %al
je 0x998b
testb $-0x80, 0x78(%rbx)
jne 0x998b
leaq 0x23f2e(%rip), %rax     # 0x2d854
cmpl $0x2, (%rax)
je 0x998b
movq 0x70(%rbx), %rdi
testq %rdi, %rdi
je 0x998b
pushq $0x4
popq %rsi
callq 0x12f50
testl %eax, %eax
jne 0x998b
orb $-0x80, 0x78(%rbx)
movq %r15, %rdi
xorl %esi, %esi
callq 0x9f94
leaq 0x13fb3(%rip), %rdi     # 0x1d908
leaq 0x23e84(%rip), %rsi     # 0x2d7e0
xorl %eax, %eax
callq 0xb178
movsbl 0x8d(%rbx), %edi
callq 0xd4b0
jmp 0x998b
xorl %r13d, %r13d
xorl %edi, %edi
callq 0xa05a
jmp 0x998b
pushq $0x1
popq %rsi
movq %r14, %rdi
callq 0x9d41
movb $0x1, %r13b
leaq 0x23ee2(%rip), %rax     # 0x2d874
andl $0x0, (%rax)
movl %r13d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq