// File: /workspace/github_c_makefile_star2_O2/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 0x41ed3(%rip), %rax     # 0x66ec0
movq (%rax), %rax
movss 0x20(%rax), %xmm1
xorps %xmm0, %xmm0
ucomiss %xmm0, %xmm1
jne 0x24fff
jnp 0x25019
movq 0x419f2(%rip), %rax     # 0x669f8
movq (%rax), %rax
movss 0x20(%rax), %xmm1
ucomiss %xmm0, %xmm1
jne 0x25019
jnp 0x25181
movq 0x415e0(%rip), %r12     # 0x66600
callq *0x148(%r12)
movq %rax, %r14
leaq 0x30e58(%rip), %rsi     # 0x55e8a
movq %rax, %rdi
callq 0x186d0
movl %eax, %ebp
testl %eax, %eax
je 0x2515f
pushq $0x1
popq %rdi
callq *0x140(%r12)
leaq 0x2a136(%rip), %rsi     # 0x4f18c
movq %rax, %rdi
callq 0x186d0
testl %eax, %eax
je 0x2515f
leaq 0x2b614(%rip), %rsi     # 0x50681
movq %r14, %rdi
callq 0x186d0
testl %eax, %eax
je 0x251af
leaq 0x2b605(%rip), %rsi     # 0x50689
movq %r14, %rdi
callq 0x186d0
testl %eax, %eax
je 0x25204
leaq 0x2a0e3(%rip), %rsi     # 0x4f17e
movq %r14, %rdi
callq 0x186d0
testl %eax, %eax
je 0x25264
leaq 0x2b5f4(%rip), %rsi     # 0x506a6
movq %r14, %rdi
callq 0x186d0
testl %eax, %eax
je 0x252de
movq %r14, %rdi
callq 0x18a80
testq %rax, %rax
jne 0x250eb
pushq $0x1
popq %rdi
callq *0x140(%r12)
movq %rax, %rdi
callq 0x18a80
testq %rax, %rax
je 0x253c7
movq %rax, %r14
cmpq $0x0, 0x8(%rax)
je 0x25383
movq %r14, %rax
subq 0x41d3d(%rip), %rax     # 0x66e40
movl $0x88, %ecx
cqto
idivq %rcx
testb $0x2, 0x68(%r14)
jne 0x25391
callq 0x198d0
movq %rax, %r15
movq (%r14), %rax
movq %rax, 0x138(%r15)
movq %r15, %rdi
movq %r14, %rsi
callq 0x18fe0
movq %r15, %rdi
movq %rbx, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x19cc0
cmpl $0x0, 0x60(%r15)
je 0x2532c
movq %r15, %rdi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x19c50
callq *0x138(%r12)
cmpl $0x3, %eax
jne 0x2519b
pushq $0x2
popq %rdi
callq *0x140(%r12)
movq %rax, %rdi
callq 0x197a0
jmp 0x251a1
leaq 0x2b4d2(%rip), %rdx     # 0x5065a
pushq $0x2
popq %rsi
movq %rbx, %rdi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x18ec0
movl 0x258(%rbx), %eax
movl %eax, 0x254(%rbx)
testl %ebp, %ebp
jne 0x2532c
movq 0x41c8a(%rip), %rcx     # 0x66e40
addq $0x68, %rcx
movq 0x41b7f(%rip), %rdx     # 0x66d40
movl 0x61c(%rdx), %eax
xorl %esi, %esi
movslq %eax, %rdi
cmpq %rdi, %rsi
jge 0x251fa
cmpq $0x0, -0x60(%rcx)
je 0x251ee
testb $0x1, (%rcx)
je 0x251ee
movq 0x58(%rbx), %rax
incl 0x318(%rax,%rsi,4)
movl 0x61c(%rdx), %eax
incq %rsi
addq $0x88, %rcx
jmp 0x251c9
testl %ebp, %ebp
jne 0x2532c
jmp 0x25211
movq 0x41b35(%rip), %rax     # 0x66d40
movl 0x61c(%rax), %eax
movq 0x41c28(%rip), %r14     # 0x66e40
xorl %r15d, %r15d
movq 0x41b1e(%rip), %r12     # 0x66d40
movslq %eax, %rcx
cmpq %rcx, %r15
jge 0x2525c
cmpq $0x0, 0x8(%r14)
je 0x25250
testb $0x2, 0x68(%r14)
je 0x25250
movq %rbx, %rdi
movq %r14, %rsi
movl $0x3e8, %edx            # imm = 0x3E8
callq 0x193b0
movl 0x61c(%r12), %eax
incq %r15
addq $0x88, %r14
jmp 0x25222
testl %ebp, %ebp
jne 0x2532c
leaq 0x2a1a2(%rip), %rdi     # 0x4f40d
callq 0x18a80
movq 0x58(%rbx), %rcx
movq 0x41bc5(%rip), %r14     # 0x66e40
subq %r14, %rax
movl $0x88, %r15d
cqto
idivq %r15
andl $0x0, 0x318(%rcx,%rax,4)
leaq 0x2b3f6(%rip), %rdi     # 0x5068e
callq 0x18a80
movq 0x58(%rbx), %rcx
subq %r14, %rax
cqto
idivq %r15
andl $0x0, 0x318(%rcx,%rax,4)
leaq 0x2b3e3(%rip), %rdi     # 0x5069b
callq 0x18a80
movq %rax, %rcx
subq %r14, %rax
cqto
idivq %r15
movq 0x70(%rcx), %rcx
movl 0x4(%rcx), %ecx
movq 0x58(%rbx), %rdx
movl %ecx, 0x318(%rdx,%rax,4)
testl %ebp, %ebp
jne 0x2532c
leaq 0x2b3c1(%rip), %rdi     # 0x506a6
callq 0x18a80
movq %rax, %r15
callq 0x198d0
movq %rax, %r14
movq (%r15), %rax
movq %rax, 0x138(%r14)
movq %r14, %rdi
movq %r15, %rsi
callq 0x18fe0
movq %r14, %rdi
movq %rbx, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x19cc0
cmpl $0x0, 0x60(%r14)
je 0x25328
movq %r14, %rdi
callq 0x19c50
testl %ebp, %ebp
je 0x25335
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq 0x41b04(%rip), %rax     # 0x66e40
addq $0x68, %rax
movq 0x419f9(%rip), %rcx     # 0x66d40
movl 0x61c(%rcx), %esi
xorl %edx, %edx
movslq %esi, %rdi
cmpq %rdi, %rdx
jge 0x2532c
cmpq $0x0, -0x60(%rax)
je 0x25378
testb $0x7, (%rax)
jne 0x25378
movq 0x58(%rbx), %rsi
movl $0x1, 0x318(%rsi,%rdx,4)
movl 0x61c(%rcx), %esi
incq %rdx
addq $0x88, %rax
jmp 0x2534f
movq 0x10(%r12), %rcx
leaq 0x2b332(%rip), %rdx     # 0x506c1
jmp 0x253d3
movq %rax, %r15
callq *0x138(%r12)
cmpl $0x3, %eax
jne 0x253e5
pushq $0x2
popq %rdi
callq *0x140(%r12)
movq %rax, %rdi
callq 0x197a0
movq 0x58(%rbx), %rcx
movslq %r15d, %rdx
movl %eax, 0x318(%rcx,%rdx,4)
jmp 0x2532c
movq 0x10(%r12), %rcx
leaq 0x2b2e0(%rip), %rdx     # 0x506b3
pushq $0x2
popq %rsi
movq %rbx, %rdi
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmpq *%rcx
movl 0x5c(%r14), %eax
movq 0x58(%rbx), %rcx
movslq %r15d, %rdx
addl %eax, 0x318(%rcx,%rdx,4)
jmp 0x2532c