// File: /workspace/github_c_makefile_star2_O2/QwazyWabbitWOS[P]lmctf60/p_weapon.c
// Function: fire_hook
edict_t *fire_hook (edict_t *self, vec3_t start, vec3_t dir, int speed)
{
	edict_t	*bolt;
	trace_t	tr;

	VectorNormalize (dir);

	bolt = G_Spawn();
	VectorCopy (start, bolt->s.origin);
	VectorCopy (start, bolt->s.old_origin);
	vectoangles (dir, bolt->s.angles);
	bolt->s.angles[PITCH] += 90;
	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/ghook/tris.md2");
//	bolt->s.sound = gi.soundindex ("weapons/grapple/grfire.wav");
	bolt->owner = self;
	bolt->touch = hook_touch;
	bolt->die = hook_die;
	bolt->nextthink = level.time + 1;
	bolt->think = Grapple_Bolt_Think;
	bolt->dmg = 2;
	bolt->takedamage = DAMAGE_YES;
	bolt->health = 59;	 // after 59 damage, hook destoyed
	gi.linkentity (bolt);


	//surt the muzzle flash code also causes a shotgun noise!!!!

		// send muzzle flash
//	gi.WriteByte (svc_muzzleflash);
//	gi.WriteShort (self-g_edicts);
//	gi.WriteByte (MZ_SHOTGUN | is_silenced);
//	gi.multicast (self->s.origin, MULTICAST_PVS);

	//surt can that be avoided?

	gi.sound(self, CHAN_AUTO, gi.soundindex("weapons/grapple/grfire.wav"), 0.8f, ATTN_NORM, 0);
//	gi.dprintf("Played grapple sound.\n");

//	bolt->s.sound = gi.soundindex ("weapons/grapple/grfire.wav");
//surt the above works, but sounds bad
	/*
	if (self->client)
		check_dodge (self, bolt->s.origin, dir, speed);
	*/

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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %ecx, %ebp
movq %rdx, %r14
movq %rsi, %r13
movq %rdi, %r12
movq %rdx, %rdi
callq 0x183c0
callq 0x198d0
movq %rax, %rbx
movss (%r13), %xmm0
leaq 0x4(%rax), %r15
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 0x19240
movss 0x10(%rbx), %xmm0
addss 0xa0cf(%rip), %xmm0     # 0x55404
movss %xmm0, 0x10(%rbx)
cvtsi2ss %ebp, %xmm0
leaq 0x1c0(%rbx), %rsi
movq %r14, %rdi
callq 0x18a70
movl $0x8, 0x118(%rbx)
movabsq $0x600000300000002, %rax # imm = 0x600000300000002
movq %rax, 0x108(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0xcc(%rbx)
andq $0x0, 0xdc(%rbx)
movq 0x1b27f(%rip), %rbp     # 0x66600
leaq 0xbc04(%rip), %rdi      # 0x56f8c
callq *0x40(%rbp)
movl %eax, 0x28(%rbx)
movq %r12, 0x110(%rbx)
movq 0x1b73c(%rip), %rax     # 0x66ad8
movq %rax, 0x220(%rbx)
movq 0x1b9e6(%rip), %rax     # 0x66d90
movq %rax, 0x238(%rbx)
movq 0x1b9e8(%rip), %rax     # 0x66da0
movss 0x4(%rax), %xmm0
addss 0x3b63(%rip), %xmm0     # 0x4ef28
movss %xmm0, 0x200(%rbx)
movq 0x1baf4(%rip), %rax     # 0x66ec8
movq %rax, 0x210(%rbx)
movabsq $0x200000001, %rax      # imm = 0x200000001
movq %rax, 0x27c(%rbx)
movl $0x3b, 0x254(%rbx)
movq %rbx, %rdi
callq *0x90(%rbp)
movq 0x20(%rbp), %r13
leaq 0xbba0(%rip), %rdi      # 0x56faa
callq *0x48(%rbp)
movss 0x404b(%rip), %xmm0     # 0x4f460
xorps %xmm2, %xmm2
movq %r12, %rdi
xorl %esi, %esi
movl %eax, %edx
movss 0x3b01(%rip), %xmm1     # 0x4ef28
callq *%r13
leaq 0x4(%r12), %rsi
movl $0x6000003, (%rsp)      # imm = 0x6000003
leaq 0x10(%rsp), %r13
movq %r13, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
movq %r15, %r8
movq %r12, %r9
callq *0x60(%rbp)
movss 0x3ad5(%rip), %xmm0     # 0x4ef28
ucomiss 0x8(%r13), %xmm0
jbe 0x4b485
movq 0x50(%rsp), %r12
movss 0x47d5(%rip), %xmm0     # 0x4fc3c
movq %r15, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x19940
movq %rbx, %rdi
movq %r12, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq *0x220(%rbx)
movq %rbx, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq