// File: /workspace/github_c_makefile_star2_O2/QwazyWabbitWOS[P]lmctf60/p_weapon.c
// Function: weapon_bfg_fire
void weapon_bfg_fire (edict_t *ent)
{
	vec3_t	offset, start;
	vec3_t	forward, right;
	int		damage;
	float	damage_radius = 1000;
	
#ifdef WEAP_BALANCE_OK	
	if ((int)ctfflags->value & CTF_WEAP_BALANCE)
		damage_radius = 1200; //SURT was 1000
#endif

	if (deathmatch->value)
		damage = 200;
	else
		damage = 500;

#ifdef WEAP_BALANCE_OK	
	if ((int)ctfflags->value & CTF_WEAP_BALANCE)
		damage = 180; //SURT was 200
#endif

	if (ent->client->ps.gunframe == 9)
	{
		// send muzzle flash
		gi.WriteByte (svc_muzzleflash);
		gi.WriteShort (ent-g_edicts);
		gi.WriteByte (MZ_BFG | is_silenced);
		gi.multicast (ent->s.origin, MULTICAST_PVS);

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

		PlayerNoise(ent, start, PNOISE_WEAPON);
		return;
	}

	// cells can go down during windup (from power armor hits), so
	// check again and abort firing if we don't have enough now
	if (ent->client->pers.inventory[ent->client->ammo_index] < 50)
	{
		ent->client->ps.gunframe++;
		return;
	}

	if (is_quad)
		damage *= 4;

	AngleVectors (ent->client->v_angle, forward, right, NULL);

	VectorScale (forward, -2, ent->client->kick_origin);

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

	VectorSet(offset, 8, 8, ent->viewheight-8);
	P_ProjectSource (ent->client, ent->s.origin, offset, forward, right, start);

#ifdef WEAP_BALANCE_OK	
	if ((int)ctfflags->value & CTF_WEAP_BALANCE)
		fire_bfg (ent, start, forward, damage, 180, damage_radius); //SURT 180 was 400
	else
		fire_bfg (ent, start, forward, damage, 400, damage_radius); //SURT
#else
	fire_bfg (ent, start, forward, damage, 400, damage_radius); //SURT
#endif

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

	PlayerNoise(ent, start, PNOISE_WEAPON);

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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x40, %rsp
movq 0x1c25e(%rip), %rax     # 0x66ec0
movq (%rax), %rax
xorps %xmm0, %xmm0
ucomiss 0x20(%rax), %xmm0
setp %al
setne %cl
orb %al, %cl
movl $0xc8, %ecx
movl $0x1f4, %eax            # imm = 0x1F4
cmovnel %ecx, %eax
movq %rdi, %rbx
movq 0x58(%rdi), %rdi
movl 0x5c(%rdi), %ecx
cmpl $0x9, %ecx
jne 0x4ad00
movq 0x1b969(%rip), %r14     # 0x66600
pushq $0x1
popq %rbp
movl %ebp, %edi
callq *0xc8(%r14)
movq 0x1b8ae(%rip), %rcx     # 0x66558
movq %rbx, %rax
subq (%rcx), %rax
movl $0x4a8, %ecx            # imm = 0x4A8
cqto
idivq %rcx
movl %eax, %edi
callq *0xd0(%r14)
movzbl 0x4c4ce(%rip), %edi     # 0x97198
shll $0x7, %edi
orl $0xc, %edi
callq *0xc8(%r14)
leaq 0x4(%rbx), %rdi
pushq $0x2
popq %rsi
callq *0xb0(%r14)
movq 0x58(%rbx), %rax
incl 0x5c(%rax)
leaq 0xc(%rsp), %rsi
movq %rbx, %rdi
movl %ebp, %edx
callq 0x19010
jmp 0x4ae60
movslq 0xe38(%rdi), %rdx
cmpl $0x31, 0x318(%rdi,%rdx,4)
jg 0x4ad1b
incl %ecx
movl %ecx, 0x5c(%rdi)
jmp 0x4ae60
cmpl $0x0, 0x4c472(%rip)     # 0x97194
leal (,%rax,4), %ebp
cmovel %eax, %ebp
addq $0xebc, %rdi            # imm = 0xEBC
leaq 0x34(%rsp), %r14
leaq 0x28(%rsp), %r15
movq %r14, %rsi
movq %r15, %rdx
xorl %ecx, %ecx
callq 0x183d0
movl $0xe88, %esi            # imm = 0xE88
addq 0x58(%rbx), %rsi
movss 0x56b5(%rip), %xmm0     # 0x50410
movq %r14, %rdi
callq 0x18a70
movq 0x58(%rbx), %rax
movl $0xc2200000, 0xe98(%rax) # imm = 0xC2200000
callq 0x19bf0
andl $0x7fff, %eax           # imm = 0x7FFF
cvtsi2ss %eax, %xmm0
divss 0x4501(%rip), %xmm0     # 0x4f288
cvtss2sd %xmm0, %xmm0
addsd 0x6e65(%rip), %xmm0     # 0x51bf8
addsd %xmm0, %xmm0
mulsd 0xbdf9(%rip), %xmm0     # 0x56b98
cvtsd2ss %xmm0, %xmm0
movq 0x58(%rbx), %rdi
movss %xmm0, 0xe94(%rdi)
movq 0x1bfea(%rip), %rax     # 0x66da0
movss 0x4(%rax), %xmm0
addss 0x563d(%rip), %xmm0     # 0x50400
movss %xmm0, 0xe9c(%rdi)
movsd 0x85ed(%rip), %xmm0     # 0x533c0
leaq 0x18(%rsp), %rdx
movsd %xmm0, (%rdx)
movl 0x278(%rbx), %eax
addl $-0x8, %eax
cvtsi2ss %eax, %xmm0
movss %xmm0, 0x8(%rdx)
leaq 0x4(%rbx), %rsi
leaq 0xc(%rsp), %r12
movq %r14, %rcx
movq %r15, %r8
movq %r12, %r9
callq 0x48f06
movss 0x4103(%rip), %xmm0     # 0x4ef10
movq %rbx, %rdi
movq %r12, %rsi
movq %r14, %rdx
movl %ebp, %ecx
movl $0x190, %r8d            # imm = 0x190
callq 0x199f0
movq 0x58(%rbx), %rax
incl 0x5c(%rax)
pushq $0x1
popq %rdx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x19010
movq 0x1b7d9(%rip), %rax     # 0x66618
movq (%rax), %rax
cvttss2si 0x20(%rax), %eax
btl $0xd, %eax
jb 0x4ae60
movq 0x58(%rbx), %rax
movslq 0xe38(%rax), %rcx
addl $-0x32, 0x318(%rax,%rcx,4)
addq $0x40, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq