// File: /workspace/github_c_makefile_star2_O3/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 0x9513
movl %eax, %ecx
xorl %eax, %eax
testb %cl, %cl
jne 0xad8e
testb $0x2, 0x78(%rbx)
jne 0xad8e
leaq 0x23471(%rip), %rax     # 0x2d89c
movb $0x0, (%rax)
leaq 0x23457(%rip), %rax     # 0x2d88c
movl $0x0, (%rax)
leaq 0x23456(%rip), %rax     # 0x2d898
movb $0x1, (%rax)
cmpb $0x4d, 0x8d(%rbx)
jne 0xa463
movl $0x1, %edi
callq 0x9522
testb %al, %al
je 0xa463
movb $0x4d, 0x8e(%rbx)
movl $0x1, %edi
callq 0x9513
testb %al, %al
je 0xa47a
leaq 0x1685a(%rip), %r14     # 0x20cd2
jmp 0xa490
movslq 0x80(%rbx), %rax
imulq $0x70, %rax, %rax
leaq 0x1ff34(%rip), %rcx     # 0x2a3c0
movq (%rcx,%rax), %r14
leaq 0x238c9(%rip), %r15     # 0x2dd60
movq (%r15), %rsi
movq %rbx, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x9c9d
testb %al, %al
je 0xa4e3
movl $0x8, %edi
callq 0x9513
testb %al, %al
je 0xa551
movq %r14, %rdi
movl $0x1, %esi
callq 0xa2f5
leaq 0x15448(%rip), %rdi     # 0x1f918
leaq 0x23319(%rip), %rsi     # 0x2d7f0
xorl %eax, %eax
callq 0xb620
jmp 0xad74
movzbl 0x8d(%rbx), %eax
cmpl $0x45, %eax
je 0xad74
cmpl $0x46, %eax
jne 0xa515
leaq 0x23389(%rip), %rax     # 0x2d888
movl (%rax), %eax
movq (%r15), %rcx
subl %eax, 0x30(%rcx)
jg 0xa515
movsbl 0x80(%rbx), %edi
callq 0x12c60
movq %r14, %rdi
movl $0x1, %esi
callq 0xa2f5
testq %r14, %r14
leaq 0x1945d(%rip), %rax     # 0x23989
leaq 0x17902(%rip), %rdx     # 0x21e35
cmoveq %rax, %rdx
leaq 0x15585(%rip), %rdi     # 0x1fac3
leaq 0x232ab(%rip), %rsi     # 0x2d7f0
xorl %eax, %eax
callq 0xb620
jmp 0xad74
leaq 0x2334b(%rip), %rax     # 0x2d8a3
movb $0x0, (%rax)
cmpb $0x45, 0x8d(%rbx)
je 0xa586
movq %r14, %rdi
movl $0x1, %esi
callq 0xa2f5
leaq 0x15543(%rip), %rdi     # 0x1fabb
leaq 0x23271(%rip), %rsi     # 0x2d7f0
xorl %eax, %eax
callq 0xb620
movq (%r15), %rax
cmpl $0x0, 0x30(%rax)
jg 0xa59b
movsbl 0x80(%rbx), %edi
callq 0x12c60
testb $0x20, 0x79(%rbx)
jne 0xad74
movzbl 0x8d(%rbx), %eax
cmpl $0x62, %eax
jg 0xa624
cmpl $0x4b, %eax
jle 0xa693
addl $-0x4c, %eax
cmpl $0xb, %eax
ja 0xad74
leaq 0x1525f(%rip), %rcx     # 0x1f82c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x2328f(%rip), %r13     # 0x2d86c
movl (%r13), %r12d
leaq 0x1fd08(%rip), %rbp     # 0x2a2f0
movl (%rbp), %eax
leal (%rax,%rax,4), %eax
leal 0x32(,%rax,2), %edi
xorl %eax, %eax
callq 0xc674
movl (%r13), %ecx
subl %eax, %ecx
addl $-0x2, %ecx
movl %ecx, (%r13)
movl $0x3, %edi
callq 0xad9d
testl %eax, %eax
je 0xac17
movl (%r13), %eax
jmp 0xac8b
leal -0x63(%rax), %ecx
cmpl $0xd, %ecx
ja 0xa6f8
leaq 0x15225(%rip), %rax     # 0x1f85c
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movl $0x1, %edi
callq 0xad9d
testl %eax, %eax
jne 0xad74
leaq 0x15387(%rip), %rdi     # 0x1f9e0
xorl %eax, %eax
callq 0xb620
leaq 0x15397(%rip), %rdi     # 0x1f9fe
xorl %eax, %eax
callq 0xb620
leaq 0x2636b(%rip), %rax     # 0x309e0
movq (%rax), %rdi
movl $0x20, %esi
callq 0xb89e
movsbl 0x80(%rbx), %edi
callq 0x12c60
jmp 0xad74
cmpl $0x41, %eax
je 0xab43
cmpl $0x45, %eax
je 0xaafd
cmpl $0x46, %eax
jne 0xad74
leaq 0x235ab(%rip), %rax     # 0x2dc60
orb $0x1, 0x79(%rax)
movl $0x46, %edi
callq 0xd595
cltq
imulq $0x70, %rax, %rax
leaq 0x1fcf0(%rip), %rcx     # 0x2a3c0
leaq (%rcx,%rax), %rdi
addq $0x60, %rdi
leaq 0x231a9(%rip), %rax     # 0x2d888
movl (%rax), %edx
incl %edx
movl %edx, (%rax)
leaq 0x152c7(%rip), %rsi     # 0x1f9b3
xorl %eax, %eax
callq 0x64f0
jmp 0xad74
cmpl $0x75, %eax
je 0xab96
cmpl $0x77, %eax
jne 0xad74
xorl %edi, %edi
callq 0xad9d
testl %eax, %eax
jne 0xad74
movl $0x10, %edi
callq 0x12c34
testb %al, %al
jne 0xad74
leaq 0x15347(%rip), %rdi     # 0x1fa79
xorl %eax, %eax
callq 0xb620
movsbl 0x80(%rbx), %edx
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
jmp 0xad6a
xorl %edi, %edi
callq 0xad9d
testl %eax, %eax
jne 0xad74
leaq 0x23500(%rip), %rax     # 0x2dc60
cmpl $0x4, 0x10(%rax)
jl 0xad74
movl $0x2, %edi
callq 0x12c34
testb %al, %al
jne 0xad74
movl $0x10, %edi
callq 0x12c34
testb %al, %al
jne 0xad74
leaq 0x152c4(%rip), %rdi     # 0x1fa59
xorl %eax, %eax
callq 0xb620
movl $0x1, %edi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0x1, %edx
callq 0x11d8e
jmp 0xad74
movl $0x64, %edi
xorl %eax, %eax
callq 0xc674
cmpl $0x31, %eax
jg 0xa7d7
testb $0x2, 0x79(%rbx)
jne 0xa7d7
leaq 0x2348d(%rip), %rax     # 0x2dc60
orb $0x1, 0x79(%rax)
xorl %edi, %edi
callq 0xad9d
testl %eax, %eax
jne 0xad74
movl $0x10, %edi
callq 0x12c34
testb %al, %al
jne 0xab83
movl $0x2, %edi
callq 0x12c34
testb %al, %al
jne 0xab83
movl $0x1, %edi
movl $0x4, %esi
callq 0xc695
leaq 0x23440(%rip), %r14     # 0x2dc60
movl 0x10(%r14), %ebp
negl %eax
movl $0x1, %edi
movl %eax, %esi
movl $0x1, %edx
callq 0x11d8e
movl 0x10(%r14), %eax
cmpl %ebp, %eax
jge 0xa856
notl %eax
addl %eax, %ebp
leaq 0x752e(%rip), %rdi      # 0x11d78
movl %ebp, %esi
movl $0xa, %edx
callq 0x8ba7
leaq 0x151c6(%rip), %rdi     # 0x1fa23
jmp 0xab8a
movl $0x2, %edi
callq 0xad9d
testl %eax, %eax
jne 0xad74
movl $0x17, %edi
callq 0x12c34
testb %al, %al
jne 0xad74
leaq 0x151ab(%rip), %rdi     # 0x1fa38
xorl %eax, %eax
callq 0xb620
movl $0x1, %edi
movl $0x8, %esi
jmp 0xa8dc
movl $0x2, %edi
callq 0xad9d
testl %eax, %eax
jne 0xad74
movl $0x17, %edi
callq 0x12c34
testb %al, %al
jne 0xad74
leaq 0x1517e(%rip), %rdi     # 0x1fa49
xorl %eax, %eax
callq 0xb620
movl $0x1, %edi
movl $0x4, %esi
callq 0xc695
negl %eax
movsbl 0x80(%rbx), %edx
movl %eax, %edi
xorl %esi, %esi
jmp 0xad6f
xorl %edi, %edi
callq 0xad9d
testl %eax, %eax
jne 0xad74
movl $0x10, %edi
callq 0x12c34
testb %al, %al
jne 0xad74
movl $0x4000, %edi           # imm = 0x4000
callq 0x9513
testb %al, %al
je 0xad06
movl $0x3, %edi
movl $0xa, %esi
callq 0xc695
leaq -0x1807(%rip), %rdi     # 0x9135
movl %eax, %esi
callq 0x8bde
jmp 0xad74
leaq 0x23311(%rip), %r14     # 0x2dc60
movq 0x68(%r14), %r12
testq %r12, %r12
je 0xad74
xorl %r13d, %r13d
xorl %r15d, %r15d
movq 0x10(%r12), %rdi
callq 0x1bc95
cmpl %r13d, %eax
cmovgq %r12, %r15
cmovgl %eax, %r13d
movq (%r12), %r12
testq %r12, %r12
jne 0xa962
testq %r15, %r15
je 0xad74
movq 0x10(%r15), %r12
movl $0x10, %esi
movq %r12, %rdi
callq 0x9540
testb %al, %al
je 0xad74
movl 0x50(%rbx), %esi
movl 0x54(%rbx), %edi
callq 0x7502
testq %rax, %rax
je 0xa9c3
addq $0x50, %rbx
movq %rbx, %rdi
movq %rax, %rsi
callq 0xadd9
xorl %ebx, %ebx
movq %r12, %rdi
movl $0x1, %esi
callq 0x1aa04
leaq 0x14ffb(%rip), %rdi     # 0x1f9d2
movq %rax, %rsi
xorl %eax, %eax
callq 0xb620
addq $0x68, %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0xbd4c
movq %r15, %rdi
callq 0xbdda
movq %r12, %rdi
callq 0x10bd9
xorl %eax, %eax
callq 0x9560
jmp 0xad74
xorl %edi, %edi
callq 0xad9d
testl %eax, %eax
jne 0xad74
movl $0x10, %edi
callq 0x12c34
testb %al, %al
jne 0xad74
movq (%r15), %rax
cmpl $0x4, 0x14(%rax)
jl 0xad74
movl $0x2, %edi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0x1, %edx
callq 0x11d8e
leaq 0x14f01(%rip), %rdi     # 0x1f956
jmp 0xab8a
leaq 0x22df7(%rip), %r14     # 0x2d858
movq (%r14), %rdi
callq 0x6869
testb %al, %al
je 0xad74
leaq 0x14eb6(%rip), %rdi     # 0x1f92e
xorl %eax, %eax
callq 0xb620
movq (%r14), %rax
incl 0x34(%rax)
jmp 0xad74
movl $0x64, %edi
xorl %eax, %eax
callq 0xc674
cmpl $0xe, %eax
jg 0xad74
movl $0x10, %edi
callq 0x12c34
testb %al, %al
jne 0xad74
movq (%r15), %rax
cmpq $0x0, 0x20(%rax)
jg 0xaac7
movsbl 0x80(%rbx), %edi
callq 0x12c60
leaq 0x14ecb(%rip), %rdi     # 0x1f999
xorl %eax, %eax
callq 0xb620
movq (%r15), %rax
movslq 0x28(%rax), %rcx
movl %ecx, %edx
decl %edx
movl %edx, 0x28(%rax)
je 0xad43
leaq 0x21f40(%rip), %rdx     # 0x2ca30
movq -0x10(%rdx,%rcx,8), %rcx
incq %rcx
jmp 0xad4c
movl $0x1, %edi
callq 0x9522
testb %al, %al
je 0xad74
leaq 0x2314a(%rip), %r14     # 0x2dc60
cmpl $0x0, 0x88(%r14)
jg 0xad74
movl $0x10, %edi
xorl %eax, %eax
callq 0xc674
addl $0x19, %eax
movl %eax, 0x88(%r14)
leaq 0x14e01(%rip), %rdi     # 0x1f942
jmp 0xab8a
xorl %edi, %edi
callq 0xad9d
testl %eax, %eax
jne 0xad74
leaq 0x23107(%rip), %rax     # 0x2dc60
cmpl $0x4, 0x10(%rax)
jl 0xad74
movl $0x2, %edi
callq 0x12c34
testb %al, %al
jne 0xab83
movl $0x10, %edi
callq 0x12c34
testb %al, %al
je 0xacd6
leaq 0x14dfa(%rip), %rdi     # 0x1f984
xorl %eax, %eax
callq 0xb620
jmp 0xad74
xorl %edi, %edi
callq 0xad9d
testl %eax, %eax
jne 0xad74
leaq 0x230b4(%rip), %rax     # 0x2dc60
cmpl $0x4, 0x10(%rax)
jl 0xad74
movl $0x2, %edi
callq 0x12c34
testb %al, %al
jne 0xad74
movl $0x10, %edi
callq 0x12c34
testb %al, %al
jne 0xad74
leaq 0x14e88(%rip), %rdi     # 0x1fa69
xorl %eax, %eax
callq 0xb620
movl $0x1, %edi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0x1, %edx
callq 0x11d8e
movl $0x5, %edi
movl $0xa, %esi
callq 0xc695
leaq 0x7166(%rip), %rdi      # 0x11d78
jmp 0xad35
movl (%rbp), %eax
leal (%rax,%rax,4), %eax
leal 0x32(,%rax,2), %edi
xorl %eax, %eax
callq 0xc674
movl %eax, 0x4(%rsp)
movl (%rbp), %eax
leal (%rax,%rax,4), %eax
leal 0x32(,%rax,2), %edi
xorl %eax, %eax
callq 0xc674
movl %eax, %r14d
movl (%rbp), %eax
leal (%rax,%rax,4), %eax
leal 0x32(,%rax,2), %edi
xorl %eax, %eax
callq 0xc674
movl %eax, %r15d
movl (%rbp), %eax
leal (%rax,%rax,4), %eax
leal 0x32(,%rax,2), %edi
xorl %eax, %eax
callq 0xc674
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 0xac99
movl $0x0, (%r13)
xorl %eax, %eax
cmpl %r12d, %eax
je 0xacac
leaq 0x14d13(%rip), %rdi     # 0x1f9b8
xorl %eax, %eax
callq 0xb620
movl 0x50(%rbx), %esi
movl 0x54(%rbx), %edi
callq 0x7502
testq %rax, %rax
je 0xad74
addq $0x50, %rbx
movq %rbx, %rdi
movq %rax, %rsi
callq 0xadd9
xorl %ebx, %ebx
jmp 0xad74
leaq 0x22b83(%rip), %rax     # 0x2d860
cmpl $0x0, (%rax)
jle 0xad74
movl $0x1, %edi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0x1, %edx
callq 0x11d8e
leaq 0x14c6a(%rip), %rdi     # 0x1f96b
jmp 0xab8a
leaq 0x14d82(%rip), %rdi     # 0x1fa8f
xorl %eax, %eax
callq 0xb620
leaq 0x22f45(%rip), %rax     # 0x2dc60
orb $0x40, 0x79(%rax)
movl $0x5, %edi
movl $0xa, %esi
callq 0xc695
leaq -0x1c00(%rip), %rdi     # 0x9135
movl $0x1, %esi
movl %eax, %edx
callq 0x8ba7
jmp 0xad74
movl $0x1, 0x28(%rax)
xorl %ecx, %ecx
movq %rcx, 0x20(%rax)
movl $0x1, %edi
movl $0xa, %esi
callq 0xc695
negl %eax
movsbl 0x80(%rbx), %edx
movl %eax, %edi
movl $0x1, %esi
callq 0x11d3c
callq 0x6070
leaq 0x22b04(%rip), %rax     # 0x2d884
movl $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