// File: /workspace/github_c_makefile_star2_O1/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 $0x30, %rsp
movq %rdi, %rbx
movq 0x58(%rdi), %rdi
movslq 0xe38(%rdi), %rax
cmpl $0x0, 0x318(%rdi,%rax,4)
movl 0x5c(%rdi), %eax
jle 0x50c39
cmpl $0x4, %eax
jne 0x50c15
addq $0xebc, %rdi            # imm = 0xEBC
leaq 0x18(%rsp), %r14
leaq 0xc(%rsp), %r12
movq %r14, %rsi
movq %r12, %rdx
xorl %ecx, %ecx
callq 0x183a0
movl $0xe88, %esi            # imm = 0xE88
addq 0x58(%rbx), %rsi
movss 0x492d(%rip), %xmm0     # 0x55410
movq %r14, %rdi
callq 0x189d0
movabsq $0x4100000041000000, %rax # imm = 0x4100000041000000
leaq 0x24(%rsp), %rdx
movq %rax, (%rdx)
movl 0x278(%rbx), %eax
addl $-0x8, %eax
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
movss %xmm0, 0x8(%rdx)
movq 0x58(%rbx), %rdi
leaq 0x4(%rbx), %rsi
movq %rsp, %r15
movq %r14, %rcx
movq %r12, %r8
movq %r15, %r9
callq 0x4dde7
movq 0x58(%rbx), %rax
xorl %ebp, %ebp
cmpl $0x0, 0xf3c(%rax)
setne %bpl
movq 0x18abd(%rip), %rax     # 0x69600
movq 0x20(%rax), %r12
leaq 0xb180(%rip), %rcx      # 0x5bcce
leaq 0xb192(%rip), %rdi      # 0x5bce7
cmovneq %rcx, %rdi
callq *0x48(%rax)
movss 0x33c4(%rip), %xmm0     # 0x53f28
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 0x18a8a(%rip), %rax     # 0x69618
movq (%rax), %rax
cvttss2si 0x20(%rax), %eax
btl $0xd, %eax
jb 0x50bae
movq 0x58(%rbx), %rax
movslq 0xe38(%rax), %rcx
decl 0x318(%rax,%rcx,4)
movq 0x58(%rbx), %rax
movl $0xc0000000, 0xe98(%rax) # imm = 0xC0000000
callq 0x19a20
andl $0x7fff, %eax           # imm = 0x7FFF
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
divss 0x36b3(%rip), %xmm0     # 0x54288
cvtss2sd %xmm0, %xmm0
addsd 0x5fcf(%rip), %xmm0     # 0x56bb0
addsd %xmm0, %xmm0
addsd %xmm0, %xmm0
cvtsd2ss %xmm0, %xmm0
movq 0x58(%rbx), %rax
movss %xmm0, 0xe94(%rax)
movq 0x191a0(%rip), %rcx     # 0x69da0
movss 0x4(%rcx), %xmm0
addss 0x47f7(%rip), %xmm0     # 0x55404
movss %xmm0, 0xe9c(%rax)
movq 0x58(%rbx), %rax
incl 0x5c(%rax)
movq %rsp, %rsi
movq %rbx, %rdi
movl $0x1, %edx
callq 0x18ef0
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
incl %eax
movl %eax, 0x5c(%rdi)
movq 0x1915b(%rip), %r14     # 0x69da0
movss 0x4(%r14), %xmm0
ucomiss 0x244(%rbx), %xmm0
jb 0x50c9a
movq 0x189a5(%rip), %rax     # 0x69600
movq 0x20(%rax), %r15
leaq 0xb04f(%rip), %rdi      # 0x5bcb5
callq *0x48(%rax)
movss 0x32b7(%rip), %xmm0     # 0x53f28
xorps %xmm2, %xmm2
movq %rbx, %rdi
movl $0x2, %esi
movl %eax, %edx
movaps %xmm0, %xmm1
callq *%r15
movss 0x329c(%rip), %xmm0     # 0x53f28
addss 0x4(%r14), %xmm0
movss %xmm0, 0x244(%rbx)
movq %rbx, %rdi
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x192b0