// File: /workspace/github_c_makefile_star2_O1/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, 0x4cc9d(%rip)     # 0x9a094
movl $0x7d, %eax
movl $0x1f4, %r14d           # imm = 0x1F4
cmovel %eax, %r14d
movabsq $0x4100000041000000, %rax # imm = 0x4100000041000000
leaq 0x2c(%rsp), %r12
movq %rax, (%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 0x20(%rsp), %r15
leaq 0x14(%rsp), %r13
movq %r15, %rsi
movq %r13, %rdx
xorl %ecx, %ecx
callq 0x183a0
movq 0x58(%rbx), %rdi
leaq 0x4(%rbx), %rsi
leaq 0x8(%rsp), %rbp
movq %r12, %rdx
movq %r15, %rcx
movq %r13, %r8
movq %rbp, %r9
callq 0x4dde7
movq 0x58(%rbx), %rax
movss 0xf18(%rax), %xmm0
movq 0x1c922(%rip), %r12     # 0x69da0
subss 0x4(%r12), %xmm0
movss 0x6a7f(%rip), %xmm1     # 0x53f0c
subss %xmm0, %xmm1
mulss 0xe657(%rip), %xmm1     # 0x5baf0
addss 0x9a2f(%rip), %xmm1     # 0x56ed0
cvttss2si %xmm1, %r8d
movss 0xe646(%rip), %xmm1     # 0x5baf4
movq %rbx, %rdi
movq %rbp, %rsi
movq %r15, %rdx
movl %r14d, %ecx
movl 0x4(%rsp), %r9d
callq 0x18290
movq 0x1c14d(%rip), %rax     # 0x69618
movq (%rax), %rax
cvttss2si 0x20(%rax), %eax
btl $0xd, %eax
jb 0x4d4eb
movq 0x58(%rbx), %rax
movslq 0xe38(%rax), %rcx
decl 0x318(%rax,%rcx,4)
movss 0x4(%r12), %xmm0
addss 0x6a2e(%rip), %xmm0     # 0x53f28
movq 0x58(%rbx), %rax
movss %xmm0, 0xf18(%rax)
cmpl $0x0, 0x260(%rbx)
jne 0x4d55a
cmpl $0xff, 0x28(%rbx)
jne 0x4d55a
cmpl $0x0, 0x254(%rbx)
jle 0x4d55a
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