// File: /workspace/github_c_makefile_star2_O1/QwazyWabbitWOS[P]lmctf60/g_phys.c
// Function: SV_Physics_Step
void SV_Physics_Step (edict_t *ent)
{
	qboolean	wasonground;
	qboolean	hitsound = false;
	float		*vel;
	float		speed, newspeed, control;
	float		friction;
	edict_t		*groundentity;
	int			mask;

	// airborn monsters should always check for ground
#ifdef MONSTERS_OK
	if (!ent->groundentity)
		M_CheckGround (ent);
#endif
	groundentity = ent->groundentity;

	SV_CheckVelocity (ent);

	if (groundentity)
		wasonground = true;
	else
		wasonground = false;
		
	if (ent->avelocity[0] || ent->avelocity[1] || ent->avelocity[2])
		SV_AddRotationalFriction (ent);

	// add gravity except:
	//   flying monsters
	//   swimming monsters who are in the water
	if (! wasonground)
		if (!(ent->flags & FL_FLY))
			if (!((ent->flags & FL_SWIM) && (ent->waterlevel > 2)))
			{
				if (ent->velocity[2] < sv_gravity->value*-0.1)
					hitsound = true;
				if (ent->waterlevel == 0)
					SV_AddGravity (ent);
			}

	// friction for flying monsters that have been given vertical velocity
	if ((ent->flags & FL_FLY) && (ent->velocity[2] != 0))
	{
		speed = fabs(ent->velocity[2]);
		control = speed < sv_stopspeed ? sv_stopspeed : speed;
		friction = sv_friction/3;
		newspeed = speed - (FRAMETIME * control * friction);
		if (newspeed < 0)
			newspeed = 0;
		newspeed /= speed;
		ent->velocity[2] *= newspeed;
	}

	// friction for flying monsters that have been given vertical velocity
	if ((ent->flags & FL_SWIM) && (ent->velocity[2] != 0))
	{
		speed = fabs(ent->velocity[2]);
		control = speed < sv_stopspeed ? sv_stopspeed : speed;
		newspeed = speed - (FRAMETIME * control * sv_waterfriction * ent->waterlevel);
		if (newspeed < 0)
			newspeed = 0;
		newspeed /= speed;
		ent->velocity[2] *= newspeed;
	}

	if (ent->velocity[2] || ent->velocity[1] || ent->velocity[0])
	{
		// apply friction
		// let dead monsters who aren't completely onground slide
		if ((wasonground) || (ent->flags & (FL_SWIM|FL_FLY)))
			if (!(ent->health <= 0.0 && !M_CheckBottom(ent)))
			{
				vel = ent->velocity;
				speed = sqrtf(vel[0] * vel[0] + vel[1] * vel[1]);
				if (speed)
				{
					friction = sv_friction;

					control = speed < sv_stopspeed ? sv_stopspeed : speed;
					newspeed = speed - FRAMETIME*control*friction;

					if (newspeed < 0)
						newspeed = 0;
					newspeed /= speed;

					vel[0] *= newspeed;
					vel[1] *= newspeed;
				}
			}

		if (ent->svflags & SVF_MONSTER)
			mask = MASK_MONSTERSOLID;
		else
			mask = MASK_SOLID;
		SV_FlyMove (ent, FRAMETIME, mask);

		gi.linkentity (ent);
		G_TouchTriggers (ent);
		if (!ent->inuse)
			return;

		if (ent->groundentity)
			if (!wasonground)
				if (hitsound)
					gi.sound (ent, 0, gi.soundindex("world/land.wav"), 1, 1, 0);
	}

// regular thinking
	SV_RunThink (ent);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x2b8(%rdi), %r14
movq 0x30a9c(%rip), %rax     # 0x69970
movq (%rax), %rax
movl $0x70, %ecx
movaps 0x1dd2d(%rip), %xmm0    # 0x56c10
movss (%rbx,%rcx,4), %xmm2
movss 0x20(%rax), %xmm1
ucomiss %xmm1, %xmm2
ja 0x38efa
xorps %xmm0, %xmm1
ucomiss %xmm2, %xmm1
jbe 0x38eff
movss %xmm1, (%rbx,%rcx,4)
incq %rcx
cmpq $0x73, %rcx
jne 0x38ee3
movss 0x1cc(%rbx), %xmm1
xorps %xmm0, %xmm0
ucomiss %xmm0, %xmm1
jne 0x38f3b
jp 0x38f3b
movss 0x1d0(%rbx), %xmm1
ucomiss %xmm0, %xmm1
jne 0x38f3b
jp 0x38f3b
movss 0x1d4(%rbx), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x38f3b
jnp 0x38f43
movq %rbx, %rdi
callq 0x18850
testq %r14, %r14
jne 0x38f67
movl 0x11c(%rbx), %eax
testb $0x1, %al
jne 0x38f67
testb $0x2, %al
je 0x3919e
cmpl $0x2, 0x30c(%rbx)
jle 0x3919e
xorl %ebp, %ebp
movl 0x11c(%rbx), %eax
testb $0x1, %al
je 0x38fbf
movss 0x1c8(%rbx), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x38f85
jnp 0x38fbf
movaps 0x1afb4(%rip), %xmm2    # 0x53f40
andps %xmm0, %xmm2
movss 0x1df2d(%rip), %xmm3    # 0x56ec4
maxss %xmm2, %xmm3
mulss 0x1bc5d(%rip), %xmm3    # 0x54c00
addss %xmm3, %xmm3
addss %xmm2, %xmm3
maxss %xmm3, %xmm1
divss %xmm2, %xmm1
mulss %xmm0, %xmm1
movss %xmm1, 0x1c8(%rbx)
testb $0x2, %al
je 0x39017
movss 0x1c8(%rbx), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x38fd5
jnp 0x39017
movaps 0x1af64(%rip), %xmm2    # 0x53f40
andps %xmm0, %xmm2
movss 0x1dedd(%rip), %xmm3    # 0x56ec4
maxss %xmm2, %xmm3
cvtsi2ssl 0x30c(%rbx), %xmm4
mulss 0x1bc05(%rip), %xmm3    # 0x54c00
mulss %xmm4, %xmm3
addss %xmm2, %xmm3
maxss %xmm3, %xmm1
divss %xmm2, %xmm1
mulss %xmm0, %xmm1
movss %xmm1, 0x1c8(%rbx)
movss 0x1c8(%rbx), %xmm1
xorps %xmm0, %xmm0
ucomiss %xmm0, %xmm1
jne 0x3904e
jp 0x3904e
movss 0x1c4(%rbx), %xmm1
ucomiss %xmm0, %xmm1
jne 0x3904e
jp 0x3904e
movss 0x1c0(%rbx), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x3904e
jnp 0x39181
testq %r14, %r14
sete %cl
testb $0x3, %al
sete %al
testb %al, %cl
jne 0x39102
cmpl $0x0, 0x254(%rbx)
jg 0x3907a
movq %rbx, %rdi
callq 0x19130
testl %eax, %eax
je 0x39102
movss 0x1c0(%rbx), %xmm0
movss 0x1c4(%rbx), %xmm1
mulss %xmm1, %xmm1
mulss %xmm0, %xmm0
addss %xmm1, %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jb 0x390a4
sqrtss %xmm0, %xmm0
jmp 0x390ac
callq 0x18e80
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x390b3
jnp 0x39102
movss 0x1de09(%rip), %xmm1    # 0x56ec4
maxss %xmm0, %xmm1
mulss 0x1bb39(%rip), %xmm1    # 0x54c00
mulss 0x1ae31(%rip), %xmm1    # 0x53f00
addss %xmm0, %xmm1
xorps %xmm2, %xmm2
maxss %xmm1, %xmm2
divss %xmm0, %xmm2
movss 0x1c0(%rbx), %xmm0
mulss %xmm2, %xmm0
movss %xmm0, 0x1c0(%rbx)
mulss 0x1c4(%rbx), %xmm2
movss %xmm2, 0x1c4(%rbx)
testb $0x4, 0xc8(%rbx)
movl $0x3, %eax
movl $0x2020003, %esi        # imm = 0x2020003
cmovel %eax, %esi
movss 0x1b172(%rip), %xmm0    # 0x54290
movq %rbx, %rdi
callq 0x18140
movq 0x304d3(%rip), %r15     # 0x69600
movq %rbx, %rdi
callq *0x90(%r15)
movq %rbx, %rdi
callq 0x19200
cmpl $0x0, 0x60(%rbx)
je 0x39193
cmpq $0x0, 0x2b8(%rbx)
setne %al
testq %r14, %r14
jne 0x39181
andb %al, %bpl
je 0x39181
movq 0x20(%r15), %r14
leaq 0x1f742(%rip), %rdi     # 0x588a7
callq *0x48(%r15)
movss 0x1adb7(%rip), %xmm0    # 0x53f28
xorps %xmm2, %xmm2
movq %rbx, %rdi
xorl %esi, %esi
movl %eax, %edx
movaps %xmm0, %xmm1
callq *%r14
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x18620
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movss 0x1c8(%rbx), %xmm0
xorps %xmm2, %xmm2
cvtss2sd %xmm0, %xmm2
movq 0x30e0c(%rip), %rax     # 0x69fc0
movq (%rax), %rax
movss 0x20(%rax), %xmm1
cvtss2sd %xmm1, %xmm3
mulsd 0x1f638(%rip), %xmm3    # 0x58800
ucomisd %xmm2, %xmm3
seta %bpl
cmpl $0x0, 0x30c(%rbx)
jne 0x38f69
mulss 0x1e0(%rbx), %xmm1
mulss 0x1ba13(%rip), %xmm1    # 0x54c00
addss %xmm1, %xmm0
movss %xmm0, 0x1c8(%rbx)
jmp 0x38f69