// File: /workspace/github_c_makefile_star2_O1/QwazyWabbitWOS[P]lmctf60/g_weapon.c
// Function: fire_blaster
void fire_blaster (edict_t *self, vec3_t start, vec3_t dir, int damage, int speed, int effect, qboolean hyper)
{
	edict_t	*bolt;
	trace_t	tr;

	VectorNormalize (dir);


#ifdef WEAP_BALANCE_OK	
	
	// Only change hand blaster effect
	if (((int)ctfflags->value & CTF_WEAP_BALANCE) &&
		effect & EF_BLASTER)
	{
		bolt = G_Spawn();
		bolt->svflags = SVF_DEADMONSTER;
		VectorCopy (start, bolt->s.origin);
		vectoangles (dir, bolt->s.angles);
		VectorScale (dir, speed, bolt->velocity);
		VectorAdd (start, bolt->velocity, bolt->s.old_origin);
		bolt->clipmask = MASK_SHOT;

		bolt->movetype = MOVETYPE_FLYMISSILE;
		bolt->solid = SOLID_BBOX;
		bolt->s.renderfx |= RF_BEAM | RF_FULLBRIGHT;
		bolt->s.modelindex = 1;			// must be non-zero
		bolt->owner = self;

		// set the beam diameter
		bolt->s.frame = 3;

		// set the color
		if (self->client && self->client->ctf.teamnum == CTF_TEAM_RED)		// on red team
			bolt->s.skinnum = 0xf2f2f0f0;		// red
		else												// on blue team
			bolt->s.skinnum = 0xf3f3f1f1;		// sorta blue


		VectorSet (bolt->mins, -8, -8, -8);
		VectorSet (bolt->maxs, 8, 8, 8);

		bolt->touch = blaster_touch;
		bolt->nextthink = level.time + 4;
		bolt->think = G_FreeEdict;
		bolt->dmg = damage;
		bolt->svflags |= SVF_DEADMONSTER;
		
		gi.linkentity (bolt);

		//bolt->spawnflags |= 0x80000001;
		//bolt->svflags &= ~SVF_NOCLIENT;
		if (self->client)
			check_dodge (self, bolt->s.origin, dir, speed);

		tr = gi.trace (self->s.origin, NULL, NULL, bolt->s.origin, bolt, MASK_SHOT);
		if (tr.fraction < 1.0)
		{
			VectorMA (bolt->s.origin, -10, dir, bolt->s.origin);
			bolt->touch (bolt, tr.ent, NULL, NULL);
		}

		return;
	}
#endif


	bolt = G_Spawn();
	bolt->svflags = SVF_DEADMONSTER;
	// yes, I know it looks weird that projectiles are deadmonsters
	// what this means is that when prediction is used against the object
	// (blaster/hyperblaster shots), the player won't be solid clipped against
	// the object.  Right now trying to run into a firing hyperblaster
	// is very jerky since you are predicted 'against' the shots.
	VectorCopy (start, bolt->s.origin);
	VectorCopy (start, bolt->s.old_origin);
	vectoangles (dir, bolt->s.angles);
	VectorScale (dir, speed, bolt->velocity);
	bolt->movetype = MOVETYPE_FLYMISSILE;
	bolt->clipmask = MASK_SHOT;
	bolt->solid = SOLID_BBOX;
	bolt->s.effects |= effect;
	VectorClear (bolt->mins);
	VectorClear (bolt->maxs);
	bolt->s.modelindex = gi.modelindex ("models/objects/laser/tris.md2");
	bolt->s.sound = gi.soundindex ("misc/lasfly.wav");
	bolt->owner = self;
	bolt->touch = blaster_touch;
	bolt->nextthink = level.time + 2;
	bolt->think = G_FreeEdict;
	bolt->dmg = damage;
	bolt->classname = "bolt";
	if (hyper)
		bolt->spawnflags = 1;
	gi.linkentity (bolt);

	if (self->client)
		check_dodge (self, bolt->s.origin, dir, speed);

	tr = gi.trace (self->s.origin, NULL, NULL, bolt->s.origin, bolt, MASK_SHOT);
	if (tr.fraction < 1.0)
	{
		VectorMA (bolt->s.origin, -10, dir, bolt->s.origin);
		bolt->touch (bolt, tr.ent, NULL, NULL);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %r9d, 0x8(%rsp)
movl %r8d, %ebp
movl %ecx, 0xc(%rsp)
movq %rdx, %r14
movq %rsi, %r13
movq %rdi, %r12
movq %rdx, %rdi
callq 0x18390
callq 0x19710
movq %rax, %r15
movq %rax, %rbx
movl $0x2, 0xc8(%rax)
movss (%r13), %xmm0
movss %xmm0, 0x4(%rax)
movss 0x4(%r13), %xmm0
movss %xmm0, 0x8(%rax)
movss 0x8(%r13), %xmm0
movss %xmm0, 0xc(%rax)
movss (%r13), %xmm0
movss %xmm0, 0x1c(%rax)
movss 0x4(%r13), %xmm0
movss %xmm0, 0x20(%rax)
movss 0x8(%r13), %xmm0
movss %xmm0, 0x24(%rax)
leaq 0x10(%rax), %rsi
movq %r14, %rdi
callq 0x190d0
xorps %xmm0, %xmm0
cvtsi2ss %ebp, %xmm0
leaq 0x1c0(%r15), %rsi
movq %r14, %rdi
callq 0x189d0
movl $0x8, 0x118(%r15)
movabsq $0x600000300000002, %rax # imm = 0x600000300000002
movq %rax, 0x108(%r15)
movl 0x8(%rsp), %eax
orl %eax, 0x40(%r15)
xorps %xmm0, %xmm0
movups %xmm0, 0xcc(%r15)
movq $0x0, 0xdc(%r15)
movq 0x292b1(%rip), %rbp     # 0x69600
leaq 0x1a022(%rip), %rdi     # 0x5a378
callq *0x40(%rbp)
movl %eax, 0x28(%r15)
leaq 0x1743b(%rip), %rdi     # 0x5779f
callq *0x48(%rbp)
movl %eax, 0x4c(%r15)
movq %r12, 0x110(%r15)
movq 0x297e7(%rip), %rax     # 0x69b60
movq %rax, 0x220(%r15)
movq 0x29a19(%rip), %rax     # 0x69da0
movss 0x4(%rax), %xmm0
addss 0x140c4(%rip), %xmm0    # 0x54458
movss %xmm0, 0x200(%r15)
movq 0x2908c(%rip), %rax     # 0x69430
movq %rax, 0x210(%r15)
movl 0xc(%rsp), %eax
movl %eax, 0x280(%r15)
leaq 0x19fd9(%rip), %rax     # 0x5a396
movq %rax, 0x138(%r15)
cmpl $0x0, 0x90(%rsp)
je 0x403d8
movl $0x1, 0x140(%rbx)
addq $0x4, %r15
movq %rbx, %rdi
callq *0x90(%rbp)
cmpq $0x0, 0x58(%r12)
je 0x403f8
movq %r15, %rdi
movq %r14, %rsi
callq 0x40464
addq $0x4, %r12
movl $0x6000003, (%rsp)      # imm = 0x6000003
leaq 0x10(%rsp), %r13
movq %r13, %rdi
movq %r12, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
movq %r15, %r8
movq %rbx, %r9
callq *0x60(%rbp)
movss 0x13b05(%rip), %xmm0    # 0x53f28
ucomiss 0x8(%r13), %xmm0
jbe 0x40455
movq 0x50(%rsp), %r12
movss 0x147d5(%rip), %xmm0    # 0x54c0c
movq %r15, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x19770
movq %rbx, %rdi
movq %r12, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq *0x220(%rbx)
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq