// File: /workspace/github_c_makefile_star2_O2/QwazyWabbitWOS[P]lmctf60/g_chase.c
// Function: UpdateChaseCam
void UpdateChaseCam(edict_t *ent)
{
	vec3_t goal, forward, right, angles;
	edict_t *targ;
	trace_t trace;
	int i;

	// is our chase target gone?
	if (!ent->client->chase_target->inuse
		|| ent->client->chase_target->client->resp.spectator) {
		edict_t *old = ent->client->chase_target;
		ChaseNext(ent);
		if (ent->client->chase_target == old) {
			ent->client->chase_target = NULL;
			ent->client->ps.pmove.pm_flags &= ~PMF_NO_PREDICTION;
			return;
		}
	}

	targ = ent->client->chase_target;
	VectorCopy(targ->client->v_angle, angles);
	VectorCopy (targ->s.origin, goal);
	goal[2] += targ->viewheight;

	vec3_t	targorigin;

	VectorCopy (goal, targorigin);

	AngleVectors (angles, forward, right, NULL);
	VectorMA (goal, 30, forward, goal);

	// trace from targorigin to final chase origin goal
	trace = gi.trace (targorigin, vec3_origin, vec3_origin, goal, targ, MASK_SOLID);

	// test for hit so we don't go out of the map!
	if (trace.fraction < 1) {
		vec3_t	temp;

		// we hit something, need to do a bit of avoidance

		// take real end point
		VectorCopy (trace.endpos, goal);

		// real dir vector
		VectorSubtract (goal, targorigin, temp);

		// scale it back bit more
		VectorMA (targorigin, 0.9f, temp, goal);
	}

	VectorCopy(goal, ent->s.origin);
	for (i=0 ; i<3 ; i++) {
		ent->client->ps.pmove.delta_angles[i] = ANGLE2SHORT(targ->client->v_angle[i] - ent->client->resp.cmd_angles[i]);
	}

	if (targ->deadflag) {
		ent->client->ps.viewangles[ROLL] = 40;
		ent->client->ps.viewangles[PITCH] = -15;
		ent->client->ps.viewangles[YAW] = targ->client->killer_yaw;
		ent->client->ps.pmove.pm_type = PM_DEAD;
	} else {
		VectorCopy(targ->client->v_angle, ent->client->ps.viewangles);
		VectorCopy(targ->client->v_angle, ent->client->v_angle);
		ent->client->ps.pmove.pm_type = PM_FREEZE;
	}

	ent->viewheight = 0;
	ent->client->ps.pmove.pm_flags |= PMF_NO_PREDICTION;
	gi.linkentity(ent);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rdi, %rbx
movq 0x58(%rdi), %rax
movq 0xf30(%rax), %r15
cmpl $0x0, 0x60(%r15)
je 0x22d17
movq 0x58(%r15), %rax
cmpl $0x0, 0xe04(%rax)
je 0x22d46
movq %rbx, %rdi
callq 0x19730
movq 0x58(%rbx), %rax
movq 0xf30(%rax), %r14
cmpq %r15, %r14
je 0x22d35
movq 0x58(%r14), %rax
jmp 0x22d49
andq $0x0, 0xf30(%rax)
andb $-0x41, 0x10(%rax)
jmp 0x22f3f
movq %r15, %r14
movsd 0xebc(%rax), %xmm0
leaq 0x28(%rsp), %rdi
movsd %xmm0, (%rdi)
movss 0xec4(%rax), %xmm0
movss %xmm0, 0x8(%rdi)
movsd 0x4(%r14), %xmm0
leaq 0x8(%rsp), %r15
movsd %xmm0, (%r15)
cvtsi2ssl 0x278(%r14), %xmm1
addss 0xc(%r14), %xmm1
movss %xmm1, 0x8(%r15)
leaq 0x18(%rsp), %r12
movsd %xmm0, (%r12)
movss %xmm1, 0x8(%r12)
leaq 0x44(%rsp), %r13
leaq 0x38(%rsp), %rdx
movq %r13, %rsi
xorl %ecx, %ecx
callq 0x183d0
movss 0x2c4da(%rip), %xmm0    # 0x4f294
movq %r15, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x19940
movq 0x43831(%rip), %rbp     # 0x66600
movl $0x3, (%rsp)
movq 0x4398b(%rip), %rcx     # 0x66768
leaq 0x50(%rsp), %r13
movq %r13, %rdi
movq %r12, %rsi
movq %rcx, %rdx
movq %r15, %r8
movq %r14, %r9
callq *0x60(%rbp)
movss 0x2c12c(%rip), %xmm0    # 0x4ef28
ucomiss 0x8(%r13), %xmm0
jbe 0x22e45
leaq 0x50(%rsp), %rsi
movsd 0xc(%rsi), %xmm0
movss 0x14(%rsi), %xmm1
leaq 0x8(%rsp), %rdx
movlps %xmm0, (%rdx)
movss %xmm1, 0x8(%rdx)
leaq 0x18(%rsp), %rdi
movsd (%rdi), %xmm2
subps %xmm2, %xmm0
movlps %xmm0, (%rsi)
subss 0x8(%rdi), %xmm1
movss %xmm1, 0x8(%rsi)
movss 0x2cf1c(%rip), %xmm0    # 0x4fd5c
callq 0x19940
movsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x4(%rbx)
movss 0x10(%rsp), %xmm0
movss %xmm0, 0xc(%rbx)
movq 0x58(%r14), %rcx
movq 0x58(%rbx), %rax
xorl %edx, %edx
movss 0x2cef3(%rip), %xmm0    # 0x4fd60
movss 0x2ceef(%rip), %xmm1    # 0x4fd64
cmpq $0x3, %rdx
je 0x22ea3
movss 0xebc(%rcx,%rdx,4), %xmm2
subss 0xdf8(%rax,%rdx,4), %xmm2
mulss %xmm0, %xmm2
divss %xmm1, %xmm2
cvttss2si %xmm2, %esi
movw %si, 0x14(%rax,%rdx,2)
incq %rdx
jmp 0x22e75
cmpl $0x0, 0x260(%r14)
je 0x22eca
movl $0x42200000, 0x24(%rax) # imm = 0x42200000
movl $0xc1700000, 0x1c(%rax) # imm = 0xC1700000
addq $0xe74, %rcx            # imm = 0xE74
pushq $0x2
popq %rdx
pushq $0x20
popq %rsi
jmp 0x22f20
movss 0xebc(%rcx), %xmm0
movss %xmm0, 0x1c(%rax)
movss 0xec0(%rcx), %xmm0
movss %xmm0, 0x20(%rax)
movss 0xec4(%rcx), %xmm0
movss %xmm0, 0x24(%rax)
movss 0xebc(%rcx), %xmm0
movss %xmm0, 0xebc(%rax)
movss 0xec0(%rcx), %xmm0
addq $0xec4, %rcx            # imm = 0xEC4
movss %xmm0, 0xec0(%rax)
pushq $0x4
popq %rdx
movl $0xec4, %esi            # imm = 0xEC4
movss (%rcx), %xmm0
movss %xmm0, (%rax,%rsi)
movl %edx, (%rax)
andl $0x0, 0x278(%rbx)
orb $0x40, 0x10(%rax)
movq %rbx, %rdi
callq *0x90(%rbp)
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq