// File: /workspace/github_c_makefile_star2_O2/QwazyWabbitWOS[P]lmctf60/m_move.c
// Function: SV_movestep
qboolean SV_movestep (edict_t *ent, vec3_t move, qboolean relink)
{
	float		dz;
	vec3_t		oldorg, neworg, end;
	trace_t		trace;
	int			i;
	float		stepsize;
	vec3_t		test;
	int			contents;

// try the move	
	VectorCopy (ent->s.origin, oldorg);
	VectorAdd (ent->s.origin, move, neworg);

// flying monsters don't step up
	if ( ent->flags & (FL_SWIM | FL_FLY) )
	{
	// try one move with vertical motion, then one without
		for (i=0 ; i<2 ; i++)
		{
			VectorAdd (ent->s.origin, move, neworg);
			if (i == 0 && ent->enemy)
			{
				if (!ent->goalentity)
					ent->goalentity = ent->enemy;
				dz = ent->s.origin[2] - ent->goalentity->s.origin[2];
				if (ent->goalentity->client)
				{
					if (dz > 40)
						neworg[2] -= 8;
					if (!((ent->flags & FL_SWIM) && (ent->waterlevel < 2)))
						if (dz < 30)
							neworg[2] += 8;
				}
				else
				{
					if (dz > 8)
						neworg[2] -= 8;
					else if (dz > 0)
						neworg[2] -= dz;
					else if (dz < -8)
						neworg[2] += 8;
					else
						neworg[2] += dz;
				}
			}
			trace = gi.trace (ent->s.origin, ent->mins, ent->maxs, neworg, ent, MASK_MONSTERSOLID);
	
			// fly monsters don't enter water voluntarily
			if (ent->flags & FL_FLY)
			{
				if (!ent->waterlevel)
				{
					test[0] = trace.endpos[0];
					test[1] = trace.endpos[1];
					test[2] = trace.endpos[2] + ent->mins[2] + 1;
					contents = gi.pointcontents(test);
					if (contents & MASK_WATER)
						return false;
				}
			}

			// swim monsters don't exit water voluntarily
			if (ent->flags & FL_SWIM)
			{
				if (ent->waterlevel < 2)
				{
					test[0] = trace.endpos[0];
					test[1] = trace.endpos[1];
					test[2] = trace.endpos[2] + ent->mins[2] + 1;
					contents = gi.pointcontents(test);
					if (!(contents & MASK_WATER))
						return false;
				}
			}

			if (trace.fraction == 1)
			{
				VectorCopy (trace.endpos, ent->s.origin);
				if (relink)
				{
					gi.linkentity (ent);
					G_TouchTriggers (ent);
				}
				return true;
			}
			
			if (!ent->enemy)
				break;
		}
		
		return false;
	}

// push down from a step height above the wished position
	if (!(ent->monsterinfo.aiflags & AI_NOSTEP))
		stepsize = STEPSIZE;
	else
		stepsize = 1;

	neworg[2] += stepsize;
	VectorCopy (neworg, end);
	end[2] -= stepsize*2;

	trace = gi.trace (neworg, ent->mins, ent->maxs, end, ent, MASK_MONSTERSOLID);

	if (trace.allsolid)
		return false;

	if (trace.startsolid)
	{
		neworg[2] -= stepsize;
		trace = gi.trace (neworg, ent->mins, ent->maxs, end, ent, MASK_MONSTERSOLID);
		if (trace.allsolid || trace.startsolid)
			return false;
	}


	// don't go in to water
	if (ent->waterlevel == 0)
	{
		test[0] = trace.endpos[0];
		test[1] = trace.endpos[1];
		test[2] = trace.endpos[2] + ent->mins[2] + 1;	
		contents = gi.pointcontents(test);

		if (contents & MASK_WATER)
			return false;
	}

	if (trace.fraction == 1)
	{
	// if monster had the ground pulled out, go ahead and fall
		if ( ent->flags & FL_PARTIALGROUND )
		{
			VectorAdd (ent->s.origin, move, ent->s.origin);
			if (relink)
			{
				gi.linkentity (ent);
				G_TouchTriggers (ent);
			}
			ent->groundentity = NULL;
			return true;
		}
	
		return false;		// walked off an edge
	}

// check point traces down for dangling corners
	VectorCopy (trace.endpos, ent->s.origin);
	
	if (!M_CheckBottom (ent))
	{
		if ( ent->flags & FL_PARTIALGROUND )
		{	// entity had floor mostly pulled out from underneath it
			// and is trying to correct
			if (relink)
			{
				gi.linkentity (ent);
				G_TouchTriggers (ent);
			}
			return true;
		}
		VectorCopy (oldorg, ent->s.origin);
		return false;
	}

	if ( ent->flags & FL_PARTIALGROUND )
	{
		ent->flags &= ~FL_PARTIALGROUND;
	}
	ent->groundentity = trace.ent;
	ent->groundentity_linkcount = trace.ent->linkcount;

// the move is ok
	if (relink)
	{
		gi.linkentity (ent);
		G_TouchTriggers (ent);
	}
	return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movl %edx, 0x1c(%rsp)
movq %rsi, %r15
movq %rdi, %rbx
movsd 0x4(%rdi), %xmm1
movss 0xc(%rdi), %xmm2
movsd (%rsi), %xmm0
addps %xmm1, %xmm0
movlps %xmm0, 0x20(%rsp)
testb $0x3, 0x11c(%rdi)
je 0x3e1c5
leaq 0x4(%rbx), %rax
movq %rax, 0x50(%rsp)
leaq 0xcc(%rbx), %r13
leaq 0xd8(%rbx), %rbp
pushq $0x2
popq %rax
movl %eax, %r12d
xorl %r14d, %r14d
subl $0x1, %r12d
jb 0x3e302
movsd 0x4(%rbx), %xmm0
movsd (%r15), %xmm1
addps %xmm0, %xmm1
movlps %xmm1, 0x20(%rsp)
movss 0xc(%rbx), %xmm1
movss 0x8(%r15), %xmm0
addss %xmm1, %xmm0
movss %xmm0, 0x28(%rsp)
cmpl $0x2, %eax
jne 0x3e08f
movq 0x2a0(%rbx), %rax
testq %rax, %rax
je 0x3e08f
movq 0x1e8(%rbx), %rcx
testq %rcx, %rcx
jne 0x3e00a
movq %rax, 0x1e8(%rbx)
movq %rax, %rcx
subss 0xc(%rcx), %xmm1
cmpq $0x0, 0x58(%rcx)
je 0x3e056
ucomiss 0x13c0b(%rip), %xmm1    # 0x51c28
jbe 0x3e02d
addss 0x123e5(%rip), %xmm0    # 0x5040c
movss %xmm0, 0x28(%rsp)
testb $0x2, 0x11c(%rbx)
je 0x3e03f
cmpl $0x2, 0x30c(%rbx)
jl 0x3e08f
movss 0x1124d(%rip), %xmm2    # 0x4f294
ucomiss %xmm1, %xmm2
jbe 0x3e08f
addss 0x10ea4(%rip), %xmm0    # 0x4eef8
jmp 0x3e089
ucomiss 0x10e9b(%rip), %xmm1    # 0x4eef8
jbe 0x3e069
addss 0x123a5(%rip), %xmm0    # 0x5040c
jmp 0x3e089
ucomiss 0x11920(%rip), %xmm1    # 0x4f990
jbe 0x3e078
subss %xmm1, %xmm0
jmp 0x3e089
movss 0x1238c(%rip), %xmm2    # 0x5040c
ucomiss %xmm1, %xmm2
ja 0x3e04c
addss %xmm1, %xmm0
movss %xmm0, 0x28(%rsp)
movl $0x2020003, (%rsp)      # imm = 0x2020003
leaq 0x60(%rsp), %rdi
movq 0x50(%rsp), %rsi
movq %r13, %rdx
movq %rbp, %rcx
leaq 0x20(%rsp), %r8
movq %rbx, %r9
movq 0x2854b(%rip), %rax     # 0x66600
callq *0x60(%rax)
movss 0x68(%rsp), %xmm2
movsd 0x6c(%rsp), %xmm0
movss 0x74(%rsp), %xmm1
movl 0x11c(%rbx), %eax
testb $0x1, %al
je 0x3e13b
cmpl $0x0, 0x30c(%rbx)
jne 0x3e13b
movss %xmm2, 0x14(%rsp)
movaps %xmm0, 0x40(%rsp)
movlps %xmm0, 0x30(%rsp)
movss 0xd4(%rbx), %xmm0
movss %xmm1, 0x18(%rsp)
addss %xmm1, %xmm0
addss 0x10e21(%rip), %xmm0    # 0x4ef28
movss %xmm0, 0x38(%rsp)
leaq 0x30(%rsp), %rdi
movq 0x284e7(%rip), %rax     # 0x66600
callq *0x68(%rax)
testb $0x38, %al
jne 0x3e302
movl 0x11c(%rbx), %eax
movaps 0x40(%rsp), %xmm0
movss 0x18(%rsp), %xmm1
movss 0x14(%rsp), %xmm2
testb $0x2, %al
je 0x3e1a0
cmpl $0x1, 0x30c(%rbx)
jg 0x3e1a0
movlps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x40(%rsp)
movss 0xd4(%rbx), %xmm0
addss %xmm1, %xmm0
addss 0x10dc2(%rip), %xmm0    # 0x4ef28
movss %xmm0, 0x38(%rsp)
leaq 0x30(%rsp), %rdi
movq 0x28488(%rip), %rax     # 0x66600
movss %xmm1, 0x18(%rsp)
movss %xmm2, 0x14(%rsp)
callq *0x68(%rax)
movss 0x14(%rsp), %xmm2
movss 0x18(%rsp), %xmm1
movaps 0x40(%rsp), %xmm0
testb $0x38, %al
je 0x3e302
ucomiss 0x10d81(%rip), %xmm2    # 0x4ef28
jne 0x3e1af
jnp 0x3e2d6
cmpq $0x0, 0x2a0(%rbx)
movl %r12d, %eax
jne 0x3dfaa
jmp 0x3e302
movaps %xmm1, 0x40(%rsp)
movss 0x8(%r15), %xmm1
xorl %eax, %eax
btl $0xa, 0x3c0(%rbx)
addss %xmm2, %xmm1
setae %al
leaq 0x17558(%rip), %rcx     # 0x55740
movss (%rcx,%rax,4), %xmm3
addss %xmm3, %xmm1
leaq 0x20(%rsp), %rsi
movss %xmm1, 0x8(%rsi)
leaq 0xa8(%rsp), %r8
movlps %xmm0, (%r8)
movss %xmm3, 0x50(%rsp)
movaps %xmm3, %xmm0
addss %xmm3, %xmm0
subss %xmm0, %xmm1
movss %xmm1, 0x8(%r8)
movq 0x283db(%rip), %rax     # 0x66600
leaq 0xcc(%rbx), %r12
leaq 0xd8(%rbx), %r13
movl $0x2020003, (%rsp)      # imm = 0x2020003
leaq 0x60(%rsp), %rbp
movq %rbp, %rdi
movq %r12, %rdx
movq %r13, %rcx
movq %rbx, %r9
movss %xmm2, 0x18(%rsp)
callq *0x60(%rax)
xorl %r14d, %r14d
cmpl $0x0, (%rbp)
jne 0x3e302
movss 0x50(%rsp), %xmm1
movq 0x28392(%rip), %rax     # 0x66600
cmpl $0x0, 0x64(%rsp)
je 0x3e317
leaq 0x20(%rsp), %rsi
movss 0x8(%rsi), %xmm0
subss %xmm1, %xmm0
movss %xmm0, 0x8(%rsi)
movl $0x2020003, (%rsp)      # imm = 0x2020003
leaq 0x60(%rsp), %rbp
leaq 0xa8(%rsp), %r8
movq %rbp, %rdi
movq %r12, %rdx
movq %r13, %rcx
movq %rbx, %r9
movq %rax, %r13
callq *0x60(%rax)
movl 0x4(%rbp), %eax
orl (%rbp), %eax
jne 0x3e302
movss 0x68(%rsp), %xmm2
movsd 0x6c(%rsp), %xmm0
movss 0x74(%rsp), %xmm1
movq 0xa0(%rsp), %r12
jmp 0x3e334
movlps %xmm0, 0x4(%rbx)
movss %xmm1, 0xc(%rbx)
pushq $0x1
popq %r14
cmpl $0x0, 0x1c(%rsp)
je 0x3e302
movq %rbx, %rdi
movq 0x2830c(%rip), %rax     # 0x66600
callq *0x90(%rax)
movq %rbx, %rdi
callq 0x19380
movl %r14d, %eax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movss 0x68(%rsp), %xmm2
movsd 0x6c(%rsp), %xmm0
movss 0x74(%rsp), %xmm1
movq 0xa0(%rsp), %r12
movq %rax, %r13
cmpl $0x0, 0x30c(%rbx)
je 0x3e3b2
ucomiss 0x10be4(%rip), %xmm2    # 0x4ef28
jne 0x3e406
jp 0x3e406
testb $0x1, 0x11d(%rbx)
je 0x3e302
movss 0x4(%rbx), %xmm0
movss 0x8(%rbx), %xmm1
addss (%r15), %xmm0
movss %xmm0, 0x4(%rbx)
addss 0x4(%r15), %xmm1
movss %xmm1, 0x8(%rbx)
movss 0xc(%rbx), %xmm0
addss 0x8(%r15), %xmm0
movss %xmm0, 0xc(%rbx)
cmpl $0x0, 0x1c(%rsp)
je 0x3e3a1
movq %rbx, %rdi
callq *0x90(%r13)
movq %rbx, %rdi
callq 0x19380
andq $0x0, 0x2b8(%rbx)
pushq $0x1
popq %r14
jmp 0x3e302
leaq 0x30(%rsp), %rdi
movlps %xmm0, (%rdi)
movaps %xmm0, 0x50(%rsp)
movss 0xd4(%rbx), %xmm0
addss %xmm1, %xmm0
addss 0x10b55(%rip), %xmm0    # 0x4ef28
movss %xmm0, 0x8(%rdi)
movss %xmm1, 0x14(%rsp)
movss %xmm2, 0x3c(%rsp)
callq *0x68(%r13)
movss 0x3c(%rsp), %xmm2
movss 0x14(%rsp), %xmm1
movaps 0x50(%rsp), %xmm0
testb $0x38, %al
jne 0x3e302
jmp 0x3e33d
movlps %xmm0, 0x4(%rbx)
movss %xmm1, 0xc(%rbx)
movq %rbx, %rdi
callq 0x192a0
movl 0x11c(%rbx), %ecx
testl %eax, %eax
je 0x3e447
btl $0x8, %ecx
jae 0x3e433
andl $0xfffffeff, %ecx       # imm = 0xFFFFFEFF
movl %ecx, 0x11c(%rbx)
movq %r12, 0x2b8(%rbx)
movl 0x64(%r12), %eax
movl %eax, 0x2c0(%rbx)
jmp 0x3e466
btl $0x8, %ecx
jb 0x3e466
movaps 0x40(%rsp), %xmm0
movlps %xmm0, 0x4(%rbx)
movss 0x18(%rsp), %xmm0
movss %xmm0, 0xc(%rbx)
jmp 0x3e302
pushq $0x1
popq %r14
cmpl $0x0, 0x1c(%rsp)
je 0x3e302
movq %rbx, %rdi
callq *0x90(%r13)
jmp 0x3e2fa