// File: /workspace/github_c_makefile_star2_O3/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 $0xb8, %rsp
testq %rdi, %rdi
je 0x37fe4
movq %rdx, %rbp
movq %rsi, %r14
movq %rdi, %r15
xorl %eax, %eax
movss 0x1b515(%rip), %xmm0    # 0x52efc
xorps %xmm1, %xmm1
leaq 0x20007(%rip), %rcx     # 0x579f8
movsd 0x20007(%rip), %xmm2    # 0x57a00
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
cmpq $0x3, %rax
jne 0x379f9
xorl %eax, %eax
movss (%r14,%rax), %xmm0
movss 0xe4(%r15,%rax), %xmm1
addss %xmm0, %xmm1
movss %xmm1, 0x4c(%rsp,%rax)
addss 0xf0(%r15,%rax), %xmm0
movss %xmm0, 0x40(%rsp,%rax)
addq $0x4, %rax
cmpq $0xc, %rax
jne 0x37a31
movq 0x30cfc(%rip), %rax     # 0x68768
movsd (%rax), %xmm0
movsd (%rbp), %xmm1
subps %xmm1, %xmm0
leaq 0x60(%rsp), %rdi
movlps %xmm0, (%rdi)
movss 0x8(%rax), %xmm0
subss 0x8(%rbp), %xmm0
movss %xmm0, 0x8(%rdi)
leaq 0x34(%rsp), %rsi
leaq 0x28(%rsp), %rdx
leaq 0x1c(%rsp), %rcx
callq 0x183a0
movq 0x30d9e(%rip), %rdx     # 0x68848
movq (%rdx), %rax
movq %r15, (%rax)
movss 0x4(%r15), %xmm0
movq (%rdx), %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 0x37b14
movswl 0x16(%rcx), %ecx
xorps %xmm0, %xmm0
cvtsi2ss %ecx, %xmm0
movss %xmm0, 0x20(%rax)
movss 0x18(%r15), %xmm0
addq $0x28, %rax
movq %rax, (%rdx)
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 (%rbp), %xmm1
movss %xmm1, 0x10(%r15)
movss 0x14(%r15), %xmm1
addss 0x4(%rbp), %xmm1
movss %xmm1, 0x14(%r15)
addss 0x8(%rbp), %xmm0
movss %xmm0, 0x18(%r15)
movq 0x30a7c(%rip), %rax     # 0x68600
movq %r15, %rdi
callq *0x90(%rax)
movq 0x30f74(%rip), %r13     # 0x68b08
cmpl $0x2, 0x8c(%r13)
jl 0x37fae
movq 0x309af(%rip), %rax     # 0x68558
movl $0x4a8, %r12d           # imm = 0x4A8
addq (%rax), %r12
movl $0x1, %ebx
movq %rbp, 0x10(%rsp)
cmpl $0x0, 0x60(%r12)
je 0x37f98
cmpl $0x4, 0x118(%r12)
jb 0x37f98
cmpq $0x0, 0x68(%r12)
je 0x37f98
cmpq %r15, 0x2b8(%r12)
je 0x37cca
movss 0xe4(%r12), %xmm0
ucomiss 0x40(%rsp), %xmm0
jae 0x37f98
movss 0xe8(%r12), %xmm0
ucomiss 0x44(%rsp), %xmm0
jae 0x37f98
movss 0xec(%r12), %xmm0
ucomiss 0x48(%rsp), %xmm0
jae 0x37f98
movss 0x4c(%rsp), %xmm0
ucomiss 0xf0(%r12), %xmm0
jae 0x37f98
movss 0x50(%rsp), %xmm0
ucomiss 0xf4(%r12), %xmm0
jae 0x37f98
movss 0x54(%rsp), %xmm0
ucomiss 0xf8(%r12), %xmm0
jae 0x37f98
movl 0x10c(%r12), %eax
testl %eax, %eax
movl $0x3, %ecx
cmovel %ecx, %eax
leaq 0x4(%r12), %rsi
leaq 0xcc(%r12), %rdx
leaq 0xd8(%r12), %rcx
movl %eax, (%rsp)
leaq 0x70(%rsp), %rdi
movq %rsi, %r8
movq %r12, %r9
movq 0x30955(%rip), %rax     # 0x68600
callq *0x60(%rax)
cmpl $0x0, 0x74(%rsp)
je 0x37f98
movq 0x30898(%rip), %rax     # 0x68558
cmpq $0x0, (%rax)
je 0x37f98
cmpl $0x2, 0x118(%r15)
jne 0x37ce0
movq 0x30b6d(%rip), %rcx     # 0x68848
movq (%rcx), %r13
jmp 0x37cf8
movq 0x30b61(%rip), %rcx     # 0x68848
movq (%rcx), %r13
cmpq %r15, 0x2b8(%r12)
jne 0x38014
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
je 0x37da8
movswl 0x16(%rax), %ecx
cvtsi2ss %ecx, %xmm3
addss 0x4(%rbp), %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, 0x60(%rsp)
movaps %xmm1, %xmm3
subss 0xc(%r15), %xmm3
movss %xmm3, 0x68(%rsp)
movaps %xmm2, %xmm5
shufps $0x55, %xmm2, %xmm5     # xmm5 = xmm5[1,1],xmm2[1,1]
movss 0x38(%rsp), %xmm4
mulss %xmm5, %xmm4
movss 0x34(%rsp), %xmm6
mulss %xmm2, %xmm6
addss %xmm4, %xmm6
movss 0x3c(%rsp), %xmm4
mulss %xmm3, %xmm4
addss %xmm6, %xmm4
movss 0x2c(%rsp), %xmm6
mulss %xmm5, %xmm6
movss 0x28(%rsp), %xmm7
mulss %xmm2, %xmm7
addss %xmm6, %xmm7
movss 0x30(%rsp), %xmm6
mulss %xmm3, %xmm6
addss %xmm7, %xmm6
xorps 0x1deab(%rip), %xmm6    # 0x55cd0
unpcklps %xmm6, %xmm4            # xmm4 = xmm4[0],xmm6[0],xmm4[1],xmm6[1]
mulss 0x20(%rsp), %xmm5
movss 0x1c(%rsp), %xmm6
mulss %xmm2, %xmm6
addss %xmm5, %xmm6
movss 0x24(%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 0x37e7b
movq $0x0, 0x2b8(%r12)
leaq 0x4(%r12), %rbp
movl 0x10c(%r12), %eax
testl %eax, %eax
movl $0x3, %ecx
cmovel %ecx, %eax
leaq 0xcc(%r12), %r13
leaq 0xd8(%r12), %rcx
movl %eax, (%rsp)
leaq 0x70(%rsp), %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq %rcx, 0x58(%rsp)
movq %rbp, %r8
movq %r12, %r9
movq 0x3073e(%rip), %rax     # 0x68600
callq *0x60(%rax)
cmpl $0x0, 0x74(%rsp)
je 0x37f7c
movq 0x30681(%rip), %rax     # 0x68558
cmpq $0x0, (%rax)
je 0x37f7c
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)
movl 0x10c(%r12), %eax
testl %eax, %eax
movl $0x3, %ecx
cmovel %ecx, %eax
movl %eax, (%rsp)
leaq 0x70(%rsp), %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq 0x58(%rsp), %rcx
movq %rbp, %r8
movq %r12, %r9
movq 0x306b2(%rip), %rax     # 0x68600
callq *0x60(%rax)
cmpl $0x0, 0x74(%rsp)
movq 0x308eb(%rip), %rax     # 0x68848
movq (%rax), %r13
je 0x37f73
movq 0x305ef(%rip), %rcx     # 0x68558
cmpq $0x0, (%rcx)
jne 0x38014
addq $-0x28, %r13
movq %r13, (%rax)
jmp 0x37f8c
movq %r12, %rdi
movq 0x3067a(%rip), %rax     # 0x68600
callq *0x90(%rax)
movq 0x10(%rsp), %rbp
movq 0x30b70(%rip), %r13     # 0x68b08
incl %ebx
addq $0x4a8, %r12            # imm = 0x4A8
cmpl 0x8c(%r13), %ebx
jl 0x37bbc
movq 0x30893(%rip), %rax     # 0x68848
movq (%rax), %r14
addq $-0x28, %r14
movl $0x1, %ebx
cmpq 0x30d10(%rip), %r14     # 0x68cd8
jb 0x38000
movq 0x30d07(%rip), %r15     # 0x68cd8
movq (%r14), %rdi
callq 0x19200
addq $-0x28, %r14
cmpq %r15, %r14
jae 0x37fd1
jmp 0x38000
movq 0x30615(%rip), %rcx     # 0x68600
leaq 0x1fa66(%rip), %rdi     # 0x57a58
leaq 0x1fa78(%rip), %rsi     # 0x57a71
xorl %ebx, %ebx
xorl %eax, %eax
callq *0x8(%rcx)
movl %ebx, %eax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x3085d(%rip), %rax     # 0x68878
movq %r12, (%rax)
addq $-0x28, %r13
xorl %ebx, %ebx
cmpq 0x30cad(%rip), %r13     # 0x68cd8
jb 0x38000
movq 0x30ca4(%rip), %r14     # 0x68cd8
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 0x3808d
cvttss2si 0x20(%r13), %ecx
movw %cx, 0x16(%rax)
movq 0x3056c(%rip), %rax     # 0x68600
callq *0x90(%rax)
addq $-0x28, %r13
cmpq %r14, %r13
jae 0x38034
jmp 0x38000