// File: /workspace/github_c_makefile_star2_O2/QwazyWabbitWOS[P]lmctf60/g_weapon.c
// Function: bfg_think
void bfg_think (edict_t *self)
{
	edict_t	*ent;
	edict_t	*ignore;
	vec3_t	point;
	vec3_t	dir;
	vec3_t	start;
	vec3_t	end;
	int		dmg;
	trace_t	tr;

	if (deathmatch->value)
		dmg = 5;
	else
		dmg = 10;

#ifdef WEAP_BALANCE_OK	
	if ((int)ctfflags->value & CTF_WEAP_BALANCE)
		dmg = 3; //don't burn the players so hard
#endif

	ent = NULL;
	while ((ent = findradius(ent, self->s.origin, 256)) != NULL)
	{
		if (ent == self)
			continue;

		if (ent == self->owner)
			continue;

		if (!ent->takedamage)
			continue;

		if (!(ent->svflags & SVF_MONSTER) && (!ent->client) && (strcmp(ent->classname, "misc_explobox") != 0))
			continue;

		VectorMA (ent->absmin, 0.5, ent->size, point);

		VectorSubtract (point, self->s.origin, dir);
		VectorNormalize (dir);

		ignore = self;
		VectorCopy (self->s.origin, start);
		VectorMA (start, 2048, dir, 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) && (tr.ent != self->owner))
				T_Damage (tr.ent, self, self->owner, dir, tr.endpos, vec3_origin, dmg, 1, DAMAGE_ENERGY, MOD_BFG_LASER);

			// if we hit something that's not a monster or player we're done
			if (!(tr.ent->svflags & SVF_MONSTER) && (!tr.ent->client))
			{
				gi.WriteByte (svc_temp_entity);
				gi.WriteByte (TE_LASER_SPARKS);
				gi.WriteByte (4);
				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);
		}

		gi.WriteByte (svc_temp_entity);
		gi.WriteByte (TE_BFG_LASER);
		gi.WritePosition (self->s.origin);
		gi.WritePosition (tr.endpos);
		gi.multicast (self->s.origin, MULTICAST_PHS);
	}

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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %rdi, %rbx
movq 0x297d5(%rip), %rax     # 0x66ec0
movq (%rax), %rax
xorps %xmm0, %xmm0
cmpeqss 0x20(%rax), %xmm0
movd %xmm0, %eax
andl $0x1, %eax
leal (%rax,%rax,4), %eax
addl $0x5, %eax
movq %rax, 0x28(%rsp)
leaq 0x4(%rdi), %rax
movq %rax, 0x10(%rsp)
leaq 0x54(%rsp), %rbp
xorl %r13d, %r13d
leaq 0x18(%rsp), %r15
movq %rsp, %r14
leaq 0x90(%rsp), %r12
movq %r13, %rdi
movq 0x10(%rsp), %rsi
movss 0x117ea(%rip), %xmm0    # 0x4ef24
callq 0x19a50
testq %rax, %rax
je 0x3d97f
movq %rax, %r13
cmpq %rbx, %rax
je 0x3d72a
cmpq 0x110(%rbx), %r13
je 0x3d72a
cmpl $0x0, 0x27c(%r13)
je 0x3d72a
testb $0x4, 0xc8(%r13)
jne 0x3d778
cmpq $0x0, 0x58(%r13)
je 0x3d95f
leaq 0xe4(%r13), %rdi
movq %r13, %rsi
addq $0xfc, %rsi
movss 0x12c6f(%rip), %xmm0    # 0x50400
leaq 0x30(%rsp), %rdx
callq 0x19940
movsd 0x30(%rsp), %xmm0
movsd 0x4(%rbx), %xmm1
subps %xmm1, %xmm0
movlps %xmm0, 0x18(%rsp)
movss 0x38(%rsp), %xmm0
subss 0xc(%rbx), %xmm0
movss %xmm0, 0x20(%rsp)
movq %r15, %rdi
callq 0x183c0
movsd 0x4(%rbx), %xmm0
movsd %xmm0, (%rsp)
movss 0xc(%rbx), %xmm0
movss %xmm0, 0x8(%rsp)
movq %r14, %rdi
movss 0x11745(%rip), %xmm0    # 0x4ef2c
movq %r15, %rsi
leaq 0x3c(%rsp), %rdx
callq 0x19940
movq %rbx, %r9
subq $0x8, %rsp
movq %r12, %rdi
movq %r14, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
leaq 0x44(%rsp), %r8
pushq $0x6000001              # imm = 0x6000001
movq 0x28dea(%rip), %rax     # 0x66600
callq *0x60(%rax)
addq $0x10, %rsp
pushq $0x9
popq %rcx
leaq 0x48(%rsp), %rdi
movq %r12, %rsi
rep  movsq (%rsi), %es:(%rdi)
movq 0x88(%rsp), %r9
testq %r9, %r9
je 0x3d909
cmpl $0x0, 0x27c(%r9)
je 0x3d88a
testb $0x4, 0x11c(%r9)
jne 0x3d88a
movq 0x110(%rbx), %rdx
cmpq %rdx, %r9
je 0x3d88a
movq %r9, %rdi
movq %rbx, %rsi
movq %r15, %rcx
movq %rbp, %r8
movq 0x28ef9(%rip), %r9      # 0x66768
pushq $0xc
pushq $0x4
pushq $0x1
pushq 0x40(%rsp)
callq 0x19260
addq $0x20, %rsp
movq 0x88(%rsp), %r9
testb $0x4, 0xc8(%r9)
jne 0x3d89b
cmpq $0x0, 0x58(%r9)
je 0x3d8b7
movsd 0x54(%rsp), %xmm0
movsd %xmm0, (%rsp)
movss 0x5c(%rsp), %xmm0
movss %xmm0, 0x8(%rsp)
jmp 0x3d7f7
pushq $0x3
popq %rdi
movq 0x28d3f(%rip), %r14     # 0x66600
callq *0xc8(%r14)
pushq $0xf
popq %rdi
callq *0xc8(%r14)
pushq $0x4
popq %rdi
callq *0xc8(%r14)
movq %rbp, %rdi
callq *0xf0(%r14)
leaq 0x60(%rsp), %rdi
callq *0xf8(%r14)
movl 0x3c(%rbx), %edi
callq *0xc8(%r14)
movq %rbp, %rdi
pushq $0x2
popq %rsi
callq *0xb0(%r14)
pushq $0x3
popq %rdi
movq 0x28ced(%rip), %r14     # 0x66600
callq *0xc8(%r14)
pushq $0x17
popq %rdi
callq *0xc8(%r14)
movq %rbp, %r15
movq 0x10(%rsp), %rbp
movq %rbp, %rdi
callq *0xf0(%r14)
movq %r15, %rdi
callq *0xf0(%r14)
movq %r14, %rax
movq %rbp, %rdi
movq %r15, %rbp
leaq 0x18(%rsp), %r15
movq %rsp, %r14
pushq $0x1
popq %rsi
callq *0xb0(%rax)
jmp 0x3d72a
movq 0x138(%r13), %rdi
leaq 0x16aa3(%rip), %rsi     # 0x54410
callq 0x18bc0
testl %eax, %eax
jne 0x3d72a
jmp 0x3d778
movq 0x2941a(%rip), %rax     # 0x66da0
movss 0x4(%rax), %xmm0
addss 0x118fd(%rip), %xmm0    # 0x4f290
movss %xmm0, 0x200(%rbx)
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq