// File: /workspace/github_c_makefile_star2_O2/QwazyWabbitWOS[P]lmctf60/g_target.c
// Function: target_laser_think
void target_laser_think (edict_t *self)
{
	edict_t	*ignore;
	vec3_t	start;
	vec3_t	end;
	trace_t	tr;
	vec3_t	point;
	vec3_t	last_movedir;
	int		count;

	if (self->spawnflags & 0x80000000)
		count = 8;
	else
		count = 4;

	if (self->enemy)
	{
		VectorCopy (self->movedir, last_movedir);
		VectorMA (self->enemy->absmin, 0.5, self->enemy->size, point);
		VectorSubtract (point, self->s.origin, self->movedir);
		VectorNormalize (self->movedir);
		if (!VectorCompare(self->movedir, last_movedir))
			self->spawnflags |= 0x80000000;
	}

	ignore = self;
	VectorCopy (self->s.origin, start);
	VectorMA (start, 2048, self->movedir, end);
	while(1)
	{
		tr = gi.trace (start, NULL, NULL, end, ignore, CONTENTS_SOLID|CONTENTS_MONSTER|CONTENTS_DEADMONSTER);

		if (!tr.ent)
			break;

		// hurt it if we can
		if ((tr.ent->takedamage) && !(tr.ent->flags & FL_IMMUNE_LASER))
			T_Damage (tr.ent, self, self->activator, self->movedir, tr.endpos, vec3_origin, self->dmg, 1, DAMAGE_ENERGY, MOD_TARGET_LASER);

		// if we hit something that's not a monster or player or is immune to lasers, we're done
		if (!(tr.ent->svflags & SVF_MONSTER) && (!tr.ent->client))
		{
			if (self->spawnflags & 0x80000000)
			{
				self->spawnflags &= ~0x80000000;
				gi.WriteByte (svc_temp_entity);
				gi.WriteByte (TE_LASER_SPARKS);
				gi.WriteByte (count);
				gi.WritePosition (tr.endpos);
				gi.WriteDir (tr.plane.normal);
				gi.WriteByte (self->s.skinnum);
				gi.multicast (tr.endpos, MULTICAST_PVS);
			}
			break;
		}

		ignore = tr.ent;
		VectorCopy (tr.endpos, start);
	}

	VectorCopy (tr.endpos, self->s.old_origin);

	self->nextthink = level.time + FRAMETIME;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %rdi, %rbx
movl 0x140(%rdi), %r13d
shrl $0x1f, %r13d
movq 0x2a0(%rdi), %rsi
testq %rsi, %rsi
je 0x3968e
leaq 0x19c(%rbx), %r14
movsd 0x19c(%rbx), %xmm0
leaq 0x68(%rsp), %r15
movsd %xmm0, (%r15)
movss 0x1a4(%rbx), %xmm0
movss %xmm0, 0x8(%r15)
leaq 0xe4(%rsi), %rdi
addq $0xfc, %rsi
movss 0x16dc6(%rip), %xmm0    # 0x50400
leaq 0x78(%rsp), %r12
movq %r12, %rdx
callq 0x19940
movsd (%r12), %xmm0
movsd 0x4(%rbx), %xmm1
subps %xmm1, %xmm0
movlps %xmm0, 0x19c(%rbx)
movss 0x8(%r12), %xmm0
subss 0xc(%rbx), %xmm0
movss %xmm0, 0x1a4(%rbx)
movq %r14, %rdi
callq 0x183c0
movq %r14, %rdi
movq %r15, %rsi
callq 0x18c20
testl %eax, %eax
jne 0x3968e
orb $-0x80, 0x143(%rbx)
leal 0x4(,%r13,4), %eax
movl %eax, 0x4(%rsp)
movsd 0x4(%rbx), %xmm0
leaq 0x10(%rsp), %r15
movsd %xmm0, (%r15)
movss 0xc(%rbx), %xmm0
movss %xmm0, 0x8(%r15)
leaq 0x19c(%rbx), %rsi
movss 0x15869(%rip), %xmm0    # 0x4ef2c
leaq 0x84(%rsp), %r13
movq %r15, %rdi
movq %rsi, 0x8(%rsp)
movq %r13, %rdx
callq 0x19940
leaq 0x90(%rsp), %rbp
pushq $0x9
popq %r14
leaq 0x20(%rsp), %r12
movq %rbx, %r9
subq $0x8, %rsp
movq %rbp, %rdi
movq %r15, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
movq %r13, %r8
pushq $0x6000001              # imm = 0x6000001
movq 0x2cef4(%rip), %rax     # 0x66600
callq *0x60(%rax)
addq $0x10, %rsp
movq %r14, %rcx
movq %r12, %rdi
movq %rbp, %rsi
rep  movsq (%rsi), %es:(%rdi)
movq 0x60(%rsp), %r9
testq %r9, %r9
je 0x39815
cmpl $0x0, 0x27c(%r9)
je 0x3977a
testb $0x4, 0x11c(%r9)
jne 0x3977a
movq 0x2b0(%rbx), %rdx
movl 0x280(%rbx), %eax
movq %r9, %rdi
movq %rbx, %rsi
movq 0x8(%rsp), %rcx
leaq 0x2c(%rsp), %r8
movq 0x2d003(%rip), %r9      # 0x66768
pushq $0x1e
pushq $0x4
pushq $0x1
pushq %rax
callq 0x19260
addq $0x20, %rsp
movq 0x60(%rsp), %r9
testb $0x4, 0xc8(%r9)
jne 0x3978b
cmpq $0x0, 0x58(%r9)
je 0x397a8
movsd 0x2c(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
movss 0x34(%rsp), %xmm0
movss %xmm0, 0x18(%rsp)
jmp 0x396ef
movl 0x140(%rbx), %eax
testl %eax, %eax
jns 0x39815
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, 0x140(%rbx)
pushq $0x3
popq %rdi
movq 0x2ce39(%rip), %r14     # 0x66600
callq *0xc8(%r14)
pushq $0xf
popq %rdi
callq *0xc8(%r14)
movl 0x4(%rsp), %edi
callq *0xc8(%r14)
leaq 0x2c(%rsp), %r15
movq %r15, %rdi
callq *0xf0(%r14)
leaq 0x38(%rsp), %rdi
callq *0xf8(%r14)
movl 0x3c(%rbx), %edi
callq *0xc8(%r14)
pushq $0x2
popq %rsi
movq %r15, %rdi
callq *0xb0(%r14)
movsd 0x2c(%rsp), %xmm0
movsd %xmm0, 0x1c(%rbx)
movss 0x34(%rsp), %xmm0
movss %xmm0, 0x24(%rbx)
movq 0x2d56e(%rip), %rax     # 0x66da0
movss 0x4(%rax), %xmm0
addss 0x15a51(%rip), %xmm0    # 0x4f290
movss %xmm0, 0x200(%rbx)
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq