// File: /workspace/github_c_makefile_star2_O2/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 0x20a3d(%rip), %rax     # 0x66f48
movss (%rax), %xmm0
movq 0x20762(%rip), %rax     # 0x66c78
mulss (%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movq 0x58(%rdi), %rax
movlhps %xmm0, %xmm0            # xmm0 = xmm0[0,0]
mulpd 0x10623(%rip), %xmm0    # 0x56b50
cvtpd2ps %xmm0, %xmm0
movlpd %xmm0, 0x44(%rax)
movq 0x20653(%rip), %rcx     # 0x66b90
testb $0x1, (%rcx)
je 0x46553
movapd 0xb766(%rip), %xmm1     # 0x51cb0
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 0xf1c2(%rip), %xmm0     # 0x55728
movss 0xf1b6(%rip), %xmm1     # 0x55724
movss 0x97ee(%rip), %xmm2     # 0x4fd64
movss 0xf1a2(%rip), %xmm3     # 0x55720
movss 0xf1a6(%rip), %xmm4     # 0x5572c
movss 0xf1aa(%rip), %xmm5     # 0x55738
movsd 0x96b2(%rip), %xmm6     # 0x4fc48
movsd 0xb652(%rip), %xmm7     # 0x51bf0
cmpq $0x3, %rcx
je 0x46658
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
cvtss2sd %xmm9, %xmm8
cmpq $0x1, %rcx
jne 0x46633
cvtss2sd 0x48(%rax), %xmm9
movaps %xmm8, %xmm10
mulsd %xmm6, %xmm10
addsd %xmm9, %xmm10
cvtsd2ss %xmm10, %xmm9
movss %xmm9, 0x48(%rax)
cvtss2sd 0x40(%rax,%rcx,4), %xmm9
mulsd %xmm7, %xmm8
addsd %xmm9, %xmm8
cvtsd2ss %xmm8, %xmm8
movss %xmm8, 0x40(%rax,%rcx,4)
incq %rcx
jmp 0x4659e
andl $0x0, 0x54(%rax)
andq $0x0, 0x4c(%rax)
movq 0x1fda0(%rip), %rcx     # 0x66408
movq (%rcx), %rcx
movq 0x2040e(%rip), %rdx     # 0x66a80
movq (%rdx), %rdx
movq 0x2041c(%rip), %rsi     # 0x66a98
movq (%rsi), %rsi
xorl %edi, %edi
leaq 0x50ad0(%rip), %r8      # 0x97158
leaq 0x50ab9(%rip), %r9      # 0x97148
leaq 0x50ada(%rip), %r10     # 0x97170
cmpq $0xc, %rdi
je 0x466e3
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
jmp 0x46696
retq