// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movss 0x5cd4(%rip), %xmm0     # 0x6fef8
movss %xmm0, -0x40(%rbp)
movq 0x18c90(%rip), %rax     # 0x82ec0
movq (%rax), %rax
movss 0x20(%rax), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x6a244
jp 0x6a244
jmp 0x6a24d
movl $0xc8, -0x3c(%rbp)
jmp 0x6a254
movl $0x1f4, -0x3c(%rbp)     # imm = 0x1F4
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
cmpl $0x9, 0x5c(%rax)
jne 0x6a30f
movl $0x1, %edi
movq 0x1838e(%rip), %rax     # 0x82600
callq *0xc8(%rax)
movq 0x18381(%rip), %rax     # 0x82600
movq 0xd0(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x8(%rbp), %rax
movq 0x182c3(%rip), %rcx     # 0x82558
movq (%rcx), %rcx
subq %rcx, %rax
movl $0x4a8, %ecx            # imm = 0x4A8
cqto
idivq %rcx
movq %rax, %rcx
movq -0x48(%rbp), %rax
movl %ecx, %edi
callq *%rax
movq 0x18349(%rip), %rax     # 0x82600
movq 0xc8(%rax), %rax
movzbl 0x48fa3(%rip), %edi     # 0xb3268
orl $0xc, %edi
callq *%rax
movq 0x1832f(%rip), %rax     # 0x82600
movq 0xb0(%rax), %rax
movq -0x8(%rbp), %rdi
addq $0x4, %rdi
movl $0x2, %esi
callq *%rax
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl 0x5c(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x5c(%rax)
movq -0x8(%rbp), %rdi
leaq -0x20(%rbp), %rsi
movl $0x1, %edx
callq 0x19080
jmp 0x6a502
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x58(%rcx), %rcx
movslq 0xe38(%rcx), %rcx
cmpl $0x32, 0x318(%rax,%rcx,4)
jge 0x6a346
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl 0x5c(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x5c(%rax)
jmp 0x6a502
cmpl $0x0, 0x48f17(%rip)     # 0xb3264
je 0x6a358
movl -0x3c(%rbp), %eax
shll $0x2, %eax
movl %eax, -0x3c(%rbp)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rdi
addq $0xebc, %rdi            # imm = 0xEBC
leaq -0x2c(%rbp), %rsi
leaq -0x38(%rbp), %rdx
xorl %eax, %eax
movl %eax, %ecx
callq 0x183e0
leaq -0x2c(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rsi
addq $0xe88, %rsi            # imm = 0xE88
movss 0x7081(%rip), %xmm0     # 0x71414
callq 0x18a80
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movss 0xd6ac(%rip), %xmm0     # 0x77a54
movss %xmm0, 0xe98(%rax)
callq 0x19c80
andl $0x7fff, %eax           # imm = 0x7FFF
cvtsi2ss %eax, %xmm0
movss 0x5ec2(%rip), %xmm1     # 0x70288
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0x7052(%rip), %xmm0     # 0x71428
subsd %xmm0, %xmm1
movsd 0x87b6(%rip), %xmm0     # 0x72b98
mulsd %xmm1, %xmm0
movsd 0xa302(%rip), %xmm1     # 0x746f0
mulsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movss %xmm0, 0xe94(%rax)
movss 0x8742(%rip), %xmm0     # 0x72b50
movq 0x1898b(%rip), %rax     # 0x82da0
addss 0x4(%rax), %xmm0
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movss %xmm0, 0xe9c(%rax)
movss 0x5aca(%rip), %xmm0     # 0x6fefc
movss %xmm0, -0x14(%rbp)
movss 0x5abd(%rip), %xmm0     # 0x6fefc
movss %xmm0, -0x10(%rbp)
movq -0x8(%rbp), %rax
movl 0x278(%rax), %eax
subl $0x8, %eax
cvtsi2ss %eax, %xmm0
movss %xmm0, -0xc(%rbp)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rdi
movq -0x8(%rbp), %rsi
addq $0x4, %rsi
leaq -0x14(%rbp), %rdx
leaq -0x2c(%rbp), %rcx
leaq -0x38(%rbp), %r8
leaq -0x20(%rbp), %r9
callq 0x67590
movq -0x8(%rbp), %rdi
leaq -0x20(%rbp), %rsi
leaq -0x2c(%rbp), %rdx
movl -0x3c(%rbp), %ecx
movss -0x40(%rbp), %xmm0
movl $0x190, %r8d            # imm = 0x190
callq 0x19a80
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl 0x5c(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x5c(%rax)
movq -0x8(%rbp), %rdi
leaq -0x20(%rbp), %rsi
movl $0x1, %edx
callq 0x19080
movq 0x18150(%rip), %rax     # 0x82618
movq (%rax), %rax
cvttss2si 0x20(%rax), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
jne 0x6a502
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x58(%rcx), %rcx
movslq 0xe38(%rcx), %rcx
movl 0x318(%rax,%rcx,4), %edx
subl $0x32, %edx
movl %edx, 0x318(%rax,%rcx,4)
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)