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

	if (ent->s.modelindex != 255)
		return;		// not in the player model

	if (ent->movetype == MOVETYPE_NOCLIP)
		return;

	if ((ent->client->oldvelocity[2] < 0) && (ent->velocity[2] > ent->client->oldvelocity[2]) && (!ent->groundentity))
	{
		delta = ent->client->oldvelocity[2];
	}
	else
	{
		if (!ent->groundentity)
			return;
		delta = ent->velocity[2] - ent->client->oldvelocity[2];
	}
	delta = delta*delta * 0.0001;

	// never take falling damage if completely underwater
	if (ent->waterlevel == 3)
		return;
	if (ent->waterlevel == 2)
		delta *= 0.25;
	if (ent->waterlevel == 1)
		delta *= 0.5;

	if (delta < 1)
		return;

	if (delta < 15)
	{
		ent->s.event = EV_FOOTSTEP;
		return;
	}

	ent->client->fall_value = delta*0.5;
	if (ent->client->fall_value > 40)
		ent->client->fall_value = 40;
	ent->client->fall_time = level.time + FALL_TIME;

	if (delta > 30)
	{
		if (ent->health > 0)
		{
			if (delta >= 55)
				ent->s.event = EV_FALLFAR;
			else
				ent->s.event = EV_FALL;
		}
		ent->pain_debounce_time = level.time;	// no normal pain sound
		damage = (delta-30)/2;
		if (damage < 1)
			damage = 1;
		VectorSet (dir, 0, 0, 1);

		if (!deathmatch->value || !((int)dmflags->value & DF_NO_FALLING) )
			T_Damage (ent, world, world, dir, ent->s.origin, vec3_origin, damage, 0, 0, MOD_FALLING);
	}
	else
	{
		ent->s.event = EV_FALLSHORT;
		return;
	}
}

// Assembly:
cmpl $0xff, 0x28(%rdi)
jne 0x4acca
cmpl $0x1, 0x118(%rdi)
je 0x4acca
subq $0x18, %rsp
movq 0x58(%rdi), %rax
movss 0xee0(%rax), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm0, %xmm1
jbe 0x4ab3c
movss 0x1c8(%rdi), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x4ab3c
cmpq $0x0, 0x2b8(%rdi)
je 0x4ab59
cmpq $0x0, 0x2b8(%rdi)
je 0x4acc6
movss 0x1c8(%rdi), %xmm1
subss %xmm0, %xmm1
movaps %xmm1, %xmm0
movl 0x30c(%rdi), %ecx
cmpl $0x3, %ecx
je 0x4acc6
mulss %xmm0, %xmm0
cvtss2sd %xmm0, %xmm0
mulsd 0x10058(%rip), %xmm0    # 0x5abd0
cvtsd2ss %xmm0, %xmm0
cmpl $0x2, %ecx
jne 0x4ab89
mulss 0x88e7(%rip), %xmm0     # 0x53470
cmpl $0x1, %ecx
jne 0x4ab96
mulss 0x986a(%rip), %xmm0     # 0x54400
movss 0x838a(%rip), %xmm1     # 0x52f28
ucomiss %xmm0, %xmm1
ja 0x4acc6
movss 0x88a5(%rip), %xmm1     # 0x53454
ucomiss %xmm0, %xmm1
jbe 0x4abc0
movl $0x2, 0x50(%rdi)
jmp 0x4acc6
movss 0x9838(%rip), %xmm1     # 0x54400
mulss %xmm0, %xmm1
movss 0xb074(%rip), %xmm2     # 0x55c48
minss %xmm1, %xmm2
movss %xmm2, 0xea4(%rax)
movq 0x1e1b9(%rip), %rcx     # 0x68da0
movss 0x4(%rcx), %xmm1
movss 0xfff4(%rip), %xmm2     # 0x5abe8
addss %xmm1, %xmm2
movss %xmm2, 0xea0(%rax)
ucomiss 0x868d(%rip), %xmm0     # 0x53294
jbe 0x4acbf
cmpl $0x0, 0x254(%rdi)
jle 0x4ac28
ucomiss 0xfff3(%rip), %xmm0     # 0x5ac10
movl $0x5, %eax
sbbl $0x0, %eax
movl %eax, 0x50(%rdi)
movss %xmm1, 0x244(%rdi)
addss 0xffdc(%rip), %xmm0     # 0x5ac14
mulss 0x97c0(%rip), %xmm0     # 0x54400
cvttss2si %xmm0, %ecx
cmpl $0x2, %ecx
movl $0x1, %eax
cmovgel %ecx, %eax
movq $0x0, 0x8(%rsp)
movl $0x3f800000, 0x10(%rsp) # imm = 0x3F800000
movq 0x1e259(%rip), %rcx     # 0x68ec0
movq (%rcx), %rcx
movss 0x20(%rcx), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x4ac79
jnp 0x4ac8d
movq 0x1d998(%rip), %rcx     # 0x68618
movq (%rcx), %rcx
cvttss2si 0x20(%rcx), %ecx
testb $0x8, %cl
jne 0x4acc6
movq 0x1d8c4(%rip), %rcx     # 0x68558
movq (%rcx), %rdx
leaq 0x4(%rdi), %r8
xorl %r10d, %r10d
movq 0x1dac3(%rip), %r9      # 0x68768
leaq 0x8(%rsp), %rcx
movq %rdx, %rsi
pushq $0x16
pushq %r10
pushq %r10
pushq %rax
callq 0x190f0
addq $0x20, %rsp
jmp 0x4acc6
movl $0x3, 0x50(%rdi)
addq $0x18, %rsp
retq