// File: /workspace/github_c_makefile_star2_O1/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 0x38b9f
movss 0x1c8(%rbx), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x38b78
movq $0x0, 0x2b8(%rbx)
movq 0x2b8(%rbx), %rax
testq %rax, %rax
je 0x38b95
cmpl $0x0, 0x60(%rax)
jne 0x38b95
movq $0x0, 0x2b8(%rbx)
cmpq $0x0, 0x2b8(%rbx)
je 0x38bae
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1c0(%rbx), %r15
leaq 0x4(%rbx), %r14
movss 0x4(%rbx), %xmm0
movss %xmm0, 0x8(%rsp)
movss 0x8(%rbx), %xmm0
movss %xmm0, 0xc(%rsp)
movss 0xc(%rbx), %xmm0
movss %xmm0, 0x10(%rsp)
movq 0x30d8f(%rip), %rax     # 0x69970
movq (%rax), %rax
movl $0x70, %ecx
movaps 0x1e020(%rip), %xmm0    # 0x56c10
movss (%rbx,%rcx,4), %xmm2
movss 0x20(%rax), %xmm1
ucomiss %xmm1, %xmm2
ja 0x38c07
xorps %xmm0, %xmm1
ucomiss %xmm2, %xmm1
jbe 0x38c0c
movss %xmm1, (%rbx,%rcx,4)
incq %rcx
cmpq $0x73, %rcx
jne 0x38bf0
movl 0x118(%rbx), %eax
cmpl $0xa, %eax
ja 0x38c2a
movl $0x540, %ecx            # imm = 0x540
btl %eax, %ecx
jb 0x38c59
movq 0x3138f(%rip), %rax     # 0x69fc0
movq (%rax), %rax
movss 0x20(%rax), %xmm0
mulss 0x1e0(%rbx), %xmm0
mulss 0x1bfb7(%rip), %xmm0    # 0x54c00
addss 0x1c8(%rbx), %xmm0
movss %xmm0, 0x1c8(%rbx)
leaq 0x10(%rbx), %rdi
leaq 0x1cc(%rbx), %rsi
movss 0x1b624(%rip), %xmm0    # 0x54290
movq %rdi, %rdx
callq 0x19770
leaq 0x14(%rsp), %r12
movq %r15, %rdi
movss 0x1b60c(%rip), %xmm0    # 0x54290
movq %r12, %rsi
callq 0x189d0
leaq 0x20(%rsp), %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x18310
cmpl $0x0, 0x60(%rbx)
je 0x38b9f
movss 0x1b27a(%rip), %xmm0    # 0x53f28
ucomiss 0x28(%rsp), %xmm0
jbe 0x38d86
movl 0x118(%rbx), %edx
xorl %eax, %eax
cmpl $0x9, %edx
sete %cl
cmpl $0xa, %edx
je 0x38cdc
movb %cl, %al
leaq 0x1fb23(%rip), %rcx     # 0x587f8
movss (%rcx,%rax,4), %xmm0
jmp 0x38ce4
movss 0x1b774(%rip), %xmm0    # 0x54458
leaq 0x38(%rsp), %rsi
movq %r15, %rdi
movq %r15, %rdx
callq 0x18b50
movl 0x118(%rbx), %eax
cmpl $0xa, %eax
je 0x38d86
xorps %xmm0, %xmm0
cvtss2sd 0x40(%rsp), %xmm0
ucomisd 0x1facc(%rip), %xmm0    # 0x587e0
jbe 0x38d86
cmpl $0x9, %eax
jne 0x38d2c
movss 0x1ded9(%rip), %xmm0    # 0x56bfc
ucomiss 0x1c8(%rbx), %xmm0
jbe 0x38d86
movq 0x60(%rsp), %rax
movq %rax, 0x2b8(%rbx)
movl 0x64(%rax), %eax
movl %eax, 0x2c0(%rbx)
movq 0x30a20(%rip), %rax     # 0x69768
movss (%rax), %xmm0
movss %xmm0, 0x1c0(%rbx)
movss 0x4(%rax), %xmm1
movss %xmm1, 0x1c4(%rbx)
movss 0x8(%rax), %xmm2
movss %xmm2, 0x1c8(%rbx)
movss %xmm0, 0x1cc(%rbx)
movss %xmm1, 0x1d0(%rbx)
movss %xmm2, 0x1d4(%rbx)
movl 0x308(%rbx), %ebp
movq 0x3086d(%rip), %r12     # 0x69600
movq %r14, %rdi
callq *0x68(%r12)
movl %eax, 0x308(%rbx)
xorl %ecx, %ecx
testb $0x38, %al
setne %cl
movl %ecx, 0x30c(%rbx)
testb $0x38, %bpl
sete %dl
testb %cl, %dl
je 0x38dc0
leaq 0x8(%rsp), %r14
jmp 0x38dd0
testb $0x38, %bpl
sete %cl
testb $0x38, %al
setne %al
orb %cl, %al
jne 0x38e06
movq 0x28(%r12), %r13
movq 0x3077c(%rip), %rax     # 0x69558
movq (%rax), %r15
leaq 0x1fab0(%rip), %rdi     # 0x58896
callq *0x48(%r12)
movss 0x1b135(%rip), %xmm0    # 0x53f28
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 0x38b9f
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 0x38e0d