// File: /workspace/github_c_makefile_star2_O3/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 0x3ff23
leaq 0x4(%rbx), %rsi
movl $0x2, %edx
callq 0x18ef0
movq 0x2a0(%rbx), %rdi
testq %rdi, %rdi
je 0x4003b
movsd 0xcc(%rdi), %xmm0
movsd 0xd8(%rdi), %xmm1
addps %xmm0, %xmm1
leaq 0x8(%rsp), %r15
movlps %xmm1, (%r15)
movss 0xd4(%rdi), %xmm0
addss 0xe0(%rdi), %xmm0
movss %xmm0, 0x8(%r15)
addq $0x4, %rdi
movss 0x1448f(%rip), %xmm0    # 0x54400
movq %r15, %rsi
movq %r15, %rdx
callq 0x19760
movsd 0x4(%rbx), %xmm0
movsd (%r15), %xmm1
subps %xmm1, %xmm0
movlps %xmm0, (%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, (%rsp)
movq %r15, %rdi
callq 0x192e0
cvtss2sd %xmm0, %xmm0
mulsd 0x15c52(%rip), %xmm0    # 0x55c18
addsd (%rsp), %xmm0
cvtsd2ss %xmm0, %xmm0
movq 0x2a0(%rbx), %rdi
movsd 0x4(%rdi), %xmm1
movsd 0x4(%rbx), %xmm2
subps %xmm2, %xmm1
leaq 0x18(%rsp), %rcx
movlps %xmm1, (%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 0x2874c(%rip), %r9      # 0x68768
movq %rbx, %rsi
movq %r14, %r8
pushq %rax
pushq $0x1
pushq %r10
pushq %r10
callq 0x190f0
addq $0x20, %rsp
movq 0x2a0(%rbx), %rdx
jmp 0x4003d
xorl %edx, %edx
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
movq 0x110(%rbx), %rsi
xorps %xmm0, %xmm0
cvtsi2ssl 0x280(%rbx), %xmm0
movss 0x288(%rbx), %xmm1
movq %rbx, %rdi
callq 0x180c0
leaq 0x4(%rbx), %r14
leaq 0x1c0(%rbx), %rsi
movss 0x194e5(%rip), %xmm0    # 0x59570
leaq 0x8(%rsp), %r15
movq %r14, %rdi
movq %r15, %rdx
callq 0x19760
movq 0x2855e(%rip), %r12     # 0x68600
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 0x19a50
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq