// File: /workspace/github_c_makefile_star2_O2/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 0x18660
testb $0x4, 0x11d(%rbx)
jne 0x3556e
movss 0x1c8(%rbx), %xmm0
leaq 0x2b8(%rbx), %rax
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x35356
andq $0x0, (%rax)
jmp 0x3536a
movq (%rax), %rcx
testq %rcx, %rcx
je 0x3536a
cmpl $0x0, 0x60(%rcx)
jne 0x3556e
jmp 0x35350
leaq 0x1c0(%rbx), %r15
movsd 0x4(%rbx), %xmm0
movsd %xmm0, 0x8(%rsp)
movss 0xc(%rbx), %xmm0
movss %xmm0, 0x10(%rsp)
movq %rbx, %rdi
callq 0x19190
movl 0x118(%rbx), %eax
cmpl $0xa, %eax
ja 0x353a4
movl $0x540, %ecx            # imm = 0x540
btl %eax, %ecx
jb 0x353ac
movq %rbx, %rdi
callq 0x18a50
leaq 0x10(%rbx), %rdi
leaq 0x1cc(%rbx), %rsi
movss 0x19ed1(%rip), %xmm0    # 0x4f290
movq %rdi, %rdx
callq 0x19940
leaq 0x14(%rsp), %r14
movq %r15, %rdi
movss 0x19eb9(%rip), %xmm0    # 0x4f290
movq %r14, %rsi
callq 0x18a70
leaq 0x20(%rsp), %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x18340
cmpl $0x0, 0x60(%rbx)
je 0x3556e
leaq 0x4(%rbx), %r14
movss 0x19b23(%rip), %xmm0    # 0x4ef28
ucomiss 0x28(%rsp), %xmm0
jbe 0x354b8
movl 0x118(%rbx), %edx
xorl %eax, %eax
cmpl $0x9, %edx
sete %cl
cmpl $0xa, %edx
je 0x35433
movb %cl, %al
leaq 0x1e5bc(%rip), %rcx     # 0x539e8
movss (%rcx,%rax,4), %xmm0
jmp 0x3543b
movss 0x1a031(%rip), %xmm0    # 0x4f46c
leaq 0x38(%rsp), %rsi
movq %r15, %rdi
movq %r15, %rdx
callq 0x18bf0
movl 0x118(%rbx), %eax
cmpl $0xa, %eax
je 0x354b8
cvtss2sd 0x40(%rsp), %xmm0
ucomisd 0x1e56c(%rip), %xmm0    # 0x539d0
jbe 0x354b8
cmpl $0x9, %eax
jne 0x3547c
movss 0x1dda1(%rip), %xmm0    # 0x53214
ucomiss 0x1c8(%rbx), %xmm0
jbe 0x354b8
movq 0x60(%rsp), %rax
movq %rax, 0x2b8(%rbx)
movl 0x64(%rax), %eax
movl %eax, 0x2c0(%rbx)
movq 0x312d0(%rip), %rax     # 0x66768
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 0x3113b(%rip), %r12     # 0x66600
movq %r14, %rdi
callq *0x68(%r12)
movl %eax, 0x308(%rbx)
testb $0x38, %al
je 0x354ee
movl $0x1, 0x30c(%rbx)
testb $0x38, %bpl
jne 0x35531
leaq 0x8(%rsp), %r14
jmp 0x354fb
andl $0x0, 0x30c(%rbx)
testb $0x38, %bpl
je 0x35531
movq 0x28(%r12), %r13
movq 0x31051(%rip), %rax     # 0x66558
movq (%rax), %r15
leaq 0x1e579(%rip), %rdi     # 0x53a8a
callq *0x48(%r12)
movss 0x19a0a(%rip), %xmm0    # 0x4ef28
xorps %xmm2, %xmm2
movq %r14, %rdi
movq %r15, %rsi
xorl %edx, %edx
movl %eax, %ecx
movaps %xmm0, %xmm1
callq *%r13
movq %rbx, %r14
movq 0x2c8(%r14), %r14
testq %r14, %r14
je 0x3556e
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)
jmp 0x35534
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq