// File: /workspace/github_c_makefile_star2_O3/QwazyWabbitWOS[P]lmctf60/p_weapon.c
// Function: weapon_plasma_fire
void weapon_plasma_fire (edict_t *ent)
{
	vec3_t	offset, start;
	vec3_t	forward, right;

	// if outa ammo, don't fire
	if (ent->client->pers.inventory[ent->client->ammo_index] < 1) {
		ent->client->ps.gunframe++;

		if (level.time >= ent->pain_debounce_time)
		{
			gi.sound(ent, CHAN_VOICE, gi.soundindex(PLASMA_SOUND_EMPTY), 1, ATTN_NORM, 0);
			ent->pain_debounce_time = level.time + 1;
		}
		
		NoAmmoWeaponChange (ent);
		return;
	}

	if (ent->client->ps.gunframe == 4) {
		AngleVectors (ent->client->v_angle, forward, right, NULL);
		VectorScale (forward, -2, ent->client->kick_origin);
		
		// fire weapon
		VectorSet(offset, 8, 8, ent->viewheight-8);
		P_ProjectSource (ent->client, ent->s.origin, offset, forward, right, start);

		if( ent->client->plasma_mode ) {
		gi.sound( ent,CHAN_WEAPON, gi.soundindex(PLASMA_SOUND_FIRE1), 1,
		          ATTN_NORM,0 );
		fire_plasma (ent, start, forward, 1);
		} else {
		gi.sound( ent,CHAN_WEAPON, gi.soundindex(PLASMA_SOUND_FIRE2), 1,
		          ATTN_NORM,0 );
		fire_plasma (ent, start, forward, 0);
		}

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

		// make a big pitch kick with an inverse fall
		ent->client->v_dmg_pitch = -2;
		ent->client->v_dmg_roll = crandom()*2;
		ent->client->v_dmg_time = level.time + DAMAGE_TIME;

	}


	//-bat Silence??
	// send muzzle flash
	//gi.WriteByte (svc_muzzleflash);
	//gi.WriteShort (ent-g_edicts);
	//gi.WriteByte (MZ_ROCKET | is_silenced);
	//gi.multicast (ent->s.origin, MULTICAST_PVS);


	ent->client->ps.gunframe++;

	PlayerNoise(ent, start, PNOISE_WEAPON);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x40, %rsp
movq %rdi, %rbx
movq 0x58(%rdi), %rdi
movslq 0xe38(%rdi), %rax
cmpl $0x0, 0x318(%rdi,%rax,4)
movl 0x5c(%rdi), %eax
jle 0x4fed2
cmpl $0x4, %eax
jne 0x4feae
addq $0xebc, %rdi            # imm = 0xEBC
leaq 0x34(%rsp), %r14
leaq 0x28(%rsp), %r12
movq %r14, %rsi
movq %r12, %rdx
xorl %ecx, %ecx
callq 0x183a0
movl $0xe88, %esi            # imm = 0xE88
addq 0x58(%rbx), %rsi
movss 0x469a(%rip), %xmm0     # 0x54410
movq %r14, %rdi
callq 0x189d0
movsd 0x765a(%rip), %xmm0     # 0x573e0
leaq 0x18(%rsp), %rdx
movsd %xmm0, (%rdx)
movl 0x278(%rbx), %eax
addl $-0x8, %eax
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
movss %xmm0, 0x8(%rdx)
movq 0x58(%rbx), %rax
leaq 0x4(%rbx), %rsi
movl 0x300(%rax), %edi
leaq 0xc(%rsp), %r15
movq %r14, %rcx
movq %r12, %r8
movq %r15, %r9
callq 0x4d0c5
movq 0x58(%rbx), %rax
xorl %ebp, %ebp
cmpl $0x0, 0xf3c(%rax)
setne %bpl
movq 0x18823(%rip), %rax     # 0x68600
movq 0x20(%rax), %r12
leaq 0xb236(%rip), %rcx      # 0x5b01e
leaq 0xb248(%rip), %rdi      # 0x5b037
cmovneq %rcx, %rdi
callq *0x48(%rax)
movss 0x312a(%rip), %xmm0     # 0x52f28
xorps %xmm2, %xmm2
movq %rbx, %rdi
movl $0x1, %esi
movl %eax, %edx
movaps %xmm0, %xmm1
callq *%r12
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rdx
movl %ebp, %ecx
callq 0x18440
movq 0x187f0(%rip), %rax     # 0x68618
movq (%rax), %rax
cvttss2si 0x20(%rax), %eax
btl $0xd, %eax
movq 0x58(%rbx), %rax
jb 0x4fe48
movslq 0xe38(%rax), %rcx
decl 0x318(%rax,%rcx,4)
movl $0xc0000000, 0xe98(%rax) # imm = 0xC0000000
callq 0x19a10
andl $0x7fff, %eax           # imm = 0x7FFF
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
divss 0x341d(%rip), %xmm0     # 0x53288
cvtss2sd %xmm0, %xmm0
addsd 0x5da1(%rip), %xmm0     # 0x55c18
addsd %xmm0, %xmm0
addsd %xmm0, %xmm0
cvtsd2ss %xmm0, %xmm0
movq 0x58(%rbx), %rdi
movss %xmm0, 0xe94(%rdi)
movq 0x18f0a(%rip), %rax     # 0x68da0
movss 0x4(%rax), %xmm0
addss 0x455d(%rip), %xmm0     # 0x54400
movss %xmm0, 0xe9c(%rdi)
movl 0x5c(%rdi), %eax
incl %eax
movl %eax, 0x5c(%rdi)
leaq 0xc(%rsp), %rsi
movq %rbx, %rdi
movl $0x1, %edx
callq 0x18ef0
addq $0x40, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
incl %eax
movl %eax, 0x5c(%rdi)
movq 0x18ec2(%rip), %r14     # 0x68da0
movss 0x4(%r14), %xmm0
ucomiss 0x244(%rbx), %xmm0
jb 0x4ff33
movq 0x1870c(%rip), %rax     # 0x68600
movq 0x20(%rax), %r15
leaq 0xb106(%rip), %rdi      # 0x5b005
callq *0x48(%rax)
movss 0x301e(%rip), %xmm0     # 0x52f28
xorps %xmm2, %xmm2
movq %rbx, %rdi
movl $0x2, %esi
movl %eax, %edx
movaps %xmm0, %xmm1
callq *%r15
movss 0x3003(%rip), %xmm0     # 0x52f28
addss 0x4(%r14), %xmm0
movss %xmm0, 0x244(%rbx)
movq %rbx, %rdi
addq $0x40, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x192b0