// File: /workspace/github_c_makefile_star2_O1/QwazyWabbitWOS[P]lmctf60/g_weapon.c
// Function: Grenade_Explode
static void Grenade_Explode (edict_t *ent)
{
	vec3_t		origin;
	int			mod;

	if (ent->owner->client)
		PlayerNoise(ent->owner, ent->s.origin, PNOISE_IMPACT);

	//FIXME: if we are onground then raise our Z just a bit since we are a point?
	if (ent->enemy)
	{
		float	points;
		vec3_t	v;
		vec3_t	dir;

		VectorAdd (ent->enemy->mins, ent->enemy->maxs, v);
		VectorMA (ent->enemy->s.origin, 0.5, v, v);
		VectorSubtract (ent->s.origin, v, v);
		points = ent->dmg - 0.5 * VectorLength (v);
		VectorSubtract (ent->enemy->s.origin, ent->s.origin, dir);
		if (ent->spawnflags & 1)
			mod = MOD_HANDGRENADE;
		else
			mod = MOD_GRENADE;
		T_Damage (ent->enemy, ent, ent->owner, dir, ent->s.origin, vec3_origin, (int)points, (int)points, DAMAGE_RADIUS, mod);
	}

	if (ent->spawnflags & 2)
		mod = MOD_HELD_GRENADE;
	else if (ent->spawnflags & 1)
		mod = MOD_HG_SPLASH;
	else
		mod = MOD_G_SPLASH;
	T_RadiusDamage(ent, ent->owner, ent->dmg, ent->enemy, ent->dmg_radius, mod);

	VectorMA (ent->s.origin, -0.02f, ent->velocity, origin);
	gi.WriteByte (svc_temp_entity);
	if (ent->waterlevel)
	{
		if (ent->groundentity)
			gi.WriteByte (TE_GRENADE_EXPLOSION_WATER);
		else
			gi.WriteByte (TE_ROCKET_EXPLOSION_WATER);
	}
	else
	{
		if (ent->groundentity)
			gi.WriteByte (TE_GRENADE_EXPLOSION);
		else
			gi.WriteByte (TE_ROCKET_EXPLOSION);
	}
	gi.WritePosition (origin);
	gi.multicast (ent->s.origin, MULTICAST_PHS);

	G_FreeEdict (ent);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
movq 0x110(%rdi), %rdi
cmpq $0x0, 0x58(%rdi)
je 0x407d9
leaq 0x4(%rbx), %rsi
movl $0x2, %edx
callq 0x18ef0
movq 0x2a0(%rbx), %rdi
testq %rdi, %rdi
je 0x4091a
movss 0xcc(%rdi), %xmm0
addss 0xd8(%rdi), %xmm0
leaq 0x10(%rsp), %r15
movss %xmm0, (%r15)
movss 0xd0(%rdi), %xmm0
addss 0xdc(%rdi), %xmm0
movss %xmm0, 0x4(%r15)
movss 0xd4(%rdi), %xmm0
addss 0xe0(%rdi), %xmm0
movss %xmm0, 0x8(%r15)
addq $0x4, %rdi
movss 0x14bc9(%rip), %xmm0    # 0x55404
movq %r15, %rsi
movq %r15, %rdx
callq 0x19770
movss 0x4(%rbx), %xmm0
subss (%r15), %xmm0
movss %xmm0, (%r15)
movss 0x8(%rbx), %xmm0
subss 0x4(%r15), %xmm0
movss %xmm0, 0x4(%r15)
movss 0xc(%rbx), %xmm0
subss 0x8(%r15), %xmm0
leaq 0x4(%rbx), %r14
movss %xmm0, 0x8(%r15)
xorps %xmm0, %xmm0
cvtsi2sdl 0x280(%rbx), %xmm0
movsd %xmm0, 0x8(%rsp)
movq %r15, %rdi
callq 0x192e0
cvtss2sd %xmm0, %xmm0
mulsd 0x16310(%rip), %xmm0    # 0x56bb0
addsd 0x8(%rsp), %xmm0
cvtsd2ss %xmm0, %xmm0
movq 0x2a0(%rbx), %rdi
movss 0x4(%rdi), %xmm1
subss 0x4(%rbx), %xmm1
leaq 0x1c(%rsp), %rcx
movss %xmm1, (%rcx)
movss 0x8(%rdi), %xmm1
subss 0x8(%rbx), %xmm1
movss %xmm1, 0x4(%rcx)
movss 0xc(%rdi), %xmm1
subss 0xc(%rbx), %xmm1
movss %xmm1, 0x8(%rcx)
movl 0x140(%rbx), %eax
andl $0x1, %eax
leal (%rax,%rax,8), %eax
addl $0x6, %eax
movq 0x110(%rbx), %rdx
cvttss2si %xmm0, %r10d
movq 0x28e64(%rip), %r9      # 0x69768
movq %rbx, %rsi
movq %r14, %r8
pushq %rax
pushq $0x1
pushq %r10
pushq %r10
callq 0x190f0
addq $0x20, %rsp
movl 0x140(%rbx), %eax
movl %eax, %ecx
andl $0x1, %ecx
testb $0x2, %al
leal 0x7(%rcx,%rcx,8), %eax
movl $0x18, %ecx
cmovel %eax, %ecx
xorps %xmm0, %xmm0
cvtsi2ssl 0x280(%rbx), %xmm0
movq 0x110(%rbx), %rsi
movq 0x2a0(%rbx), %rdx
movss 0x288(%rbx), %xmm1
movq %rbx, %rdi
callq 0x180c0
leaq 0x4(%rbx), %r14
leaq 0x1c0(%rbx), %rsi
movss 0x199f1(%rip), %xmm0    # 0x5a360
leaq 0x10(%rsp), %r15
movq %r14, %rdi
movq %r15, %rdx
callq 0x19770
movq 0x28c7a(%rip), %r12     # 0x69600
movl $0x3, %edi
callq *0xc8(%r12)
cmpl $0x0, 0x30c(%rbx)
movl $0x8, %eax
movl $0x12, %edi
cmovel %eax, %edi
cmpq $0x1, 0x2b8(%rbx)
sbbl $0x0, %edi
callq *0xc8(%r12)
movq %r15, %rdi
callq *0xf0(%r12)
movq %r14, %rdi
movl $0x1, %esi
callq *0xb0(%r12)
movq %rbx, %rdi
callq 0x19a60
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq