// File: /workspace/github_c_makefile_star2_O2/QwazyWabbitWOS[P]lmctf60/g_phys.c
// Function: SV_Push
qboolean SV_Push (edict_t *pusher, vec3_t move, vec3_t amove)
{
	int			i, e;
	edict_t		*check, *block;
	vec3_t		mins, maxs;
	pushed_t	*p;
	vec3_t		org, org2, move2, forward, right, up;

	if (!pusher)
	{
		gi.dprintf("NULL pusher passed to %s", __func__);
		return false;
	}

	// clamp the move to 1/8 units, so the position will
	// be accurate for client side prediction
	for (i=0 ; i<3 ; i++)
	{
		float	temp;
		temp = move[i]*8.0;
		if (temp > 0.0)
			temp += 0.5;
		else
			temp -= 0.5;
		move[i] = 0.125 * (int)temp;
	}

	// find the bounding box
	for (i=0 ; i<3 ; i++)
	{
		mins[i] = pusher->absmin[i] + move[i];
		maxs[i] = pusher->absmax[i] + move[i];
	}

// we need this for pushing things later
	VectorSubtract (vec3_origin, amove, org);
	AngleVectors (org, forward, right, up);

// save the pusher's original position
	pushed_p->ent = pusher;
	VectorCopy (pusher->s.origin, pushed_p->origin);
	VectorCopy (pusher->s.angles, pushed_p->angles);
	if (pusher->client)
		pushed_p->deltayaw = pusher->client->ps.pmove.delta_angles[YAW];
	pushed_p++;

// move the pusher to it's final position
	VectorAdd (pusher->s.origin, move, pusher->s.origin);
	VectorAdd (pusher->s.angles, amove, pusher->s.angles);
	gi.linkentity (pusher);

// see if any solid entities are inside the final position
	check = g_edicts+1;
	for (e = 1; e < globals.num_edicts; e++, check++)
	{
		if (!check->inuse)
			continue;
		if (check->movetype == MOVETYPE_PUSH
		|| check->movetype == MOVETYPE_STOP
		|| check->movetype == MOVETYPE_NONE
		|| check->movetype == MOVETYPE_NOCLIP)
			continue;

		if (!check->area.prev)
			continue;		// not linked in anywhere

	// if the entity is standing on the pusher, it will definitely be moved
		if (check->groundentity != pusher)
		{
			// see if the ent needs to be tested
			if ( check->absmin[0] >= maxs[0]
			|| check->absmin[1] >= maxs[1]
			|| check->absmin[2] >= maxs[2]
			|| check->absmax[0] <= mins[0]
			|| check->absmax[1] <= mins[1]
			|| check->absmax[2] <= mins[2] )
				continue;

			// see if the ent's bbox is inside the pusher's final position
			if (!SV_TestEntityPosition (check))
				continue;
		}

		if ((pusher->movetype == MOVETYPE_PUSH) || (check->groundentity == pusher))
		{
			// move this entity
			pushed_p->ent = check;
			VectorCopy (check->s.origin, pushed_p->origin);
			VectorCopy (check->s.angles, pushed_p->angles);
			pushed_p++;

			// try moving the contacted entity 
			VectorAdd (check->s.origin, move, check->s.origin);
			if (check->client)
			{	// FIXME: doesn't rotate monsters?
				check->client->ps.pmove.delta_angles[YAW] += amove[YAW];
			}

			// figure movement due to the pusher's amove
			VectorSubtract (check->s.origin, pusher->s.origin, org);
			org2[0] = DotProduct (org, forward);
			org2[1] = -DotProduct (org, right);
			org2[2] = DotProduct (org, up);
			VectorSubtract (org2, org, move2);
			VectorAdd (check->s.origin, move2, check->s.origin);

			// may have pushed them off an edge
			if (check->groundentity != pusher)
				check->groundentity = NULL;

			block = SV_TestEntityPosition (check);
			if (!block)
			{	// pushed ok
				gi.linkentity (check);
				// impact?
				continue;
			}

			// if it is ok to leave in the old position, do it
			// this is only relevent for riding entities, not pushed
			// FIXME: this doesn't acount for rotation
			VectorSubtract (check->s.origin, move, check->s.origin);
			block = SV_TestEntityPosition (check);
			if (!block)
			{
				pushed_p--;
				continue;
			}
		}
		
		// save off the obstacle so we can call the block function
		obstacle = check;

		// move back any entities we already moved
		// go backwards, so if the same entity was pushed
		// twice, it goes back to the original position
		for (p=pushed_p-1 ; p>=pushed ; p--)
		{
			VectorCopy (p->origin, p->ent->s.origin);
			VectorCopy (p->angles, p->ent->s.angles);
			if (p->ent->client)
			{
				p->ent->client->ps.pmove.delta_angles[YAW] = p->deltayaw;
			}
			gi.linkentity (p->ent);
		}
		return false;
	}

//FIXME: is there a better way to handle this?
	// see if anything we moved has touched a trigger
	for (p=pushed_p-1 ; p>=pushed ; p--)
		G_TouchTriggers (p->ent);

	return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
testq %rdi, %rdi
je 0x3505e
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
xorl %eax, %eax
movss 0x1a38c(%rip), %xmm0    # 0x4eef8
xorps %xmm1, %xmm1
leaq 0x1ee62(%rip), %rcx     # 0x539d8
movsd 0x1ee62(%rip), %xmm2    # 0x539e0
cmpq $0x3, %rax
je 0x34bb6
movss (%r14,%rax,4), %xmm3
mulss %xmm0, %xmm3
xorl %edx, %edx
ucomiss %xmm1, %xmm3
seta %dl
addss (%rcx,%rdx,4), %xmm3
cvttps2dq %xmm3, %xmm3
cvtdq2pd %xmm3, %xmm3
mulsd %xmm2, %xmm3
cvtsd2ss %xmm3, %xmm3
movss %xmm3, (%r14,%rax,4)
incq %rax
jmp 0x34b7e
xorl %eax, %eax
cmpq $0xc, %rax
je 0x34bee
movss (%r14,%rax), %xmm0
movss 0xe4(%r15,%rax), %xmm1
addss %xmm0, %xmm1
movss %xmm1, 0x34(%rsp,%rax)
addss 0xf0(%r15,%rax), %xmm0
movss %xmm0, 0x28(%rsp,%rax)
addq $0x4, %rax
jmp 0x34bb8
movq 0x31b73(%rip), %rax     # 0x66768
movsd (%rax), %xmm0
movsd (%rbx), %xmm1
subps %xmm1, %xmm0
leaq 0x48(%rsp), %rdi
movlps %xmm0, (%rdi)
movss 0x8(%rax), %xmm0
subss 0x8(%rbx), %xmm0
movss %xmm0, 0x8(%rdi)
leaq 0x1c(%rsp), %rsi
leaq 0x10(%rsp), %rdx
leaq 0x4(%rsp), %rcx
callq 0x183d0
movq 0x31c16(%rip), %r13     # 0x66848
movq (%r13), %rax
movq %r15, (%rax)
movss 0x4(%r15), %xmm0
movq (%r13), %rax
movss %xmm0, 0x8(%rax)
movss 0x8(%r15), %xmm0
movss %xmm0, 0xc(%rax)
movss 0xc(%r15), %xmm0
movss %xmm0, 0x10(%rax)
movss 0x10(%r15), %xmm0
movss %xmm0, 0x14(%rax)
movss 0x14(%r15), %xmm0
movss %xmm0, 0x18(%rax)
movss 0x18(%r15), %xmm0
movss %xmm0, 0x1c(%rax)
movq 0x58(%r15), %rcx
testq %rcx, %rcx
je 0x34c9b
movswl 0x16(%rcx), %ecx
cvtsi2ss %ecx, %xmm0
movss %xmm0, 0x20(%rax)
movss 0x18(%r15), %xmm0
addq $0x28, %rax
movq %rax, (%r13)
movss 0x4(%r15), %xmm1
movss 0x8(%r15), %xmm2
addss (%r14), %xmm1
movss %xmm1, 0x4(%r15)
addss 0x4(%r14), %xmm2
movss %xmm2, 0x8(%r15)
movss 0xc(%r15), %xmm1
addss 0x8(%r14), %xmm1
movss %xmm1, 0xc(%r15)
movss 0x10(%r15), %xmm1
addss (%rbx), %xmm1
movss %xmm1, 0x10(%r15)
movss 0x14(%r15), %xmm1
addss 0x4(%rbx), %xmm1
movss %xmm1, 0x14(%r15)
movq %rbx, 0x40(%rsp)
addss 0x8(%rbx), %xmm0
movss %xmm0, 0x18(%r15)
movq 0x318f0(%rip), %rax     # 0x66600
movq %r15, %rdi
callq *0x90(%rax)
movq 0x31838(%rip), %rax     # 0x66558
movl $0x4a8, %r12d           # imm = 0x4A8
addq (%rax), %r12
pushq $0x1
popq %rbp
movq 0x31dd5(%rip), %rbx     # 0x66b08
cmpl 0x8c(%rbx), %ebp
jge 0x35039
cmpl $0x0, 0x60(%r12)
je 0x3502b
cmpl $0x4, 0x118(%r12)
jb 0x3502b
cmpq $0x0, 0x68(%r12)
je 0x3502b
cmpq %r15, 0x2b8(%r12)
je 0x34e03
movss 0xe4(%r12), %xmm0
ucomiss 0x28(%rsp), %xmm0
jae 0x3502b
movss 0xe8(%r12), %xmm0
ucomiss 0x2c(%rsp), %xmm0
jae 0x3502b
movss 0xec(%r12), %xmm0
ucomiss 0x30(%rsp), %xmm0
jae 0x3502b
movss 0x34(%rsp), %xmm0
ucomiss 0xf0(%r12), %xmm0
jae 0x3502b
movss 0x38(%rsp), %xmm0
ucomiss 0xf4(%r12), %xmm0
jae 0x3502b
movss 0x3c(%rsp), %xmm0
ucomiss 0xf8(%r12), %xmm0
jae 0x3502b
movq %r12, %rdi
callq 0x18970
testq %rax, %rax
je 0x3502b
cmpl $0x2, 0x118(%r15)
jne 0x34e16
movq %r13, %rcx
movq (%r13), %r13
jmp 0x34e2b
movq %r13, %rcx
movq (%r13), %r13
cmpq %r15, 0x2b8(%r12)
jne 0x3508b
movq %r12, (%r13)
movss 0x4(%r12), %xmm0
movq (%rcx), %rax
movss %xmm0, 0x8(%rax)
movss 0x8(%r12), %xmm0
movss %xmm0, 0xc(%rax)
movss 0xc(%r12), %xmm0
movss %xmm0, 0x10(%rax)
movss 0x10(%r12), %xmm0
movss %xmm0, 0x14(%rax)
movss 0x14(%r12), %xmm0
movss %xmm0, 0x18(%rax)
movss 0x18(%r12), %xmm0
movss %xmm0, 0x1c(%rax)
addq $0x28, %rax
movq %rax, (%rcx)
movss 0x4(%r12), %xmm0
addss (%r14), %xmm0
movss 0x8(%r12), %xmm2
movss %xmm0, 0x4(%r12)
addss 0x4(%r14), %xmm2
movss %xmm2, 0x8(%r12)
movss 0xc(%r12), %xmm1
addss 0x8(%r14), %xmm1
movss %xmm1, 0xc(%r12)
movq 0x58(%r12), %rax
testq %rax, %rax
movq %rcx, %r13
je 0x34ee3
movswl 0x16(%rax), %ecx
cvtsi2ss %ecx, %xmm3
movq 0x40(%rsp), %rcx
addss 0x4(%rcx), %xmm3
cvttss2si %xmm3, %ecx
movw %cx, 0x16(%rax)
movsd 0x4(%r15), %xmm3
unpcklps %xmm2, %xmm0            # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
movaps %xmm0, %xmm2
subps %xmm3, %xmm2
movlps %xmm2, 0x48(%rsp)
movaps %xmm1, %xmm3
subss 0xc(%r15), %xmm3
movss %xmm3, 0x50(%rsp)
movaps %xmm2, %xmm5
shufps $0x55, %xmm2, %xmm5     # xmm5 = xmm5[1,1],xmm2[1,1]
movss 0x20(%rsp), %xmm4
mulss %xmm5, %xmm4
movss 0x1c(%rsp), %xmm6
mulss %xmm2, %xmm6
addss %xmm4, %xmm6
movss 0x24(%rsp), %xmm4
mulss %xmm3, %xmm4
addss %xmm6, %xmm4
movss 0x14(%rsp), %xmm6
mulss %xmm5, %xmm6
movss 0x10(%rsp), %xmm7
mulss %xmm2, %xmm7
addss %xmm6, %xmm7
movss 0x18(%rsp), %xmm6
mulss %xmm3, %xmm6
addss %xmm7, %xmm6
xorps 0x1cd50(%rip), %xmm6    # 0x51cb0
unpcklps %xmm6, %xmm4            # xmm4 = xmm4[0],xmm6[0],xmm4[1],xmm6[1]
mulss 0x8(%rsp), %xmm5
movss 0x4(%rsp), %xmm6
mulss %xmm2, %xmm6
addss %xmm5, %xmm6
movss 0xc(%rsp), %xmm5
mulss %xmm3, %xmm5
addss %xmm6, %xmm5
subss %xmm3, %xmm5
subps %xmm2, %xmm4
addps %xmm0, %xmm4
movlps %xmm4, 0x4(%r12)
addss %xmm1, %xmm5
movss %xmm5, 0xc(%r12)
cmpq %r15, 0x2b8(%r12)
je 0x34fb3
andq $0x0, 0x2b8(%r12)
movq %r12, %rdi
callq 0x18970
testq %rax, %rax
je 0x3501b
movss 0x4(%r12), %xmm0
movss 0x8(%r12), %xmm1
subss (%r14), %xmm0
movss %xmm0, 0x4(%r12)
subss 0x4(%r14), %xmm1
movss %xmm1, 0x8(%r12)
movss 0xc(%r12), %xmm0
subss 0x8(%r14), %xmm0
movss %xmm0, 0xc(%r12)
movq %r12, %rdi
callq 0x18970
movq %r13, %rcx
movq (%r13), %r13
testq %rax, %rax
jne 0x3508b
addq $-0x28, %r13
movq %r13, (%rcx)
movq %rcx, %r13
jmp 0x3502b
movq %r12, %rdi
movq 0x315db(%rip), %rax     # 0x66600
callq *0x90(%rax)
incl %ebp
addq $0x4a8, %r12            # imm = 0x4A8
jmp 0x34d33
movq (%r13), %r14
addq $-0x28, %r14
pushq $0x1
popq %rbx
movq 0x31c8d(%rip), %r15     # 0x66cd8
cmpq %r15, %r14
jb 0x3507a
movq (%r14), %rdi
callq 0x19380
addq $-0x28, %r14
jmp 0x3504b
movq 0x3159b(%rip), %rcx     # 0x66600
leaq 0x1e9cc(%rip), %rdi     # 0x53a38
leaq 0x1e9de(%rip), %rsi     # 0x53a51
xorl %ebx, %ebx
xorl %eax, %eax
callq *0x8(%rcx)
movl %ebx, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x317e6(%rip), %rax     # 0x66878
movq %r12, (%rax)
addq $-0x28, %r13
movq 0x31c38(%rip), %rbx     # 0x66cd8
movq 0x31559(%rip), %r14     # 0x66600
cmpq %rbx, %r13
jb 0x35112
movss 0x8(%r13), %xmm0
movq (%r13), %rdi
movss %xmm0, 0x4(%rdi)
movss 0xc(%r13), %xmm0
movss %xmm0, 0x8(%rdi)
movss 0x10(%r13), %xmm0
movss %xmm0, 0xc(%rdi)
movss 0x14(%r13), %xmm0
movss %xmm0, 0x10(%rdi)
movss 0x18(%r13), %xmm0
movss %xmm0, 0x14(%rdi)
movss 0x1c(%r13), %xmm0
movss %xmm0, 0x18(%rdi)
movq 0x58(%rdi), %rax
testq %rax, %rax
je 0x35105
cvttss2si 0x20(%r13), %ecx
movw %cx, 0x16(%rax)
callq *0x90(%r14)
addq $-0x28, %r13
jmp 0x350a7
xorl %ebx, %ebx
jmp 0x3507a