// File: /workspace/github_c_makefile_star2_O1/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 $0x30, %rsp
movq 0x1a216(%rip), %rax     # 0x69ec0
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 0x4fd49
movq 0x19921(%rip), %r14     # 0x69600
movl $0x1, %edi
callq *0xc8(%r14)
movq 0x19866(%rip), %rax     # 0x69558
movq %rbx, %rcx
subq (%rax), %rcx
shrq $0x3, %rcx
imull $0x8ce2cabd, %ecx, %edi # imm = 0x8CE2CABD
callq *0xd0(%r14)
movzbl 0x4a388(%rip), %edi     # 0x9a098
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)
movq %rsp, %rsi
movq %rbx, %rdi
movl $0x1, %edx
callq 0x18ef0
jmp 0x4feb0
movslq 0xe38(%rdi), %rdx
cmpl $0x31, 0x318(%rdi,%rdx,4)
jg 0x4fd64
incl %ecx
movl %ecx, 0x5c(%rdi)
jmp 0x4feb0
cmpl $0x0, 0x4a329(%rip)     # 0x9a094
leal (,%rax,4), %ebp
cmovel %eax, %ebp
addq $0xebc, %rdi            # imm = 0xEBC
leaq 0x18(%rsp), %r14
leaq 0xc(%rsp), %r15
movq %r14, %rsi
movq %r15, %rdx
xorl %ecx, %ecx
callq 0x183a0
movl $0xe88, %esi            # imm = 0xE88
addq 0x58(%rbx), %rsi
movss 0x566c(%rip), %xmm0     # 0x55410
movq %r14, %rdi
callq 0x189d0
movq 0x58(%rbx), %rax
movl $0xc2200000, 0xe98(%rax) # imm = 0xC2200000
callq 0x19a20
andl $0x7fff, %eax           # imm = 0x7FFF
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
divss 0x44b5(%rip), %xmm0     # 0x54288
cvtss2sd %xmm0, %xmm0
addsd 0x6dd1(%rip), %xmm0     # 0x56bb0
addsd %xmm0, %xmm0
mulsd 0xbabd(%rip), %xmm0     # 0x5b8a8
cvtsd2ss %xmm0, %xmm0
movq 0x58(%rbx), %rdi
movss %xmm0, 0xe94(%rdi)
movq 0x19f9e(%rip), %rax     # 0x69da0
movss 0x4(%rax), %xmm0
addss 0x55f5(%rip), %xmm0     # 0x55404
movss %xmm0, 0xe9c(%rdi)
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)
leaq 0x4(%rbx), %rsi
movq %rsp, %r12
movq %r14, %rcx
movq %r15, %r8
movq %r12, %r9
callq 0x4dde7
movss 0x40b5(%rip), %xmm0     # 0x53f10
movq %rbx, %rdi
movq %r12, %rsi
movq %r14, %rdx
movl %ebp, %ecx
movl $0x190, %r8d            # imm = 0x190
callq 0x19820
movq 0x58(%rbx), %rax
incl 0x5c(%rax)
movq %rbx, %rdi
movq %r12, %rsi
movl $0x1, %edx
callq 0x18ef0
movq 0x19789(%rip), %rax     # 0x69618
movq (%rax), %rax
cvttss2si 0x20(%rax), %eax
btl $0xd, %eax
jb 0x4feb0
movq 0x58(%rbx), %rax
movslq 0xe38(%rax), %rcx
addl $-0x32, 0x318(%rax,%rcx,4)
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq