// File: /workspace/github_c_makefile_star2_O3/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, %r14
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 0x41848
leaq 0x4(%rbx), %rax
movq %rax, 0x50(%rsp)
leaq 0xcc(%rbx), %r12
leaq 0xd8(%rbx), %r13
movb $0x1, %r15b
xorl %ebp, %ebp
movsd 0x4(%rbx), %xmm0
movsd (%r14), %xmm1
addps %xmm0, %xmm1
movlps %xmm1, 0x20(%rsp)
movss 0xc(%rbx), %xmm1
movss 0x8(%r14), %xmm0
addss %xmm1, %xmm0
movss %xmm0, 0x28(%rsp)
testb $0x1, %r15b
je 0x41709
movq 0x2a0(%rbx), %rax
testq %rax, %rax
je 0x41709
movq 0x1e8(%rbx), %rcx
testq %rcx, %rcx
jne 0x41684
movq %rax, 0x1e8(%rbx)
movq %rax, %rcx
subss 0xc(%rcx), %xmm1
cmpq $0x0, 0x58(%rcx)
je 0x416d0
ucomiss 0x145b1(%rip), %xmm1    # 0x55c48
jbe 0x416a7
addss 0x12d6b(%rip), %xmm0    # 0x5440c
movss %xmm0, 0x28(%rsp)
testb $0x2, 0x11c(%rbx)
je 0x416b9
cmpl $0x2, 0x30c(%rbx)
jl 0x41709
movss 0x11bd3(%rip), %xmm2    # 0x53294
ucomiss %xmm1, %xmm2
jbe 0x41709
addss 0x1182e(%rip), %xmm0    # 0x52efc
jmp 0x41703
ucomiss 0x11825(%rip), %xmm1    # 0x52efc
jbe 0x416e3
addss 0x12d2b(%rip), %xmm0    # 0x5440c
jmp 0x41703
ucomiss 0x122a6(%rip), %xmm1    # 0x53990
jbe 0x416f2
subss %xmm1, %xmm0
jmp 0x41703
movss 0x12d12(%rip), %xmm2    # 0x5440c
ucomiss %xmm1, %xmm2
ja 0x416c6
addss %xmm1, %xmm0
movss %xmm0, 0x28(%rsp)
movl $0x2020003, (%rsp)      # imm = 0x2020003
leaq 0x60(%rsp), %rdi
movq 0x50(%rsp), %rsi
movq %r12, %rdx
movq %r13, %rcx
leaq 0x20(%rsp), %r8
movq %rbx, %r9
movq 0x26ed1(%rip), %rax     # 0x68600
callq *0x60(%rax)
movss 0x68(%rsp), %xmm2
movsd 0x6c(%rsp), %xmm0
movss 0x74(%rsp), %xmm1
movl 0x11c(%rbx), %eax
testb $0x1, %al
je 0x417b5
cmpl $0x0, 0x30c(%rbx)
jne 0x417b5
movss %xmm2, 0x14(%rsp)
movaps %xmm0, 0x40(%rsp)
movlps %xmm0, 0x30(%rsp)
movss 0xd4(%rbx), %xmm0
movss %xmm1, 0x18(%rsp)
addss %xmm1, %xmm0
addss 0x117a7(%rip), %xmm0    # 0x52f28
movss %xmm0, 0x38(%rsp)
leaq 0x30(%rsp), %rdi
movq 0x26e6d(%rip), %rax     # 0x68600
callq *0x68(%rax)
testb $0x38, %al
jne 0x4198a
movl 0x11c(%rbx), %eax
movaps 0x40(%rsp), %xmm0
movss 0x18(%rsp), %xmm1
movss 0x14(%rsp), %xmm2
testb $0x2, %al
je 0x4181a
cmpl $0x1, 0x30c(%rbx)
jg 0x4181a
movlps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x40(%rsp)
movss 0xd4(%rbx), %xmm0
addss %xmm1, %xmm0
addss 0x11748(%rip), %xmm0    # 0x52f28
movss %xmm0, 0x38(%rsp)
leaq 0x30(%rsp), %rdi
movq 0x26e0e(%rip), %rax     # 0x68600
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 0x4198a
ucomiss 0x11707(%rip), %xmm2    # 0x52f28
jne 0x41829
jnp 0x4195b
cmpq $0x0, 0x2a0(%rbx)
setne %al
testb %r15b, %al
movl $0x0, %r15d
jne 0x4162d
jmp 0x4198c
movaps %xmm1, 0x40(%rsp)
movss 0x8(%r14), %xmm1
xorl %eax, %eax
btl $0xa, 0x3c0(%rbx)
addss %xmm2, %xmm1
setae %al
leaq 0x17eed(%rip), %rcx     # 0x59758
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 0x26d58(%rip), %rax     # 0x68600
leaq 0xcc(%rbx), %r15
leaq 0xd8(%rbx), %r12
movl $0x2020003, (%rsp)      # imm = 0x2020003
leaq 0x60(%rsp), %r13
movq %r13, %rdi
movq %r15, %rdx
movq %r12, %rcx
movq %rbx, %r9
movss %xmm2, 0x18(%rsp)
callq *0x60(%rax)
xorl %ebp, %ebp
cmpl $0x0, (%r13)
jne 0x4198c
movss 0x50(%rsp), %xmm1
movq 0x26d0f(%rip), %rax     # 0x68600
cmpl $0x0, 0x64(%rsp)
je 0x419a0
leaq 0x20(%rsp), %rsi
movss 0x8(%rsi), %xmm0
subss %xmm1, %xmm0
movss %xmm0, 0x8(%rsi)
movl $0x2020003, (%rsp)      # imm = 0x2020003
leaq 0x60(%rsp), %r13
leaq 0xa8(%rsp), %r8
movq %r13, %rdi
movq %r15, %rdx
movq %r12, %rcx
movq %rbx, %r9
movq %rax, %r12
callq *0x60(%rax)
movl 0x4(%r13), %eax
orl (%r13), %eax
jne 0x4198c
movss 0x68(%rsp), %xmm2
movsd 0x6c(%rsp), %xmm0
movss 0x74(%rsp), %xmm1
movq 0xa0(%rsp), %r15
jmp 0x419bd
movlps %xmm0, 0x4(%rbx)
movss %xmm1, 0xc(%rbx)
movl $0x1, %ebp
cmpl $0x0, 0x1c(%rsp)
je 0x4198c
movq %rbx, %rdi
movq 0x26c86(%rip), %rax     # 0x68600
callq *0x90(%rax)
movq %rbx, %rdi
callq 0x19200
jmp 0x4198c
xorl %ebp, %ebp
movl %ebp, %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), %r15
movq %rax, %r12
cmpl $0x0, 0x30c(%rbx)
je 0x41a40
ucomiss 0x1155b(%rip), %xmm2    # 0x52f28
jne 0x41a95
jp 0x41a95
testb $0x1, 0x11d(%rbx)
je 0x4198c
movss 0x4(%rbx), %xmm0
movss 0x8(%rbx), %xmm1
addss (%r14), %xmm0
movss %xmm0, 0x4(%rbx)
addss 0x4(%r14), %xmm1
movss %xmm1, 0x8(%rbx)
movss 0xc(%rbx), %xmm0
addss 0x8(%r14), %xmm0
movss %xmm0, 0xc(%rbx)
cmpl $0x0, 0x1c(%rsp)
je 0x41a2b
movq %rbx, %rdi
callq *0x90(%r12)
movq %rbx, %rdi
callq 0x19200
movq $0x0, 0x2b8(%rbx)
movl $0x1, %ebp
jmp 0x4198c
leaq 0x30(%rsp), %rdi
movlps %xmm0, (%rdi)
movaps %xmm0, 0x50(%rsp)
movss 0xd4(%rbx), %xmm0
addss %xmm1, %xmm0
addss 0x114c7(%rip), %xmm0    # 0x52f28
movss %xmm0, 0x8(%rdi)
movss %xmm1, 0x14(%rsp)
movss %xmm2, 0x3c(%rsp)
callq *0x68(%r12)
movss 0x3c(%rsp), %xmm2
movss 0x14(%rsp), %xmm1
movaps 0x50(%rsp), %xmm0
testb $0x38, %al
jne 0x4198c
jmp 0x419c6
movlps %xmm0, 0x4(%rbx)
movss %xmm1, 0xc(%rbx)
movq %rbx, %rdi
callq 0x19130
movl 0x11c(%rbx), %ecx
testl %eax, %eax
je 0x41ad5
btl $0x8, %ecx
jae 0x41ac2
andl $0xfffffeff, %ecx       # imm = 0xFFFFFEFF
movl %ecx, 0x11c(%rbx)
movq %r15, 0x2b8(%rbx)
movl 0x64(%r15), %eax
movl %eax, 0x2c0(%rbx)
jmp 0x41af4
btl $0x8, %ecx
jb 0x41af4
movaps 0x40(%rsp), %xmm0
movlps %xmm0, 0x4(%rbx)
movss 0x18(%rsp), %xmm0
movss %xmm0, 0xc(%rbx)
jmp 0x4198c
movl $0x1, %ebp
cmpl $0x0, 0x1c(%rsp)
je 0x4198c
movq %rbx, %rdi
callq *0x90(%r12)
jmp 0x41980