// File: /workspace/github_c_makefile_star2_O3/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 0x19f02(%rip), %rax     # 0x68ec0
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 0x4f05f
movq 0x1960d(%rip), %r14     # 0x68600
movl $0x1, %edi
callq *0xc8(%r14)
movq 0x19552(%rip), %rax     # 0x68558
movq %rbx, %rcx
subq (%rax), %rcx
shrq $0x3, %rcx
imull $0x8ce2cabd, %ecx, %edi # imm = 0x8CE2CABD
callq *0xd0(%r14)
movzbl 0x4a074(%rip), %edi     # 0x99098
shll $0x7, %edi
orl $0xc, %edi
callq *0xc8(%r14)
leaq 0x4(%rbx), %rdi
movl $0x2, %esi
callq *0xb0(%r14)
movq 0x58(%rbx), %rax
incl 0x5c(%rax)
leaq 0xc(%rsp), %rsi
movq %rbx, %rdi
movl $0x1, %edx
callq 0x18ef0
jmp 0x4f1cd
movslq 0xe38(%rdi), %rdx
cmpl $0x31, 0x318(%rdi,%rdx,4)
jg 0x4f07a
incl %ecx
movl %ecx, 0x5c(%rdi)
jmp 0x4f1cd
cmpl $0x0, 0x4a013(%rip)     # 0x99094
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 0x183a0
movl $0xe88, %esi            # imm = 0xE88
addq 0x58(%rbx), %rsi
movss 0x5356(%rip), %xmm0     # 0x54410
movq %r14, %rdi
callq 0x189d0
movq 0x58(%rbx), %rax
movl $0xc2200000, 0xe98(%rax) # imm = 0xC2200000
callq 0x19a10
andl $0x7fff, %eax           # imm = 0x7FFF
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
divss 0x419f(%rip), %xmm0     # 0x53288
cvtss2sd %xmm0, %xmm0
addsd 0x6b23(%rip), %xmm0     # 0x55c18
addsd %xmm0, %xmm0
mulsd 0xbad7(%rip), %xmm0     # 0x5abd8
cvtsd2ss %xmm0, %xmm0
movq 0x58(%rbx), %rax
movss %xmm0, 0xe94(%rax)
movq 0x19c88(%rip), %rcx     # 0x68da0
movss 0x4(%rcx), %xmm0
addss 0x52db(%rip), %xmm0     # 0x54400
movss %xmm0, 0xe9c(%rax)
movsd 0x82ab(%rip), %xmm0     # 0x573e0
leaq 0x18(%rsp), %rdx
movsd %xmm0, (%rdx)
movl 0x278(%rbx), %ecx
addl $-0x8, %ecx
xorps %xmm0, %xmm0
cvtsi2ss %ecx, %xmm0
movss %xmm0, 0x8(%rdx)
leaq 0x4(%rbx), %rsi
movl 0x300(%rax), %edi
leaq 0xc(%rsp), %r12
movq %r14, %rcx
movq %r15, %r8
movq %r12, %r9
callq 0x4d0c5
movss 0x3d80(%rip), %xmm0     # 0x52ef8
movq %rbx, %rdi
movq %r12, %rsi
movq %r14, %rdx
movl %ebp, %ecx
movl $0x190, %r8d            # imm = 0x190
callq 0x19810
movq 0x58(%rbx), %rax
incl 0x5c(%rax)
movq %rbx, %rdi
movq %r12, %rsi
movl $0x1, %edx
callq 0x18ef0
movq 0x1946c(%rip), %rax     # 0x68618
movq (%rax), %rax
cvttss2si 0x20(%rax), %eax
btl $0xd, %eax
jb 0x4f1cd
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