// File: /workspace/github_c_makefile_star2_O3/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 $0xe8, %rsp
movq %rdi, %rbx
movl 0x140(%rdi), %ebp
movq 0x2a0(%rdi), %rsi
testq %rsi, %rsi
je 0x3c951
leaq 0x19c(%rbx), %r14
movsd 0x19c(%rbx), %xmm0
leaq 0x80(%rsp), %r15
movsd %xmm0, (%r15)
movss 0x1a4(%rbx), %xmm0
movss %xmm0, 0x8(%r15)
leaq 0xe4(%rsi), %rdi
addq $0xfc, %rsi
movss 0x17b06(%rip), %xmm0    # 0x54400
leaq 0x90(%rsp), %r12
movq %r12, %rdx
callq 0x19760
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 0x18390
movq %r14, %rdi
movq %r15, %rsi
callq 0x18b70
testl %eax, %eax
jne 0x3c951
orb $-0x80, 0x143(%rbx)
movsd 0x4(%rbx), %xmm0
leaq 0x10(%rsp), %r15
movsd %xmm0, (%r15)
movss 0xc(%rbx), %xmm0
movss %xmm0, 0x8(%r15)
leaq 0x19c(%rbx), %rsi
movss 0x165b2(%rip), %xmm0    # 0x52f2c
leaq 0x2c(%rsp), %r12
movq %r15, %rdi
movq %rsi, 0x20(%rsp)
movq %r12, %rdx
callq 0x19760
movq 0x2bc6a(%rip), %r14     # 0x68600
subq $0x8, %rsp
leaq 0xa8(%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 0x38(%rsp), %rax
movl $0x9, %ecx
movq %rax, %rdi
movq %r13, %rsi
rep  movsq (%rsi), %es:(%rdi)
movq 0x40(%rax), %r9
testq %r9, %r9
je 0x3cb22
shrl $0x1f, %ebp
leal 0x4(,%rbp,4), %eax
movl %eax, 0xc(%rsp)
leaq 0xa0(%rsp), %r12
leaq 0x10(%rsp), %r13
leaq 0x2c(%rsp), %rbp
leaq 0x38(%rsp), %r15
cmpl $0x0, 0x27c(%r9)
je 0x3ca51
testb $0x4, 0x11c(%r9)
jne 0x3ca51
movq 0x2b0(%rbx), %rdx
movl 0x280(%rbx), %eax
movq %r9, %rdi
movq %rbx, %rsi
movq 0x20(%rsp), %rcx
leaq 0x44(%rsp), %r8
movq 0x2bd2c(%rip), %r9      # 0x68768
pushq $0x1e
pushq $0x4
pushq $0x1
pushq %rax
callq 0x190f0
addq $0x20, %rsp
movq 0x78(%rsp), %r9
testb $0x4, 0xc8(%r9)
jne 0x3ca62
cmpq $0x0, 0x58(%r9)
je 0x3cab6
movsd 0x44(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
movss 0x4c(%rsp), %xmm0
movss %xmm0, 0x18(%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 0x78(%rsp), %r9
testq %r9, %r9
jne 0x3ca04
jmp 0x3cb22
movl 0x140(%rbx), %eax
testl %eax, %eax
jns 0x3cb22
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, 0x140(%rbx)
movl $0x3, %edi
callq *0xc8(%r14)
movl $0xf, %edi
callq *0xc8(%r14)
movl 0xc(%rsp), %edi
callq *0xc8(%r14)
leaq 0x44(%rsp), %r15
movq %r15, %rdi
callq *0xf0(%r14)
leaq 0x50(%rsp), %rdi
callq *0xf8(%r14)
movl 0x3c(%rbx), %edi
callq *0xc8(%r14)
movq %r15, %rdi
movl $0x2, %esi
callq *0xb0(%r14)
movsd 0x44(%rsp), %xmm0
movsd %xmm0, 0x1c(%rbx)
movss 0x4c(%rsp), %xmm0
movss %xmm0, 0x24(%rbx)
movq 0x2c261(%rip), %rax     # 0x68da0
movss 0x4(%rax), %xmm0
addss 0x16744(%rip), %xmm0    # 0x53290
movss %xmm0, 0x200(%rbx)
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq