// File: lotuskip[P]yuxtapa/server/chores.cpp
// Function: (anonymous namespace)::missile_hit_PC(std::_List_iterator<Player>, OwnedEnt*, bool)
void missile_hit_PC(const list<Player>::iterator pit, OwnedEnt* mis,
	const bool should_void_zap)
{
	list<Player>::iterator shooter = mis->get_owner();
	if(dynamic_cast<Arrow*>(mis)) // it's an arrow
	{
		if(pit->team != shooter->team) // shooting teammates don't count as hit
			shooter->stats_i->arch_hits++;

		if(test_hit(pit, 7, 1, 7, 0)) // arrows: 1d7+0 damage, +7 to hit
		{
			if(pit->cl_props.hp <= 0) // (check if died)
			{
				string msg = " was shot by ";
				if(pit->team == shooter->team)
				{
					msg += teammate_str;
					shooter->stats_i->tks++;
				}
				else // shot enemy, count kill
					record_kill(shooter, WTK_ARROW);
				player_death(pit, msg + shooter->nick + '.', true);
			}
			else
				pit->needs_state_upd = true;
		}
		mis->makevoid(); // occupied flag is unset in kill_player if necessary
	}
	else // a mm or a zap
	{
		bool is_zap = dynamic_cast<Zap*>(mis);
		if(is_zap && shooter->team != pit->team)
			shooter->stats_i->cm_hits++;
		if(pit->nomagicres())
		{
			add_action_ind(pit->own_pc->getpos(), A_HIT);

			char dam = 1 + random()%5; // 1d5
			if(is_zap)
				dam += 1 + random()%5; // 2d5 for zaps
			pit->cl_props.hp -= dam;
			if(pit->cl_props.hp <= 0) // died
			{
				string msg = spell_kill_msg[is_zap][0];
				if(pit == shooter)
					msg += spell_kill_msg[is_zap][1];
				else
				{
					if(pit->team == shooter->team)
					{
						msg += teammate_str;
						shooter->stats_i->tks++;
					}
					else
						record_kill(shooter, is_zap ? WTK_ZAP : WTK_MM);
					msg += shooter->nick;
					if(!is_zap)
						msg += "\'s ";
				}
				msg += spell_kill_msg[is_zap][2];
				player_death(pit, msg, true);
			}
			else
				pit->needs_state_upd = true;
		} // no magic resistance
		else
			add_action_ind(pit->own_pc->getpos(), A_MISS);
		// mms voided always, zaps only if we are allowed to do so here:
		if(should_void_zap || !is_zap)
			mis->makevoid(); // occupied flag is unset in kill_player if necessary
	} // mm or zap
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x150, %rsp            # imm = 0x150
movb %dl, %al
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
andb $0x1, %al
movb %al, -0x11(%rbp)
movq -0x10(%rbp), %rdi
callq 0x3d0f0
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xf8(%rbp)
cmpq $0x0, %rax
je 0x56bef
movq -0xf8(%rbp), %rdi
leaq 0x35e42(%rip), %rsi     # 0x8ca18
leaq 0x3610b(%rip), %rdx     # 0x8cce8
xorl %eax, %eax
movl %eax, %ecx
callq 0x55e0
movq %rax, -0x100(%rbp)
jmp 0x56bfa
xorl %eax, %eax
movq %rax, -0x100(%rbp)
jmp 0x56bfa
movq -0x100(%rbp), %rax
cmpq $0x0, %rax
je 0x56e6b
leaq -0x8(%rbp), %rdi
callq 0x1b050
movl 0xac(%rax), %eax
movl %eax, -0x104(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x1b050
movq %rax, %rcx
movl -0x104(%rbp), %eax
cmpl 0xac(%rcx), %eax
je 0x56c64
leaq -0x20(%rbp), %rdi
callq 0x1b050
movq %rax, %rdi
addq $0x80, %rdi
callq 0x1b390
movq 0x108(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x108(%rax)
movq -0x8(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
movl $0x7, %ecx
movl $0x1, %edx
xorl %r8d, %r8d
movl %ecx, %esi
callq 0x56120
testb $0x1, %al
jne 0x56c8d
jmp 0x56e5d
leaq -0x8(%rbp), %rdi
callq 0x1b050
movsbl 0x143(%rax), %eax
cmpl $0x0, %eax
jg 0x56e4b
leaq -0x49(%rbp), %rdi
movq %rdi, -0x110(%rbp)
callq 0x5930
movq -0x110(%rbp), %rdx
leaq 0x15929(%rip), %rsi     # 0x6c5ed
leaq -0x48(%rbp), %rdi
callq 0x18880
jmp 0x56ccf
leaq -0x49(%rbp), %rdi
callq 0x5590
leaq -0x8(%rbp), %rdi
callq 0x1b050
movl 0xac(%rax), %eax
movl %eax, -0x114(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x1b050
movq %rax, %rcx
movl -0x114(%rbp), %eax
cmpl 0xac(%rcx), %eax
jne 0x56d70
leaq 0x3d3ba(%rip), %rsi     # 0x940c8
leaq -0x48(%rbp), %rdi
callq 0x56e0
jmp 0x56d19
leaq -0x20(%rbp), %rdi
callq 0x1b050
movq %rax, %rdi
addq $0x80, %rdi
callq 0x1b390
movq 0x90(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x90(%rax)
jmp 0x56d8a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x49(%rbp), %rdi
callq 0x5590
jmp 0x57285
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x56e3d
movq -0x20(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rdi
movl $0x1, %esi
callq 0x51b40
jmp 0x56d88
jmp 0x56d8a
movq -0x8(%rbp), %rax
movq %rax, -0x70(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x1b050
movq %rax, %rdx
addq $0x88, %rdx
leaq -0xb0(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x24cb0
jmp 0x56db7
leaq -0x90(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
movl $0x2e, %edx
callq 0x3ca50
jmp 0x56dd1
movq -0x70(%rbp), %rdi
leaq -0x90(%rbp), %rsi
movl $0x1, %edx
callq 0x517d0
jmp 0x56de8
leaq -0x90(%rbp), %rdi
callq 0x5a48
leaq -0xb0(%rbp), %rdi
callq 0x5a48
leaq -0x48(%rbp), %rdi
callq 0x5a48
jmp 0x56e5b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x56e31
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x5a48
leaq -0xb0(%rbp), %rdi
callq 0x5a48
leaq -0x48(%rbp), %rdi
callq 0x5a48
jmp 0x57285
leaq -0x8(%rbp), %rdi
callq 0x1b050
movb $0x1, 0x14d(%rax)
jmp 0x56e5d
movq -0x10(%rbp), %rdi
callq 0x4d8d0
jmp 0x5727c
movq -0x10(%rbp), %rax
movq %rax, -0x120(%rbp)
cmpq $0x0, %rax
je 0x56ea3
movq -0x120(%rbp), %rdi
leaq 0x35b8e(%rip), %rsi     # 0x8ca18
leaq 0x35e87(%rip), %rdx     # 0x8cd18
xorl %eax, %eax
movl %eax, %ecx
callq 0x55e0
movq %rax, -0x128(%rbp)
jmp 0x56eae
xorl %eax, %eax
movq %rax, -0x128(%rbp)
jmp 0x56eae
movq -0x128(%rbp), %rax
cmpq $0x0, %rax
setne %al
andb $0x1, %al
movb %al, -0xb1(%rbp)
testb $0x1, -0xb1(%rbp)
je 0x56f26
leaq -0x20(%rbp), %rdi
callq 0x1b050
movl 0xac(%rax), %eax
movl %eax, -0x12c(%rbp)
leaq -0x8(%rbp), %rdi
callq 0x1b050
movq %rax, %rcx
movl -0x12c(%rbp), %eax
cmpl 0xac(%rcx), %eax
je 0x56f26
leaq -0x20(%rbp), %rdi
callq 0x1b050
movq %rax, %rdi
addq $0x80, %rdi
callq 0x1b390
movq 0x118(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x118(%rax)
leaq -0x8(%rbp), %rdi
callq 0x1b050
movq %rax, %rdi
callq 0x21f00
testb $0x1, %al
jne 0x56f40
jmp 0x57204
leaq -0x8(%rbp), %rdi
callq 0x1b050
movq 0x138(%rax), %rsi
leaq -0xb6(%rbp), %rdi
movq %rdi, -0x138(%rbp)
callq 0x1b190
movq -0x138(%rbp), %rdi
movl $0x4, %esi
callq 0x47f20
jmp 0x56f76
leaq -0xb6(%rbp), %rdi
callq 0x60460
callq 0x5270
movl $0x5, %ecx
cqto
idivq %rcx
addq $0x1, %rdx
movb %dl, %al
movb %al, -0xb7(%rbp)
testb $0x1, -0xb1(%rbp)
je 0x56fe9
callq 0x5270
movl $0x5, %ecx
cqto
idivq %rcx
addq $0x1, %rdx
movsbq -0xb7(%rbp), %rax
addq %rdx, %rax
movb %al, -0xb7(%rbp)
jmp 0x56fe9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0xb6(%rbp), %rdi
callq 0x60460
jmp 0x57285
movsbl -0xb7(%rbp), %eax
movl %eax, -0x13c(%rbp)
leaq -0x8(%rbp), %rdi
callq 0x1b050
movl -0x13c(%rbp), %edx
movsbl 0x143(%rax), %ecx
subl %edx, %ecx
movb %cl, 0x143(%rax)
leaq -0x8(%rbp), %rdi
callq 0x1b050
movsbl 0x143(%rax), %eax
cmpl $0x0, %eax
jg 0x571f2
movb -0xb1(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
leaq 0x3d0b1(%rip), %rsi     # 0x940f0
imulq $0x60, %rax, %rax
addq %rax, %rsi
leaq -0xd8(%rbp), %rdi
callq 0x5220
leaq -0x8(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0x3d990
testb $0x1, %al
jne 0x57065
jmp 0x570b2
movzbl -0xb1(%rbp), %eax
andl $0x1, %eax
leaq (%rax,%rax,2), %rax
shll $0x5, %eax
leaq 0x3d073(%rip), %rcx     # 0x940f0
leaq 0x20(%rax,%rcx), %rsi
leaq -0xd8(%rbp), %rdi
callq 0x56e0
jmp 0x57090
jmp 0x57194
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x5a48
jmp 0x57285
leaq -0x8(%rbp), %rdi
callq 0x1b050
movl 0xac(%rax), %eax
movl %eax, -0x140(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x1b050
movq %rax, %rcx
movl -0x140(%rbp), %eax
cmpl 0xac(%rcx), %eax
jne 0x57122
leaq 0x3cfe0(%rip), %rsi     # 0x940c8
leaq -0xd8(%rbp), %rdi
callq 0x56e0
jmp 0x570f6
leaq -0x20(%rbp), %rdi
callq 0x1b050
movq %rax, %rdi
addq $0x80, %rdi
callq 0x1b390
movq 0x90(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x90(%rax)
jmp 0x57151
movq -0x20(%rbp), %rax
movq %rax, -0xe0(%rbp)
movb -0xb1(%rbp), %al
notb %al
movzbl %al, %ecx
andl $0x1, %ecx
movl %ecx, %eax
leal 0x3(%rax,%rax,2), %esi
movq -0xe0(%rbp), %rdi
callq 0x51b40
jmp 0x5714f
jmp 0x57151
leaq -0x20(%rbp), %rdi
callq 0x1b050
movq %rax, %rsi
addq $0x88, %rsi
leaq -0xd8(%rbp), %rdi
callq 0x56e0
jmp 0x57172
testb $0x1, -0xb1(%rbp)
jne 0x57192
leaq 0x15479(%rip), %rsi     # 0x6c5fb
leaq -0xd8(%rbp), %rdi
callq 0x54f0
jmp 0x57190
jmp 0x57192
jmp 0x57194
movzbl -0xb1(%rbp), %eax
andl $0x1, %eax
leaq (%rax,%rax,2), %rax
shll $0x5, %eax
leaq 0x3cf44(%rip), %rcx     # 0x940f0
leaq 0x40(%rax,%rcx), %rsi
leaq -0xd8(%rbp), %rdi
callq 0x56e0
jmp 0x571bf
movq -0x8(%rbp), %rax
movq %rax, -0xe8(%rbp)
movq -0xe8(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
movl $0x1, %edx
callq 0x517d0
jmp 0x571e4
leaq -0xd8(%rbp), %rdi
callq 0x5a48
jmp 0x57202
leaq -0x8(%rbp), %rdi
callq 0x1b050
movb $0x1, 0x14d(%rax)
jmp 0x57262
leaq -0x8(%rbp), %rdi
callq 0x1b050
movq 0x138(%rax), %rsi
leaq -0xec(%rbp), %rdi
movq %rdi, -0x148(%rbp)
callq 0x1b190
movq -0x148(%rbp), %rdi
movl $0x5, %esi
callq 0x47f20
jmp 0x5723a
leaq -0xec(%rbp), %rdi
callq 0x60460
jmp 0x57262
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0xec(%rbp), %rdi
callq 0x60460
jmp 0x57285
testb $0x1, -0x11(%rbp)
jne 0x57271
testb $0x1, -0xb1(%rbp)
jne 0x5727a
movq -0x10(%rbp), %rdi
callq 0x4d8d0
jmp 0x5727c
addq $0x150, %rsp            # imm = 0x150
popq %rbp
retq
movq -0x58(%rbp), %rdi
callq 0x5920
nop