// File: /workspace/github_c_makefile_star2_O3/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 0x9513
testb %al, %al
je 0x997d
xorl %r13d, %r13d
jmp 0x9c8b
movl (%r15), %esi
movl 0x4(%r15), %edi
callq 0x7502
testq %rax, %rax
je 0x9a1e
movq %rax, %r14
movq 0x10(%rax), %rbx
leaq 0x23eec(%rip), %rax     # 0x2d88c
movl $0x0, (%rax)
leaq 0x23eeb(%rip), %rax     # 0x2d898
movb $0x1, (%rax)
leaq 0x242a9(%rip), %rax     # 0x2dc60
leaq 0x50(%rax), %rsi
movq %r15, %rdi
callq 0x74b9
cmpb $0x4d, 0x8d(%rbx)
jne 0x9a04
cmpb $0x4d, 0x8e(%rbx)
je 0x9a04
movl $0x1, %edi
callq 0x9522
testb %al, %al
je 0x9a04
leaq 0x15ed3(%rip), %rdi     # 0x1f8bd
xorl %r13d, %r13d
xorl %eax, %eax
callq 0xb620
movb $0x4d, 0x8e(%rbx)
testb %bpl, %bpl
je 0x9c7e
movl $0x1, %edi
callq 0x9513
testb %al, %al
je 0x9a8b
leaq 0x172b9(%rip), %r15     # 0x20cd2
jmp 0x9aa1
movq 0x2050b(%rip), %rbx     # 0x29f30
movq (%rbx), %rdi
movl (%r15), %edx
movl 0x4(%r15), %esi
callq 0x6490
cmpl $-0x1, %eax
je 0x9a46
movq (%rbx), %rdi
movl $0x2e, %esi
callq 0x64c0
leaq 0x26fa3(%rip), %rbx     # 0x309f0
movq (%rbx), %rdi
movl (%r15), %edx
movl 0x4(%r15), %esi
callq 0x6490
cmpl $-0x1, %eax
je 0x9a6e
movq (%rbx), %rdi
movl $0x20, %esi
callq 0x64c0
xorl %r13d, %r13d
xorl %edi, %edi
callq 0xcae0
leaq 0x15e15(%rip), %rdi     # 0x1f894
xorl %eax, %eax
callq 0xb620
jmp 0x9c8b
movslq 0x80(%rbx), %rax
imulq $0x70, %rax, %rax
leaq 0x20923(%rip), %rcx     # 0x2a3c0
movq (%rcx,%rax), %r15
movl $0x1000, %edi           # imm = 0x1000
callq 0x9513
testb %al, %al
je 0x9ace
movq 0x78(%rbx), %rax
movl %eax, %ecx
andl $0x1010, %ecx           # imm = 0x1010
cmpl $0x10, %ecx
jne 0x9ace
orq $0x1000, %rax           # imm = 0x1000
movq %rax, 0x78(%rbx)
addl $0x3, 0x2c(%rbx)
leaq 0x2428b(%rip), %rax     # 0x2dd60
movq (%rax), %rdi
movzbl %bpl, %ecx
movq %rbx, %rsi
movq %r12, %rdx
callq 0x9c9d
testb %al, %al
je 0x9afd
testb %bpl, %bpl
je 0x9b19
movq %r12, %rdi
movq %r15, %rsi
callq 0x9fef
jmp 0x9b4f
testb %bpl, %bpl
je 0x9c2c
movq %r12, %rdi
movq %r15, %rsi
callq 0xa382
xorl %r13d, %r13d
jmp 0x9c7e
movl $0x756f79, 0x23ccd(%rip) # imm = 0x756F79
leaq 0x23cc6(%rip), %r12     # 0x2d7f0
callq 0x6030
movq (%rax), %rax
movb 0x1e4(%rax), %al
movb %al, 0x23cb2(%rip)      # 0x2d7f0
leaq 0x15f76(%rip), %rdi     # 0x1fabb
movq %r12, %rsi
xorl %eax, %eax
callq 0xb620
movl $0x800, %edi            # imm = 0x800
callq 0x9513
testb %al, %al
je 0x9ba5
leaq 0x15d6f(%rip), %rdi     # 0x1f8d3
xorl %eax, %eax
callq 0xb620
leaq 0x15d7d(%rip), %rdi     # 0x1f8ef
movq %r15, %rsi
xorl %eax, %eax
callq 0xb620
orb $0x2, 0x79(%rbx)
leaq 0x240d9(%rip), %rax     # 0x2dc60
andb $-0x9, 0x79(%rax)
movl $0x100, %edi            # imm = 0x100
callq 0x9513
testb %al, %al
je 0x9ba5
movsbl 0x8d(%rbx), %edi
callq 0xdca2
cmpl $0x0, 0x30(%rbx)
jle 0x9c6e
movq %rbx, %rdi
callq 0xdd0a
movb $0x1, %r13b
testb %al, %al
je 0x9c7e
testb $-0x80, 0x78(%rbx)
jne 0x9c7e
leaq 0x23c91(%rip), %rax     # 0x2d864
cmpl $0x2, (%rax)
je 0x9c7e
movq 0x70(%rbx), %rdi
testq %rdi, %rdi
je 0x9c7e
movl $0x4, %esi
callq 0x13d18
testl %eax, %eax
jne 0x9c7e
orb $-0x80, 0x78(%rbx)
movq %r15, %rdi
xorl %esi, %esi
callq 0xa2f5
leaq 0x15cf8(%rip), %rdi     # 0x1f908
leaq 0x23bd9(%rip), %rsi     # 0x2d7f0
xorl %eax, %eax
callq 0xb620
movsbl 0x8d(%rbx), %edi
callq 0xdca2
jmp 0x9c7e
movl $0x756f79, 0x23bba(%rip) # imm = 0x756F79
leaq 0x23bb3(%rip), %rbx     # 0x2d7f0
callq 0x6030
movq (%rax), %rax
movb 0x1e4(%rax), %al
movb %al, 0x23b9f(%rip)      # 0x2d7f0
leaq 0x15e6b(%rip), %rdi     # 0x1fac3
leaq 0x19d2a(%rip), %rdx     # 0x23989
xorl %r13d, %r13d
movq %rbx, %rsi
xorl %eax, %eax
callq 0xb620
jmp 0x9c7e
movq %r14, %rdi
movl $0x1, %esi
callq 0xa04b
movb $0x1, %r13b
leaq 0x23bff(%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