// File: /workspace/github_c_makefile_star2_O3/QwazyWabbitWOS[P]lmctf60/g_phys.c
// Function: SV_Physics_Toss
void SV_Physics_Toss (edict_t *ent)
{
	trace_t		trace;
	vec3_t		move;
	float		backoff;
	edict_t		*slave;
	qboolean	wasinwater;
	qboolean	isinwater;
	vec3_t		old_origin;

// regular thinking
	SV_RunThink (ent);

	// if not a team captain, so movement will be handled elsewhere
	if ( ent->flags & FL_TEAMSLAVE)
		return;

	if (ent->velocity[2] > 0)
		ent->groundentity = NULL;

// check for the groundentity going away
	if (ent->groundentity)
		if (!ent->groundentity->inuse)
			ent->groundentity = NULL;

// if onground, return without moving
	if ( ent->groundentity )
		return;

	VectorCopy (ent->s.origin, old_origin);

	SV_CheckVelocity (ent);

// add gravity
	if (ent->movetype != MOVETYPE_FLY
	&& ent->movetype != MOVETYPE_FLYMISSILE
 	&& ent->movetype != MOVETYPE_REFLECT)	// SKWiD MOD
		SV_AddGravity (ent);

// move angles
	VectorMA (ent->s.angles, FRAMETIME, ent->avelocity, ent->s.angles);

// move origin
	VectorScale (ent->velocity, FRAMETIME, move);
	trace = SV_PushEntity (ent, move);
	if (!ent->inuse)
		return;

	if (trace.fraction < 1)
	{
		if (ent->movetype == MOVETYPE_REFLECT)  // SKWiD MOD
 			backoff = 2.0;	// get out of bsp
		else if (ent->movetype == MOVETYPE_BOUNCE)
			backoff = 1.5;
		else
			backoff = 1;

		ClipVelocity (ent->velocity, trace.plane.normal, ent->velocity, backoff);

	// stop if on ground
 		if (ent->movetype != MOVETYPE_REFLECT) {   // SKWiD MOD
		if (trace.plane.normal[2] > 0.7)
		{		
			if (ent->velocity[2] < 60 || ent->movetype != MOVETYPE_BOUNCE )
			{
				ent->groundentity = trace.ent;
				ent->groundentity_linkcount = trace.ent->linkcount;
				VectorCopy (vec3_origin, ent->velocity);
				VectorCopy (vec3_origin, ent->avelocity);
			}
		}
		} // SKWiD MOD
//		if (ent->touch)
//			ent->touch (ent, trace.ent, &trace.plane, trace.surface);
	}
	
// check for water transition
	wasinwater = (ent->watertype & MASK_WATER);
	ent->watertype = gi.pointcontents (ent->s.origin);
	isinwater = ent->watertype & MASK_WATER;

	if (isinwater)
		ent->waterlevel = 1;
	else
		ent->waterlevel = 0;

	if (!wasinwater && isinwater)
		gi.positioned_sound (old_origin, g_edicts, CHAN_AUTO, gi.soundindex("misc/h2ohit1.wav"), 1, 1, 0);
	else if (wasinwater && !isinwater)
		gi.positioned_sound (ent->s.origin, g_edicts, CHAN_AUTO, gi.soundindex("misc/h2ohit1.wav"), 1, 1, 0);

// move teamslaves
	for (slave = ent->teamchain; slave; slave = slave->teamchain)
	{
		VectorCopy (ent->s.origin, slave->s.origin);
		gi.linkentity (slave);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rdi, %rbx
callq 0x18620
testb $0x4, 0x11d(%rbx)
jne 0x38567
movss 0x1c8(%rbx), %xmm0
leaq 0x2b8(%rbx), %rax
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x382eb
movq $0x0, (%rax)
jmp 0x382ff
movq (%rax), %rcx
testq %rcx, %rcx
je 0x382ff
cmpl $0x0, 0x60(%rcx)
jne 0x38567
jmp 0x382e2
leaq 0x1c0(%rbx), %r15
leaq 0x4(%rbx), %r14
movsd 0x4(%rbx), %xmm0
movsd %xmm0, 0x8(%rsp)
movss 0xc(%rbx), %xmm0
movss %xmm0, 0x10(%rsp)
movq 0x30649(%rip), %rax     # 0x68970
movq (%rax), %rax
movl $0x70, %ecx
movaps 0x1d99a(%rip), %xmm0    # 0x55cd0
movss (%rbx,%rcx,4), %xmm2
movss 0x20(%rax), %xmm1
ucomiss %xmm1, %xmm2
ja 0x3834d
xorps %xmm0, %xmm1
ucomiss %xmm2, %xmm1
jbe 0x38352
movss %xmm1, (%rbx,%rcx,4)
incq %rcx
cmpq $0x73, %rcx
jne 0x38336
movl 0x118(%rbx), %eax
cmpl $0xa, %eax
ja 0x38370
movl $0x540, %ecx            # imm = 0x540
btl %eax, %ecx
jb 0x3839f
movq 0x30c49(%rip), %rax     # 0x68fc0
movq (%rax), %rax
movss 0x20(%rax), %xmm0
mulss 0x1e0(%rbx), %xmm0
mulss 0x1b8a1(%rip), %xmm0    # 0x53c30
addss 0x1c8(%rbx), %xmm0
movss %xmm0, 0x1c8(%rbx)
leaq 0x10(%rbx), %rdi
leaq 0x1cc(%rbx), %rsi
movss 0x1aede(%rip), %xmm0    # 0x53290
movq %rdi, %rdx
callq 0x19760
leaq 0x14(%rsp), %r12
movq %r15, %rdi
movss 0x1aec6(%rip), %xmm0    # 0x53290
movq %r12, %rsi
callq 0x189d0
leaq 0x20(%rsp), %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x18310
cmpl $0x0, 0x60(%rbx)
je 0x38567
movss 0x1ab34(%rip), %xmm0    # 0x52f28
ucomiss 0x28(%rsp), %xmm0
jbe 0x384aa
movl 0x118(%rbx), %edx
xorl %eax, %eax
cmpl $0x9, %edx
sete %cl
cmpl $0xa, %edx
je 0x38422
movb %cl, %al
leaq 0x1f5ed(%rip), %rcx     # 0x57a08
movss (%rcx,%rax,4), %xmm0
jmp 0x3842a
movss 0x1b042(%rip), %xmm0    # 0x5346c
leaq 0x38(%rsp), %rsi
movq %r15, %rdi
movq %r15, %rdx
callq 0x18b50
movl 0x118(%rbx), %eax
cmpl $0xa, %eax
je 0x384aa
xorps %xmm0, %xmm0
cvtss2sd 0x40(%rsp), %xmm0
ucomisd 0x1f59a(%rip), %xmm0    # 0x579f0
jbe 0x384aa
cmpl $0x9, %eax
jne 0x3846e
movss 0x1edcf(%rip), %xmm0    # 0x57234
ucomiss 0x1c8(%rbx), %xmm0
jbe 0x384aa
movq 0x60(%rsp), %rax
movq %rax, 0x2b8(%rbx)
movl 0x64(%rax), %eax
movl %eax, 0x2c0(%rbx)
movq 0x302de(%rip), %rax     # 0x68768
movss (%rax), %xmm0
movsd 0x4(%rax), %xmm1
shufps $0x40, %xmm1, %xmm0     # xmm0 = xmm0[0,0],xmm1[0,1]
shufps $0x78, %xmm0, %xmm0     # xmm0 = xmm0[0,2,3,1]
movups %xmm0, 0x1c0(%rbx)
movsd %xmm1, 0x1d0(%rbx)
movl 0x308(%rbx), %ebp
movq 0x30149(%rip), %r12     # 0x68600
movq %r14, %rdi
callq *0x68(%r12)
movl %eax, 0x308(%rbx)
testb $0x38, %al
je 0x384e0
movl $0x1, 0x30c(%rbx)
testb $0x38, %bpl
jne 0x38526
leaq 0x8(%rsp), %r14
jmp 0x384f0
movl $0x0, 0x30c(%rbx)
testb $0x38, %bpl
je 0x38526
movq 0x28(%r12), %r13
movq 0x3005c(%rip), %rax     # 0x68558
movq (%rax), %r15
leaq 0x1f5a4(%rip), %rdi     # 0x57aaa
callq *0x48(%r12)
movss 0x1aa15(%rip), %xmm0    # 0x52f28
xorps %xmm2, %xmm2
movq %r14, %rdi
movq %r15, %rsi
xorl %edx, %edx
movl %eax, %ecx
movaps %xmm0, %xmm1
callq *%r13
movq 0x2c8(%rbx), %r14
testq %r14, %r14
je 0x38567
movss 0x4(%rbx), %xmm0
movss %xmm0, 0x4(%r14)
movss 0x8(%rbx), %xmm0
movss %xmm0, 0x8(%r14)
movss 0xc(%rbx), %xmm0
movss %xmm0, 0xc(%r14)
movq %r14, %rdi
callq *0x90(%r12)
movq 0x2c8(%r14), %r14
jmp 0x3852d
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq