// File: /workspace/github_c_makefile_star2_O0/QwazyWabbitWOS[P]lmctf60/g_items.c
// Function: SpawnItem
void SpawnItem (edict_t *ent, gitem_t *item)
{
	PrecacheItem (item);


	//Radomize the quad
	//This is called every time any item is spawned, but it
	//is ok to make things more random.
	if((int)ctfflags->value & CTF_RANDOM_QUAD)
		itemlist[QUAD_INDEX].quantity = 50 + (rand() % 31);


	if (ent->spawnflags)
	{
		if (strcmp(ent->classname, "key_power_cube") != 0)
		{
			ent->spawnflags = 0;
			gi.dprintf("%s at %s has invalid spawnflags set\n", ent->classname, vtos(ent->s.origin));
		}
	}

	// some items will be prevented in deathmatch
	if (deathmatch->value)
	{
		if ( (int)dmflags->value & DF_NO_ARMOR )
		{
			if (item->pickup == Pickup_Armor || item->pickup == Pickup_PowerArmor)
			{
				G_FreeEdict (ent);
				return;
			}
		}
		if ( (int)dmflags->value & DF_NO_ITEMS )
		{
			if (item->pickup == Pickup_Powerup)
			{
				G_FreeEdict (ent);
				return;
			}
		}
		if ( (int)dmflags->value & DF_NO_HEALTH )
		{
			if (item->pickup == Pickup_Health || item->pickup == Pickup_Adrenaline || item->pickup == Pickup_AncientHead)
			{
				G_FreeEdict (ent);
				return;
			}
		}
		if ( (int)dmflags->value & DF_INFINITE_AMMO )
		{
			if ( (item->flags == IT_AMMO) || (strcmp(ent->classname, "weapon_bfg") == 0) )
			{
				G_FreeEdict (ent);
				return;
			}
		}

		//surt ... ummm this code vanished at some point ... why?
		if ( ! ((int)ctfflags->value & CTF_ALLOW_INVULN) )
		{
			//unless they enabled the allow invulnerability flag, take it out
			if (item->use == Use_Invulnerability)
			{
				G_FreeEdict(ent);
				return;
			}
		}

		if ((int)disabled_weps->value)
		{
			if ( ((int)disabled_weps->value & DIS_BFG) && (strcmp(ent->classname, "weapon_bfg") == 0) )
			{
				G_FreeEdict (ent);
				return;
			}
			if ( ((int)disabled_weps->value & DIS_HYPERBLASTER) && (strcmp(ent->classname, "weapon_hyperblaster") == 0) )
			{
				G_FreeEdict (ent);
				return;
			}
			if ( ((int)disabled_weps->value & DIS_RAILGUN) && (strcmp(ent->classname, "weapon_railgun") == 0) )
			{
				G_FreeEdict (ent);
				return;
			}
			if ( ((int)disabled_weps->value & DIS_ROCKETLAUNCHER) && (strcmp(ent->classname, "weapon_rocketlauncher") == 0) )
			{
				G_FreeEdict (ent);
				return;
			}
			if ( ((int)disabled_weps->value & DIS_GRENADELAUNCHER) && (strcmp(ent->classname, "weapon_grenadelauncher") == 0) )
			{
				G_FreeEdict (ent);
				return;
			}
			if ( ((int)disabled_weps->value & DIS_CHAINGUN) && (strcmp(ent->classname, "weapon_chaingun") == 0) )
			{
				G_FreeEdict (ent);
				return;
			}
			if ( ((int)disabled_weps->value & DIS_MACHINEGUN) && (strcmp(ent->classname, "weapon_machinegun") == 0) )
			{
				G_FreeEdict (ent);
				return;
			}
			if ( ((int)disabled_weps->value & DIS_SUPERSHOTGUN) && (strcmp(ent->classname, "weapon_supershotgun") == 0) )
			{
				G_FreeEdict (ent);
				return;
			}
			if ( ((int)disabled_weps->value & DIS_SHOTGUN) && (strcmp(ent->classname, "weapon_shotgun") == 0) )
			{
				G_FreeEdict (ent);
				return;
			}

			if ( ((int)disabled_weps->value & DIS_PLASMA) && (strcmp(ent->classname, "weapon_plasma") == 0) )
			{
				G_FreeEdict (ent);
				return;
			}

		}

		
	}

	if (coop->value && (strcmp(ent->classname, "key_power_cube") == 0))
	{
		ent->spawnflags |= (1 << (8 + level.power_cubes));
		level.power_cubes++;
	}

	// don't let them drop items that stay in a coop game
	if ((coop->value) && (item->flags & IT_STAY_COOP))
	{
		item->drop = NULL;
	}

	ent->item = item;
	ent->nextthink = level.time + 2 * FRAMETIME;    // items start after other solids
	ent->think = droptofloor;
	ent->s.effects = item->world_model_flags;
	ent->s.renderfx = RF_GLOW;
	if (ent->model)
		gi.modelindex (ent->model);

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0x18810
movq 0x46688(%rip), %rax     # 0x82b58
movq (%rax), %rax
cvttss2si 0x20(%rax), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
je 0x3c4ff
callq 0x19c80
movl $0x1f, %ecx
cltd
idivl %ecx
addl $0x32, %edx
movq 0x46947(%rip), %rax     # 0x82e40
movl %edx, 0xd1c(%rax)
movq -0x8(%rbp), %rax
cmpl $0x0, 0x140(%rax)
je 0x3c579
movq -0x8(%rbp), %rax
movq 0x138(%rax), %rdi
leaq 0x3698f(%rip), %rsi     # 0x72ead
callq 0x18bf0
cmpl $0x0, %eax
je 0x3c577
movq -0x8(%rbp), %rax
movl $0x0, 0x140(%rax)
movq 0x460c3(%rip), %rax     # 0x82600
movq 0x8(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq 0x138(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rdi
addq $0x4, %rdi
callq 0x19260
movq -0x20(%rbp), %rsi
movq -0x18(%rbp), %rcx
movq %rax, %rdx
leaq 0x36a07(%rip), %rdi     # 0x72f7a
movb $0x0, %al
callq *%rcx
jmp 0x3c579
movq 0x46940(%rip), %rax     # 0x82ec0
movq (%rax), %rax
movss 0x20(%rax), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x3c597
jp 0x3c597
jmp 0x3c9a7
movq 0x4607a(%rip), %rax     # 0x82618
movq (%rax), %rax
cvttss2si 0x20(%rax), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
je 0x3c5e2
movq -0x10(%rbp), %rax
movq 0x466f5(%rip), %rcx     # 0x82cb0
cmpq %rcx, 0x8(%rax)
je 0x3c5d2
movq -0x10(%rbp), %rax
movq 0x462cc(%rip), %rcx     # 0x82898
cmpq %rcx, 0x8(%rax)
jne 0x3c5e0
movq -0x8(%rbp), %rdi
callq 0x19cd0
jmp 0x3cada
jmp 0x3c5e2
movq 0x4602f(%rip), %rax     # 0x82618
movq (%rax), %rax
cvttss2si 0x20(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x3c61a
movq -0x10(%rbp), %rax
movq 0x4603c(%rip), %rcx     # 0x82640
cmpq %rcx, 0x8(%rax)
jne 0x3c618
movq -0x8(%rbp), %rdi
callq 0x19cd0
jmp 0x3cada
jmp 0x3c61a
movq 0x45ff7(%rip), %rax     # 0x82618
movq (%rax), %rax
cvttss2si 0x20(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x3c674
movq -0x10(%rbp), %rax
movq 0x4683c(%rip), %rcx     # 0x82e78
cmpq %rcx, 0x8(%rax)
je 0x3c664
movq -0x10(%rbp), %rax
movq 0x4656b(%rip), %rcx     # 0x82bb8
cmpq %rcx, 0x8(%rax)
je 0x3c664
movq -0x10(%rbp), %rax
movq 0x46412(%rip), %rcx     # 0x82a70
cmpq %rcx, 0x8(%rax)
jne 0x3c672
movq -0x8(%rbp), %rdi
callq 0x19cd0
jmp 0x3cada
jmp 0x3c674
movq 0x45f9d(%rip), %rax     # 0x82618
movq (%rax), %rax
cvttss2si 0x20(%rax), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
je 0x3c6c3
movq -0x10(%rbp), %rax
cmpl $0x2, 0x68(%rax)
je 0x3c6b3
movq -0x8(%rbp), %rax
movq 0x138(%rax), %rdi
leaq 0x3390b(%rip), %rsi     # 0x6ffb4
callq 0x18bf0
cmpl $0x0, %eax
jne 0x3c6c1
movq -0x8(%rbp), %rdi
callq 0x19cd0
jmp 0x3cada
jmp 0x3c6c3
movq 0x4648e(%rip), %rax     # 0x82b58
movq (%rax), %rax
cvttss2si 0x20(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
jne 0x3c6fb
movq -0x10(%rbp), %rax
movq 0x461db(%rip), %rcx     # 0x828c0
cmpq %rcx, 0x10(%rax)
jne 0x3c6f9
movq -0x8(%rbp), %rdi
callq 0x19cd0
jmp 0x3cada
jmp 0x3c6fb
movq 0x45d3e(%rip), %rax     # 0x82440
movq (%rax), %rax
cvttss2si 0x20(%rax), %eax
cmpl $0x0, %eax
je 0x3c9a5
movq 0x45d26(%rip), %rax     # 0x82440
movq (%rax), %rax
cvttss2si 0x20(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x3c754
movq -0x8(%rbp), %rax
movq 0x138(%rax), %rdi
leaq 0x33878(%rip), %rsi     # 0x6ffb4
callq 0x18bf0
cmpl $0x0, %eax
jne 0x3c754
movq -0x8(%rbp), %rdi
callq 0x19cd0
jmp 0x3cada
movq 0x45ce5(%rip), %rax     # 0x82440
movq (%rax), %rax
cvttss2si 0x20(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x3c795
movq -0x8(%rbp), %rax
movq 0x138(%rax), %rdi
leaq 0x33867(%rip), %rsi     # 0x6ffe4
callq 0x18bf0
cmpl $0x0, %eax
jne 0x3c795
movq -0x8(%rbp), %rdi
callq 0x19cd0
jmp 0x3cada
movq 0x45ca4(%rip), %rax     # 0x82440
movq (%rax), %rax
cvttss2si 0x20(%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x3c7d6
movq -0x8(%rbp), %rax
movq 0x138(%rax), %rdi
leaq 0x33801(%rip), %rsi     # 0x6ffbf
callq 0x18bf0
cmpl $0x0, %eax
jne 0x3c7d6
movq -0x8(%rbp), %rdi
callq 0x19cd0
jmp 0x3cada
movq 0x45c63(%rip), %rax     # 0x82440
movq (%rax), %rax
cvttss2si 0x20(%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x3c817
movq -0x8(%rbp), %rax
movq 0x138(%rax), %rdi
leaq 0x337cf(%rip), %rsi     # 0x6ffce
callq 0x18bf0
cmpl $0x0, %eax
jne 0x3c817
movq -0x8(%rbp), %rdi
callq 0x19cd0
jmp 0x3cada
movq 0x45c22(%rip), %rax     # 0x82440
movq (%rax), %rax
cvttss2si 0x20(%rax), %eax
andl $0x10, %eax
cmpl $0x0, %eax
je 0x3c858
movq -0x8(%rbp), %rax
movq 0x138(%rax), %rdi
leaq 0x337c8(%rip), %rsi     # 0x70008
callq 0x18bf0
cmpl $0x0, %eax
jne 0x3c858
movq -0x8(%rbp), %rdi
callq 0x19cd0
jmp 0x3cada
movq 0x45be1(%rip), %rax     # 0x82440
movq (%rax), %rax
cvttss2si 0x20(%rax), %eax
andl $0x20, %eax
cmpl $0x0, %eax
je 0x3c899
movq -0x8(%rbp), %rax
movq 0x138(%rax), %rdi
leaq 0x33777(%rip), %rsi     # 0x6fff8
callq 0x18bf0
cmpl $0x0, %eax
jne 0x3c899
movq -0x8(%rbp), %rdi
callq 0x19cd0
jmp 0x3cada
movq 0x45ba0(%rip), %rax     # 0x82440
movq (%rax), %rax
cvttss2si 0x20(%rax), %eax
andl $0x40, %eax
cmpl $0x0, %eax
je 0x3c8da
movq -0x8(%rbp), %rax
movq 0x138(%rax), %rdi
leaq 0x3375d(%rip), %rsi     # 0x7001f
callq 0x18bf0
cmpl $0x0, %eax
jne 0x3c8da
movq -0x8(%rbp), %rdi
callq 0x19cd0
jmp 0x3cada
movq 0x45b5f(%rip), %rax     # 0x82440
movq (%rax), %rax
cvttss2si 0x20(%rax), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0x3c91d
movq -0x8(%rbp), %rax
movq 0x138(%rax), %rdi
leaq 0x3372c(%rip), %rsi     # 0x70031
callq 0x18bf0
cmpl $0x0, %eax
jne 0x3c91d
movq -0x8(%rbp), %rdi
callq 0x19cd0
jmp 0x3cada
movq 0x45b1c(%rip), %rax     # 0x82440
movq (%rax), %rax
cvttss2si 0x20(%rax), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x0, %eax
je 0x3c960
movq -0x8(%rbp), %rax
movq 0x138(%rax), %rdi
leaq 0x336fd(%rip), %rsi     # 0x70045
callq 0x18bf0
cmpl $0x0, %eax
jne 0x3c960
movq -0x8(%rbp), %rdi
callq 0x19cd0
jmp 0x3cada
movq 0x45ad9(%rip), %rax     # 0x82440
movq (%rax), %rax
cvttss2si 0x20(%rax), %eax
andl $0x200, %eax            # imm = 0x200
cmpl $0x0, %eax
je 0x3c9a3
movq -0x8(%rbp), %rax
movq 0x138(%rax), %rdi
leaq 0x36614(%rip), %rsi     # 0x72f9f
callq 0x18bf0
cmpl $0x0, %eax
jne 0x3c9a3
movq -0x8(%rbp), %rdi
callq 0x19cd0
jmp 0x3cada
jmp 0x3c9a5
jmp 0x3c9a7
movq 0x465b2(%rip), %rax     # 0x82f60
movq (%rax), %rax
movss 0x20(%rax), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x3c9c2
jp 0x3c9c2
jmp 0x3ca24
movq -0x8(%rbp), %rax
movq 0x138(%rax), %rdi
leaq 0x364d9(%rip), %rsi     # 0x72ead
callq 0x18bf0
cmpl $0x0, %eax
jne 0x3ca24
movq 0x463bb(%rip), %rax     # 0x82da0
movl 0x154(%rax), %ecx
addl $0x8, %ecx
movl $0x1, %eax
shll %cl, %eax
movl %eax, %ecx
movq -0x8(%rbp), %rax
orl 0x140(%rax), %ecx
movl %ecx, 0x140(%rax)
movq 0x46392(%rip), %rax     # 0x82da0
movl 0x154(%rax), %ecx
addl $0x1, %ecx
movq 0x46382(%rip), %rax     # 0x82da0
movl %ecx, 0x154(%rax)
movq 0x46535(%rip), %rax     # 0x82f60
movq (%rax), %rax
movss 0x20(%rax), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x3ca3f
jp 0x3ca3f
jmp 0x3ca5a
movq -0x10(%rbp), %rax
movl 0x68(%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x3ca5a
movq -0x10(%rbp), %rax
movq $0x0, 0x18(%rax)
movq -0x10(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x330(%rax)
movss 0x363eb(%rip), %xmm0    # 0x72e5c
movq 0x46328(%rip), %rax     # 0x82da0
addss 0x4(%rax), %xmm0
movq -0x8(%rbp), %rax
movss %xmm0, 0x200(%rax)
movq -0x8(%rbp), %rax
movq 0x45a8c(%rip), %rcx     # 0x82520
movq %rcx, 0x210(%rax)
movq -0x10(%rbp), %rax
movl 0x38(%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x40(%rax)
movq -0x8(%rbp), %rax
movl $0x200, 0x44(%rax)      # imm = 0x200
movq -0x8(%rbp), %rax
cmpq $0x0, 0x120(%rax)
je 0x3cada
movq 0x45b37(%rip), %rax     # 0x82600
movq 0x40(%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x120(%rcx), %rdi
callq *%rax
addq $0x20, %rsp
popq %rbp
retq