// File: /workspace/github_c_makefile_star2_O1/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), %ebp
movq 0x2a0(%rdi), %rsi
testq %rsi, %rsi
je 0x3d280
leaq 0x19c(%rbx), %r14
movss 0x19c(%rbx), %xmm0
leaq 0x78(%rsp), %r15
movss %xmm0, (%r15)
movss 0x1a0(%rbx), %xmm0
movss %xmm0, 0x4(%r15)
movss 0x1a4(%rbx), %xmm0
movss %xmm0, 0x8(%r15)
leaq 0xe4(%rsi), %rdi
addq $0xfc, %rsi
movss 0x181ed(%rip), %xmm0    # 0x55404
leaq 0x84(%rsp), %r12
movq %r12, %rdx
callq 0x19770
movss (%r12), %xmm0
subss 0x4(%rbx), %xmm0
movss %xmm0, 0x19c(%rbx)
movss 0x4(%r12), %xmm0
subss 0x8(%rbx), %xmm0
movss %xmm0, 0x1a0(%rbx)
movss 0x8(%r12), %xmm0
subss 0xc(%rbx), %xmm0
movss %xmm0, 0x1a4(%rbx)
movq %r14, %rdi
callq 0x18390
movq %r14, %rdi
movq %r15, %rsi
callq 0x18b70
testl %eax, %eax
jne 0x3d280
orb $-0x80, 0x143(%rbx)
movss 0x4(%rbx), %xmm0
leaq 0xc(%rsp), %r15
movss %xmm0, (%r15)
movss 0x8(%rbx), %xmm0
movss %xmm0, 0x4(%r15)
movss 0xc(%rbx), %xmm0
movss %xmm0, 0x8(%r15)
leaq 0x19c(%rbx), %rsi
movss 0x16c78(%rip), %xmm0    # 0x53f2c
leaq 0x6c(%rsp), %r12
movq %r15, %rdi
movq %rsi, 0x18(%rsp)
movq %r12, %rdx
callq 0x19770
movq 0x2c330(%rip), %r14     # 0x69600
subq $0x8, %rsp
leaq 0x98(%rsp), %r13
movq %r13, %rdi
movq %r15, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
movq %r12, %r8
movq %rbx, %r9
pushq $0x6000001              # imm = 0x6000001
callq *0x60(%r14)
addq $0x10, %rsp
leaq 0x20(%rsp), %rax
movl $0x9, %ecx
movq %rax, %rdi
movq %r13, %rsi
rep  movsq (%rsi), %es:(%rdi)
movq 0x40(%rax), %rdi
testq %rdi, %rdi
je 0x3d455
shrl $0x1f, %ebp
leal 0x4(,%rbp,4), %eax
movl %eax, 0x8(%rsp)
leaq 0x90(%rsp), %r12
leaq 0xc(%rsp), %r13
leaq 0x6c(%rsp), %rbp
leaq 0x20(%rsp), %r15
cmpl $0x0, 0x27c(%rdi)
je 0x3d381
testb $0x4, 0x11c(%rdi)
jne 0x3d381
movq 0x2b0(%rbx), %rdx
movl 0x280(%rbx), %eax
movq %rbx, %rsi
movq 0x18(%rsp), %rcx
leaq 0x2c(%rsp), %r8
movq 0x2c3f7(%rip), %r9      # 0x69768
pushq $0x1e
pushq $0x4
pushq $0x1
pushq %rax
callq 0x190f0
addq $0x20, %rsp
movq 0x60(%rsp), %r9
testb $0x4, 0xc8(%r9)
jne 0x3d397
cmpq $0x0, 0x58(%r9)
je 0x3d3e9
movss 0x2c(%rsp), %xmm0
movss %xmm0, 0xc(%rsp)
movq 0x30(%rsp), %rax
movq %rax, 0x10(%rsp)
subq $0x8, %rsp
movq %r12, %rdi
movq %r13, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
movq %rbp, %r8
pushq $0x6000001              # imm = 0x6000001
callq *0x60(%r14)
addq $0x10, %rsp
movl $0x9, %ecx
movq %r15, %rdi
movq %r12, %rsi
rep  movsq (%rsi), %es:(%rdi)
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
jne 0x3d33e
jmp 0x3d455
movl 0x140(%rbx), %eax
testl %eax, %eax
jns 0x3d455
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, 0x140(%rbx)
movl $0x3, %edi
callq *0xc8(%r14)
movl $0xf, %edi
callq *0xc8(%r14)
movl 0x8(%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)
movq %r15, %rdi
movl $0x2, %esi
callq *0xb0(%r14)
movss 0x2c(%rsp), %xmm0
movss %xmm0, 0x1c(%rbx)
movss 0x30(%rsp), %xmm0
movss %xmm0, 0x20(%rbx)
movss 0x34(%rsp), %xmm0
movss %xmm0, 0x24(%rbx)
movq 0x2c923(%rip), %rax     # 0x69da0
movss 0x4(%rax), %xmm0
addss 0x16e06(%rip), %xmm0    # 0x54290
movss %xmm0, 0x200(%rbx)
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq