// File: /workspace/github_c_makefile_star2_O1/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 0x9595
movl %eax, %ecx
xorl %eax, %eax
testb %cl, %cl
jne 0xae41
testb $0x2, 0x78(%rbx)
jne 0xae41
leaq 0x233b3(%rip), %rax     # 0x2d89c
movb $0x0, (%rax)
leaq 0x23399(%rip), %rax     # 0x2d88c
movl $0x0, (%rax)
leaq 0x23398(%rip), %rax     # 0x2d898
movb $0x1, (%rax)
cmpb $0x4d, 0x8d(%rbx)
jne 0xa521
movl $0x1, %edi
callq 0x95a4
testb %al, %al
je 0xa521
movb $0x4d, 0x8e(%rbx)
movl $0x1, %edi
callq 0x9595
testb %al, %al
je 0xa538
leaq 0x1678b(%rip), %r14     # 0x20cc1
jmp 0xa54e
movslq 0x80(%rbx), %rax
imulq $0x70, %rax, %rax
leaq 0x1fe76(%rip), %rcx     # 0x2a3c0
movq (%rcx,%rax), %r14
leaq 0x2380b(%rip), %r15     # 0x2dd60
movq (%r15), %rsi
movq %rbx, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x9d18
testb %al, %al
je 0xa5a1
movl $0x8, %edi
callq 0x9595
testb %al, %al
je 0xa60f
movq %r14, %rdi
movl $0x1, %esi
callq 0xa3b3
leaq 0x1538a(%rip), %rdi     # 0x1f918
leaq 0x2325b(%rip), %rsi     # 0x2d7f0
xorl %eax, %eax
callq 0xb6e0
jmp 0xae27
movzbl 0x8d(%rbx), %eax
cmpl $0x45, %eax
je 0xae27
cmpl $0x46, %eax
jne 0xa5d3
leaq 0x232cb(%rip), %rax     # 0x2d888
movl (%rax), %eax
movq (%r15), %rcx
subl %eax, 0x30(%rcx)
jg 0xa5d3
movsbl 0x80(%rbx), %edi
callq 0x12dc8
movq %r14, %rdi
movl $0x1, %esi
callq 0xa3b3
testq %r14, %r14
leaq 0x19327(%rip), %rax     # 0x23911
leaq 0x177cc(%rip), %rdx     # 0x21dbd
cmoveq %rax, %rdx
leaq 0x154c7(%rip), %rdi     # 0x1fac3
leaq 0x231ed(%rip), %rsi     # 0x2d7f0
xorl %eax, %eax
callq 0xb6e0
jmp 0xae27
leaq 0x2328d(%rip), %rax     # 0x2d8a3
movb $0x0, (%rax)
cmpb $0x45, 0x8d(%rbx)
je 0xa644
movq %r14, %rdi
movl $0x1, %esi
callq 0xa3b3
leaq 0x15485(%rip), %rdi     # 0x1fabb
leaq 0x231b3(%rip), %rsi     # 0x2d7f0
xorl %eax, %eax
callq 0xb6e0
movq (%r15), %rax
cmpl $0x0, 0x30(%rax)
jg 0xa659
movsbl 0x80(%rbx), %edi
callq 0x12dc8
testb $0x20, 0x79(%rbx)
jne 0xae27
movzbl 0x8d(%rbx), %eax
cmpl $0x62, %eax
jg 0xa79a
cmpl $0x4b, %eax
jle 0xa809
addl $-0x4c, %eax
cmpl $0xb, %eax
ja 0xae27
leaq 0x1519d(%rip), %rcx     # 0x1f82c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x231cd(%rip), %r12     # 0x2d86c
movl (%r12), %r13d
leaq 0x1fc46(%rip), %rbp     # 0x2a2f0
movl (%rbp), %eax
leal (%rax,%rax,4), %eax
leal 0x32(,%rax,2), %edi
xorl %eax, %eax
callq 0xc72d
movl (%r12), %ecx
subl %eax, %ecx
addl $-0x2, %ecx
movl %ecx, (%r12)
movl $0x3, %edi
callq 0xae50
testl %eax, %eax
jne 0xa74d
movl (%rbp), %eax
leal (%rax,%rax,4), %eax
leal 0x32(,%rax,2), %edi
xorl %eax, %eax
callq 0xc72d
movl %eax, 0x4(%rsp)
movl (%rbp), %eax
leal (%rax,%rax,4), %eax
leal 0x32(,%rax,2), %edi
xorl %eax, %eax
callq 0xc72d
movl %eax, %r14d
movl (%rbp), %eax
leal (%rax,%rax,4), %eax
leal 0x32(,%rax,2), %edi
xorl %eax, %eax
callq 0xc72d
movl %eax, %r15d
movl (%rbp), %eax
leal (%rax,%rax,4), %eax
leal 0x32(,%rax,2), %edi
xorl %eax, %eax
callq 0xc72d
movl (%r12), %ecx
addl 0x4(%rsp), %r14d
addl %r15d, %eax
addl %r14d, %eax
negl %eax
addl %ecx, %eax
addl $-0x8, %eax
movl %eax, (%r12)
cmpl $0x0, (%r12)
jns 0xa75c
movl $0x0, (%r12)
cmpl %r13d, (%r12)
je 0xa770
leaq 0x1524f(%rip), %rdi     # 0x1f9b8
xorl %eax, %eax
callq 0xb6e0
movl 0x50(%rbx), %esi
movl 0x54(%rbx), %edi
callq 0x75c5
testq %rax, %rax
je 0xae27
addq $0x50, %rbx
movq %rbx, %rdi
movq %rax, %rsi
callq 0xae8c
xorl %ebx, %ebx
jmp 0xae27
leal -0x63(%rax), %ecx
cmpl $0xd, %ecx
ja 0xa86e
leaq 0x150af(%rip), %rax     # 0x1f85c
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movl $0x1, %edi
callq 0xae50
testl %eax, %eax
jne 0xae27
leaq 0x15211(%rip), %rdi     # 0x1f9e0
xorl %eax, %eax
callq 0xb6e0
leaq 0x15221(%rip), %rdi     # 0x1f9fe
xorl %eax, %eax
callq 0xb6e0
leaq 0x261f5(%rip), %rax     # 0x309e0
movq (%rax), %rdi
movl $0x20, %esi
callq 0xb95e
movsbl 0x80(%rbx), %edi
callq 0x12dc8
jmp 0xae27
cmpl $0x41, %eax
je 0xacb6
cmpl $0x45, %eax
je 0xac70
cmpl $0x46, %eax
jne 0xae27
leaq 0x23435(%rip), %rax     # 0x2dc60
orb $0x1, 0x79(%rax)
movl $0x46, %edi
callq 0xd60b
cltq
imulq $0x70, %rax, %rax
leaq 0x1fb7a(%rip), %rcx     # 0x2a3c0
leaq (%rcx,%rax), %rdi
addq $0x60, %rdi
leaq 0x23033(%rip), %rax     # 0x2d888
movl (%rax), %edx
incl %edx
movl %edx, (%rax)
leaq 0x15151(%rip), %rsi     # 0x1f9b3
xorl %eax, %eax
callq 0x64f0
jmp 0xae27
cmpl $0x75, %eax
je 0xad09
cmpl $0x77, %eax
jne 0xae27
xorl %edi, %edi
callq 0xae50
testl %eax, %eax
jne 0xae27
movl $0x10, %edi
callq 0x12d9c
testb %al, %al
jne 0xae27
leaq 0x151d1(%rip), %rdi     # 0x1fa79
xorl %eax, %eax
callq 0xb6e0
movsbl 0x80(%rbx), %edx
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
jmp 0xae1d
xorl %edi, %edi
callq 0xae50
testl %eax, %eax
jne 0xae27
leaq 0x2338a(%rip), %rax     # 0x2dc60
cmpl $0x4, 0x10(%rax)
jl 0xae27
movl $0x2, %edi
callq 0x12d9c
testb %al, %al
jne 0xae27
movl $0x10, %edi
callq 0x12d9c
testb %al, %al
jne 0xae27
leaq 0x1514e(%rip), %rdi     # 0x1fa59
xorl %eax, %eax
callq 0xb6e0
movl $0x1, %edi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0x1, %edx
callq 0x11f24
jmp 0xae27
movl $0x64, %edi
xorl %eax, %eax
callq 0xc72d
cmpl $0x31, %eax
jg 0xa94d
testb $0x2, 0x79(%rbx)
jne 0xa94d
leaq 0x23317(%rip), %rax     # 0x2dc60
orb $0x1, 0x79(%rax)
xorl %edi, %edi
callq 0xae50
testl %eax, %eax
jne 0xae27
movl $0x10, %edi
callq 0x12d9c
testb %al, %al
jne 0xacf6
movl $0x2, %edi
callq 0x12d9c
testb %al, %al
jne 0xacf6
movl $0x1, %edi
movl $0x4, %esi
callq 0xc74e
leaq 0x232ca(%rip), %r14     # 0x2dc60
movl 0x10(%r14), %ebp
negl %eax
movl $0x1, %edi
movl %eax, %esi
movl $0x1, %edx
callq 0x11f24
movl 0x10(%r14), %eax
cmpl %ebp, %eax
jge 0xa9cc
notl %eax
addl %eax, %ebp
leaq 0x754e(%rip), %rdi      # 0x11f0e
movl %ebp, %esi
movl $0xa, %edx
callq 0x8c6f
leaq 0x15050(%rip), %rdi     # 0x1fa23
jmp 0xacfd
movl $0x2, %edi
callq 0xae50
testl %eax, %eax
jne 0xae27
movl $0x17, %edi
callq 0x12d9c
testb %al, %al
jne 0xae27
leaq 0x15035(%rip), %rdi     # 0x1fa38
xorl %eax, %eax
callq 0xb6e0
movl $0x1, %edi
movl $0x8, %esi
jmp 0xaa52
movl $0x2, %edi
callq 0xae50
testl %eax, %eax
jne 0xae27
movl $0x17, %edi
callq 0x12d9c
testb %al, %al
jne 0xae27
leaq 0x15008(%rip), %rdi     # 0x1fa49
xorl %eax, %eax
callq 0xb6e0
movl $0x1, %edi
movl $0x4, %esi
callq 0xc74e
negl %eax
movsbl 0x80(%rbx), %edx
movl %eax, %edi
xorl %esi, %esi
jmp 0xae22
xorl %edi, %edi
callq 0xae50
testl %eax, %eax
jne 0xae27
movl $0x10, %edi
callq 0x12d9c
testb %al, %al
jne 0xae27
movl $0x4000, %edi           # imm = 0x4000
callq 0x9595
testb %al, %al
je 0xadb7
movl $0x3, %edi
movl $0xa, %esi
callq 0xc74e
leaq -0x18c7(%rip), %rdi     # 0x91eb
movl %eax, %esi
callq 0x8ca6
jmp 0xae27
leaq 0x2319b(%rip), %r14     # 0x2dc60
movq 0x68(%r14), %r12
xorl %r13d, %r13d
xorl %r15d, %r15d
testq %r12, %r12
je 0xaaef
movq 0x10(%r12), %rdi
callq 0x1bd69
cmpl %r13d, %eax
cmovgq %r12, %r15
cmovgl %eax, %r13d
movq (%r12), %r12
jmp 0xaacf
testq %r15, %r15
je 0xae27
movq 0x10(%r15), %r12
movl $0x10, %esi
movq %r12, %rdi
callq 0x95c2
testb %al, %al
je 0xae27
movl 0x50(%rbx), %esi
movl 0x54(%rbx), %edi
callq 0x75c5
testq %rax, %rax
je 0xab32
addq $0x50, %rbx
movq %rbx, %rdi
movq %rax, %rsi
callq 0xae8c
xorl %ebx, %ebx
movq %r12, %rdi
movl $0x1, %esi
callq 0x1aaa4
leaq 0x14e8c(%rip), %rdi     # 0x1f9d2
movq %rax, %rsi
xorl %eax, %eax
callq 0xb6e0
addq $0x68, %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0xbe00
movq %r15, %rdi
callq 0xbe93
movq %r12, %rdi
callq 0x10d55
xorl %eax, %eax
callq 0x95e0
jmp 0xae27
xorl %edi, %edi
callq 0xae50
testl %eax, %eax
jne 0xae27
movl $0x10, %edi
callq 0x12d9c
testb %al, %al
jne 0xae27
movq (%r15), %rax
cmpl $0x4, 0x14(%rax)
jl 0xae27
movl $0x2, %edi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0x1, %edx
callq 0x11f24
leaq 0x14d92(%rip), %rdi     # 0x1f956
jmp 0xacfd
leaq 0x22c88(%rip), %r14     # 0x2d858
movq (%r14), %rdi
callq 0x686e
testb %al, %al
je 0xae27
leaq 0x14d47(%rip), %rdi     # 0x1f92e
xorl %eax, %eax
callq 0xb6e0
movq (%r14), %rax
incl 0x34(%rax)
jmp 0xae27
movl $0x64, %edi
xorl %eax, %eax
callq 0xc72d
cmpl $0xe, %eax
jg 0xae27
movl $0x10, %edi
callq 0x12d9c
testb %al, %al
jne 0xae27
movq (%r15), %rax
cmpq $0x0, 0x20(%rax)
jg 0xac36
movsbl 0x80(%rbx), %edi
callq 0x12dc8
leaq 0x14d5c(%rip), %rdi     # 0x1f999
xorl %eax, %eax
callq 0xb6e0
movq (%r15), %rax
movslq 0x28(%rax), %rcx
movl %ecx, %edx
decl %edx
movl %edx, 0x28(%rax)
je 0xadf4
leaq 0x21dd1(%rip), %rdx     # 0x2ca30
movq -0x10(%rdx,%rcx,8), %rcx
incq %rcx
movq %rcx, 0x20(%rax)
jmp 0xae03
movl $0x1, %edi
callq 0x95a4
testb %al, %al
je 0xae27
leaq 0x22fd7(%rip), %r14     # 0x2dc60
cmpl $0x0, 0x88(%r14)
jg 0xae27
movl $0x10, %edi
xorl %eax, %eax
callq 0xc72d
addl $0x19, %eax
movl %eax, 0x88(%r14)
leaq 0x14c8e(%rip), %rdi     # 0x1f942
jmp 0xacfd
xorl %edi, %edi
callq 0xae50
testl %eax, %eax
jne 0xae27
leaq 0x22f94(%rip), %rax     # 0x2dc60
cmpl $0x4, 0x10(%rax)
jl 0xae27
movl $0x2, %edi
callq 0x12d9c
testb %al, %al
jne 0xacf6
movl $0x10, %edi
callq 0x12d9c
testb %al, %al
je 0xad87
leaq 0x14c87(%rip), %rdi     # 0x1f984
xorl %eax, %eax
callq 0xb6e0
jmp 0xae27
xorl %edi, %edi
callq 0xae50
testl %eax, %eax
jne 0xae27
leaq 0x22f41(%rip), %rax     # 0x2dc60
cmpl $0x4, 0x10(%rax)
jl 0xae27
movl $0x2, %edi
callq 0x12d9c
testb %al, %al
jne 0xae27
movl $0x10, %edi
callq 0x12d9c
testb %al, %al
jne 0xae27
leaq 0x14d15(%rip), %rdi     # 0x1fa69
xorl %eax, %eax
callq 0xb6e0
movl $0x1, %edi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0x1, %edx
callq 0x11f24
movl $0x5, %edi
movl $0xa, %esi
callq 0xc74e
leaq 0x7189(%rip), %rdi      # 0x11f0e
jmp 0xade6
leaq 0x22ad2(%rip), %rax     # 0x2d860
cmpl $0x0, (%rax)
jle 0xae27
movl $0x1, %edi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0x1, %edx
callq 0x11f24
leaq 0x14bb9(%rip), %rdi     # 0x1f96b
jmp 0xacfd
leaq 0x14cd1(%rip), %rdi     # 0x1fa8f
xorl %eax, %eax
callq 0xb6e0
leaq 0x22e94(%rip), %rax     # 0x2dc60
orb $0x40, 0x79(%rax)
movl $0x5, %edi
movl $0xa, %esi
callq 0xc74e
leaq -0x1bfb(%rip), %rdi     # 0x91eb
movl $0x1, %esi
movl %eax, %edx
callq 0x8c6f
jmp 0xae27
movq $0x0, 0x20(%rax)
movl $0x1, 0x28(%rax)
movl $0x1, %edi
movl $0xa, %esi
callq 0xc74e
negl %eax
movsbl 0x80(%rbx), %edx
movl %eax, %edi
movl $0x1, %esi
callq 0x11ec8
callq 0x6070
leaq 0x22a51(%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