// File: /workspace/github_c_makefile_star2_O1/QwazyWabbitWOS[P]lmctf60/p_weapon.c
// Function: weapon_shotgun_fire
void weapon_shotgun_fire (edict_t *ent)
{
	vec3_t		start;
	vec3_t		forward, right;
	vec3_t		offset;
	int			damage = 4;
	int			kick = 8;
	int			count = 0; //surt weapon balance

	if (ent->client->ps.gunframe == 9)
	{
		ent->client->ps.gunframe++;
		return;
	}

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

	VectorScale (forward, -2, ent->client->kick_origin);
	ent->client->kick_angles[0] = -2;

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

	if (is_quad)
	{
		damage *= 4;
		kick *= 4;
	}

#ifdef WEAP_BALANCE_OK	
	if ((int)ctfflags->value & CTF_WEAP_BALANCE) //surt
	{
		damage+=1; //slightly more damage, except with quad
		count = 2; //more pellets 
	}
#endif

	if (deathmatch->value)
		fire_shotgun (ent, start, forward, damage, kick, 500, 500, DEFAULT_DEATHMATCH_SHOTGUN_COUNT + count, MOD_SHOTGUN); //surt balance
	else
		fire_shotgun (ent, start, forward, damage, kick, 500, 500, DEFAULT_SHOTGUN_COUNT + count, MOD_SHOTGUN); //surt balance

	// send muzzle flash
	gi.WriteByte (svc_muzzleflash);
	gi.WriteShort (ent-g_edicts);
	gi.WriteByte (MZ_SHOTGUN | is_silenced);
	gi.multicast (ent->s.origin, MULTICAST_PVS);

	ent->client->ps.gunframe++;
	PlayerNoise(ent, start, PNOISE_WEAPON);

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

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x30, %rsp
movq %rdi, %rbx
movq 0x58(%rdi), %rdi
cmpl $0x9, 0x5c(%rdi)
jne 0x4f2b6
movl $0xa, 0x5c(%rdi)
jmp 0x4f418
addq $0xebc, %rdi            # imm = 0xEBC
leaq 0x18(%rsp), %r12
leaq 0xc(%rsp), %r13
movq %r12, %rsi
movq %r13, %rdx
xorl %ecx, %ecx
callq 0x183a0
movl $0xe88, %esi            # imm = 0xE88
addq 0x58(%rbx), %rsi
movss 0x612b(%rip), %xmm0     # 0x55410
movq %r12, %rdi
callq 0x189d0
movq 0x58(%rbx), %rdi
movl $0xc0000000, 0xe7c(%rdi) # imm = 0xC0000000
movabsq $0x4100000000000000, %rax # imm = 0x4100000000000000
movq %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), %r15
leaq 0x24(%rsp), %r14
movq %r15, %rsi
movq %r12, %rcx
movq %r13, %r8
movq %r14, %r9
callq 0x4dde7
cmpl $0x0, 0x4ad53(%rip)     # 0x9a094
movl $0x8, %eax
movl $0x20, %r8d
cmovel %eax, %r8d
movl $0x4, %eax
movl $0x10, %ecx
cmovel %eax, %ecx
subq $0x8, %rsp
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rdx
movl $0x1f4, %r9d            # imm = 0x1F4
pushq $0x2
pushq $0xc
pushq $0x1f4                  # imm = 0x1F4
callq 0x186c0
addq $0x20, %rsp
movq 0x1a277(%rip), %r12     # 0x69600
movl $0x1, %edi
callq *0xc8(%r12)
movq 0x1a1bb(%rip), %rax     # 0x69558
movq %rbx, %rcx
subq (%rax), %rcx
shrq $0x3, %rcx
imull $0x8ce2cabd, %ecx, %edi # imm = 0x8CE2CABD
callq *0xd0(%r12)
movzbl 0x4acdc(%rip), %edi     # 0x9a098
shll $0x7, %edi
orl $0x2, %edi
callq *0xc8(%r12)
movq %r15, %rdi
movl $0x2, %esi
callq *0xb0(%r12)
movq 0x58(%rbx), %rax
incl 0x5c(%rax)
movq %rbx, %rdi
movq %r14, %rsi
movl $0x1, %edx
callq 0x18ef0
movq 0x1a220(%rip), %rax     # 0x69618
movq (%rax), %rax
cvttss2si 0x20(%rax), %eax
btl $0xd, %eax
jb 0x4f418
movq 0x58(%rbx), %rax
movslq 0xe38(%rax), %rcx
decl 0x318(%rax,%rcx,4)
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq