// File: /workspace/github_c_makefile_star2_O3/QwazyWabbitWOS[P]lmctf60/p_view.c
// Function: SV_CalcGunOffset
void SV_CalcGunOffset (edict_t *ent)
{
	int		i;
	float	delta;

	// gun angles from bobbing
	ent->client->ps.gunangles[ROLL] = xyspeed * bobfracsin * 0.005;
	ent->client->ps.gunangles[YAW] = xyspeed * bobfracsin * 0.01;
	if (bobcycle & 1)
	{
		ent->client->ps.gunangles[ROLL] = -ent->client->ps.gunangles[ROLL];
		ent->client->ps.gunangles[YAW] = -ent->client->ps.gunangles[YAW];
	}

	ent->client->ps.gunangles[PITCH] = xyspeed * bobfracsin * 0.005;

	// gun angles from delta movement
	for (i=0 ; i<3 ; i++)
	{
		delta = ent->client->oldviewangles[i] - ent->client->ps.viewangles[i];
		if (delta > 180)
			delta -= 360;
		if (delta < -180)
			delta += 360;
		if (delta > 45)
			delta = 45;
		if (delta < -45)
			delta = -45;
		if (i == YAW)
			ent->client->ps.gunangles[ROLL] += 0.1*delta;
		ent->client->ps.gunangles[i] += 0.2 * delta;
	}

	// gun height
	VectorClear (ent->client->ps.gunoffset);
//	ent->ps->gunorigin[2] += bob;

	// gun_x / gun_y / gun_z are development tools
	for (i=0 ; i<3 ; i++)
	{
		ent->client->ps.gunoffset[i] += forward[i]*(gun_y->value);
		ent->client->ps.gunoffset[i] += right[i]*gun_x->value;
		ent->client->ps.gunoffset[i] += up[i]* (-gun_z->value);
	}
}

// Assembly:
movq 0x1ebf3(%rip), %rax     # 0x68f48
movss (%rax), %xmm0
movq 0x1e918(%rip), %rax     # 0x68c78
mulss (%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movq 0x58(%rdi), %rax
movlhps %xmm0, %xmm0            # xmm0 = xmm0[0,0]
mulpd 0x107e9(%rip), %xmm0    # 0x5ab60
cvtpd2ps %xmm0, %xmm0
movlpd %xmm0, 0x44(%rax)
movq 0x1e809(%rip), %rcx     # 0x68b90
testb $0x1, (%rcx)
je 0x4a39d
movapd 0xb93c(%rip), %xmm1     # 0x55cd0
xorpd %xmm0, %xmm1
movlpd %xmm1, 0x44(%rax)
shufps $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
movss %xmm0, 0x40(%rax)
xorl %ecx, %ecx
movss 0xf398(%rip), %xmm0     # 0x59748
movss 0xf38c(%rip), %xmm1     # 0x59744
movss 0x99a4(%rip), %xmm2     # 0x53d64
movss 0xf378(%rip), %xmm3     # 0x59740
movss 0xf37c(%rip), %xmm4     # 0x5974c
movss 0x10824(%rip), %xmm5    # 0x5abfc
movsd 0x9868(%rip), %xmm6     # 0x53c48
movsd 0xb828(%rip), %xmm7     # 0x55c10
movss 0xecc(%rax,%rcx,4), %xmm8
subss 0x1c(%rax,%rcx,4), %xmm8
movaps %xmm8, %xmm9
addss %xmm0, %xmm9
movaps %xmm1, %xmm10
cmpltss %xmm8, %xmm10
andps %xmm10, %xmm9
andnps %xmm8, %xmm10
orps %xmm9, %xmm10
movaps %xmm10, %xmm8
addss %xmm2, %xmm8
movaps %xmm10, %xmm9
cmpltss %xmm3, %xmm9
andps %xmm9, %xmm8
andnps %xmm10, %xmm9
orps %xmm8, %xmm9
movaps %xmm4, %xmm8
minss %xmm9, %xmm8
movaps %xmm5, %xmm9
maxss %xmm8, %xmm9
xorps %xmm8, %xmm8
cvtss2sd %xmm9, %xmm8
cmpq $0x1, %rcx
jne 0x4a47f
xorps %xmm9, %xmm9
cvtss2sd 0x48(%rax), %xmm9
movaps %xmm8, %xmm10
mulsd %xmm6, %xmm10
addsd %xmm9, %xmm10
xorps %xmm9, %xmm9
cvtsd2ss %xmm10, %xmm9
movss %xmm9, 0x48(%rax)
xorps %xmm9, %xmm9
cvtss2sd 0x40(%rax,%rcx,4), %xmm9
mulsd %xmm7, %xmm8
addsd %xmm9, %xmm8
cvtsd2ss %xmm8, %xmm8
movss %xmm8, 0x40(%rax,%rcx,4)
incq %rcx
cmpq $0x3, %rcx
jne 0x4a3e8
movl $0x0, 0x54(%rax)
movq $0x0, 0x4c(%rax)
movq 0x1df45(%rip), %rcx     # 0x68408
movq (%rcx), %rcx
movq 0x1e5b3(%rip), %rdx     # 0x68a80
movq (%rdx), %rdx
movq 0x1e5c1(%rip), %rsi     # 0x68a98
movq (%rsi), %rsi
xorl %edi, %edi
leaq 0x4eb75(%rip), %r8      # 0x99058
leaq 0x4eb5e(%rip), %r9      # 0x99048
leaq 0x4eb7f(%rip), %r10     # 0x99070
movss (%rdi,%r8), %xmm0
mulss 0x20(%rcx), %xmm0
addss 0x4c(%rax,%rdi), %xmm0
movss %xmm0, 0x4c(%rax,%rdi)
movss (%rdi,%r9), %xmm1
mulss 0x20(%rdx), %xmm1
addss %xmm0, %xmm1
movss %xmm1, 0x4c(%rax,%rdi)
movss (%rdi,%r10), %xmm0
mulss 0x20(%rsi), %xmm0
subss %xmm0, %xmm1
movss %xmm1, 0x4c(%rax,%rdi)
addq $0x4, %rdi
cmpq $0xc, %rdi
jne 0x4a4f1
retq