// File: /workspace/github_c_makefile_star2_O1/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 0x18390
callq 0x19710
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 0x190d0
movss 0x10(%rbx), %xmm0
addss 0x9e22(%rip), %xmm0     # 0x5a214
movss %xmm0, 0x10(%rbx)
xorps %xmm0, %xmm0
cvtsi2ss %ebp, %xmm0
leaq 0x1c0(%rbx), %rsi
movq %r14, %rdi
callq 0x189d0
movl $0x8, 0x118(%rbx)
movabsq $0x600000300000002, %rax # imm = 0x600000300000002
movq %rax, 0x108(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0xcc(%rbx)
movq $0x0, 0xdc(%rbx)
movq 0x191bc(%rip), %rbp     # 0x69600
leaq 0xb831(%rip), %rdi      # 0x5bc7c
callq *0x40(%rbp)
movl %eax, 0x28(%rbx)
movq %r12, 0x110(%rbx)
movq 0x19679(%rip), %rax     # 0x69ad8
movq %rax, 0x220(%rbx)
movq 0x19923(%rip), %rax     # 0x69d90
movq %rax, 0x238(%rbx)
movq 0x19925(%rip), %rax     # 0x69da0
movss 0x4(%rax), %xmm0
addss 0x3aa0(%rip), %xmm0     # 0x53f28
movss %xmm0, 0x200(%rbx)
movq 0x19a31(%rip), %rax     # 0x69ec8
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 0xb7cd(%rip), %rdi      # 0x5bc9a
callq *0x48(%rbp)
movss 0x3f78(%rip), %xmm0     # 0x54450
xorps %xmm2, %xmm2
movq %r12, %rdi
xorl %esi, %esi
movl %eax, %edx
movss 0x3a3e(%rip), %xmm1     # 0x53f28
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 0x3a12(%rip), %xmm0     # 0x53f28
ucomiss 0x8(%r13), %xmm0
jbe 0x50548
movq 0x50(%rsp), %r12
movss 0x46e2(%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)
movq %rbx, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq