// File: /workspace/github_c_makefile_star2_O1/QwazyWabbitWOS[P]lmctf60/g_items.c
// Function: Touch_Item
void Touch_Item (edict_t *ent, edict_t *other, cplane_t *plane, csurface_t *surf)
{
	qboolean	taken;

	if (Match_InCountdown())
		return;

	if (!other->client)
		return;
	if (other->health < 1)
		return;		// dead people can't pickup
	if (!ent->item->pickup)
		return;		// not a grabbable item?

	taken = ent->item->pickup(ent, other);

	if (taken)
	{
		// flash the screen
		other->client->bonus_alpha = 0.25;	

		// show icon and name on status bar
		other->client->ps.stats[STAT_PICKUP_ICON] = gi.imageindex(ent->item->icon);
		other->client->ps.stats[STAT_PICKUP_STRING] = CS_ITEMS+ITEM_INDEX(ent->item);
		other->client->pickup_msg_time = level.time + 3.0;

		// change selected item
		if (ent->item->use)
			other->client->pers.selected_item = other->client->ps.stats[STAT_SELECTED_ITEM] = ITEM_INDEX(ent->item);

		if (ent->item->pickup == Pickup_Health)
		{
			if (ent->count == 2)
				gi.sound(other, CHAN_ITEM, gi.soundindex("items/s_health.wav"), 1, ATTN_NORM, 0);
			else if (ent->count == 10)
				gi.sound(other, CHAN_ITEM, gi.soundindex("items/n_health.wav"), 1, ATTN_NORM, 0);
			else if (ent->count == 25)
				gi.sound(other, CHAN_ITEM, gi.soundindex("items/l_health.wav"), 1, ATTN_NORM, 0);
			else // (ent->count == 100)
				gi.sound(other, CHAN_ITEM, gi.soundindex("items/m_health.wav"), 1, ATTN_NORM, 0);
		}
		else if (ent->item->pickup_sound)
		{
			gi.sound(other, CHAN_ITEM, gi.soundindex(ent->item->pickup_sound), 1, ATTN_NORM, 0);
		}
	}

	if (!(ent->spawnflags & ITEM_TARGETS_USED))
	{
		G_UseTargets (ent, other);
		ent->spawnflags |= ITEM_TARGETS_USED;
	}

	if (!taken)
		return;

	if (!((coop->value) &&  (ent->item->flags & IT_STAY_COOP)) || (ent->spawnflags & (DROPPED_ITEM | DROPPED_PLAYER_ITEM)))
	{
		if (ent->flags & FL_RESPAWN)
			ent->flags &= ~FL_RESPAWN;
		else
			G_FreeEdict (ent);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
xorl %eax, %eax
callq 0x19370
testl %eax, %eax
je 0x315b3
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
cmpq $0x0, 0x58(%r14)
je 0x315aa
cmpl $0x0, 0x254(%r14)
jle 0x315aa
movq 0x330(%rbx), %rax
movq 0x8(%rax), %rax
testq %rax, %rax
je 0x315aa
movq %rbx, %rdi
movq %r14, %rsi
callq *%rax
movl %eax, %ebp
testl %eax, %eax
je 0x316f0
movq 0x58(%r14), %rax
movl $0x3e800000, 0xeac(%rax) # imm = 0x3E800000
movq 0x38005(%rip), %r12     # 0x69600
movq 0x330(%rbx), %rax
movq 0x48(%rax), %rdi
callq *0x50(%r12)
movq 0x58(%r14), %rcx
movw %ax, 0x86(%rcx)
movq 0x330(%rbx), %rax
movl 0x3881d(%rip), %edx     # 0x69e40
movl %eax, %esi
subl %edx, %esi
shrl $0x3, %esi
imull $0xfffff0f1, %esi, %edx # imm = 0xFFFFF0F1
leal 0x420(%rdx), %esi
movw %si, 0x88(%rcx)
movq 0x3875c(%rip), %rsi     # 0x69da0
movss 0x4(%rsi), %xmm0
addss 0x228bb(%rip), %xmm0    # 0x53f0c
movss %xmm0, 0xf24(%rcx)
cmpq $0x0, 0x10(%rax)
je 0x31670
movw %dx, 0x90(%rcx)
movswl %dx, %edx
movl %edx, 0x314(%rcx)
movq 0x8(%rax), %rcx
cmpq 0x387fd(%rip), %rcx     # 0x69e78
je 0x31692
movq 0x28(%rax), %rdi
testq %rdi, %rdi
je 0x316f0
movq 0x20(%r12), %r15
callq *0x48(%r12)
jmp 0x316d5
movl 0x290(%rbx), %ecx
movq 0x20(%r12), %r15
movq 0x48(%r12), %rax
cmpl $0x19, %ecx
je 0x316c3
cmpl $0xa, %ecx
je 0x316ba
cmpl $0x2, %ecx
jne 0x316cc
leaq 0x258b2(%rip), %rdi     # 0x56f6a
jmp 0x316d3
leaq 0x258bc(%rip), %rdi     # 0x56f7d
jmp 0x316d3
leaq 0x258c6(%rip), %rdi     # 0x56f90
jmp 0x316d3
leaq 0x268b8(%rip), %rdi     # 0x57f8b
callq *%rax
movss 0x2284b(%rip), %xmm0    # 0x53f28
xorps %xmm2, %xmm2
movq %r14, %rdi
movl $0x3, %esi
movl %eax, %edx
movaps %xmm0, %xmm1
callq *%r15
testb $0x4, 0x142(%rbx)
jne 0x3170b
movq %rbx, %rdi
movq %r14, %rsi
callq 0x198f0
orb $0x4, 0x142(%rbx)
testl %ebp, %ebp
je 0x315aa
movq 0x38846(%rip), %rax     # 0x69f60
movq (%rax), %rax
movss 0x20(%rax), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x3172c
jnp 0x31746
movq 0x330(%rbx), %rax
testb $0x8, 0x68(%rax)
je 0x31746
testb $0x3, 0x142(%rbx)
je 0x315aa
movl 0x11c(%rbx), %eax
testl %eax, %eax
js 0x31760
movq %rbx, %rdi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x19a60
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, 0x11c(%rbx)
jmp 0x315aa