// File: /workspace/github_c_makefile_star2_O3/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, 0x4c9ad(%rip)     # 0x99094
movl $0x7d, %eax
movl $0x1f4, %r14d           # imm = 0x1F4
cmovel %eax, %r14d
movsd 0xace2(%rip), %xmm0     # 0x573e0
leaq 0x8(%rsp), %r12
movsd %xmm0, (%r12)
movl 0x278(%rdi), %eax
addl $-0x8, %eax
xorps %xmm0, %xmm0
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 0x183a0
movq 0x58(%rbx), %rax
leaq 0x4(%rbx), %rsi
movl 0x300(%rax), %edi
leaq 0x14(%rsp), %rbp
movq %r12, %rdx
movq %r15, %rcx
movq %r13, %r8
movq %rbp, %r9
callq 0x4d0c5
movq 0x58(%rbx), %rax
movss 0xf18(%rax), %xmm0
movq 0x1c629(%rip), %r12     # 0x68da0
subss 0x4(%r12), %xmm0
movss 0x678a(%rip), %xmm1     # 0x52f10
subss %xmm0, %xmm1
mulss 0xe6be(%rip), %xmm1     # 0x5ae50
addss 0x982a(%rip), %xmm1     # 0x55fc4
cvttss2si %xmm1, %r8d
movss 0xe6ad(%rip), %xmm1     # 0x5ae54
movq %rbx, %rdi
movq %rbp, %rsi
movq %r15, %rdx
movl %r14d, %ecx
movl 0x4(%rsp), %r9d
callq 0x18290
movq 0x1be54(%rip), %rax     # 0x68618
movq (%rax), %rax
cvttss2si 0x20(%rax), %eax
btl $0xd, %eax
movq 0x58(%rbx), %rax
jb 0x4c7e4
movslq 0xe38(%rax), %rcx
decl 0x318(%rax,%rcx,4)
movss 0x4(%r12), %xmm0
addss 0x6735(%rip), %xmm0     # 0x52f28
movss %xmm0, 0xf18(%rax)
cmpl $0x0, 0x260(%rbx)
jne 0x4c84f
cmpl $0xff, 0x28(%rbx)
jne 0x4c84f
cmpl $0x0, 0x254(%rbx)
jle 0x4c84f
xorl %ecx, %ecx
testb $0x1, 0x10(%rax)
sete %cl
movl $0x77, %edx
movl $0x9f, %esi
cmovel %edx, %esi
movl $0x70, %edx
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