// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x50, %rsp
movb %dl, %al
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
andb $0x1, %al
movb %al, -0x19(%rbp)
movb $0x1, -0x39(%rbp)
movl $0x10000, %edi          # imm = 0x10000
callq 0xaa60
testb $0x1, %al
jne 0xb24b
jmp 0xb254
movb $0x0, -0x1(%rbp)
jmp 0xb5ea
movq -0x10(%rbp), %rax
movl 0x4(%rax), %edi
movq -0x10(%rbp), %rax
movl (%rax), %esi
callq 0x7c90
movq %rax, -0x38(%rbp)
cmpq $0x0, %rax
jne 0xb300
movq 0x27d45(%rip), %rax     # 0x32fc0
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movl 0x4(%rax), %esi
movq -0x10(%rbp), %rax
movl (%rax), %edx
callq 0x6490
cmpl $-0x1, %eax
jne 0xb297
jmp 0xb2ab
movq 0x27d22(%rip), %rax     # 0x32fc0
movq (%rax), %rdi
movl $0x2e, %esi
callq 0x64c0
leaq 0x2ebae(%rip), %rax     # 0x39e60
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movl 0x4(%rax), %esi
movq -0x10(%rbp), %rax
movl (%rax), %edx
callq 0x6490
cmpl $-0x1, %eax
jne 0xb2ce
jmp 0xb2e2
leaq 0x2eb8b(%rip), %rax     # 0x39e60
movq (%rax), %rdi
movl $0x20, %esi
callq 0x64c0
xorl %edi, %edi
callq 0xf540
leaq 0x1e970(%rip), %rdi     # 0x29c60
movb $0x0, %al
callq 0xd8f0
movb $0x0, -0x1(%rbp)
jmp 0xb5ea
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x30(%rbp)
leaq 0x2b9e1(%rip), %rax     # 0x36cfc
movl $0x0, (%rax)
leaq 0x2b9e0(%rip), %rax     # 0x36d08
movb $0x1, (%rax)
movq -0x10(%rbp), %rdi
leaq 0x2bd9a(%rip), %rsi     # 0x370d0
addq $0x50, %rsi
callq 0x7bf0
movq -0x28(%rbp), %rax
movsbl 0x8d(%rax), %eax
cmpl $0x4d, %eax
jne 0xb390
movq -0x28(%rbp), %rax
movsbl 0x8e(%rax), %eax
cmpl $0x4d, %eax
je 0xb390
movl $0x1, %edi
callq 0xaa90
testb $0x1, %al
jne 0xb36f
jmp 0xb390
leaq 0x1e913(%rip), %rdi     # 0x29c89
movb $0x0, %al
callq 0xd8f0
movq -0x28(%rbp), %rax
movb $0x4d, 0x8e(%rax)
movb -0x19(%rbp), %al
andb $0x1, %al
movb %al, -0x39(%rbp)
testb $0x1, -0x39(%rbp)
je 0xb5d5
movb $0x0, -0x39(%rbp)
movl $0x1, %edi
callq 0xaa60
testb $0x1, %al
jne 0xb3ae
jmp 0xb3bb
leaq 0x1fd44(%rip), %rax     # 0x2b0f9
movq %rax, -0x48(%rbp)
jmp 0xb3db
movq -0x28(%rbp), %rax
movslq 0x80(%rax), %rcx
leaq 0x27ff3(%rip), %rax     # 0x333c0
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq %rax, -0x48(%rbp)
movl $0x1000, %edi           # imm = 0x1000
callq 0xaa60
testb $0x1, %al
jne 0xb3eb
jmp 0xb431
movq -0x28(%rbp), %rax
movq 0x78(%rax), %rax
andq $0x10, %rax
cmpq $0x0, %rax
je 0xb431
movq -0x28(%rbp), %rax
movq 0x78(%rax), %rax
andq $0x1000, %rax           # imm = 0x1000
cmpq $0x0, %rax
jne 0xb431
movq -0x28(%rbp), %rax
movq 0x78(%rax), %rcx
orq $0x1000, %rcx           # imm = 0x1000
movq %rcx, 0x78(%rax)
movq -0x30(%rbp), %rax
movl 0x2c(%rax), %ecx
addl $0x3, %ecx
movl %ecx, 0x2c(%rax)
leaq 0x2bd98(%rip), %rax     # 0x371d0
movq (%rax), %rdi
movq -0x30(%rbp), %rsi
movq -0x18(%rbp), %rdx
movb -0x19(%rbp), %al
andb $0x1, %al
movzbl %al, %ecx
callq 0xb600
testb $0x1, %al
jne 0xb459
jmp 0xb5b3
movb $0x1, -0x39(%rbp)
testb $0x1, -0x19(%rbp)
je 0xb472
movq -0x18(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0xba50
jmp 0xb47b
xorl %eax, %eax
movl %eax, %edi
callq 0xbab0
movl $0x800, %edi            # imm = 0x800
callq 0xaa60
testb $0x1, %al
jne 0xb48b
jmp 0xb4fd
leaq 0x1e80d(%rip), %rdi     # 0x29c9f
movb $0x0, %al
callq 0xd8f0
movq -0x48(%rbp), %rsi
leaq 0x1e817(%rip), %rdi     # 0x29cbb
movb $0x0, %al
callq 0xd8f0
movq -0x28(%rbp), %rax
movq 0x78(%rax), %rcx
orq $0x200, %rcx            # imm = 0x200
movq %rcx, 0x78(%rax)
leaq 0x2bc0b(%rip), %rax     # 0x370d0
movq 0x78(%rax), %rcx
andq $-0x801, %rcx           # imm = 0xF7FF
leaq 0x2bbf9(%rip), %rax     # 0x370d0
movq %rcx, 0x78(%rax)
movl $0x100, %edi            # imm = 0x100
callq 0xaa60
testb $0x1, %al
jne 0xb4eb
jmp 0xb4fb
movq -0x28(%rbp), %rax
movsbl 0x8d(%rax), %edi
callq 0x10f00
jmp 0xb4fd
movq -0x30(%rbp), %rax
cmpl $0x0, 0x30(%rax)
jg 0xb51a
movq -0x38(%rbp), %rdi
movl $0x1, %esi
callq 0xbaf0
jmp 0xb5b1
movq -0x28(%rbp), %rdi
callq 0x10f90
testb $0x1, %al
jne 0xb52c
jmp 0xb5af
movq -0x28(%rbp), %rax
movq 0x78(%rax), %rax
andq $0x80, %rax
cmpq $0x0, %rax
jne 0xb5af
leaq 0x2b78d(%rip), %rax     # 0x36cd4
cmpl $0x2, (%rax)
je 0xb5ad
movq -0x28(%rbp), %rax
cmpq $0x0, 0x70(%rax)
je 0xb5ad
movq -0x28(%rbp), %rax
movq 0x70(%rax), %rdi
movl $0x4, %esi
callq 0x19950
cmpl $0x0, %eax
jne 0xb5ad
movq -0x28(%rbp), %rax
movq 0x78(%rax), %rcx
orq $0x80, %rcx
movq %rcx, 0x78(%rax)
movq -0x48(%rbp), %rdi
xorl %esi, %esi
callq 0xbe10
movq %rax, %rsi
leaq 0x1e73e(%rip), %rdi     # 0x29cd4
movb $0x0, %al
callq 0xd8f0
movq -0x28(%rbp), %rax
movsbl 0x8d(%rax), %edi
callq 0x10f00
jmp 0xb5af
jmp 0xb5b1
jmp 0xb5d3
testb $0x1, -0x19(%rbp)
je 0xb5c8
movq -0x18(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0xbec0
jmp 0xb5d1
xorl %eax, %eax
movl %eax, %edi
callq 0xbf20
jmp 0xb5d3
jmp 0xb5d5
leaq 0x2b718(%rip), %rax     # 0x36cf4
movl $0x0, (%rax)
movb -0x39(%rbp), %al
andb $0x1, %al
movb %al, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)