// File: /workspace/github_c_makefile_star2_O2/QwazyWabbitWOS[P]lmctf60/p_view.c
// Function: SV_CalcBlend
void SV_CalcBlend (edict_t *ent)
{
	int		contents;
	vec3_t	vieworg;
	int		remaining;

	ent->client->ps.blend[0] = ent->client->ps.blend[1] = 
		ent->client->ps.blend[2] = ent->client->ps.blend[3] = 0;

	// add for contents
	VectorAdd (ent->s.origin, ent->client->ps.viewoffset, vieworg);
	contents = gi.pointcontents (vieworg);
	if (contents & (CONTENTS_LAVA|CONTENTS_SLIME|CONTENTS_WATER) )
		ent->client->ps.rdflags |= RDF_UNDERWATER;
	else
		ent->client->ps.rdflags &= ~RDF_UNDERWATER;

	if (contents & (CONTENTS_SOLID|CONTENTS_LAVA))
		SV_AddBlend (1.0, 0.3f, 0.0, 0.6f, ent->client->ps.blend);
	else if (contents & CONTENTS_SLIME)
		SV_AddBlend (0.0, 0.1f, 0.05f, 0.6f, ent->client->ps.blend);
	else if (contents & CONTENTS_WATER)
		SV_AddBlend (0.5, 0.3f, 0.2f, 0.4f, ent->client->ps.blend);

	// add for powerups
	if (ent->client->quad_framenum > level.framenum)
	{
		remaining = ent->client->quad_framenum - level.framenum;
		if (remaining == 30)	// beginning to fade
			gi.sound(ent, CHAN_ITEM, gi.soundindex("items/damage2.wav"), 1, ATTN_NORM, 0);
		if (remaining > 30 || (remaining & 4) )
			SV_AddBlend (0, 0, 1, 0.08f, ent->client->ps.blend);
	}
	else if (ent->client->invincible_framenum > level.framenum)
	{
		remaining = ent->client->invincible_framenum - level.framenum;
		if (remaining == 30)	// beginning to fade
			gi.sound(ent, CHAN_ITEM, gi.soundindex("items/protect2.wav"), 1, ATTN_NORM, 0);
		if (remaining > 30 || (remaining & 4) )
			SV_AddBlend (1, 1, 0, 0.08f, ent->client->ps.blend);
	}
	else if (ent->client->enviro_framenum > level.framenum)
	{
		remaining = ent->client->enviro_framenum - level.framenum;
		if (remaining == 30)	// beginning to fade
			gi.sound(ent, CHAN_ITEM, gi.soundindex("items/airout.wav"), 1, ATTN_NORM, 0);
		if (remaining > 30 || (remaining & 4) )
			SV_AddBlend (0, 1, 0, 0.08f, ent->client->ps.blend);
	}
	else if (ent->client->breather_framenum > level.framenum)
	{
		remaining = ent->client->breather_framenum - level.framenum;
		if (remaining == 30)	// beginning to fade
			gi.sound(ent, CHAN_ITEM, gi.soundindex("items/airout.wav"), 1, ATTN_NORM, 0);
		if (remaining > 30 || (remaining & 4) )
			SV_AddBlend (0.4f, 1, 0.4f, 0.04f, ent->client->ps.blend);
	}

	// add for damage
	if (ent->client->damage_alpha > 0)
		SV_AddBlend (ent->client->damage_blend[0],ent->client->damage_blend[1]
		,ent->client->damage_blend[2], ent->client->damage_alpha, ent->client->ps.blend);

	if (ent->client->bonus_alpha > 0)
		SV_AddBlend (0.85f, 0.7f, 0.3f, ent->client->bonus_alpha, ent->client->ps.blend);

	// drop the damage value
	ent->client->damage_alpha -= 0.06f;
	if (ent->client->damage_alpha < 0)
		ent->client->damage_alpha = 0;

	// drop the bonus value
	ent->client->bonus_alpha -= 0.1f;
	if (ent->client->bonus_alpha < 0)
		ent->client->bonus_alpha = 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movq 0x58(%rdi), %rax
xorps %xmm0, %xmm0
movups %xmm0, 0x60(%rax)
movsd 0x4(%rdi), %xmm0
movsd 0x28(%rax), %xmm1
addps %xmm0, %xmm1
leaq 0x8(%rsp), %rdi
movlps %xmm1, (%rdi)
movss 0xc(%rbx), %xmm0
addss 0x30(%rax), %xmm0
movss %xmm0, 0x8(%rdi)
movq 0x1fe76(%rip), %r14     # 0x66600
callq *0x68(%r14)
xorl %ecx, %ecx
testb $0x38, %al
setne %cl
movq 0x58(%rbx), %rdi
movl 0x74(%rdi), %edx
andl $-0x2, %edx
orl %edx, %ecx
movl %ecx, 0x74(%rdi)
testb $0x9, %al
je 0x467c9
addq $0x60, %rdi
movss 0x8774(%rip), %xmm0     # 0x4ef28
movss 0x103ec(%rip), %xmm1    # 0x56ba8
movss 0x103dc(%rip), %xmm3    # 0x56ba0
xorps %xmm2, %xmm2
jmp 0x46816
testb $0x10, %al
jne 0x467f7
testb $0x20, %al
je 0x4681b
addq $0x60, %rdi
movss 0x9c23(%rip), %xmm0     # 0x50400
movss 0x103c3(%rip), %xmm1    # 0x56ba8
movss 0xb7bb(%rip), %xmm2     # 0x51fa8
movss 0x103cb(%rip), %xmm3    # 0x56bc0
jmp 0x46816
addq $0x60, %rdi
movss 0x8a8d(%rip), %xmm1     # 0x4f290
movss 0x103b1(%rip), %xmm2    # 0x56bbc
movss 0x1038d(%rip), %xmm3    # 0x56ba0
xorps %xmm0, %xmm0
callq 0x18dd0
movq 0x2057e(%rip), %rax     # 0x66da0
cvtsi2ssl (%rax), %xmm0
movq 0x58(%rbx), %rax
movss 0xf04(%rax), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x468a4
subss %xmm0, %xmm1
cvttss2si %xmm1, %ebp
cmpl $0x1e, %ebp
jne 0x4686c
movq 0x20(%r14), %r15
leaq 0x103b8(%rip), %rdi     # 0x56c07
callq *0x48(%r14)
pushq $0x3
popq %rsi
movss 0x86ca(%rip), %xmm0     # 0x4ef28
xorps %xmm2, %xmm2
movq %rbx, %rdi
movl %eax, %edx
movaps %xmm0, %xmm1
callq *%r15
cmpl $0x1f, %ebp
setl %al
testb $0x4, %bpl
sete %cl
testb %cl, %al
jne 0x46a10
movq 0x58(%rbx), %rdi
addq $0x60, %rdi
movss 0x8697(%rip), %xmm2     # 0x4ef28
movss 0x1032f(%rip), %xmm3    # 0x56bc8
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
jmp 0x46a0b
movss 0xf08(%rax), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x4691e
subss %xmm0, %xmm1
cvttss2si %xmm1, %ebp
cmpl $0x1e, %ebp
jne 0x468e6
movq 0x20(%r14), %r15
leaq 0x10350(%rip), %rdi     # 0x56c19
callq *0x48(%r14)
pushq $0x3
popq %rsi
movss 0x8650(%rip), %xmm0     # 0x4ef28
xorps %xmm2, %xmm2
movq %rbx, %rdi
movl %eax, %edx
movaps %xmm0, %xmm1
callq *%r15
cmpl $0x1f, %ebp
setl %al
testb $0x4, %bpl
sete %cl
testb %cl, %al
jne 0x46a10
movq 0x58(%rbx), %rdi
addq $0x60, %rdi
movss 0x861d(%rip), %xmm0     # 0x4ef28
movss 0x102b5(%rip), %xmm3    # 0x56bc8
xorps %xmm2, %xmm2
movaps %xmm0, %xmm1
jmp 0x46a0b
movss 0xf10(%rax), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x46995
subss %xmm0, %xmm1
cvttss2si %xmm1, %ebp
cmpl $0x1e, %ebp
jne 0x46960
movq 0x20(%r14), %r15
leaq 0xc344(%rip), %rdi      # 0x52c87
callq *0x48(%r14)
pushq $0x3
popq %rsi
movss 0x85d6(%rip), %xmm0     # 0x4ef28
xorps %xmm2, %xmm2
movq %rbx, %rdi
movl %eax, %edx
movaps %xmm0, %xmm1
callq *%r15
cmpl $0x1f, %ebp
setl %al
testb $0x4, %bpl
sete %cl
testb %cl, %al
jne 0x46a10
movq 0x58(%rbx), %rdi
addq $0x60, %rdi
movss 0x85a3(%rip), %xmm1     # 0x4ef28
movss 0x1023b(%rip), %xmm3    # 0x56bc8
xorps %xmm0, %xmm0
xorps %xmm2, %xmm2
jmp 0x46a0b
movss 0xf0c(%rax), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x46a10
subss %xmm0, %xmm1
cvttss2si %xmm1, %ebp
cmpl $0x1e, %ebp
jne 0x469d7
movq 0x20(%r14), %r15
leaq 0xc2cd(%rip), %rdi      # 0x52c87
callq *0x48(%r14)
pushq $0x3
popq %rsi
movss 0x855f(%rip), %xmm0     # 0x4ef28
xorps %xmm2, %xmm2
movq %rbx, %rdi
movl %eax, %edx
movaps %xmm0, %xmm1
callq *%r15
cmpl $0x1f, %ebp
setl %al
testb $0x4, %bpl
sete %cl
testb %cl, %al
jne 0x46a10
movq 0x58(%rbx), %rdi
addq $0x60, %rdi
movss 0x8530(%rip), %xmm1     # 0x4ef28
movss 0x101c0(%rip), %xmm0    # 0x56bc0
movss 0x101bc(%rip), %xmm3    # 0x56bc4
movaps %xmm0, %xmm2
callq 0x18dd0
movq 0x58(%rbx), %rdi
movss 0xea8(%rdi), %xmm3
xorps %xmm0, %xmm0
ucomiss %xmm0, %xmm3
jbe 0x46a4c
movss 0xeb0(%rdi), %xmm0
movss 0xeb4(%rdi), %xmm1
movss 0xeb8(%rdi), %xmm2
addq $0x60, %rdi
callq 0x18dd0
xorps %xmm0, %xmm0
movq 0x58(%rbx), %rdi
movss 0xeac(%rdi), %xmm3
ucomiss %xmm0, %xmm3
jbe 0x46a86
addq $0x60, %rdi
movss 0x10167(%rip), %xmm0    # 0x56bcc
movss 0x89fb(%rip), %xmm1     # 0x4f468
movss 0x10133(%rip), %xmm2    # 0x56ba8
callq 0x18dd0
movq 0x58(%rbx), %rdi
movss 0xeac(%rdi), %xmm3
movss 0xea8(%rdi), %xmm0
unpcklps %xmm3, %xmm0            # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
addps 0x100c8(%rip), %xmm0    # 0x56b60
xorps %xmm1, %xmm1
maxps %xmm0, %xmm1
movlps %xmm1, 0xea8(%rdi)
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq