// File: /workspace/github_c_makefile_star2_O3/QwazyWabbitWOS[P]lmctf60/g_cmds.c
// Function: Cmd_Drop_f
void Cmd_Drop_f (edict_t *ent)
{
	int			index;
	gitem_t		*it;
	char		*s;

	char message[MAX_INFO_STRING];

	s = gi.args();
	it = 0;

	//assert(false);

	if (!s || s[0] == 0)
	{
		ctf_SafePrint(ent, PRINT_HIGH, "Drop what?\n");
		return;
	}

	// CTF CODE -- LM_JORM
	if (Q_stricmp(s, "hook") == 0)
		s = "grappling hook";
	if (Q_stricmp(s, "flag") == 0)
		s = "Enemy Flag";

	if ((Q_stricmp(s, "rune") == 0) ||
		(Q_stricmp(s, "artifact") == 0) ||
		(Q_stricmp(s, "tech") == 0))
	{
		if (ent->client->rune)
		{
			it = ent->client->rune->item;
			if (it)  // We are carrying a rune
			{
				index = ITEM_INDEX(it);
				if (it->drop)
					it->drop (ent, it);
				else
				{
					sprintf(message, "Can't drop %s\n", s);
					ctf_SafePrint(ent, PRINT_HIGH, message);
				}
			}
		}
		return;
	}

	if (Q_stricmp(s, "ammo") == 0)
	{
		if (ent->client->pers.weapon->ammo)
			it =  FindItem (ent->client->pers.weapon->ammo);
	}

	// END CTF CODE -- LM_JORM

	if (!it)
		it = FindItem (s);
	if (!it)
	{
		sprintf(message, "unknown item: %s\n", s);
		ctf_SafePrint(ent, PRINT_HIGH, message);
		return;
	}
	if (!it->drop)
	{
		ctf_SafePrint(ent, PRINT_HIGH, "Item is not dropable.\n");
		return;
	}
	index = ITEM_INDEX(it);
	if (!ent->client->pers.inventory[index])
	{
		sprintf(message, "Out of item: %s\n", s);
		ctf_SafePrint(ent, PRINT_HIGH, message);
		return;
	}

	it->drop (ent, it);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x200, %rsp            # imm = 0x200
movq %rdi, %rbx
movq 0x40dbb(%rip), %rax     # 0x68600
callq *0x148(%rax)
testq %rax, %rax
je 0x27905
movq %rax, %r15
cmpb $0x0, (%rax)
je 0x27905
leaq 0x32a0e(%rip), %rsi     # 0x5a275
movq %r15, %rdi
callq 0x18690
testl %eax, %eax
leaq 0x329f3(%rip), %rax     # 0x5a26b
cmoveq %rax, %r15
leaq 0x336b8(%rip), %rsi     # 0x5af3b
movq %r15, %rdi
callq 0x18690
testl %eax, %eax
leaq 0x2ceb1(%rip), %r14     # 0x54745
cmovneq %r15, %r14
leaq 0x2ba78(%rip), %rsi     # 0x53317
movq %r14, %rdi
callq 0x18690
testl %eax, %eax
je 0x27925
leaq 0x2b945(%rip), %rsi     # 0x531f7
movq %r14, %rdi
callq 0x18690
testl %eax, %eax
je 0x27925
leaq 0x2cecf(%rip), %rsi     # 0x54794
movq %r14, %rdi
callq 0x18690
testl %eax, %eax
je 0x27925
leaq 0x2cdd1(%rip), %rsi     # 0x546a9
movq %r14, %rdi
callq 0x18690
testl %eax, %eax
je 0x2796c
movq %r14, %rdi
callq 0x189e0
testq %rax, %rax
jne 0x27992
leaq 0x2ce50(%rip), %rsi     # 0x54750
jmp 0x279e7
leaq 0x2ce7c(%rip), %rdx     # 0x54788
movl $0x2, %esi
movq %rbx, %rdi
addq $0x200, %rsp            # imm = 0x200
popq %rbx
popq %r14
popq %r15
jmp 0x18da0
movq 0x58(%rbx), %rax
movq 0xf68(%rax), %rax
testq %rax, %rax
je 0x27a07
movq 0x330(%rax), %rsi
testq %rsi, %rsi
je 0x27a07
movq 0x18(%rsi), %rax
testq %rax, %rax
je 0x27963
movq %rbx, %rdi
addq $0x200, %rsp            # imm = 0x200
popq %rbx
popq %r14
popq %r15
jmpq *%rax
leaq 0x2ce2f(%rip), %rsi     # 0x54799
jmp 0x279e7
movq 0x58(%rbx), %rax
movq 0x730(%rax), %rax
movq 0x60(%rax), %rdi
testq %rdi, %rdi
je 0x278e8
callq 0x189e0
testq %rax, %rax
je 0x278e8
movq 0x18(%rax), %rcx
testq %rcx, %rcx
je 0x279d4
movq %rax, %rdx
subq 0x4149b(%rip), %rdx     # 0x68e40
shrq $0x3, %rdx
imull $0xf0f0f0f1, %edx, %edx # imm = 0xF0F0F0F1
movq 0x58(%rbx), %rsi
movslq %edx, %rdx
cmpl $0x0, 0x318(%rsi,%rdx,4)
je 0x279e0
movq %rbx, %rdi
movq %rax, %rsi
addq $0x200, %rsp            # imm = 0x200
popq %rbx
popq %r14
popq %r15
jmpq *%rcx
leaq 0x2cdcd(%rip), %rdx     # 0x547a8
jmp 0x2790c
leaq 0x2cd90(%rip), %rsi     # 0x54777
movq %rsp, %r15
movq %r15, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x196f0
movl $0x2, %esi
movq %rbx, %rdi
movq %r15, %rdx
callq 0x18da0
addq $0x200, %rsp            # imm = 0x200
popq %rbx
popq %r14
popq %r15
retq