// File: /workspace/github_c_makefile_star2_O2/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 0x46c7d
cmpl $0x1, 0x118(%rdi)
je 0x46c7d
subq $0x18, %rsp
movq 0x58(%rdi), %rax
movss 0xee0(%rax), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm0, %xmm1
jbe 0x46af9
movss 0x1c8(%rdi), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x46af9
cmpq $0x0, 0x2b8(%rdi)
je 0x46b16
cmpq $0x0, 0x2b8(%rdi)
je 0x46c79
movss 0x1c8(%rdi), %xmm1
subss %xmm0, %xmm1
movaps %xmm1, %xmm0
movl 0x30c(%rdi), %ecx
cmpl $0x3, %ecx
je 0x46c79
mulss %xmm0, %xmm0
cvtss2sd %xmm0, %xmm0
mulsd 0x1005b(%rip), %xmm0    # 0x56b90
cvtsd2ss %xmm0, %xmm0
cmpl $0x2, %ecx
jne 0x46b46
mulss 0x892a(%rip), %xmm0     # 0x4f470
cmpl $0x1, %ecx
jne 0x46b53
mulss 0x98ad(%rip), %xmm0     # 0x50400
movss 0x83cd(%rip), %xmm1     # 0x4ef28
ucomiss %xmm0, %xmm1
ja 0x46c79
movss 0x88e8(%rip), %xmm1     # 0x4f454
ucomiss %xmm0, %xmm1
jbe 0x46b7d
movl $0x2, 0x50(%rdi)
jmp 0x46c79
movss 0x987b(%rip), %xmm1     # 0x50400
mulss %xmm0, %xmm1
movss 0xb097(%rip), %xmm2     # 0x51c28
minss %xmm1, %xmm2
movss %xmm2, 0xea4(%rax)
movq 0x201fc(%rip), %rcx     # 0x66da0
movss 0x4(%rcx), %xmm1
movss 0xfff7(%rip), %xmm2     # 0x56ba8
addss %xmm1, %xmm2
movss %xmm2, 0xea0(%rax)
ucomiss 0x86d0(%rip), %xmm0     # 0x4f294
jbe 0x46c72
cmpl $0x0, 0x254(%rdi)
jle 0x46be3
ucomiss 0xfff6(%rip), %xmm0     # 0x56bd0
pushq $0x5
popq %rax
sbbl $0x0, %eax
movl %eax, 0x50(%rdi)
addss 0xffe9(%rip), %xmm0     # 0x56bd4
mulss 0x980d(%rip), %xmm0     # 0x50400
cvttss2si %xmm0, %ecx
cmpl $0x2, %ecx
pushq $0x1
popq %rax
cmovgel %ecx, %eax
movss %xmm1, 0x244(%rdi)
andq $0x0, 0x8(%rsp)
movl $0x3f800000, 0x10(%rsp) # imm = 0x3F800000
movq 0x202a3(%rip), %rcx     # 0x66ec0
movq (%rcx), %rcx
movss 0x20(%rcx), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x46c2f
jnp 0x46c43
movq 0x1f9e2(%rip), %rcx     # 0x66618
movq (%rcx), %rcx
cvttss2si 0x20(%rcx), %ecx
testb $0x8, %cl
jne 0x46c79
movq 0x1f90e(%rip), %rcx     # 0x66558
movq (%rcx), %rdx
leaq 0x4(%rdi), %r8
movq 0x1fb10(%rip), %r9      # 0x66768
leaq 0x8(%rsp), %rcx
movq %rdx, %rsi
pushq $0x16
pushq $0x0
pushq $0x0
pushq %rax
callq 0x19260
addq $0x20, %rsp
jmp 0x46c79
movl $0x3, 0x50(%rdi)
addq $0x18, %rsp
retq