// File: /workspace/github_c_makefile_star2_O3/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 0x41d20(%rip), %rax     # 0x68ec0
movq (%rax), %rax
movss 0x20(%rax), %xmm1
xorps %xmm0, %xmm0
ucomiss %xmm0, %xmm1
jne 0x271b2
jnp 0x271cc
movq 0x4183f(%rip), %rax     # 0x689f8
movq (%rax), %rax
movss 0x20(%rax), %xmm1
ucomiss %xmm0, %xmm1
jne 0x271cc
jnp 0x27321
movq 0x4142d(%rip), %r15     # 0x68600
callq *0x148(%r15)
movq %rax, %r14
leaq 0x32cb6(%rip), %rsi     # 0x59e9a
movq %rax, %rdi
callq 0x18690
movl %eax, %ebp
testl %eax, %eax
je 0x272ff
movl $0x1, %edi
callq *0x140(%r15)
leaq 0x2bf83(%rip), %rsi     # 0x5318c
movq %rax, %rdi
callq 0x18690
testl %eax, %eax
je 0x272ff
leaq 0x2d481(%rip), %rsi     # 0x546a1
movq %r14, %rdi
callq 0x18690
testl %eax, %eax
je 0x27351
leaq 0x2d472(%rip), %rsi     # 0x546a9
movq %r14, %rdi
callq 0x18690
testl %eax, %eax
je 0x273a8
leaq 0x2bf30(%rip), %rsi     # 0x5317e
movq %r14, %rdi
callq 0x18690
testl %eax, %eax
je 0x2740a
leaq 0x2d461(%rip), %rsi     # 0x546c6
movq %r14, %rdi
callq 0x18690
testl %eax, %eax
je 0x27495
movq %r14, %rdi
callq 0x189e0
testq %rax, %rax
jne 0x2729f
movl $0x1, %edi
callq *0x140(%r15)
movq %rax, %rdi
callq 0x189e0
testq %rax, %rax
je 0x275a2
movq %rax, %r14
cmpq $0x0, 0x8(%rax)
je 0x27549
testb $0x2, 0x68(%r14)
jne 0x27556
callq 0x19700
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 0x19ab8
cmpl $0x0, 0x60(%r15)
je 0x27540
movq %r15, %rdi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x19a50
callq *0x138(%r15)
cmpl $0x3, %eax
jne 0x2733d
movl $0x2, %edi
callq *0x140(%r15)
movq %rax, %rdi
callq 0x195e0
jmp 0x27343
leaq 0x2d352(%rip), %rdx     # 0x5467a
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 0x27540
movq 0x419e8(%rip), %rcx     # 0x68d40
movl 0x61c(%rcx), %eax
testl %eax, %eax
jle 0x2739e
movq 0x41ad7(%rip), %rdx     # 0x68e40
addq $0x68, %rdx
xorl %esi, %esi
cmpq $0x0, -0x60(%rdx)
je 0x2738c
testb $0x1, (%rdx)
je 0x2738c
movq 0x58(%rbx), %rax
incl 0x318(%rax,%rsi,4)
movl 0x61c(%rcx), %eax
incq %rsi
movslq %eax, %rdi
addq $0x88, %rdx
cmpq %rdi, %rsi
jl 0x2736f
testl %ebp, %ebp
jne 0x27540
jmp 0x273b5
movq 0x41991(%rip), %rax     # 0x68d40
movl 0x61c(%rax), %eax
testl %eax, %eax
jle 0x27402
movq 0x41a80(%rip), %r14     # 0x68e40
xorl %r15d, %r15d
movq 0x41976(%rip), %r12     # 0x68d40
cmpq $0x0, 0x8(%r14)
je 0x273f0
testb $0x2, 0x68(%r14)
je 0x273f0
movq %rbx, %rdi
movq %r14, %rsi
movl $0x3e8, %edx            # imm = 0x3E8
callq 0x19230
movl 0x61c(%r12), %eax
incq %r15
movslq %eax, %rcx
addq $0x88, %r14
cmpq %rcx, %r15
jl 0x273ca
testl %ebp, %ebp
jne 0x27540
leaq 0x2bffc(%rip), %rdi     # 0x5340d
callq 0x189e0
movq 0x58(%rbx), %rcx
movq 0x41a1f(%rip), %r14     # 0x68e40
subq %r14, %rax
sarq $0x3, %rax
movabsq $-0x3c3c3c3c3c3c3c3c, %r15 # imm = 0xC3C3C3C3C3C3C3C4
imulq %r15, %rax
xorl %r12d, %r12d
movl %r12d, 0x318(%rcx,%rax)
leaq 0x2d266(%rip), %rdi     # 0x546ae
callq 0x189e0
movq 0x58(%rbx), %rcx
subq %r14, %rax
sarq $0x3, %rax
imulq %r15, %rax
movl %r12d, 0x318(%rcx,%rax)
leaq 0x2d250(%rip), %rdi     # 0x546bb
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 0x27540
leaq 0x2d22a(%rip), %rdi     # 0x546c6
callq 0x189e0
movq %rax, %r15
callq 0x19700
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 0x19ab8
cmpl $0x0, 0x60(%r14)
je 0x274df
movq %r14, %rdi
callq 0x19a50
testl %ebp, %ebp
sete %dl
movq 0x41855(%rip), %rax     # 0x68d40
movl 0x61c(%rax), %ecx
testl %ecx, %ecx
setg %sil
andb %dl, %sil
cmpb $0x1, %sil
jne 0x27540
movq 0x41939(%rip), %rdx     # 0x68e40
addq $0x68, %rdx
xorl %esi, %esi
cmpq $0x0, -0x60(%rdx)
je 0x2752e
testb $0x7, (%rdx)
jne 0x2752e
movq 0x58(%rbx), %rcx
movl $0x1, 0x318(%rcx,%rsi,4)
movl 0x61c(%rax), %ecx
incq %rsi
movslq %ecx, %rdi
addq $0x88, %rdx
cmpq %rdi, %rsi
jl 0x2750d
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq 0x10(%r15), %rcx
leaq 0x2d18d(%rip), %rdx     # 0x546e1
jmp 0x275ad
movq %r14, %rax
subq 0x418e0(%rip), %rax     # 0x68e40
sarq $0x3, %rax
movabsq $-0xf0f0f0f0f0f0f0f, %r12 # imm = 0xF0F0F0F0F0F0F0F1
imulq %rax, %r12
callq *0x138(%r15)
cmpl $0x3, %eax
jne 0x275c1
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 0x27540
movq 0x10(%r15), %rcx
leaq 0x2d126(%rip), %rdx     # 0x546d3
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 0x27540