// File: /workspace/github_c_makefile_star2_O0/QwazyWabbitWOS[P]lmctf60/p_weapon.c
// Function: Chaingun_Fire
void Chaingun_Fire (edict_t *ent)
{
	int			i;
	int			shots;
	vec3_t		start;
	vec3_t		forward, right, up;
	float		r, u;
	vec3_t		offset;
	int			damage;
	int			kick = 2;

	if (deathmatch->value)
		damage = 6;
	else
		damage = 8;

	if (ent->client->ps.gunframe == 5)
		gi.sound(ent, CHAN_AUTO, gi.soundindex("weapons/chngnu1a.wav"), 1, ATTN_IDLE, 0);

	if ((ent->client->ps.gunframe == 14) && !(ent->client->buttons & BUTTON_ATTACK))
	{
		ent->client->ps.gunframe = 32;
		ent->client->weapon_sound = 0;
		return;
	}
	else if ((ent->client->ps.gunframe == 21) && (ent->client->buttons & BUTTON_ATTACK)
		&& ent->client->pers.inventory[ent->client->ammo_index])
	{
		ent->client->ps.gunframe = 15;
	}
	else
	{
		ent->client->ps.gunframe++;
	}

	if (ent->client->ps.gunframe == 22)
	{
		ent->client->weapon_sound = 0;
		gi.sound(ent, CHAN_AUTO, gi.soundindex("weapons/chngnd1a.wav"), 1, ATTN_IDLE, 0);
	}
	else
	{
		ent->client->weapon_sound = gi.soundindex("weapons/chngnl1a.wav");
	}

	ent->client->anim_priority = ANIM_ATTACK;
	if (ent->client->ps.pmove.pm_flags & PMF_DUCKED)
	{
		ent->s.frame = FRAME_crattak1 - (ent->client->ps.gunframe & 1);
		ent->client->anim_end = FRAME_crattak9;
	}
	else
	{
		ent->s.frame = FRAME_attack1 - (ent->client->ps.gunframe & 1);
		ent->client->anim_end = FRAME_attack8;
	}

	if (ent->client->ps.gunframe <= 9)
		shots = 1;
	else if (ent->client->ps.gunframe <= 14)
	{
		if (ent->client->buttons & BUTTON_ATTACK)
			shots = 2;
		else
			shots = 1;
	}
	else
		shots = 3;

	if (ent->client->pers.inventory[ent->client->ammo_index] < shots)
		shots = ent->client->pers.inventory[ent->client->ammo_index];

	if (!shots)
	{
		if (level.time >= ent->pain_debounce_time)
		{
			gi.sound(ent, CHAN_VOICE, gi.soundindex("weapons/noammo.wav"), 1, ATTN_NORM, 0);
			ent->pain_debounce_time = level.time + 1;
		}
		NoAmmoWeaponChange (ent);
		return;
	}

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

	for (i=0 ; i<3 ; i++)
	{
		ent->client->kick_origin[i] = crandom() * 0.35;
		ent->client->kick_angles[i] = crandom() * 0.7;
	}

	for (i=0 ; i<shots ; i++)
	{
		// get start / end positions
		AngleVectors (ent->client->v_angle, forward, right, up);
		r = 7 + crandom()*4;
		u = crandom()*4;
		VectorSet(offset, 0, r, u + ent->viewheight-8);
		P_ProjectSource (ent->client, ent->s.origin, offset, forward, right, start);

		fire_bullet (ent, start, forward, damage, kick, DEFAULT_BULLET_HSPREAD, DEFAULT_BULLET_VSPREAD, MOD_CHAINGUN);
	}

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

	PlayerNoise(ent, start, PNOISE_WEAPON);

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x8(%rbp)
movl $0x2, -0x5c(%rbp)
movq 0x1a263(%rip), %rax     # 0x82ec0
movq (%rax), %rax
movss 0x20(%rax), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x68c71
jp 0x68c71
jmp 0x68c7a
movl $0x6, -0x58(%rbp)
jmp 0x68c81
movl $0x8, -0x58(%rbp)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
cmpl $0x5, 0x5c(%rax)
jne 0x68cd8
movq 0x1996a(%rip), %rax     # 0x82600
movq 0x20(%rax), %rax
movq %rax, -0x68(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x70(%rbp)
leaq 0xee3f(%rip), %rdi      # 0x77aec
movq 0x1994c(%rip), %rax     # 0x82600
callq *0x48(%rax)
movq -0x70(%rbp), %rdi
movl %eax, %edx
movq -0x68(%rbp), %rax
xorl %esi, %esi
movss 0x7221(%rip), %xmm0     # 0x6feec
movss 0x7215(%rip), %xmm1     # 0x6fee8
xorps %xmm2, %xmm2
callq *%rax
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
cmpl $0xe, 0x5c(%rax)
jne 0x68d22
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl 0xe3c(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x68d22
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl $0x20, 0x5c(%rax)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl $0x0, 0xf20(%rax)
jmp 0x6931a
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
cmpl $0x15, 0x5c(%rax)
jne 0x68d78
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl 0xe3c(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x68d78
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x58(%rcx), %rcx
movslq 0xe38(%rcx), %rcx
cmpl $0x0, 0x318(%rax,%rcx,4)
je 0x68d78
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl $0xf, 0x5c(%rax)
jmp 0x68d89
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl 0x5c(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x5c(%rax)
jmp 0x68d8b
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
cmpl $0x16, 0x5c(%rax)
jne 0x68df6
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl $0x0, 0xf20(%rax)
movq 0x1984e(%rip), %rax     # 0x82600
movq 0x20(%rax), %rax
movq %rax, -0x78(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x80(%rbp)
leaq 0xa61e(%rip), %rdi      # 0x733e7
movq 0x19830(%rip), %rax     # 0x82600
callq *0x48(%rax)
movq -0x80(%rbp), %rdi
movl %eax, %edx
movq -0x78(%rbp), %rax
xorl %esi, %esi
movss 0x7105(%rip), %xmm0     # 0x6feec
movss 0x70f9(%rip), %xmm1     # 0x6fee8
xorps %xmm2, %xmm2
callq *%rax
jmp 0x68e17
leaq 0xed04(%rip), %rdi      # 0x77b01
movq 0x197fc(%rip), %rax     # 0x82600
callq *0x48(%rax)
movl %eax, %ecx
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl %ecx, 0xf20(%rax)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl $0x4, 0xef8(%rax)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movzbl 0x10(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x68e6d
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl 0x5c(%rax), %eax
andl $0x1, %eax
movl $0xa0, %ecx
subl %eax, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x38(%rax)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl $0xa8, 0xef4(%rax)
jmp 0x68e9b
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl 0x5c(%rax), %eax
andl $0x1, %eax
movl $0x2e, %ecx
subl %eax, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x38(%rax)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl $0x35, 0xef4(%rax)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
cmpl $0x9, 0x5c(%rax)
jg 0x68eb2
movl $0x1, -0x10(%rbp)
jmp 0x68ef1
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
cmpl $0xe, 0x5c(%rax)
jg 0x68ee8
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl 0xe3c(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x68edf
movl $0x2, -0x10(%rbp)
jmp 0x68ee6
movl $0x1, -0x10(%rbp)
jmp 0x68eef
movl $0x3, -0x10(%rbp)
jmp 0x68ef1
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), %eax
cmpl -0x10(%rbp), %eax
jge 0x68f35
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), %eax
movl %eax, -0x10(%rbp)
cmpl $0x0, -0x10(%rbp)
jne 0x68fd9
movq 0x19e5a(%rip), %rax     # 0x82da0
movss 0x4(%rax), %xmm0
movq -0x8(%rbp), %rax
ucomiss 0x244(%rax), %xmm0
jb 0x68fcb
movq 0x196a1(%rip), %rax     # 0x82600
movq 0x20(%rax), %rax
movq %rax, -0x88(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x90(%rbp)
leaq 0x7d73(%rip), %rdi      # 0x70cef
movq 0x1967d(%rip), %rax     # 0x82600
callq *0x48(%rax)
movq -0x90(%rbp), %rdi
movl %eax, %edx
movq -0x88(%rbp), %rax
movl $0x2, %esi
movss 0x6f49(%rip), %xmm1     # 0x6feec
xorps %xmm2, %xmm2
movaps %xmm1, %xmm0
callq *%rax
movss 0x6f39(%rip), %xmm0     # 0x6feec
movq 0x19de6(%rip), %rax     # 0x82da0
addss 0x4(%rax), %xmm0
movq -0x8(%rbp), %rax
movss %xmm0, 0x244(%rax)
movq -0x8(%rbp), %rdi
callq 0x194b0
jmp 0x6931a
cmpl $0x0, 0x4a284(%rip)     # 0xb3264
je 0x68ff4
movl -0x58(%rbp), %eax
shll $0x2, %eax
movl %eax, -0x58(%rbp)
movl -0x5c(%rbp), %eax
shll $0x2, %eax
movl %eax, -0x5c(%rbp)
movl $0x0, -0xc(%rbp)
cmpl $0x3, -0xc(%rbp)
jge 0x690c9
callq 0x19c80
andl $0x7fff, %eax           # imm = 0x7FFF
cvtsi2ss %eax, %xmm0
movss 0x726d(%rip), %xmm1     # 0x70288
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0x83fd(%rip), %xmm0     # 0x71428
subsd %xmm0, %xmm1
movsd 0x9b61(%rip), %xmm0     # 0x72b98
mulsd %xmm1, %xmm0
movsd 0xea3d(%rip), %xmm1     # 0x77a80
mulsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movslq -0xc(%rbp), %rcx
movss %xmm0, 0xe88(%rax,%rcx,4)
callq 0x19c80
andl $0x7fff, %eax           # imm = 0x7FFF
cvtsi2ss %eax, %xmm0
movss 0x7212(%rip), %xmm1     # 0x70288
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0x83a2(%rip), %xmm0     # 0x71428
subsd %xmm0, %xmm1
movsd 0x9b06(%rip), %xmm0     # 0x72b98
mulsd %xmm1, %xmm0
movsd 0xb64a(%rip), %xmm1     # 0x746e8
mulsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movslq -0xc(%rbp), %rcx
movss %xmm0, 0xe7c(%rax,%rcx,4)
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x68ffb
movl $0x0, -0xc(%rbp)
movl -0xc(%rbp), %eax
cmpl -0x10(%rbp), %eax
jge 0x69236
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rdi
addq $0xebc, %rdi            # imm = 0xEBC
leaq -0x28(%rbp), %rsi
leaq -0x34(%rbp), %rdx
leaq -0x40(%rbp), %rcx
callq 0x183e0
callq 0x19c80
andl $0x7fff, %eax           # imm = 0x7FFF
cvtsi2ss %eax, %xmm0
movss 0x7176(%rip), %xmm1     # 0x70288
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0x8306(%rip), %xmm0     # 0x71428
subsd %xmm0, %xmm1
movsd 0x9a6a(%rip), %xmm0     # 0x72b98
mulsd %xmm1, %xmm0
movsd 0xe926(%rip), %xmm1     # 0x77a60
mulsd %xmm1, %xmm0
movsd 0xe942(%rip), %xmm1     # 0x77a88
addsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x44(%rbp)
callq 0x19c80
andl $0x7fff, %eax           # imm = 0x7FFF
cvtsi2ss %eax, %xmm0
movss 0x711f(%rip), %xmm1     # 0x70288
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0x82af(%rip), %xmm0     # 0x71428
subsd %xmm0, %xmm1
movsd 0x9a13(%rip), %xmm0     # 0x72b98
mulsd %xmm1, %xmm0
movsd 0xe8cf(%rip), %xmm1     # 0x77a60
mulsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x48(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0x54(%rbp)
movss -0x44(%rbp), %xmm0
movss %xmm0, -0x50(%rbp)
movss -0x48(%rbp), %xmm0
movq -0x8(%rbp), %rax
cvtsi2ssl 0x278(%rax), %xmm1
addss %xmm1, %xmm0
movss 0x6d2f(%rip), %xmm1     # 0x6fefc
subss %xmm1, %xmm0
movss %xmm0, -0x4c(%rbp)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rdi
movq -0x8(%rbp), %rsi
addq $0x4, %rsi
leaq -0x54(%rbp), %rdx
leaq -0x28(%rbp), %rcx
leaq -0x34(%rbp), %r8
leaq -0x1c(%rbp), %r9
callq 0x67590
movq -0x8(%rbp), %rdi
leaq -0x1c(%rbp), %rsi
leaq -0x28(%rbp), %rdx
movl -0x58(%rbp), %ecx
movl -0x5c(%rbp), %r8d
movl $0x12c, %r9d            # imm = 0x12C
movl $0x1f4, (%rsp)          # imm = 0x1F4
movl $0x5, 0x8(%rsp)
callq 0x19ca0
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x690d0
movl $0x1, %edi
movq 0x193be(%rip), %rax     # 0x82600
callq *0xc8(%rax)
movq 0x193b1(%rip), %rax     # 0x82600
movq 0xd0(%rax), %rax
movq %rax, -0x98(%rbp)
movq -0x8(%rbp), %rax
movq 0x192f0(%rip), %rcx     # 0x82558
movq (%rcx), %rcx
subq %rcx, %rax
movl $0x4a8, %ecx            # imm = 0x4A8
cqto
idivq %rcx
movq %rax, %rcx
movq -0x98(%rbp), %rax
movl %ecx, %edi
callq *%rax
movq 0x19373(%rip), %rax     # 0x82600
movq 0xc8(%rax), %rax
movl -0x10(%rbp), %edi
addl $0x3, %edi
subl $0x1, %edi
movzbl 0x49fc4(%rip), %ecx     # 0xb3268
orl %ecx, %edi
callq *%rax
movq 0x19351(%rip), %rax     # 0x82600
movq 0xb0(%rax), %rax
movq -0x8(%rbp), %rdi
addq $0x4, %rdi
movl $0x2, %esi
callq *%rax
movq -0x8(%rbp), %rdi
leaq -0x1c(%rbp), %rsi
movl $0x1, %edx
callq 0x19080
movq 0x1933a(%rip), %rax     # 0x82618
movq (%rax), %rax
cvttss2si 0x20(%rax), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
jne 0x6931a
movl -0x10(%rbp), %esi
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 %esi, %edx
movl %edx, 0x318(%rax,%rcx,4)
addq $0xb0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)