// File: /workspace/github_c_makefile_star2_O2/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 0x4baef
cmpl $0x4, %eax
jne 0x4bacd
addq $0xebc, %rdi            # imm = 0xEBC
leaq 0x34(%rsp), %r14
leaq 0x28(%rsp), %r12
movq %r14, %rsi
movq %r12, %rdx
xorl %ecx, %ecx
callq 0x183d0
movl $0xe88, %esi            # imm = 0xE88
addq 0x58(%rbx), %rsi
movss 0x4a6d(%rip), %xmm0     # 0x50410
movq %r14, %rdi
callq 0x18a70
movsd 0x7a0d(%rip), %xmm0     # 0x533c0
leaq 0x18(%rsp), %rdx
movsd %xmm0, (%rdx)
movl 0x278(%rbx), %eax
addl $-0x8, %eax
cvtsi2ss %eax, %xmm0
movss %xmm0, 0x8(%rdx)
movq 0x58(%rbx), %rdi
leaq 0x4(%rbx), %rsi
leaq 0xc(%rsp), %r15
movq %r14, %rcx
movq %r12, %r8
movq %r15, %r9
callq 0x48f06
movq 0x58(%rbx), %rax
xorl %ebp, %ebp
cmpl $0x0, 0xf3c(%rax)
setne %bpl
movq 0x1abff(%rip), %rax     # 0x66600
movq 0x20(%rax), %r12
leaq 0xb5d2(%rip), %rcx      # 0x56fde
leaq 0xb5e4(%rip), %rdi      # 0x56ff7
cmovneq %rcx, %rdi
callq *0x48(%rax)
pushq $0x1
popq %rsi
movss 0x3503(%rip), %xmm0     # 0x4ef28
xorps %xmm2, %xmm2
movq %rbx, %rdi
movl %eax, %edx
movaps %xmm0, %xmm1
callq *%r12
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rdx
movl %ebp, %ecx
callq 0x18470
movq 0x1abce(%rip), %rax     # 0x66618
movq (%rax), %rax
cvttss2si 0x20(%rax), %eax
btl $0xd, %eax
movq 0x58(%rbx), %rax
jb 0x4ba6a
movslq 0xe38(%rax), %rcx
decl 0x318(%rax,%rcx,4)
movl $0xc0000000, 0xe98(%rax) # imm = 0xC0000000
callq 0x19bf0
andl $0x7fff, %eax           # imm = 0x7FFF
cvtsi2ss %eax, %xmm0
divss 0x37fe(%rip), %xmm0     # 0x4f288
cvtss2sd %xmm0, %xmm0
addsd 0x6162(%rip), %xmm0     # 0x51bf8
addsd %xmm0, %xmm0
addsd %xmm0, %xmm0
cvtsd2ss %xmm0, %xmm0
movq 0x58(%rbx), %rdi
movss %xmm0, 0xe94(%rdi)
movq 0x1b2eb(%rip), %rax     # 0x66da0
movss 0x4(%rax), %xmm0
addss 0x493e(%rip), %xmm0     # 0x50400
movss %xmm0, 0xe9c(%rdi)
movl 0x5c(%rdi), %eax
incl %eax
movl %eax, 0x5c(%rdi)
leaq 0xc(%rsp), %rsi
pushq $0x1
popq %rdx
movq %rbx, %rdi
callq 0x19010
addq $0x40, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
incl %eax
movl %eax, 0x5c(%rdi)
movq 0x1b2a5(%rip), %r14     # 0x66da0
movss 0x4(%r14), %xmm0
ucomiss 0x244(%rbx), %xmm0
jb 0x4bb4e
movq 0x1aaef(%rip), %rax     # 0x66600
movq 0x20(%rax), %r15
leaq 0xb4a9(%rip), %rdi      # 0x56fc5
callq *0x48(%rax)
pushq $0x2
popq %rsi
movss 0x33fe(%rip), %xmm0     # 0x4ef28
xorps %xmm2, %xmm2
movq %rbx, %rdi
movl %eax, %edx
movaps %xmm0, %xmm1
callq *%r15
movss 0x33e8(%rip), %xmm0     # 0x4ef28
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 0x19430