// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movl $0x0, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq 0x2b8(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
callq 0x19200
cmpq $0x0, -0x30(%rbp)
je 0x47c3b
movl $0x1, -0xc(%rbp)
jmp 0x47c42
movl $0x0, -0xc(%rbp)
movq -0x8(%rbp), %rax
movss 0x1cc(%rax), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x47c86
jp 0x47c86
movq -0x8(%rbp), %rax
movss 0x1d0(%rax), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x47c86
jp 0x47c86
movq -0x8(%rbp), %rax
movss 0x1d4(%rax), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x47c86
jp 0x47c86
jmp 0x47c8f
movq -0x8(%rbp), %rdi
callq 0x188c0
cmpl $0x0, -0xc(%rbp)
jne 0x47d22
movq -0x8(%rbp), %rax
movl 0x11c(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x47d20
movq -0x8(%rbp), %rax
movl 0x11c(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x47cca
movq -0x8(%rbp), %rax
cmpl $0x2, 0x30c(%rax)
jg 0x47d1e
movq -0x8(%rbp), %rax
movss 0x1c8(%rax), %xmm0
cvtss2sd %xmm0, %xmm1
movq 0x3b2df(%rip), %rax     # 0x82fc0
movq (%rax), %rax
movss 0x20(%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x2c9eb(%rip), %xmm2    # 0x746e0
mulsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jbe 0x47d06
movl $0x1, -0x10(%rbp)
movq -0x8(%rbp), %rax
cmpl $0x0, 0x30c(%rax)
jne 0x47d1c
movq -0x8(%rbp), %rdi
callq 0x18a60
jmp 0x47d1e
jmp 0x47d20
jmp 0x47d22
movq -0x8(%rbp), %rax
movl 0x11c(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x47e23
movq -0x8(%rbp), %rax
movss 0x1c8(%rax), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x47d53
jp 0x47d53
jmp 0x47e23
movq -0x8(%rbp), %rax
movss 0x1c8(%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movaps 0x2ae36(%rip), %xmm1    # 0x72ba0
pand %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x1c(%rbp)
movss 0x2ae01(%rip), %xmm0    # 0x72b80
ucomiss -0x1c(%rbp), %xmm0
jbe 0x47d94
movss 0x2adf3(%rip), %xmm0    # 0x72b80
movss %xmm0, -0x38(%rbp)
jmp 0x47d9e
movss -0x1c(%rbp), %xmm0
movss %xmm0, -0x38(%rbp)
movss -0x38(%rbp), %xmm0
movss %xmm0, -0x24(%rbp)
movss 0x28138(%rip), %xmm0    # 0x6fee8
movss %xmm0, -0x28(%rbp)
movss -0x1c(%rbp), %xmm1
movss 0x284d2(%rip), %xmm0    # 0x70294
mulss -0x24(%rbp), %xmm0
movss -0x28(%rbp), %xmm2
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm0
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, -0x20(%rbp)
xorps %xmm0, %xmm0
ucomiss -0x20(%rbp), %xmm0
jbe 0x47df7
xorps %xmm0, %xmm0
movss %xmm0, -0x20(%rbp)
movss -0x1c(%rbp), %xmm1
movss -0x20(%rbp), %xmm0
divss %xmm1, %xmm0
movss %xmm0, -0x20(%rbp)
movss -0x20(%rbp), %xmm0
movq -0x8(%rbp), %rax
mulss 0x1c8(%rax), %xmm0
movss %xmm0, 0x1c8(%rax)
movq -0x8(%rbp), %rax
movl 0x11c(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x47f2a
movq -0x8(%rbp), %rax
movss 0x1c8(%rax), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x47e54
jp 0x47e54
jmp 0x47f2a
movq -0x8(%rbp), %rax
movss 0x1c8(%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movaps 0x2ad35(%rip), %xmm1    # 0x72ba0
pand %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x1c(%rbp)
movss 0x2ad00(%rip), %xmm0    # 0x72b80
ucomiss -0x1c(%rbp), %xmm0
jbe 0x47e95
movss 0x2acf2(%rip), %xmm0    # 0x72b80
movss %xmm0, -0x3c(%rbp)
jmp 0x47e9f
movss -0x1c(%rbp), %xmm0
movss %xmm0, -0x3c(%rbp)
movss -0x3c(%rbp), %xmm0
movss %xmm0, -0x24(%rbp)
movss -0x1c(%rbp), %xmm1
movss 0x283de(%rip), %xmm0    # 0x70294
mulss -0x24(%rbp), %xmm0
movss 0x28029(%rip), %xmm2    # 0x6feec
mulss %xmm2, %xmm0
movq -0x8(%rbp), %rax
cvtsi2ssl 0x30c(%rax), %xmm2
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm0
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, -0x20(%rbp)
xorps %xmm0, %xmm0
ucomiss -0x20(%rbp), %xmm0
jbe 0x47efe
xorps %xmm0, %xmm0
movss %xmm0, -0x20(%rbp)
movss -0x1c(%rbp), %xmm1
movss -0x20(%rbp), %xmm0
divss %xmm1, %xmm0
movss %xmm0, -0x20(%rbp)
movss -0x20(%rbp), %xmm0
movq -0x8(%rbp), %rax
mulss 0x1c8(%rax), %xmm0
movss %xmm0, 0x1c8(%rax)
movq -0x8(%rbp), %rax
movss 0x1c8(%rax), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x47f71
jp 0x47f71
movq -0x8(%rbp), %rax
movss 0x1c4(%rax), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x47f71
jp 0x47f71
movq -0x8(%rbp), %rax
movss 0x1c0(%rax), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x47f71
jp 0x47f71
jmp 0x48188
cmpl $0x0, -0xc(%rbp)
jne 0x47f8d
movq -0x8(%rbp), %rax
movl 0x11c(%rax), %eax
andl $0x3, %eax
cmpl $0x0, %eax
je 0x480c5
movq -0x8(%rbp), %rax
cvtsi2sdl 0x254(%rax), %xmm1
xorps %xmm0, %xmm0
ucomisd %xmm1, %xmm0
jb 0x47fb4
movq -0x8(%rbp), %rdi
callq 0x19300
cmpl $0x0, %eax
je 0x480c3
movq -0x8(%rbp), %rax
addq $0x1c0, %rax            # imm = 0x1C0
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movss (%rax), %xmm0
movq -0x18(%rbp), %rax
movss (%rax), %xmm2
movq -0x18(%rbp), %rax
movss 0x4(%rax), %xmm1
movq -0x18(%rbp), %rax
mulss 0x4(%rax), %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
callq 0x19000
movss %xmm0, -0x1c(%rbp)
movss -0x1c(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x4800a
jp 0x4800a
jmp 0x480c1
movss 0x27ef2(%rip), %xmm0    # 0x6ff04
movss %xmm0, -0x28(%rbp)
movss 0x2ab61(%rip), %xmm0    # 0x72b80
ucomiss -0x1c(%rbp), %xmm0
jbe 0x48034
movss 0x2ab53(%rip), %xmm0    # 0x72b80
movss %xmm0, -0x40(%rbp)
jmp 0x4803e
movss -0x1c(%rbp), %xmm0
movss %xmm0, -0x40(%rbp)
movss -0x40(%rbp), %xmm0
movss %xmm0, -0x24(%rbp)
movss -0x1c(%rbp), %xmm1
movss 0x2823f(%rip), %xmm0    # 0x70294
mulss -0x24(%rbp), %xmm0
movss -0x28(%rbp), %xmm2
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm0
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, -0x20(%rbp)
xorps %xmm0, %xmm0
ucomiss -0x20(%rbp), %xmm0
jbe 0x4808a
xorps %xmm0, %xmm0
movss %xmm0, -0x20(%rbp)
movss -0x1c(%rbp), %xmm1
movss -0x20(%rbp), %xmm0
divss %xmm1, %xmm0
movss %xmm0, -0x20(%rbp)
movss -0x20(%rbp), %xmm0
movq -0x18(%rbp), %rax
mulss (%rax), %xmm0
movss %xmm0, (%rax)
movss -0x20(%rbp), %xmm0
movq -0x18(%rbp), %rax
mulss 0x4(%rax), %xmm0
movss %xmm0, 0x4(%rax)
jmp 0x480c3
jmp 0x480c5
movq -0x8(%rbp), %rax
movl 0xc8(%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x480e0
movl $0x2020003, -0x34(%rbp) # imm = 0x2020003
jmp 0x480e7
movl $0x3, -0x34(%rbp)
movq -0x8(%rbp), %rdi
movl -0x34(%rbp), %esi
movss 0x2819e(%rip), %xmm0    # 0x70294
callq 0x18140
movq 0x3a4fe(%rip), %rax     # 0x82600
movq 0x90(%rax), %rax
movq -0x8(%rbp), %rdi
callq *%rax
movq -0x8(%rbp), %rdi
callq 0x193f0
movq -0x8(%rbp), %rax
cmpl $0x0, 0x60(%rax)
jne 0x48124
jmp 0x48191
movq -0x8(%rbp), %rax
cmpq $0x0, 0x2b8(%rax)
je 0x48186
cmpl $0x0, -0xc(%rbp)
jne 0x48184
cmpl $0x0, -0x10(%rbp)
je 0x48182
movq 0x3a4bb(%rip), %rax     # 0x82600
movq 0x20(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x50(%rbp)
leaq 0x2c647(%rip), %rdi     # 0x747a3
movq 0x3a49d(%rip), %rax     # 0x82600
callq *0x48(%rax)
movq -0x50(%rbp), %rdi
movl %eax, %edx
movq -0x48(%rbp), %rax
xorl %esi, %esi
movss 0x27d72(%rip), %xmm1    # 0x6feec
xorps %xmm2, %xmm2
movaps %xmm1, %xmm0
callq *%rax
jmp 0x48184
jmp 0x48186
jmp 0x48188
movq -0x8(%rbp), %rdi
callq 0x18680
addq $0x50, %rsp
popq %rbp
retq
nopw (%rax,%rax)