// File: /workspace/github_c_makefile_star2_O2/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 0x3c99c
leaq 0x4(%rbx), %rsi
pushq $0x2
popq %rdx
callq 0x19010
movq 0x2a0(%rbx), %rdi
testq %rdi, %rdi
je 0x3cab1
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 0x13a16(%rip), %xmm0    # 0x50400
movq %r15, %rsi
movq %r15, %rdx
callq 0x19940
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)
cvtsi2sdl 0x280(%rbx), %xmm0
movsd %xmm0, (%rsp)
movq %r15, %rdi
callq 0x19460
cvtss2sd %xmm0, %xmm0
mulsd 0x151bc(%rip), %xmm0    # 0x51bf8
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 0x29cd6(%rip), %r9      # 0x66768
movq %rbx, %rsi
movq %r14, %r8
pushq %rax
pushq $0x1
pushq %r10
pushq %r10
callq 0x19260
addq $0x20, %rsp
movq 0x2a0(%rbx), %rdx
jmp 0x3cab3
xorl %edx, %edx
movl 0x140(%rbx), %eax
movl %eax, %ecx
andl $0x1, %ecx
testb $0x2, %al
leal 0x7(%rcx,%rcx,8), %eax
pushq $0x18
popq %rcx
cmovel %eax, %ecx
movq 0x110(%rbx), %rsi
cvtsi2ssl 0x280(%rbx), %xmm0
movss 0x288(%rbx), %xmm1
movq %rbx, %rdi
callq 0x180c0
leaq 0x4(%rbx), %r14
leaq 0x1c0(%rbx), %rsi
movss 0x18a54(%rip), %xmm0    # 0x55550
leaq 0x8(%rsp), %r15
movq %r14, %rdi
movq %r15, %rdx
callq 0x19940
movq 0x29aed(%rip), %r12     # 0x66600
pushq $0x3
popq %rdi
callq *0xc8(%r12)
cmpl $0x0, 0x30c(%rbx)
pushq $0x8
popq %rax
pushq $0x12
popq %rdi
cmovel %eax, %edi
cmpq $0x1, 0x2b8(%rbx)
sbbl $0x0, %edi
callq *0xc8(%r12)
movq %r15, %rdi
callq *0xf0(%r12)
pushq $0x1
popq %rsi
movq %r14, %rdi
callq *0xb0(%r12)
movq %rbx, %rdi
callq 0x19c50
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq