// File: /workspace/github_c_makefile_star2_O0/QwazyWabbitWOS[P]lmctf60/p_weapon.c
// Function: Weapon_Hook_Fire
void Weapon_Hook_Fire (edict_t *ent)
{
	vec3_t	offset, mins, maxs, start, forward, right, dir;
	float		*v;
	int speed;
	vec3_t	dest;

	v = tv(-15,-15,-15);
	_VectorCopy (v, mins);
	v = tv(15,15,15);
	_VectorCopy (v, maxs);

	ent->client->isfiring = 0; // We are only "firing" when we start

	if (ent->client->hookstate == 0)
	{
		VectorCopy(ent->client->v_angle, ent->client->hookangle);
	}

	// Set out ending point to our starting point
	AngleVectors (ent->client->v_angle, forward, right, NULL);
	VectorSet(offset, 8, 8, ent->viewheight-8);
	P_ProjectSource (ent->client, ent->s.origin, offset, forward, right, start);
	
	switch (ent->client->hookstate)
	{
	case 0: // Starting
		VectorScale (forward, -2, ent->client->kick_origin);
		ent->client->kick_angles[0] = -1;
		ent->client->hookstate++;
		ent->client->isfiring = 1;

		ent->client->hook = fire_hook (ent, start, forward, GRAPPLE_FIRE_HOOK_SPEED);

		//-bat.  Let's see this right away!
		Draw_Hook(ent, start, ent->client->hook->s.origin);

	case 1: // Moving out
		if (ent->client->hook)
			Draw_Hook(ent, start, ent->client->hook->s.origin);
		break;
	case 2: // Pulling us to the hook
		if (ent->client->hook)
		{
			if (ent->client->hook->hook_target)
			{
//				if ( 
//					(!ent->client->hook->hook_target->s.origin[0] == 0) && 
//					(!ent->client->hook->hook_target->s.origin[1] == 0) && 
//					(!ent->client->hook->hook_target->s.origin[2] == 0)
//					)
//						VectorCopy(ent->client->hook->hook_target->s.origin, ent->client->hook->s.origin);
				//surt test code
				VectorAdd(ent->client->hook->hook_target->absmin, ent->client->hook->hook_offset, dest);
				VectorCopy(dest, ent->client->hook->s.origin);

			}
			Draw_Hook(ent, start, ent->client->hook->s.origin);
			VectorSubtract(ent->client->hook->s.origin, start, dir);
			speed = VectorLength(dir);

			if (!ent->client->hooklength)
				ent->client->hooklength = speed;

			//sprintf(message, "Speed %i, length %i\n", speed, ent->client->hooklength);
			//ctf_SafePrint(ent, PRINT_HIGH, message);

			ent->client->hooklength = speed;
			VectorNormalize(dir);

			if (speed > 120)
			{
#ifdef WEAP_BALANCE_OK	
				if ((int)ctfflags->value & CTF_WEAP_BALANCE)
					VectorScale(dir, GRAPPLE_PULL_BALANCED_SPEED, dir);
				else
					VectorScale(dir, GRAPPLE_PULL_SPEED, dir);
#else
	   			VectorScale(dir, GRAPPLE_PULL_SPEED, dir);
#endif
				SV_AddGravity (ent); // Add gravity
			}
			else if (speed > 100)
			{
				VectorScale(dir, speed*5, dir);
			}
			else if (speed > 80)
			{
				VectorScale(dir, speed*4, dir);
			}
			else if (speed > 40)
			{
				VectorScale(dir, speed*3, dir);
			}
			else if (speed > 20)
			{
				VectorScale(dir, speed*2, dir);
			}
			else if (speed > 10)
			{
				VectorScale(dir, speed*1, dir);
			}

			VectorCopy (dir, ent->velocity);
			VectorCopy (ent->velocity, ent->client->oldvelocity); // This prevents falling damage

			//ctf_SafePrint(ent, PRINT_HIGH, "Hook in state 2\n");
		}
		else
			ent->client->hookstate = 0;
		break;
	default: //bug
		ctf_hook_abort(ent);
		break;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movss 0x5105(%rip), %xmm2     # 0x7029c
movaps %xmm2, %xmm0
movaps %xmm2, %xmm1
callq 0x19740
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0x19c40
movss 0x50dd(%rip), %xmm2     # 0x70298
movaps %xmm2, %xmm0
movaps %xmm2, %xmm1
callq 0x19740
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rdi
leaq -0x2c(%rbp), %rsi
callq 0x19c40
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl $0x0, 0xf70(%rax)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
cmpl $0x0, 0xf40(%rax)
jne 0x6b25a
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movss 0xebc(%rax), %xmm0
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movss %xmm0, 0xf50(%rax)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movss 0xec0(%rax), %xmm0
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movss %xmm0, 0xf54(%rax)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movss 0xec4(%rax), %xmm0
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movss %xmm0, 0xf58(%rax)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rdi
addq $0xebc, %rdi            # imm = 0xEBC
xorl %eax, %eax
movl %eax, %ecx
leaq -0x44(%rbp), %rsi
movq %rsi, -0x90(%rbp)
leaq -0x50(%rbp), %rdx
movq %rdx, -0x88(%rbp)
callq 0x183e0
movq -0x90(%rbp), %rcx
movq -0x88(%rbp), %r8
movl $0x41000000, -0x14(%rbp) # imm = 0x41000000
movl $0x41000000, -0x10(%rbp) # imm = 0x41000000
movq -0x8(%rbp), %rax
movl 0x278(%rax), %eax
addl $-0x8, %eax
cvtsi2ss %eax, %xmm0
movss %xmm0, -0xc(%rbp)
movq -0x8(%rbp), %rsi
movq 0x58(%rsi), %rdi
addq $0x4, %rsi
leaq -0x14(%rbp), %rdx
leaq -0x38(%rbp), %r9
callq 0x67590
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl 0xf40(%rax), %eax
movl %eax, -0x7c(%rbp)
testl %eax, %eax
je 0x6b309
jmp 0x6b2ea
movl -0x7c(%rbp), %eax
subl $0x1, %eax
je 0x6b3b2
jmp 0x6b2f8
movl -0x7c(%rbp), %eax
subl $0x2, %eax
je 0x6b3e9
jmp 0x6b73f
leaq -0x44(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rsi
addq $0xe88, %rsi            # imm = 0xE88
movss 0x60f0(%rip), %xmm0     # 0x71414
callq 0x18a80
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movss 0x784f(%rip), %xmm0     # 0x72b88
movss %xmm0, 0xe7c(%rax)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl 0xf40(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0xf40(%rax)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl $0x1, 0xf70(%rax)
movq -0x8(%rbp), %rdi
leaq -0x38(%rbp), %rsi
leaq -0x44(%rbp), %rdx
movl $0x320, %ecx            # imm = 0x320
callq 0x198c0
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq %rcx, 0xf60(%rax)
movq -0x8(%rbp), %rdi
leaq -0x38(%rbp), %rsi
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq 0xf60(%rax), %rdx
addq $0x4, %rdx
callq 0x18b40
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
cmpq $0x0, 0xf60(%rax)
je 0x6b3e4
movq -0x8(%rbp), %rdi
leaq -0x38(%rbp), %rsi
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq 0xf60(%rax), %rdx
addq $0x4, %rdx
callq 0x18b40
jmp 0x6b748
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
cmpq $0x0, 0xf60(%rax)
je 0x6b72b
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq 0xf60(%rax), %rax
cmpq $0x0, 0x480(%rax)
je 0x6b515
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq 0xf60(%rax), %rax
movq 0x480(%rax), %rax
movss 0xe4(%rax), %xmm0
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq 0xf60(%rax), %rax
addss 0x490(%rax), %xmm0
movss %xmm0, -0x78(%rbp)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq 0xf60(%rax), %rax
movq 0x480(%rax), %rax
movss 0xe8(%rax), %xmm0
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq 0xf60(%rax), %rax
addss 0x494(%rax), %xmm0
movss %xmm0, -0x74(%rbp)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq 0xf60(%rax), %rax
movq 0x480(%rax), %rax
movss 0xec(%rax), %xmm0
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq 0xf60(%rax), %rax
addss 0x498(%rax), %xmm0
movss %xmm0, -0x70(%rbp)
movss -0x78(%rbp), %xmm0
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq 0xf60(%rax), %rax
movss %xmm0, 0x4(%rax)
movss -0x74(%rbp), %xmm0
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq 0xf60(%rax), %rax
movss %xmm0, 0x8(%rax)
movss -0x70(%rbp), %xmm0
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq 0xf60(%rax), %rax
movss %xmm0, 0xc(%rax)
movq -0x8(%rbp), %rdi
leaq -0x38(%rbp), %rsi
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq 0xf60(%rax), %rdx
addq $0x4, %rdx
callq 0x18b40
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq 0xf60(%rax), %rax
movss 0x4(%rax), %xmm0
subss -0x38(%rbp), %xmm0
movss %xmm0, -0x5c(%rbp)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq 0xf60(%rax), %rax
movss 0x8(%rax), %xmm0
subss -0x34(%rbp), %xmm0
movss %xmm0, -0x58(%rbp)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq 0xf60(%rax), %rax
movss 0xc(%rax), %xmm0
subss -0x30(%rbp), %xmm0
movss %xmm0, -0x54(%rbp)
leaq -0x5c(%rbp), %rdi
callq 0x194e0
cvttss2si %xmm0, %eax
movl %eax, -0x6c(%rbp)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
cmpl $0x0, 0xf5c(%rax)
jne 0x6b5c1
movl -0x6c(%rbp), %ecx
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl %ecx, 0xf5c(%rax)
movl -0x6c(%rbp), %ecx
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl %ecx, 0xf5c(%rax)
leaq -0x5c(%rbp), %rdi
callq 0x183d0
cmpl $0x78, -0x6c(%rbp)
jle 0x6b604
leaq -0x5c(%rbp), %rdi
leaq -0x5c(%rbp), %rsi
movss 0x4cb3(%rip), %xmm0     # 0x702a4
callq 0x18a80
movq -0x8(%rbp), %rdi
callq 0x18a60
jmp 0x6b6a2
cmpl $0x64, -0x6c(%rbp)
jle 0x6b621
leaq -0x5c(%rbp), %rdi
imull $0x5, -0x6c(%rbp), %eax
cvtsi2ss %eax, %xmm0
leaq -0x5c(%rbp), %rsi
callq 0x18a80
jmp 0x6b6a0
cmpl $0x50, -0x6c(%rbp)
jle 0x6b640
leaq -0x5c(%rbp), %rdi
movl -0x6c(%rbp), %eax
shll $0x2, %eax
cvtsi2ss %eax, %xmm0
leaq -0x5c(%rbp), %rsi
callq 0x18a80
jmp 0x6b69e
cmpl $0x28, -0x6c(%rbp)
jle 0x6b65d
leaq -0x5c(%rbp), %rdi
imull $0x3, -0x6c(%rbp), %eax
cvtsi2ss %eax, %xmm0
leaq -0x5c(%rbp), %rsi
callq 0x18a80
jmp 0x6b69c
cmpl $0x14, -0x6c(%rbp)
jle 0x6b67b
leaq -0x5c(%rbp), %rdi
movl -0x6c(%rbp), %eax
shll %eax
cvtsi2ss %eax, %xmm0
leaq -0x5c(%rbp), %rsi
callq 0x18a80
jmp 0x6b69a
cmpl $0xa, -0x6c(%rbp)
jle 0x6b698
leaq -0x5c(%rbp), %rdi
movl -0x6c(%rbp), %eax
shll $0x0, %eax
cvtsi2ss %eax, %xmm0
leaq -0x5c(%rbp), %rsi
callq 0x18a80
jmp 0x6b69a
jmp 0x6b69c
jmp 0x6b69e
jmp 0x6b6a0
jmp 0x6b6a2
movss -0x5c(%rbp), %xmm0
movq -0x8(%rbp), %rax
movss %xmm0, 0x1c0(%rax)
movss -0x58(%rbp), %xmm0
movq -0x8(%rbp), %rax
movss %xmm0, 0x1c4(%rax)
movss -0x54(%rbp), %xmm0
movq -0x8(%rbp), %rax
movss %xmm0, 0x1c8(%rax)
movq -0x8(%rbp), %rax
movss 0x1c0(%rax), %xmm0
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movss %xmm0, 0xed8(%rax)
movq -0x8(%rbp), %rax
movss 0x1c4(%rax), %xmm0
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movss %xmm0, 0xedc(%rax)
movq -0x8(%rbp), %rax
movss 0x1c8(%rax), %xmm0
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movss %xmm0, 0xee0(%rax)
jmp 0x6b73d
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl $0x0, 0xf40(%rax)
jmp 0x6b748
movq -0x8(%rbp), %rdi
callq 0x18690
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)