// File: /workspace/github_c_makefile_star2_O1/QwazyWabbitWOS[P]lmctf60/g_cmds.c
// Function: Cmd_Give_f
void Cmd_Give_f (edict_t *ent)
{
	char		*name;
	gitem_t		*it;
	int			index;
	int			i;
	qboolean	give_all;
	edict_t		*it_ent;

	it = 0;

	if (deathmatch->value && !sv_cheats->value)
	{
		ctf_SafePrint(ent, PRINT_HIGH, "Server does not have '+set cheats 1'.\n");
		return;
	}

	name = gi.args();

	if (Q_stricmp(name, "all") == 0)
		give_all = true;
	else
		give_all = false;

	if (give_all || Q_stricmp(gi.argv(1), "health") == 0)
	{
		if (gi.argc() == 3)
			ent->health = atoi(gi.argv(2));
		else
			ent->health = ent->max_health;
		if (!give_all)
			return;
	}

	if (give_all || Q_stricmp(name, "weapons") == 0)
	{
		for (i=0 ; i<game.num_items ; i++)
		{
			it = itemlist + i;
			if (!it->pickup)
				continue;
			if (!(it->flags & IT_WEAPON))
				continue;
			ent->client->pers.inventory[i] += 1;
		}
		if (!give_all)
			return;
	}

	if (give_all || Q_stricmp(name, "ammo") == 0)
	{
		for (i=0 ; i<game.num_items ; i++)
		{
			it = itemlist + i;
			if (!it->pickup)
				continue;
			if (!(it->flags & IT_AMMO))
				continue;
			Add_Ammo (ent, it, 1000);
		}
		if (!give_all)
			return;
	}

	if (give_all || Q_stricmp(name, "armor") == 0)
	{
		gitem_armor_t	*info;

		it = FindItem("Jacket Armor");
		ent->client->pers.inventory[ITEM_INDEX(it)] = 0;

		it = FindItem("Combat Armor");
		ent->client->pers.inventory[ITEM_INDEX(it)] = 0;

		it = FindItem("Body Armor");
		info = (gitem_armor_t *)it->info;
		ent->client->pers.inventory[ITEM_INDEX(it)] = info->max_count;

		if (!give_all)
			return;
	}

	if (give_all || Q_stricmp(name, "Power Shield") == 0)
	{
		it = FindItem("Power Shield");
		it_ent = G_Spawn();
		it_ent->classname = it->classname;
		SpawnItem (it_ent, it);
		Touch_Item (it_ent, ent, NULL, NULL);
		if (it_ent->inuse)
			G_FreeEdict(it_ent);

		if (!give_all)
			return;
	}

	if (give_all)
	{
		for (i=0 ; i<game.num_items ; i++)
		{
			it = itemlist + i;
			if (!it->pickup)
				continue;
			if (it->flags & (IT_ARMOR|IT_WEAPON|IT_AMMO))
				continue;
			ent->client->pers.inventory[i] = 1;
		}
		return;
	}

	it = FindItem (name);
	if (!it)
	{
		name = gi.argv(1);
		it = FindItem (name);
		if (!it)
		{
			gi.cprintf (ent, PRINT_HIGH, "unknown item\n");
			return;
		}
	}

	if (!it->pickup)
	{
		gi.cprintf (ent, PRINT_HIGH, "non-pickup item\n");
		return;
	}

	index = ITEM_INDEX(it);

	if (it->flags & IT_AMMO)
	{
		if (gi.argc() == 3)
			ent->client->pers.inventory[index] = atoi(gi.argv(2));
		else
			ent->client->pers.inventory[index] += it->quantity;
	}
	else
	{
		it_ent = G_Spawn();
		it_ent->classname = it->classname;
		SpawnItem (it_ent, it);
		Touch_Item (it_ent, ent, NULL, NULL);
		if (it_ent->inuse)
			G_FreeEdict(it_ent);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %rbx
movq 0x42b31(%rip), %rax     # 0x69ec0
movq (%rax), %rax
movss 0x20(%rax), %xmm1
xorps %xmm0, %xmm0
ucomiss %xmm0, %xmm1
jne 0x273a1
jnp 0x273bb
movq 0x42650(%rip), %rax     # 0x699f8
movq (%rax), %rax
movss 0x20(%rax), %xmm1
ucomiss %xmm0, %xmm1
jne 0x273bb
jnp 0x27510
movq 0x4223e(%rip), %r15     # 0x69600
callq *0x148(%r15)
movq %rax, %r14
leaq 0x33807(%rip), %rsi     # 0x5abda
movq %rax, %rdi
callq 0x18690
movl %eax, %ebp
testl %eax, %eax
je 0x274ee
movl $0x1, %edi
callq *0x140(%r15)
leaq 0x2cd94(%rip), %rsi     # 0x5418c
movq %rax, %rdi
callq 0x18690
testl %eax, %eax
je 0x274ee
leaq 0x2e272(%rip), %rsi     # 0x55681
movq %r14, %rdi
callq 0x18690
testl %eax, %eax
je 0x27540
leaq 0x2e263(%rip), %rsi     # 0x55689
movq %r14, %rdi
callq 0x18690
testl %eax, %eax
je 0x27592
leaq 0x2cd41(%rip), %rsi     # 0x5417e
movq %r14, %rdi
callq 0x18690
testl %eax, %eax
je 0x275e9
leaq 0x2e252(%rip), %rsi     # 0x556a6
movq %r14, %rdi
callq 0x18690
testl %eax, %eax
je 0x27674
movq %r14, %rdi
callq 0x189e0
testq %rax, %rax
jne 0x2748e
movl $0x1, %edi
callq *0x140(%r15)
movq %rax, %rdi
callq 0x189e0
testq %rax, %rax
je 0x27772
movq %rax, %r14
cmpq $0x0, 0x8(%rax)
je 0x27719
testb $0x2, 0x68(%r14)
jne 0x27726
callq 0x19710
movq %rax, %r15
movq (%r14), %rax
movq %rax, 0x138(%r15)
movq %r15, %rdi
movq %r14, %rsi
callq 0x18ec0
movq %r15, %rdi
movq %rbx, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x19ac8
cmpl $0x0, 0x60(%r15)
je 0x27710
movq %r15, %rdi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x19a60
callq *0x138(%r15)
cmpl $0x3, %eax
jne 0x2752c
movl $0x2, %edi
callq *0x140(%r15)
movq %rax, %rdi
callq 0x195e0
jmp 0x27532
leaq 0x2e143(%rip), %rdx     # 0x5565a
movl $0x2, %esi
movq %rbx, %rdi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x18da0
movl 0x258(%rbx), %eax
movl %eax, 0x254(%rbx)
testl %ebp, %ebp
jne 0x27710
movq 0x427f9(%rip), %rax     # 0x69d40
cmpl $0x0, 0x61c(%rax)
jle 0x2758a
movq 0x428e9(%rip), %rcx     # 0x69e40
addq $0x68, %rcx
xorl %edx, %edx
cmpq $0x0, -0x60(%rcx)
je 0x27574
testb $0x1, (%rcx)
je 0x27574
movq 0x58(%rbx), %rsi
incl 0x318(%rsi,%rdx,4)
incq %rdx
movslq 0x61c(%rax), %rsi
addq $0x88, %rcx
cmpq %rsi, %rdx
jl 0x2755d
testl %ebp, %ebp
jne 0x27710
movq 0x427a7(%rip), %r15     # 0x69d40
cmpl $0x0, 0x61c(%r15)
jle 0x275e1
movq 0x42896(%rip), %r14     # 0x69e40
xorl %r12d, %r12d
cmpq $0x0, 0x8(%r14)
je 0x275cb
testb $0x2, 0x68(%r14)
je 0x275cb
movq %rbx, %rdi
movq %r14, %rsi
movl $0x3e8, %edx            # imm = 0x3E8
callq 0x19230
incq %r12
movslq 0x61c(%r15), %rax
addq $0x88, %r14
cmpq %rax, %r12
jl 0x275ad
testl %ebp, %ebp
jne 0x27710
leaq 0x2ce0d(%rip), %rdi     # 0x543fd
callq 0x189e0
movq 0x58(%rbx), %rcx
movq 0x42840(%rip), %r14     # 0x69e40
subq %r14, %rax
sarq $0x3, %rax
movabsq $-0x3c3c3c3c3c3c3c3c, %r15 # imm = 0xC3C3C3C3C3C3C3C4
imulq %r15, %rax
xorl %r12d, %r12d
movl %r12d, 0x318(%rcx,%rax)
leaq 0x2e067(%rip), %rdi     # 0x5568e
callq 0x189e0
movq 0x58(%rbx), %rcx
subq %r14, %rax
sarq $0x3, %rax
imulq %r15, %rax
movl %r12d, 0x318(%rcx,%rax)
leaq 0x2e051(%rip), %rdi     # 0x5569b
callq 0x189e0
movq 0x70(%rax), %rcx
subq %r14, %rax
sarq $0x3, %rax
imulq %r15, %rax
movl 0x4(%rcx), %ecx
movq 0x58(%rbx), %rdx
movl %ecx, 0x318(%rdx,%rax)
testl %ebp, %ebp
jne 0x27710
leaq 0x2e02b(%rip), %rdi     # 0x556a6
callq 0x189e0
movq %rax, %r15
callq 0x19710
movq %rax, %r14
movq (%r15), %rax
movq %rax, 0x138(%r14)
movq %r14, %rdi
movq %r15, %rsi
callq 0x18ec0
movq %r14, %rdi
movq %rbx, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x19ac8
cmpl $0x0, 0x60(%r14)
je 0x276be
movq %r14, %rdi
callq 0x19a60
testl %ebp, %ebp
jne 0x27710
movq 0x42677(%rip), %rax     # 0x69d40
cmpl $0x0, 0x61c(%rax)
jle 0x27710
movq 0x42767(%rip), %rcx     # 0x69e40
addq $0x68, %rcx
xorl %edx, %edx
cmpq $0x0, -0x60(%rcx)
je 0x276fa
testb $0x7, (%rcx)
jne 0x276fa
movq 0x58(%rbx), %rsi
movl $0x1, 0x318(%rsi,%rdx,4)
incq %rdx
movslq 0x61c(%rax), %rsi
addq $0x88, %rcx
cmpq %rsi, %rdx
jl 0x276df
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq 0x10(%r15), %rcx
leaq 0x2df9d(%rip), %rdx     # 0x556c1
jmp 0x2777d
movq %r14, %rax
subq 0x42710(%rip), %rax     # 0x69e40
sarq $0x3, %rax
movabsq $-0xf0f0f0f0f0f0f0f, %r12 # imm = 0xF0F0F0F0F0F0F0F1
imulq %rax, %r12
callq *0x138(%r15)
cmpl $0x3, %eax
jne 0x27791
movl $0x2, %edi
callq *0x140(%r15)
movq %rax, %rdi
callq 0x195e0
movq 0x58(%rbx), %rcx
movslq %r12d, %rdx
movl %eax, 0x318(%rcx,%rdx,4)
jmp 0x27710
movq 0x10(%r15), %rcx
leaq 0x2df36(%rip), %rdx     # 0x556b3
movq %rbx, %rdi
movl $0x2, %esi
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmpq *%rcx
movl 0x5c(%r14), %eax
movq 0x58(%rbx), %rcx
movslq %r12d, %rdx
addl %eax, 0x318(%rcx,%rdx,4)
jmp 0x27710