// File: /workspace/github_c_makefile_star2_O0/QwazyWabbitWOS[P]lmctf60/p_weapon.c
// Function: Machinegun_Fire
void Machinegun_Fire (edict_t *ent)
{
	int	i;
	vec3_t		start;
	vec3_t		forward, right;
	vec3_t		angles;
	int			damage = 8;
	int			kick = 2;
	vec3_t		offset;

#ifdef WEAP_BALANCE_OK	
	if ((int)ctfflags->value & CTF_WEAP_BALANCE)
	{
		damage = 9; // 9/8 = 12.5% additional damage per bullet
		//we'll lose accuracy for our mod however (extra spread)
	}
#endif

	if (!(ent->client->buttons & BUTTON_ATTACK))
	{
		ent->client->machinegun_shots = 0;
		ent->client->ps.gunframe++;
		return;
	}

	if (ent->client->ps.gunframe == 5)
		ent->client->ps.gunframe = 4;
	else
		ent->client->ps.gunframe = 5;

	if (ent->client->pers.inventory[ent->client->ammo_index] < 1)
	{
		ent->client->ps.gunframe = 6;
		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=1 ; i<3 ; i++)
	{
		ent->client->kick_origin[i] = crandom() * 0.35;
		ent->client->kick_angles[i] = crandom() * 0.7;
	}
	ent->client->kick_origin[0] = crandom() * 0.35;
	ent->client->kick_angles[0] = ent->client->machinegun_shots * -1.5;

	// raise the gun as it is firing
	if (!deathmatch->value)
	{
		ent->client->machinegun_shots++;
		if (ent->client->machinegun_shots > 9)
			ent->client->machinegun_shots = 9;
	}

	// get start / end positions
	VectorAdd (ent->client->v_angle, ent->client->kick_angles, angles);
	AngleVectors (angles, forward, right, NULL);
	VectorSet(offset, 0, 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) //loss of accuracy
		fire_bullet (ent, start, forward, damage, kick, DEFAULT_BULLET_HSPREAD + 100, DEFAULT_BULLET_VSPREAD + 100, MOD_MACHINEGUN);
	else //id original code
		fire_bullet (ent, start, forward, damage, kick, DEFAULT_BULLET_HSPREAD, DEFAULT_BULLET_VSPREAD, MOD_MACHINEGUN);
#else
	fire_bullet (ent, start, forward, damage, kick, DEFAULT_BULLET_HSPREAD, DEFAULT_BULLET_VSPREAD, MOD_MACHINEGUN);
#endif

	gi.WriteByte (svc_muzzleflash);
	gi.WriteShort (ent-g_edicts);
	gi.WriteByte (MZ_MACHINEGUN | 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]--;

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movl $0x8, -0x40(%rbp)
movl $0x2, -0x44(%rbp)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl 0xe3c(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x6868b
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl $0x0, 0xef0(%rax)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl 0x5c(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x5c(%rax)
jmp 0x68bdf
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
cmpl $0x5, 0x5c(%rax)
jne 0x686aa
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl $0x4, 0x5c(%rax)
jmp 0x686b9
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl $0x5, 0x5c(%rax)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x58(%rcx), %rcx
movslq 0xe38(%rcx), %rcx
cmpl $0x1, 0x318(%rax,%rcx,4)
jge 0x6877b
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl $0x6, 0x5c(%rax)
movq 0x1a6ac(%rip), %rax     # 0x82da0
movss 0x4(%rax), %xmm0
movq -0x8(%rbp), %rax
ucomiss 0x244(%rax), %xmm0
jb 0x6876d
movq 0x19ef3(%rip), %rax     # 0x82600
movq 0x20(%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x60(%rbp)
leaq 0x85cb(%rip), %rdi      # 0x70cef
movq 0x19ed5(%rip), %rax     # 0x82600
callq *0x48(%rax)
movq -0x60(%rbp), %rdi
movl %eax, %edx
movq -0x58(%rbp), %rax
movl $0x2, %esi
movss 0x77a7(%rip), %xmm1     # 0x6feec
xorps %xmm2, %xmm2
movaps %xmm1, %xmm0
callq *%rax
movss 0x7797(%rip), %xmm0     # 0x6feec
movq 0x1a644(%rip), %rax     # 0x82da0
addss 0x4(%rax), %xmm0
movq -0x8(%rbp), %rax
movss %xmm0, 0x244(%rax)
movq -0x8(%rbp), %rdi
callq 0x194b0
jmp 0x68bdf
cmpl $0x0, 0x4aae2(%rip)     # 0xb3264
je 0x68796
movl -0x40(%rbp), %eax
shll $0x2, %eax
movl %eax, -0x40(%rbp)
movl -0x44(%rbp), %eax
shll $0x2, %eax
movl %eax, -0x44(%rbp)
movl $0x1, -0xc(%rbp)
cmpl $0x3, -0xc(%rbp)
jge 0x6886b
callq 0x19c80
andl $0x7fff, %eax           # imm = 0x7FFF
cvtsi2ss %eax, %xmm0
movss 0x7acb(%rip), %xmm1     # 0x70288
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0x8c5b(%rip), %xmm0     # 0x71428
subsd %xmm0, %xmm1
movsd 0xa3bf(%rip), %xmm0     # 0x72b98
mulsd %xmm1, %xmm0
movsd 0xf29b(%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 0x7a70(%rip), %xmm1     # 0x70288
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0x8c00(%rip), %xmm0     # 0x71428
subsd %xmm0, %xmm1
movsd 0xa364(%rip), %xmm0     # 0x72b98
mulsd %xmm1, %xmm0
movsd 0xbea8(%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 0x6879d
callq 0x19c80
andl $0x7fff, %eax           # imm = 0x7FFF
cvtsi2ss %eax, %xmm0
movss 0x7a07(%rip), %xmm1     # 0x70288
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0x8b97(%rip), %xmm0     # 0x71428
subsd %xmm0, %xmm1
movsd 0xa2fb(%rip), %xmm0     # 0x72b98
mulsd %xmm1, %xmm0
movsd 0xf1d7(%rip), %xmm1     # 0x77a80
mulsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movss %xmm0, 0xe88(%rax)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
cvtsi2sdl 0xef0(%rax), %xmm0
movsd 0xf19f(%rip), %xmm1     # 0x77a78
mulsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movss %xmm0, 0xe7c(%rax)
movq 0x1a5c8(%rip), %rax     # 0x82ec0
movq (%rax), %rax
movss 0x20(%rax), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x68946
jp 0x68946
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl 0xef0(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0xef0(%rax)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
cmpl $0x9, 0xef0(%rax)
jle 0x68944
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl $0x9, 0xef0(%rax)
jmp 0x68946
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movss 0xebc(%rax), %xmm0
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
addss 0xe7c(%rax), %xmm0
movss %xmm0, -0x3c(%rbp)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movss 0xec0(%rax), %xmm0
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
addss 0xe80(%rax), %xmm0
movss %xmm0, -0x38(%rbp)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movss 0xec4(%rax), %xmm0
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
addss 0xe84(%rax), %xmm0
movss %xmm0, -0x34(%rbp)
leaq -0x3c(%rbp), %rdi
leaq -0x24(%rbp), %rsi
leaq -0x30(%rbp), %rdx
xorl %eax, %eax
movl %eax, %ecx
callq 0x183e0
xorps %xmm0, %xmm0
movss %xmm0, -0x50(%rbp)
movss 0x7522(%rip), %xmm0     # 0x6fefc
movss %xmm0, -0x4c(%rbp)
movq -0x8(%rbp), %rax
movl 0x278(%rax), %eax
subl $0x8, %eax
cvtsi2ss %eax, %xmm0
movss %xmm0, -0x48(%rbp)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rdi
movq -0x8(%rbp), %rsi
addq $0x4, %rsi
leaq -0x50(%rbp), %rdx
leaq -0x24(%rbp), %rcx
leaq -0x30(%rbp), %r8
leaq -0x18(%rbp), %r9
callq 0x67590
movq -0x8(%rbp), %rdi
leaq -0x18(%rbp), %rsi
leaq -0x24(%rbp), %rdx
movl -0x40(%rbp), %ecx
movl -0x44(%rbp), %r8d
movl $0x12c, %r9d            # imm = 0x12C
movl $0x1f4, (%rsp)          # imm = 0x1F4
movl $0x4, 0x8(%rsp)
callq 0x19ca0
movl $0x1, %edi
movq 0x19bad(%rip), %rax     # 0x82600
callq *0xc8(%rax)
movq 0x19ba0(%rip), %rax     # 0x82600
movq 0xd0(%rax), %rax
movq %rax, -0x68(%rbp)
movq -0x8(%rbp), %rax
movq 0x19ae2(%rip), %rcx     # 0x82558
movq (%rcx), %rcx
subq %rcx, %rax
movl $0x4a8, %ecx            # imm = 0x4A8
cqto
idivq %rcx
movq %rax, %rcx
movq -0x68(%rbp), %rax
movl %ecx, %edi
callq *%rax
movq 0x19b68(%rip), %rax     # 0x82600
movq 0xc8(%rax), %rax
movzbl 0x4a7c2(%rip), %edi     # 0xb3268
orl $0x1, %edi
callq *%rax
movq 0x19b4e(%rip), %rax     # 0x82600
movq 0xb0(%rax), %rax
movq -0x8(%rbp), %rdi
addq $0x4, %rdi
movl $0x2, %esi
callq *%rax
movq -0x8(%rbp), %rdi
leaq -0x18(%rbp), %rsi
movl $0x1, %edx
callq 0x19080
movq 0x19b37(%rip), %rax     # 0x82618
movq (%rax), %rax
cvttss2si 0x20(%rax), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
jne 0x68b1b
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
addl $-0x1, %edx
movl %edx, 0x318(%rax,%rcx,4)
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 0x68b91
callq 0x19c80
andl $0x7fff, %eax           # imm = 0x7FFF
cvtsi2ss %eax, %xmm0
movss 0x7731(%rip), %xmm1     # 0x70288
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0xd6e9(%rip), %xmm1     # 0x76250
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %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 0x68bdf
callq 0x19c80
andl $0x7fff, %eax           # imm = 0x7FFF
cvtsi2ss %eax, %xmm0
movss 0x76e1(%rip), %xmm1     # 0x70288
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0xd699(%rip), %xmm1     # 0x76250
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %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)
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax,%rax)