// File: /workspace/github_c_makefile_star2_O1/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 $0xa8, %rsp
testq %rdi, %rdi
je 0x38861
movq %rdx, %r13
movq %rsi, %r14
movq %rdi, %r15
xorl %eax, %eax
movss 0x1bcca(%rip), %xmm0    # 0x53ef8
xorps %xmm1, %xmm1
leaq 0x205b0(%rip), %rcx     # 0x587e8
movsd 0x205b0(%rip), %xmm2    # 0x587f0
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 0x38240
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 0x38278
movq 0x314b5(%rip), %rax     # 0x69768
movss (%rax), %xmm0
movss 0x4(%rax), %xmm1
subss (%r13), %xmm0
leaq 0x34(%rsp), %rdi
movss %xmm0, (%rdi)
subss 0x4(%r13), %xmm1
movss %xmm1, 0x4(%rdi)
movss 0x8(%rax), %xmm0
subss 0x8(%r13), %xmm0
movss %xmm0, 0x8(%rdi)
leaq 0x28(%rsp), %rsi
leaq 0x1c(%rsp), %rdx
leaq 0x10(%rsp), %rcx
callq 0x183a0
movq 0x31547(%rip), %rbp     # 0x69848
movq (%rbp), %rax
movq %r15, (%rax)
movss 0x4(%r15), %xmm0
movq (%rbp), %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 0x38367
movswl 0x16(%rcx), %ecx
xorps %xmm0, %xmm0
cvtsi2ss %ecx, %xmm0
movss %xmm0, 0x20(%rax)
addq $0x28, %rax
movq %rax, (%rbp)
movss 0x4(%r15), %xmm0
movss 0x8(%r15), %xmm1
addss (%r14), %xmm0
movss %xmm0, 0x4(%r15)
addss 0x4(%r14), %xmm1
movss %xmm1, 0x8(%r15)
movss 0xc(%r15), %xmm0
addss 0x8(%r14), %xmm0
movss %xmm0, 0xc(%r15)
movss 0x10(%r15), %xmm0
addss (%r13), %xmm0
movss %xmm0, 0x10(%r15)
movss 0x14(%r15), %xmm0
addss 0x4(%r13), %xmm0
movss %xmm0, 0x14(%r15)
movss 0x18(%r15), %xmm0
addss 0x8(%r13), %xmm0
movss %xmm0, 0x18(%r15)
movq 0x3121f(%rip), %rax     # 0x69600
movq %r15, %rdi
callq *0x90(%rax)
movq 0x31717(%rip), %rax     # 0x69b08
cmpl $0x2, 0x8c(%rax)
jl 0x38831
movq 0x31153(%rip), %rcx     # 0x69558
movl $0x4a8, %r12d           # imm = 0x4A8
addq (%rcx), %r12
movl $0x1, %ebx
movq %r13, 0x8(%rsp)
cmpl $0x0, 0x60(%r12)
je 0x3881c
cmpl $0x4, 0x118(%r12)
jb 0x3881c
cmpq $0x0, 0x68(%r12)
je 0x3881c
cmpq %r15, 0x2b8(%r12)
je 0x3852d
movss 0xe4(%r12), %xmm0
ucomiss 0x40(%rsp), %xmm0
jae 0x3881c
movss 0xe8(%r12), %xmm0
ucomiss 0x44(%rsp), %xmm0
jae 0x3881c
movss 0xec(%r12), %xmm0
ucomiss 0x48(%rsp), %xmm0
jae 0x3881c
movss 0x4c(%rsp), %xmm0
ucomiss 0xf0(%r12), %xmm0
jae 0x3881c
movss 0x50(%rsp), %xmm0
ucomiss 0xf4(%r12), %xmm0
jae 0x3881c
movss 0x54(%rsp), %xmm0
ucomiss 0xf8(%r12), %xmm0
jae 0x3881c
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 0x60(%rsp), %rdi
movq %rsi, %r8
movq %r12, %r9
movq 0x310f9(%rip), %rax     # 0x69600
callq *0x60(%rax)
movq 0x315f7(%rip), %rax     # 0x69b08
cmpl $0x0, 0x64(%rsp)
je 0x3881c
movq 0x31035(%rip), %rcx     # 0x69558
cmpq $0x0, (%rcx)
je 0x3881c
cmpl $0x2, 0x118(%r15)
je 0x38545
cmpq %r15, 0x2b8(%r12)
jne 0x38891
movq (%rbp), %rax
movq %r12, (%rax)
movss 0x4(%r12), %xmm0
movq (%rbp), %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, (%rbp)
movss 0x4(%r12), %xmm0
addss (%r14), %xmm0
movss 0x8(%r12), %xmm1
movss %xmm0, 0x4(%r12)
addss 0x4(%r14), %xmm1
movss %xmm1, 0x8(%r12)
movss 0xc(%r12), %xmm0
addss 0x8(%r14), %xmm0
movss %xmm0, 0xc(%r12)
movq 0x58(%r12), %rax
testq %rax, %rax
je 0x385fe
movswl 0x16(%rax), %ecx
xorps %xmm1, %xmm1
cvtsi2ss %ecx, %xmm1
addss 0x4(%r13), %xmm1
cvttss2si %xmm1, %ecx
movw %cx, 0x16(%rax)
movss 0x4(%r12), %xmm1
movaps %xmm1, %xmm3
subss 0x4(%r15), %xmm3
movss %xmm3, 0x34(%rsp)
movss 0x8(%r12), %xmm2
movaps %xmm2, %xmm5
subss 0x8(%r15), %xmm5
movss %xmm5, 0x38(%rsp)
movaps %xmm0, %xmm4
subss 0xc(%r15), %xmm4
movss %xmm4, 0x3c(%rsp)
movss 0x2c(%rsp), %xmm6
mulss %xmm5, %xmm6
movss 0x28(%rsp), %xmm7
mulss %xmm3, %xmm7
addss %xmm6, %xmm7
movss 0x30(%rsp), %xmm6
mulss %xmm4, %xmm6
addss %xmm7, %xmm6
movss 0x20(%rsp), %xmm7
mulss %xmm5, %xmm7
movss 0x1c(%rsp), %xmm8
mulss %xmm3, %xmm8
addss %xmm7, %xmm8
movss 0x24(%rsp), %xmm7
mulss %xmm4, %xmm7
addss %xmm8, %xmm7
xorps 0x1e580(%rip), %xmm7    # 0x56c10
subss %xmm5, %xmm7
mulss 0x14(%rsp), %xmm5
subss %xmm3, %xmm6
mulss 0x10(%rsp), %xmm3
addss %xmm5, %xmm3
movss 0x18(%rsp), %xmm5
mulss %xmm4, %xmm5
addss %xmm3, %xmm5
subss %xmm4, %xmm5
addss %xmm1, %xmm6
movss %xmm6, 0x4(%r12)
addss %xmm2, %xmm7
movss %xmm7, 0x8(%r12)
addss %xmm0, %xmm5
movss %xmm5, 0xc(%r12)
cmpq %r15, 0x2b8(%r12)
je 0x386f1
movq $0x0, 0x2b8(%r12)
movl 0x10c(%r12), %eax
testl %eax, %eax
movl $0x3, %ecx
cmovel %ecx, %eax
leaq 0x4(%r12), %rbp
leaq 0xcc(%r12), %r13
leaq 0xd8(%r12), %rcx
movl %eax, (%rsp)
leaq 0x60(%rsp), %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq %rcx, 0x58(%rsp)
movq %rbp, %r8
movq %r12, %r9
movq 0x30ec8(%rip), %rax     # 0x69600
callq *0x60(%rax)
cmpl $0x0, 0x64(%rsp)
je 0x387f9
movq 0x30e0b(%rip), %rax     # 0x69558
cmpq $0x0, (%rax)
je 0x387f9
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 0x60(%rsp), %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq 0x58(%rsp), %rcx
movq %rbp, %r8
movq %r12, %r9
movq 0x30e3c(%rip), %rax     # 0x69600
callq *0x60(%rax)
cmpl $0x0, 0x64(%rsp)
movq 0x8(%rsp), %r13
movq 0x31070(%rip), %rbp     # 0x69848
movq 0x31329(%rip), %rax     # 0x69b08
je 0x387f2
movq 0x30d70(%rip), %rcx     # 0x69558
cmpq $0x0, (%rcx)
jne 0x38891
addq $-0x28, (%rbp)
jmp 0x3881c
movq %r12, %rdi
movq 0x30dfd(%rip), %rax     # 0x69600
callq *0x90(%rax)
movq 0x8(%rsp), %r13
movq 0x31033(%rip), %rbp     # 0x69848
movq 0x312ec(%rip), %rax     # 0x69b08
incl %ebx
addq $0x4a8, %r12            # imm = 0x4A8
cmpl 0x8c(%rax), %ebx
jl 0x38418
movq (%rbp), %r14
addq $-0x28, %r14
movl $0x1, %ebx
cmpq 0x31493(%rip), %r14     # 0x69cd8
jb 0x3887d
movq 0x3148a(%rip), %r15     # 0x69cd8
movq (%r14), %rdi
callq 0x19200
addq $-0x28, %r14
cmpq %r15, %r14
jae 0x3884e
jmp 0x3887d
movq 0x30d98(%rip), %rcx     # 0x69600
leaq 0x1ffd5(%rip), %rdi     # 0x58844
leaq 0x1ffe7(%rip), %rsi     # 0x5885d
xorl %ebx, %ebx
xorl %eax, %eax
callq *0x8(%rcx)
movl %ebx, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x30fe0(%rip), %rax     # 0x69878
movq %r12, (%rax)
movq (%rbp), %r14
addq $-0x28, %r14
xorl %ebx, %ebx
cmpq 0x3142c(%rip), %r14     # 0x69cd8
jb 0x3887d
movq 0x31423(%rip), %r15     # 0x69cd8
movss 0x8(%r14), %xmm0
movq (%r14), %rdi
movss %xmm0, 0x4(%rdi)
movss 0xc(%r14), %xmm0
movss %xmm0, 0x8(%rdi)
movss 0x10(%r14), %xmm0
movss %xmm0, 0xc(%rdi)
movss 0x14(%r14), %xmm0
movss %xmm0, 0x10(%rdi)
movss 0x18(%r14), %xmm0
movss %xmm0, 0x14(%rdi)
movss 0x1c(%r14), %xmm0
movss %xmm0, 0x18(%rdi)
movq 0x58(%rdi), %rax
testq %rax, %rax
je 0x3890d
cvttss2si 0x20(%r14), %ecx
movw %cx, 0x16(%rax)
movq 0x30cec(%rip), %rax     # 0x69600
callq *0x90(%rax)
addq $-0x28, %r14
cmpq %r15, %r14
jae 0x388b5
jmp 0x3887d