// File: /workspace/github_c_makefile_star2_O2/QwazyWabbitWOS[P]lmctf60/g_utils.c
// Function: G_UseTargets
void G_UseTargets (edict_t *ent, edict_t *activator)
{
	edict_t		*t;

//
// check for a delay
//
	if (ent->delay)
	{
	// create a temp object to fire at a later time
		t = G_Spawn();
		t->classname = "DelayedUse";
		t->nextthink = level.time + ent->delay;
		t->think = Think_Delay;
		t->activator = activator;
		if (!activator)
			gi.dprintf ("Think_Delay with no activator\n");
		t->message = ent->message;
		t->target = ent->target;
		t->killtarget = ent->killtarget;
		return;
	}
	
	
//
// print the message
//
	if ((ent->message) && !(activator->svflags & SVF_MONSTER))
	{
		gi.centerprintf (activator, "%s", ent->message);
		if (ent->noise_index)
			gi.sound (activator, CHAN_AUTO, ent->noise_index, 1, ATTN_NORM, 0);
		else
			gi.sound (activator, CHAN_AUTO, gi.soundindex ("misc/talk1.wav"), 1, ATTN_NORM, 0);
	}

//
// kill killtargets
//
	if (ent->killtarget)
	{
		t = NULL;
		while ((t = G_Find (t, FOFS(targetname), ent->killtarget)) != NULL)
		{
			G_FreeEdict (t);
			if (!ent->inuse)
			{
				gi.dprintf("entity was removed while using killtargets\n");
				return;
			}
		}
	}

//
// fire targets
//
	if (ent->target)
	{
		t = NULL;
		while ((t = G_Find (t, FOFS(targetname), ent->target)) != NULL)
		{
			// doors fire area portals in a specific way
			if (!Q_stricmp(t->classname, "func_areaportal") &&
				(!Q_stricmp(ent->classname, "func_door") || !Q_stricmp(ent->classname, "func_door_rotating")))
				continue;

			if (t == ent)
			{
				gi.dprintf ("WARNING: Entity used itself.\n");
			}
			else
			{
				if (t->use)
					t->use (t, ent, activator);
			}
			if (!ent->inuse)
			{
				gi.dprintf("entity was removed while using targets\n");
				return;
			}
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movss 0x2fc(%rdi), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x3b01c
jnp 0x3b0b5
callq 0x198d0
movq %rax, %r15
leaq 0x1a452(%rip), %rax     # 0x5547d
movq %rax, 0x138(%r15)
movq 0x2bd67(%rip), %rax     # 0x66da0
movss 0x4(%rax), %xmm0
addss 0x2fc(%rbx), %xmm0
movss %xmm0, 0x200(%r15)
movq 0x2b99a(%rip), %rax     # 0x669f0
movq %rax, 0x210(%r15)
movq %r14, 0x2b0(%r15)
testq %r14, %r14
jne 0x3b07c
movq 0x2b590(%rip), %rcx     # 0x66600
leaq 0x1a411(%rip), %rdi     # 0x55488
xorl %eax, %eax
callq *0x8(%rcx)
movq 0x130(%rbx), %rax
movq %rax, 0x130(%r15)
movq 0x150(%rbx), %rax
movq %rax, 0x150(%r15)
movq 0x160(%rbx), %rax
movq %rax, 0x160(%r15)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x130(%rbx), %rdx
testq %rdx, %rdx
je 0x3b116
testb $0x4, 0xc8(%r14)
jne 0x3b116
movq 0x2b52e(%rip), %r12     # 0x66600
leaq 0x138d4(%rip), %rsi     # 0x4e9ad
movq %r14, %rdi
xorl %eax, %eax
callq *0x18(%r12)
movl 0x2e8(%rbx), %edx
movq 0x20(%r12), %r15
testl %edx, %edx
jne 0x3b100
leaq 0x16c76(%rip), %rdi     # 0x51d6f
callq *0x48(%r12)
movl %eax, %edx
movss 0x13e20(%rip), %xmm0    # 0x4ef28
xorps %xmm2, %xmm2
movq %r14, %rdi
xorl %esi, %esi
movaps %xmm0, %xmm1
callq *%r15
cmpq $0x0, 0x160(%rbx)
je 0x3b164
xorl %r15d, %r15d
movq 0x160(%rbx), %rdx
movq %r15, %rdi
movl $0x158, %esi            # imm = 0x158
callq 0x195e0
testq %rax, %rax
je 0x3b164
movq %rax, %r15
movq %rax, %rdi
callq 0x19c50
cmpl $0x0, 0x60(%rbx)
jne 0x3b123
movq 0x2b4ac(%rip), %rax     # 0x66600
movq 0x8(%rax), %rcx
leaq 0x1a348(%rip), %rdi     # 0x554a7
jmp 0x3b22b
movq 0x150(%rbx), %rdx
testq %rdx, %rdx
je 0x3b0a6
leaq 0x16bc7(%rip), %r15     # 0x51d42
leaq 0x16bd0(%rip), %r12     # 0x51d52
movq 0x2b477(%rip), %rbp     # 0x66600
xorl %r13d, %r13d
movq %r13, %rdi
movl $0x158, %esi            # imm = 0x158
callq 0x195e0
testq %rax, %rax
je 0x3b0a6
movq %rax, %r13
movq 0x138(%rax), %rdi
movq %r15, %rsi
callq 0x186d0
testl %eax, %eax
je 0x3b1d6
cmpq %rbx, %r13
je 0x3b202
movq 0x228(%r13), %rax
testq %rax, %rax
je 0x3b20e
movq %r13, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq *%rax
jmp 0x3b20e
movq 0x138(%rbx), %rdi
movq %r12, %rsi
callq 0x186d0
testl %eax, %eax
je 0x3b214
movq 0x138(%rbx), %rdi
leaq 0x16b65(%rip), %rsi     # 0x51d5c
callq 0x186d0
testl %eax, %eax
jne 0x3b1b8
jmp 0x3b214
leaq 0x1a2ca(%rip), %rdi     # 0x554d3
xorl %eax, %eax
callq *0x8(%rbp)
cmpl $0x0, 0x60(%rbx)
je 0x3b220
movq 0x150(%rbx), %rdx
jmp 0x3b18c
movq 0x8(%rbp), %rcx
leaq 0x1a2c6(%rip), %rdi     # 0x554f1
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmpq *%rcx