// File: /workspace/github_c_makefile_star2_O0/QwazyWabbitWOS[P]lmctf60/plasma.c
// Function: Weapon_PLASMA_Generic
void Weapon_PLASMA_Generic (edict_t *ent, int FRAME_ACTIVATE_LAST, int FRAME_FIRE_LAST, int FRAME_IDLE_LAST, int FRAME_DEACTIVATE_LAST, int *pause_frames, int *fire_frames, void (*fire)(edict_t *ent))
{
int		n;

	if(ent->client->quad_framenum > level.framenum)
		quadmeister = true;
	else
		quadmeister = false;

	// VWep animations screw up corpses
	if(ent->deadflag || ent->s.modelindex != 255)
		return;

	//bat
	ent->client->isfiring = 0;


	if (ent->client->weaponstate == WEAPON_DROPPING)
	{
		if (ent->client->ps.gunframe == FRAME_DEACTIVATE_LAST)
		{
			ChangeWeapon (ent);
			return;
		}
		else if ((FRAME_DEACTIVATE_LAST - ent->client->ps.gunframe) == 4)
		{
			ent->client->anim_priority = ANIM_REVERSE;
			if(ent->client->ps.pmove.pm_flags & PMF_DUCKED)
			{
				ent->s.frame = FRAME_crpain4+1;
				ent->client->anim_end = FRAME_crpain1;
			}
			else
			{
				ent->s.frame = FRAME_pain304+1;
				ent->client->anim_end = FRAME_pain301;
				
			}
		}

		ent->client->ps.gunframe++;
		return;
	}

	if (ent->client->weaponstate == WEAPON_ACTIVATING)
	{
		if (ent->client->ps.gunframe == FRAME_ACTIVATE_LAST)
		{
			ent->client->weaponstate = WEAPON_READY;
			ent->client->ps.gunframe = FRAME_IDLE_FIRST;
			
			//-bat
			if(ent->client->plasma_mode)
				gi.cprintf(ent, PRINT_HIGH, "bounce plasma\n");
			else
				gi.cprintf(ent, PRINT_HIGH, "spread plasma\n");

			return;
		}

		ent->client->ps.gunframe++;
		return;
	}

	if ((ent->client->newweapon) && (ent->client->weaponstate != WEAPON_FIRING))
	{
		ent->client->weaponstate = WEAPON_DROPPING;
		ent->client->ps.gunframe = FRAME_DEACTIVATE_FIRST;

		if ((FRAME_DEACTIVATE_LAST - FRAME_DEACTIVATE_FIRST) < 4)
		{
			ent->client->anim_priority = ANIM_REVERSE;
			if(ent->client->ps.pmove.pm_flags & PMF_DUCKED)
			{
				ent->s.frame = FRAME_crpain4+1;
				ent->client->anim_end = FRAME_crpain1;
			}
			else
			{
				ent->s.frame = FRAME_pain304+1;
				ent->client->anim_end = FRAME_pain301;
				
			}
		}
		return;
	}

	if (ent->client->weaponstate == WEAPON_READY)
	{
		if ( ((ent->client->latched_buttons|ent->client->buttons) & BUTTON_ATTACK) )
		{
			ent->client->latched_buttons &= ~BUTTON_ATTACK;
			if ((!ent->client->ammo_index) || 
				( ent->client->pers.inventory[ent->client->ammo_index] >= ent->client->pers.weapon->quantity))
			{
				ent->client->ps.gunframe = FRAME_FIRE_FIRST;
				ent->client->weaponstate = WEAPON_FIRING;

				// start the animation
				ent->client->anim_priority = ANIM_ATTACK;
				if (ent->client->ps.pmove.pm_flags & PMF_DUCKED)
				{
					ent->s.frame = FRAME_crattak1-1;
					ent->client->anim_end = FRAME_crattak9;
				}
				else
				{
					ent->s.frame = FRAME_attack1-1;
					ent->client->anim_end = FRAME_attack8;
				}
			}
			else
			{
				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);
			}
		}
		else
		{
			if (ent->client->ps.gunframe == FRAME_IDLE_LAST)
			{
				ent->client->ps.gunframe = FRAME_IDLE_FIRST;
				return;
			}

			if (pause_frames)
			{
				for (n = 0; pause_frames[n]; n++)
				{
					if (ent->client->ps.gunframe == pause_frames[n])
					{
						if (rand()&15)
							return;
					}
				}
			}

			if ( ent->client->ps.gunframe == 35 )
			gi.sound(ent,CHAN_WEAPON,
			  gi.soundindex(PLASMA_SOUND_VENT), 1, ATTN_NORM,0 );

			ent->client->ps.gunframe++;
			return;
		}
	}

	if (ent->client->weaponstate == WEAPON_FIRING)
	{
		for (n = 0; fire_frames[n]; n++)
		{
			if (ent->client->ps.gunframe == fire_frames[n])
			{
				//bat
				if(ent->client->quad_framenum > level.framenum)
					gi.sound(ent, CHAN_ITEM, gi.soundindex("items/damage3.wav"), 1, ATTN_NORM, 0);

				
				//bat
				ent->client->isfiring = 1;
				fire (ent);
				break;
			}
		}

		if (!fire_frames[n])
			ent->client->ps.gunframe++;

		if (ent->client->ps.gunframe == FRAME_IDLE_FIRST+1)
			ent->client->weaponstate = WEAPON_READY;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movl %ecx, -0x14(%rbp)
movl %r8d, -0x18(%rbp)
movq %r9, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movss 0xf04(%rax), %xmm0
movq 0x5ab34(%rip), %rax     # 0x82da0
cvtsi2ssl (%rax), %xmm1
ucomiss %xmm1, %xmm0
jbe 0x28284
movq 0x5a3f4(%rip), %rax     # 0x82670
movl $0x1, (%rax)
jmp 0x28291
movq 0x5a3e5(%rip), %rax     # 0x82670
movl $0x0, (%rax)
movq -0x8(%rbp), %rax
cmpl $0x0, 0x260(%rax)
jne 0x282ab
movq -0x8(%rbp), %rax
cmpl $0xff, 0x28(%rax)
je 0x282b0
jmp 0x288c6
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl $0x0, 0xf70(%rax)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
cmpl $0x2, 0xe78(%rax)
jne 0x28384
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl 0x5c(%rax), %eax
cmpl -0x18(%rbp), %eax
jne 0x282f5
movq -0x8(%rbp), %rdi
callq 0x18820
jmp 0x288c6
movl -0x18(%rbp), %eax
movq -0x8(%rbp), %rcx
movq 0x58(%rcx), %rcx
subl 0x5c(%rcx), %eax
cmpl $0x4, %eax
jne 0x2836c
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl $0x6, 0xef8(%rax)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movzbl 0x10(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x2834d
movq -0x8(%rbp), %rax
movl $0xad, 0x38(%rax)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl $0xa9, 0xef4(%rax)
jmp 0x2836a
movq -0x8(%rbp), %rax
movl $0x42, 0x38(%rax)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl $0x3e, 0xef4(%rax)
jmp 0x2836c
jmp 0x2836e
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl 0x5c(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x5c(%rax)
jmp 0x288c6
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
cmpl $0x1, 0xe78(%rax)
jne 0x28438
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl 0x5c(%rax), %eax
cmpl -0xc(%rbp), %eax
jne 0x28422
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl $0x0, 0xe78(%rax)
movl -0x10(%rbp), %ecx
addl $0x1, %ecx
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl %ecx, 0x5c(%rax)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
cmpl $0x0, 0xf3c(%rax)
je 0x283fe
movq 0x5a21c(%rip), %rax     # 0x82600
movq 0x10(%rax), %rcx
movq -0x8(%rbp), %rdi
movl $0x2, %esi
leaq 0x488b3(%rip), %rdx     # 0x70cab
movb $0x0, %al
callq *%rcx
jmp 0x2841d
movq 0x5a1fb(%rip), %rax     # 0x82600
movq 0x10(%rax), %rcx
movq -0x8(%rbp), %rdi
movl $0x2, %esi
leaq 0x488a1(%rip), %rdx     # 0x70cba
movb $0x0, %al
callq *%rcx
jmp 0x288c6
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl 0x5c(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x5c(%rax)
jmp 0x288c6
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
cmpq $0x0, 0xe50(%rax)
je 0x284ff
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
cmpl $0x3, 0xe78(%rax)
je 0x284ff
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl $0x2, 0xe78(%rax)
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl %ecx, 0x5c(%rax)
movl -0x18(%rbp), %eax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
subl %ecx, %eax
cmpl $0x4, %eax
jge 0x284fa
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl $0x6, 0xef8(%rax)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movzbl 0x10(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x284db
movq -0x8(%rbp), %rax
movl $0xad, 0x38(%rax)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl $0xa9, 0xef4(%rax)
jmp 0x284f8
movq -0x8(%rbp), %rax
movl $0x42, 0x38(%rax)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl $0x3e, 0xef4(%rax)
jmp 0x284fa
jmp 0x288c6
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
cmpl $0x0, 0xe78(%rax)
jne 0x2879c
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl 0xe44(%rax), %eax
movq -0x8(%rbp), %rcx
movq 0x58(%rcx), %rcx
orl 0xe3c(%rcx), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x286b2
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl 0xe44(%rax), %ecx
andl $-0x2, %ecx
movl %ecx, 0xe44(%rax)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
cmpl $0x0, 0xe38(%rax)
je 0x2859a
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
movq -0x8(%rbp), %rcx
movq 0x58(%rcx), %rcx
movq 0x730(%rcx), %rcx
cmpl 0x5c(%rcx), %eax
jl 0x28624
movl -0xc(%rbp), %ecx
addl $0x1, %ecx
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl %ecx, 0x5c(%rax)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl $0x3, 0xe78(%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 0x28602
movq -0x8(%rbp), %rax
movl $0x9f, 0x38(%rax)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl $0xa8, 0xef4(%rax)
jmp 0x2861f
movq -0x8(%rbp), %rax
movl $0x2d, 0x38(%rax)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl $0x35, 0xef4(%rax)
jmp 0x286ad
movq 0x5a775(%rip), %rax     # 0x82da0
movss 0x4(%rax), %xmm0
movq -0x8(%rbp), %rax
ucomiss 0x244(%rax), %xmm0
jb 0x286a4
movq 0x59fbc(%rip), %rax     # 0x82600
movq 0x20(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x38(%rbp)
leaq 0x48694(%rip), %rdi     # 0x70cef
movq 0x59f9e(%rip), %rax     # 0x82600
callq *0x48(%rax)
movq -0x38(%rbp), %rdi
movl %eax, %edx
movq -0x30(%rbp), %rax
movl $0x2, %esi
movss 0x47870(%rip), %xmm1    # 0x6feec
xorps %xmm2, %xmm2
movaps %xmm1, %xmm0
callq *%rax
movss 0x47860(%rip), %xmm0    # 0x6feec
movq 0x5a70d(%rip), %rax     # 0x82da0
addss 0x4(%rax), %xmm0
movq -0x8(%rbp), %rax
movss %xmm0, 0x244(%rax)
movq -0x8(%rbp), %rdi
callq 0x194b0
jmp 0x2879a
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl 0x5c(%rax), %eax
cmpl -0x14(%rbp), %eax
jne 0x286d8
movl -0x10(%rbp), %ecx
addl $0x1, %ecx
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl %ecx, 0x5c(%rax)
jmp 0x288c6
cmpq $0x0, -0x20(%rbp)
je 0x2872f
movl $0x0, -0x24(%rbp)
movq -0x20(%rbp), %rax
movslq -0x24(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
je 0x2872d
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl 0x5c(%rax), %eax
movq -0x20(%rbp), %rcx
movslq -0x24(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
jne 0x28720
callq 0x19c80
andl $0xf, %eax
cmpl $0x0, %eax
je 0x2871e
jmp 0x288c6
jmp 0x28720
jmp 0x28722
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x286e6
jmp 0x2872f
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
cmpl $0x23, 0x5c(%rax)
jne 0x28784
movq 0x59ebc(%rip), %rax     # 0x82600
movq 0x20(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x48(%rbp)
leaq 0x485a7(%rip), %rdi     # 0x70d02
movq 0x59e9e(%rip), %rax     # 0x82600
callq *0x48(%rax)
movq -0x48(%rbp), %rdi
movl %eax, %edx
movq -0x40(%rbp), %rax
movl $0x1, %esi
movss 0x47770(%rip), %xmm1    # 0x6feec
xorps %xmm2, %xmm2
movaps %xmm1, %xmm0
callq *%rax
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl 0x5c(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x5c(%rax)
jmp 0x288c6
jmp 0x2879c
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
cmpl $0x3, 0xe78(%rax)
jne 0x288c6
movl $0x0, -0x24(%rbp)
movq 0x10(%rbp), %rax
movslq -0x24(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
je 0x2887b
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl 0x5c(%rax), %eax
movq 0x10(%rbp), %rcx
movslq -0x24(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
jne 0x2886b
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movss 0xf04(%rax), %xmm0
movq 0x5a5a3(%rip), %rax     # 0x82da0
cvtsi2ssl (%rax), %xmm1
ucomiss %xmm1, %xmm0
jbe 0x2884d
movq 0x59df3(%rip), %rax     # 0x82600
movq 0x20(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x58(%rbp)
leaq 0x4b241(%rip), %rdi     # 0x73a65
movq 0x59dd5(%rip), %rax     # 0x82600
callq *0x48(%rax)
movq -0x58(%rbp), %rdi
movl %eax, %edx
movq -0x50(%rbp), %rax
movl $0x3, %esi
movss 0x476a7(%rip), %xmm1    # 0x6feec
xorps %xmm2, %xmm2
movaps %xmm1, %xmm0
callq *%rax
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl $0x1, 0xf70(%rax)
movq 0x18(%rbp), %rax
movq -0x8(%rbp), %rdi
callq *%rax
jmp 0x2887b
jmp 0x2886d
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x287b8
movq 0x10(%rbp), %rax
movslq -0x24(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
jne 0x2889a
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl 0x5c(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x5c(%rax)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl 0x5c(%rax), %eax
movl -0x10(%rbp), %ecx
addl $0x1, %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jne 0x288c4
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl $0x0, 0xe78(%rax)
jmp 0x288c6
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)