// File: /workspace/github_c_makefile_star2_O2/ajpaulson[P]srogue11/fight.c
// Function: attack
int attack(struct thing *mp)
{
	char *mname;

	if (pl_on(ISETHER))		/* ethereal players cant be hit */
		return(0);
	if (mp->t_flags & ISPARA)	/* paralyzed monsters */
		return(0);
	running = FALSE;
	quiet = 0;
	isfight = TRUE;
	if (mp->t_type == 'M' && pl_off(ISBLIND))
		mp->t_disguise = 'M';
	if (pl_on(ISBLIND))
		mname = "it";
	else
		mname = monsters[mp->t_indx].m_name;
	if (roll_em(&mp->t_stats, him, NULL, FALSE)) {
		if (pl_on(ISINVINC)) {
			msg("%s does not harm you.",prname(mname,TRUE));
		}
		else {
			nochange = FALSE;
			if (mp->t_type != 'E')
				hit(mname);
			if (him->s_hpt <= 0)
				death(mp->t_indx);
			if (off(*mp, ISCANC))
				switch (mp->t_type) {
				case 'R':
					if (hurt_armor(cur_armor)) {
						msg("Your armor weakens.");
						cur_armor->o_ac++;
					}
				when 'E':
				/*
				 * The gaze of the floating eye hypnotizes you
				 */
					if (pl_off(ISBLIND) && player.t_nocmd <= 0) {
						player.t_nocmd = rnd(16) + 25;
						msg("You are transfixed.");
					}
				when 'Q':
					if (!save(VS_POISON) && !iswearing(R_SUSAB)) {
						if (him->s_ef.a_dex > MINABIL) {
							chg_abil(DEX, -1, TRUE);
							msg("You feel less agile.");
						}
					}
				when 'A':
					if (!save(VS_POISON) && herostr() > MINABIL) {
						if (!iswearing(R_SUSTSTR) && !iswearing(R_SUSAB)) {
							if (levcount > 0) {
								chg_abil(STR, -1, TRUE);
								msg("A sting has weakened you");
							}
						}
						else
							msg("Sting has no effect.");
					}
				when 'W':
					if (rnd(100) < 15 && !iswearing(R_SUSAB)) {
						if (him->s_exp <= 0)
							death(mp->t_indx);
						msg("You suddenly feel weaker.");
						if (--him->s_lvl == 0) {
							him->s_exp = 0;
							him->s_lvl = 1;
						}
						else
							him->s_exp = e_levels[him->s_lvl - 1] + 1;
						chg_hpt(-roll(1,10),TRUE,mp->t_indx);
					}
				when 'F':
					player.t_flags |= ISHELD;
					sprintf(monsters[midx('F')].m_stats.s_dmg,"%dd1",++fung_hit);
				when 'L': {
					long lastpurse;
					struct linked_list *lep;

					lastpurse = purse;
					purse -= GOLDCALC;
					if (!save(VS_MAGIC))
						purse -= GOLDCALC + GOLDCALC + GOLDCALC + GOLDCALC;
					if (purse < 0)
						purse = 0;
					if (purse != lastpurse)
						msg("Your purse feels lighter.");
					lep = find_mons(mp->t_pos.y,mp->t_pos.x);
					if (lep != NULL)
					{
						remove_monster(&mp->t_pos, lep);
						mp = NULL;
					}
				}
				when 'N': {
					struct linked_list *steal, *list;
					struct object *sobj;
					int stworth = 0, wo;

					/*
					 * Nymph's steal a magic item, look through the pack
					 * and pick out one we like, namely the object worth
					 * the most bucks.
					 */
					steal = NULL;
					for (list = pack; list != NULL; list = next(list)) {
						wo = get_worth(OBJPTR(list));
						if (wo > stworth) {
							stworth = wo;
							steal = list;
						}
					}
					if (steal != NULL) {
						sobj = OBJPTR(steal);
						if (o_off(sobj, ISPROT)) {
							struct linked_list *nym;

							nym = find_mons(mp->t_pos.y, mp->t_pos.x);
							if (nym != NULL)
							{
								remove_monster(&mp->t_pos, nym);
								mp = NULL;
							}
							msg("She stole %s!", inv_name(sobj, TRUE));
							detach(pack, steal);
							discard(steal);
							cur_null(sobj);
							updpack();
						}
					}
				}
				when 'c':
					if (!save(VS_PETRIFICATION)) {
						msg("Your body begins to solidify.");
						msg("You are turned to stone !!! --More--");
						wait_for(cw, ' ');
						death(mp->t_indx);
					}
				when 'd':
					if (rnd(100) < 50 && !(mp->t_flags & ISHUH))
						player.t_flags |= ISHELD;
					if (!save(VS_POISON)) {
						if (iswearing(R_SUSAB) || iswearing(R_SUSTSTR))
							msg("Sting has no effect.");
						else {
							int fewer, ostr;

							fewer = roll(1,4);
							ostr = herostr();
							chg_abil(STR,-fewer,TRUE);
							if (herostr() < ostr) {
								fewer = ostr - herostr();
								fuse(rchg_str, fewer - 1, 10);
							}
							msg("You feel weaker now.");
						}
					}
				when 'g':
					if (!save(VS_BREATH) && !iswearing(R_BREATH)) {
						msg("You feel singed.");
						chg_hpt(-roll(1,8),FALSE,mp->t_indx);
					}
				when 'h':
					if (!save(VS_BREATH) && !iswearing(R_BREATH)) {
						msg("You are seared.");
						chg_hpt(-roll(1,4),FALSE,mp->t_indx);
					}
				when 'p':
					if (!save(VS_POISON) && herostr() > MINABIL) {
						if (!iswearing(R_SUSTSTR) && !iswearing(R_SUSAB)) {
							msg("You are gnawed.");
							chg_abil(STR,-1,TRUE);
						}
					}
				when 'u':
					if (!save(VS_POISON) && herostr() > MINABIL) {
						if (!iswearing(R_SUSTSTR) && !iswearing(R_SUSAB)) {
							msg("You are bitten.");
							chg_abil(STR, -1, TRUE);
							fuse(rchg_str, 1, roll(5,10));
				 		}
					}
				when 'w':
					if (!save(VS_POISON) && !iswearing(R_SUSAB)) {
						msg("You feel devitalized.");
						chg_hpt(-1,TRUE,mp->t_indx);
					}
				when 'i':
					if (!save(VS_PARALYZATION) && !iswearing(R_SUSAB)) {
						if (pl_on(ISSLOW))
							lengthen(notslow,roll(3,10));
						else {
							msg("You feel impaired.");
							player.t_flags |= ISSLOW;
							fuse(notslow,TRUE,roll(5,10));
						}
					}
				otherwise:
					break;
			}
		}
	}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl $0x10000, %edi          # imm = 0x10000
callq 0x932c
movl %eax, %ecx
xorl %eax, %eax
testb %cl, %cl
jne 0xa924
testb $0x2, 0x78(%rbx)
jne 0xa924
leaq 0x237c6(%rip), %rax     # 0x2d88c
movb $0x0, (%rax)
leaq 0x237ac(%rip), %rax     # 0x2d87c
andl $0x0, (%rax)
leaq 0x237ae(%rip), %rax     # 0x2d888
movb $0x1, (%rax)
cmpb $0x4d, 0x8d(%rbx)
jne 0xa0f9
pushq $0x1
popq %rdi
callq 0x933b
testb %al, %al
je 0xa0f9
movb $0x4d, 0x8e(%rbx)
pushq $0x1
popq %rdi
callq 0x932c
testb %al, %al
je 0xa10e
leaq 0x14bc6(%rip), %r14     # 0x1ecd2
jmp 0xa124
movslq 0x80(%rbx), %rax
imulq $0x70, %rax, %rax
leaq 0x20290(%rip), %rcx     # 0x2a3b0
movq (%rcx,%rax), %r14
leaq 0x23c25(%rip), %r15     # 0x2dd50
movq (%r15), %rsi
movq %rbx, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x99a7
testb %al, %al
je 0xa16f
pushq $0x8
popq %rdi
callq 0x932c
testb %al, %al
je 0xa1ae
pushq $0x1
popq %rsi
movq %r14, %rdi
callq 0x9f94
leaq 0x137bc(%rip), %rdi     # 0x1d918
leaq 0x2367d(%rip), %rsi     # 0x2d7e0
xorl %eax, %eax
callq 0xb178
jmp 0xa90d
movzbl 0x8d(%rbx), %eax
cmpl $0x45, %eax
je 0xa90d
cmpl $0x46, %eax
jne 0xa1a1
leaq 0x236ed(%rip), %rax     # 0x2d878
movl (%rax), %eax
movq (%r15), %rcx
subl %eax, 0x30(%rcx)
jg 0xa1a1
movsbl 0x80(%rbx), %edi
callq 0x11fd0
movq %r14, %rdi
callq 0xa05a
jmp 0xa90d
leaq 0x236de(%rip), %rax     # 0x2d893
movb $0x0, (%rax)
cmpb $0x45, 0x8d(%rbx)
je 0xa1c9
movq %r14, %rdi
callq 0x9d22
movq (%r15), %rax
cmpl $0x0, 0x30(%rax)
jg 0xa1de
movsbl 0x80(%rbx), %edi
callq 0x11fd0
testb $0x20, 0x79(%rbx)
jne 0xa90d
movzbl 0x8d(%rbx), %eax
leal -0x63(%rax), %ecx
cmpl $0xd, %ecx
jbe 0xa259
leal -0x4c(%rax), %ecx
cmpl $0xb, %ecx
ja 0xa2b8
leaq 0x13622(%rip), %rax     # 0x1d82c
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
leaq 0x23642(%rip), %r13     # 0x2d85c
movl (%r13), %r12d
leaq 0x200bb(%rip), %rbp     # 0x2a2e0
imull $0xa, (%rbp), %edi
addl $0x32, %edi
xorl %eax, %eax
callq 0xc004
movl (%r13), %ecx
subl %eax, %ecx
addl $-0x2, %ecx
movl %ecx, (%r13)
pushq $0x3
popq %rdi
callq 0xa933
testl %eax, %eax
je 0xa7e1
movl (%r13), %eax
jmp 0xa83d
leaq 0x135fc(%rip), %rax     # 0x1d85c
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
pushq $0x1
popq %rdi
callq 0xa933
testl %eax, %eax
jne 0xa90d
leaq 0x13760(%rip), %rdi     # 0x1d9e0
xorl %eax, %eax
callq 0xb178
leaq 0x13770(%rip), %rdi     # 0x1d9fe
xorl %eax, %eax
callq 0xb178
leaq 0x26734(%rip), %rax     # 0x309d0
movq (%rax), %rdi
pushq $0x20
popq %rsi
callq 0xb399
movsbl 0x80(%rbx), %edi
callq 0x11fd0
jmp 0xa90d
cmpl $0x41, %eax
je 0xa792
cmpl $0x45, %eax
je 0xa750
cmpl $0x46, %eax
je 0xa692
cmpl $0x75, %eax
je 0xa6da
cmpl $0x77, %eax
jne 0xa90d
xorl %edi, %edi
callq 0xa933
testl %eax, %eax
jne 0xa90d
pushq $0x10
popq %rdi
callq 0x11fa5
testb %al, %al
jne 0xa90d
leaq 0x1376e(%rip), %rdi     # 0x1da79
xorl %eax, %eax
callq 0xb178
movsbl 0x80(%rbx), %edx
pushq $-0x1
popq %rdi
pushq $0x1
popq %rsi
jmp 0xa908
pushq $0x64
popq %rdi
xorl %eax, %eax
callq 0xc004
cmpl $0x31, %eax
jg 0xa344
testb $0x2, 0x79(%rbx)
jne 0xa344
leaq 0x23910(%rip), %rax     # 0x2dc50
orb $0x1, 0x79(%rax)
xorl %edi, %edi
callq 0xa933
testl %eax, %eax
jne 0xa90d
pushq $0x10
popq %rdi
callq 0x11fa5
testb %al, %al
jne 0xa7ce
pushq $0x2
popq %rdi
callq 0x11fa5
testb %al, %al
jne 0xa7ce
pushq $0x1
popq %r14
pushq $0x4
popq %rsi
movl %r14d, %edi
callq 0xc025
leaq 0x238c7(%rip), %r15     # 0x2dc50
movl 0x10(%r15), %ebp
negl %eax
movl %r14d, %edi
movl %eax, %esi
movl %r14d, %edx
callq 0x111a5
movl 0x10(%r15), %eax
cmpl %ebp, %eax
jge 0xa3b9
notl %eax
addl %eax, %ebp
leaq 0x6de5(%rip), %rdi      # 0x11194
pushq $0xa
popq %rdx
movl %ebp, %esi
callq 0x8a46
leaq 0x13663(%rip), %rdi     # 0x1da23
jmp 0xa7d5
xorl %edi, %edi
callq 0xa933
testl %eax, %eax
jne 0xa90d
leaq 0x23875(%rip), %rax     # 0x2dc50
cmpl $0x4, 0x10(%rax)
jl 0xa90d
pushq $0x2
popq %rdi
callq 0x11fa5
testb %al, %al
jne 0xa90d
pushq $0x10
popq %rdi
callq 0x11fa5
testb %al, %al
jne 0xa90d
leaq 0x1364d(%rip), %rdi     # 0x1da59
xorl %eax, %eax
callq 0xb178
pushq $-0x1
popq %rsi
pushq $0x1
popq %rdi
movl %edi, %edx
callq 0x111a5
jmp 0xa90d
pushq $0x2
popq %rdi
callq 0xa933
testl %eax, %eax
jne 0xa90d
pushq $0x17
popq %rdi
callq 0x11fa5
testb %al, %al
jne 0xa90d
leaq 0x135ec(%rip), %rdi     # 0x1da38
xorl %eax, %eax
callq 0xb178
pushq $0x1
popq %rdi
pushq $0x8
jmp 0xa4df
xorl %edi, %edi
callq 0xa933
testl %eax, %eax
jne 0xa90d
pushq $0x10
popq %rdi
callq 0x11fa5
testb %al, %al
jne 0xa90d
movl $0x4000, %edi           # imm = 0x4000
callq 0x932c
testb %al, %al
je 0xa8aa
pushq $0x3
popq %rdi
pushq $0xa
popq %rsi
callq 0xc025
leaq -0x1512(%rip), %rdi     # 0x8f8e
movl %eax, %esi
callq 0x8a7d
jmp 0xa90d
pushq $0x2
popq %rdi
callq 0xa933
testl %eax, %eax
jne 0xa90d
pushq $0x17
popq %rdi
callq 0x11fa5
testb %al, %al
jne 0xa90d
leaq 0x13576(%rip), %rdi     # 0x1da49
xorl %eax, %eax
callq 0xb178
pushq $0x1
popq %rdi
pushq $0x4
popq %rsi
callq 0xc025
negl %eax
movsbl 0x80(%rbx), %edx
movl %eax, %edi
xorl %esi, %esi
jmp 0xa908
pushq $0x64
popq %rdi
xorl %eax, %eax
callq 0xc004
cmpl $0xe, %eax
jg 0xa90d
pushq $0x10
popq %rdi
callq 0x11fa5
testb %al, %al
jne 0xa90d
movq (%r15), %rax
cmpq $0x0, 0x20(%rax)
jg 0xa530
movsbl 0x80(%rbx), %edi
callq 0x11fd0
leaq 0x13462(%rip), %rdi     # 0x1d999
xorl %eax, %eax
callq 0xb178
movq (%r15), %rax
movslq 0x28(%rax), %rcx
movl %ecx, %edx
decl %edx
movl %edx, 0x28(%rax)
je 0xa8e1
leaq 0x224c7(%rip), %rdx     # 0x2ca20
movq -0x10(%rdx,%rcx,8), %rcx
incq %rcx
jmp 0xa8ea
leaq 0x232db(%rip), %r14     # 0x2d848
movq (%r14), %rdi
callq 0x67e0
testb %al, %al
je 0xa90d
leaq 0x133aa(%rip), %rdi     # 0x1d92e
xorl %eax, %eax
callq 0xb178
movq (%r14), %rax
incl 0x34(%rax)
jmp 0xa90d
xorl %edi, %edi
callq 0xa933
testl %eax, %eax
jne 0xa90d
pushq $0x10
popq %rdi
callq 0x11fa5
testb %al, %al
jne 0xa90d
movq (%r15), %rax
cmpl $0x4, 0x14(%rax)
jl 0xa90d
pushq $0x2
popq %rdi
pushq $-0x1
popq %rsi
pushq $0x1
popq %rdx
callq 0x111a5
leaq 0x1337f(%rip), %rdi     # 0x1d956
jmp 0xa7d5
leaq 0x2366d(%rip), %r15     # 0x2dc50
leaq 0x68(%r15), %r12
xorl %r14d, %r14d
xorl %ebp, %ebp
movq (%r12), %r12
testq %r12, %r12
je 0xa60a
movq 0x10(%r12), %rdi
callq 0x1a1b0
cmpl %ebp, %eax
cmovgq %r12, %r14
cmovgl %eax, %ebp
jmp 0xa5ec
testq %r14, %r14
je 0xa90d
movq 0x10(%r14), %r12
pushq $0x10
popq %rsi
movq %r12, %rdi
callq 0x9359
testb %al, %al
je 0xa90d
movl 0x50(%rbx), %esi
movl 0x54(%rbx), %edi
callq 0x745e
testq %rax, %rax
je 0xa64b
addq $0x50, %rbx
movq %rbx, %rdi
movq %rax, %rsi
callq 0xa93f
xorl %ebx, %ebx
pushq $0x1
popq %rsi
movq %r12, %rdi
callq 0x1908c
leaq 0x13375(%rip), %rdi     # 0x1d9d2
movq %rax, %rsi
xorl %eax, %eax
callq 0xb178
addq $0x68, %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0xb7f4
movq %r14, %rdi
callq 0xb857
movq %r12, %rdi
callq 0x100da
xorl %eax, %eax
callq 0x9378
jmp 0xa90d
leaq 0x235b7(%rip), %rax     # 0x2dc50
orb $0x1, 0x79(%rax)
pushq $0x46
popq %rdi
callq 0xcdec
cltq
imulq $0x70, %rax, %rax
leaq 0x1fcfe(%rip), %rcx     # 0x2a3b0
leaq (%rcx,%rax), %rdi
addq $0x60, %rdi
leaq 0x231b7(%rip), %rax     # 0x2d878
movl (%rax), %edx
incl %edx
movl %edx, (%rax)
leaq 0x132e5(%rip), %rsi     # 0x1d9b3
xorl %eax, %eax
callq 0x64d0
jmp 0xa90d
xorl %edi, %edi
callq 0xa933
testl %eax, %eax
jne 0xa90d
leaq 0x23560(%rip), %rax     # 0x2dc50
cmpl $0x4, 0x10(%rax)
jl 0xa90d
pushq $0x2
popq %rdi
callq 0x11fa5
testb %al, %al
jne 0xa90d
pushq $0x10
popq %rdi
callq 0x11fa5
testb %al, %al
jne 0xa90d
leaq 0x13348(%rip), %rdi     # 0x1da69
xorl %eax, %eax
callq 0xb178
pushq $-0x1
popq %rsi
pushq $0x1
popq %rbp
movl %ebp, %edi
movl %ebp, %edx
callq 0x111a5
pushq $0x5
popq %rdi
pushq $0xa
popq %rsi
callq 0xc025
leaq 0x6a4b(%rip), %rdi      # 0x11194
movl %ebp, %esi
jmp 0xa8d8
pushq $0x1
popq %rdi
callq 0x933b
testb %al, %al
je 0xa90d
leaq 0x234e9(%rip), %r14     # 0x2dc50
cmpl $0x0, 0x88(%r14)
jg 0xa90d
pushq $0x10
popq %rdi
xorl %eax, %eax
callq 0xc004
addl $0x19, %eax
movl %eax, 0x88(%r14)
leaq 0x131b2(%rip), %rdi     # 0x1d942
jmp 0xa7d5
xorl %edi, %edi
callq 0xa933
testl %eax, %eax
jne 0xa90d
leaq 0x234a8(%rip), %rax     # 0x2dc50
cmpl $0x4, 0x10(%rax)
jl 0xa90d
pushq $0x2
popq %rdi
callq 0x11fa5
testb %al, %al
jne 0xa7ce
pushq $0x10
popq %rdi
callq 0x11fa5
testb %al, %al
je 0xa885
leaq 0x131af(%rip), %rdi     # 0x1d984
xorl %eax, %eax
callq 0xb178
jmp 0xa90d
imull $0xa, (%rbp), %edi
addl $0x32, %edi
xorl %eax, %eax
callq 0xc004
movl %eax, 0x4(%rsp)
imull $0xa, (%rbp), %edi
addl $0x32, %edi
xorl %eax, %eax
callq 0xc004
movl %eax, %r14d
imull $0xa, (%rbp), %edi
addl $0x32, %edi
xorl %eax, %eax
callq 0xc004
movl %eax, %r15d
imull $0xa, (%rbp), %edi
addl $0x32, %edi
xorl %eax, %eax
callq 0xc004
movl (%r13), %ecx
addl 0x4(%rsp), %r14d
addl %r15d, %eax
addl %r14d, %eax
negl %eax
addl %ecx, %eax
addl $-0x8, %eax
movl %eax, (%r13)
testl %eax, %eax
jns 0xa848
andl $0x0, (%r13)
xorl %eax, %eax
cmpl %r12d, %eax
je 0xa85b
leaq 0x13164(%rip), %rdi     # 0x1d9b8
xorl %eax, %eax
callq 0xb178
movl 0x50(%rbx), %esi
movl 0x54(%rbx), %edi
callq 0x745e
testq %rax, %rax
je 0xa90d
addq $0x50, %rbx
movq %rbx, %rdi
movq %rax, %rsi
callq 0xa93f
xorl %ebx, %ebx
jmp 0xa90d
leaq 0x22fc4(%rip), %rax     # 0x2d850
cmpl $0x0, (%rax)
jle 0xa90d
pushq $-0x1
popq %rsi
pushq $0x1
popq %rdi
movl %edi, %edx
callq 0x111a5
leaq 0x130c6(%rip), %rdi     # 0x1d96b
jmp 0xa7d5
leaq 0x131de(%rip), %rdi     # 0x1da8f
xorl %eax, %eax
callq 0xb178
leaq 0x23391(%rip), %rax     # 0x2dc50
orb $0x40, 0x79(%rax)
pushq $0x5
popq %rdi
pushq $0xa
popq %rsi
callq 0xc025
leaq -0x1947(%rip), %rdi     # 0x8f8e
pushq $0x1
popq %rsi
movl %eax, %edx
callq 0x8a46
jmp 0xa90d
movl $0x1, 0x28(%rax)
xorl %ecx, %ecx
movq %rcx, 0x20(%rax)
pushq $0x1
popq %rbp
pushq $0xa
popq %rsi
movl %ebp, %edi
callq 0xc025
negl %eax
movsbl 0x80(%rbx), %edx
movl %eax, %edi
movl %ebp, %esi
callq 0x11158
callq 0x6070
leaq 0x22f5b(%rip), %rax     # 0x2d874
andl $0x0, (%rax)
xorl %eax, %eax
cmpq $0x1, %rbx
sbbl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq