// File: /workspace/github_c_makefile_star2_O2/QwazyWabbitWOS[P]lmctf60/p_weapon.c
// Function: weapon_grenade_fire
void weapon_grenade_fire (edict_t *ent, qboolean held)
{
	vec3_t	offset;
	vec3_t	forward, right;
	vec3_t	start;
	int		damage = 125;
	float	timer;
	int		speed;
	float	radius;

	radius = damage+40;
	if (is_quad)
		damage *= 4;

	VectorSet(offset, 8, 8, ent->viewheight-8);
	AngleVectors (ent->client->v_angle, forward, right, NULL);
	P_ProjectSource (ent->client, ent->s.origin, offset, forward, right, start);

	timer = ent->client->grenade_time - level.time;
	speed = GRENADE_MINSPEED + (GRENADE_TIMER - timer) * ((GRENADE_MAXSPEED - GRENADE_MINSPEED) / GRENADE_TIMER);
	fire_grenade2 (ent, start, forward, damage, speed, timer, radius, held);

	if (! ( (int)dmflags->value & DF_INFINITE_AMMO ) )
		ent->client->pers.inventory[ent->client->ammo_index]--;

	ent->client->grenade_time = level.time + 1.0;

	if(ent->deadflag || ent->s.modelindex != 255) // VWep animations screw up corpses
	{
		return;
	}

	if (ent->health <= 0)
		return;

	if (ent->client->ps.pmove.pm_flags & PMF_DUCKED)
	{
		ent->client->anim_priority = ANIM_ATTACK;
		ent->s.frame = FRAME_crattak1-1;
		ent->client->anim_end = FRAME_crattak3;
	}
	else
	{
		ent->client->anim_priority = ANIM_REVERSE;
		ent->s.frame = FRAME_wave08;
		ent->client->anim_end = FRAME_wave01;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %esi, 0x4(%rsp)
movq %rdi, %rbx
cmpl $0x0, 0x4ec0a(%rip)     # 0x97194
pushq $0x7d
popq %rax
movl $0x1f4, %r14d           # imm = 0x1F4
cmovel %eax, %r14d
movsd 0xae21(%rip), %xmm0     # 0x533c0
leaq 0x8(%rsp), %r12
movsd %xmm0, (%r12)
movl 0x278(%rdi), %eax
addl $-0x8, %eax
cvtsi2ss %eax, %xmm0
movss %xmm0, 0x8(%r12)
movl $0xebc, %edi            # imm = 0xEBC
addq 0x58(%rbx), %rdi
leaq 0x2c(%rsp), %r15
leaq 0x20(%rsp), %r13
movq %r15, %rsi
movq %r13, %rdx
xorl %ecx, %ecx
callq 0x183d0
movq 0x58(%rbx), %rdi
leaq 0x4(%rbx), %rsi
leaq 0x14(%rsp), %rbp
movq %r12, %rdx
movq %r15, %rcx
movq %r13, %r8
movq %rbp, %r9
callq 0x48f06
movq 0x58(%rbx), %rax
movss 0xf18(%rax), %xmm0
movq 0x1e791(%rip), %r12     # 0x66da0
subss 0x4(%r12), %xmm0
movss 0x68ee(%rip), %xmm1     # 0x4ef0c
subss %xmm0, %xmm1
mulss 0xe7e6(%rip), %xmm1     # 0x56e10
addss 0x9972(%rip), %xmm1     # 0x51fa4
cvttss2si %xmm1, %r8d
movss 0xe7d5(%rip), %xmm1     # 0x56e14
movq %rbx, %rdi
movq %rbp, %rsi
movq %r15, %rdx
movl %r14d, %ecx
movl 0x4(%rsp), %r9d
callq 0x182b0
movq 0x1dfbc(%rip), %rax     # 0x66618
movq (%rax), %rax
cvttss2si 0x20(%rax), %eax
btl $0xd, %eax
movq 0x58(%rbx), %rax
jb 0x4867c
movslq 0xe38(%rax), %rcx
decl 0x318(%rax,%rcx,4)
movss 0x4(%r12), %xmm0
addss 0x689d(%rip), %xmm0     # 0x4ef28
movss %xmm0, 0xf18(%rax)
cmpl $0x0, 0x260(%rbx)
jne 0x486e3
cmpl $0xff, 0x28(%rbx)
jne 0x486e3
cmpl $0x0, 0x254(%rbx)
jle 0x486e3
xorl %ecx, %ecx
testb $0x1, 0x10(%rax)
sete %cl
pushq $0x77
popq %rdx
movl $0x9f, %esi
cmovel %edx, %esi
pushq $0x70
popq %rdx
movl $0xa2, %edi
cmovel %edx, %edi
leal 0x4(,%rcx,2), %ecx
movl %ecx, 0xef8(%rax)
movl %esi, 0x38(%rbx)
movl %edi, 0xef4(%rax)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq