// File: /workspace/github_c_makefile_star2_O2/QwazyWabbitWOS[P]lmctf60/m_move.c
// Function: M_CheckBottom
qboolean M_CheckBottom (edict_t *ent)
{
	vec3_t	mins, maxs, start, stop;
	trace_t	trace;
	int		x, y;
	float	mid, bottom;
	
	VectorAdd (ent->s.origin, ent->mins, mins);
	VectorAdd (ent->s.origin, ent->maxs, maxs);

// if all of the points under the corners are solid world, don't bother
// with the tougher checks
// the corners must be within 16 of the midpoint
	start[2] = mins[2] - 1;
	for	(x=0 ; x<=1 ; x++)
		for	(y=0 ; y<=1 ; y++)
		{
			start[0] = x ? maxs[0] : mins[0];
			start[1] = y ? maxs[1] : mins[1];
			if (gi.pointcontents (start) != CONTENTS_SOLID)
				goto realcheck;
		}

	c_yes++;
	return true;		// we got out easy

realcheck:
	c_no++;
//
// check it for real...
//
	start[2] = mins[2];
	
// the midpoint must be within 16 of the bottom
	start[0] = stop[0] = (mins[0] + maxs[0])*0.5f;
	start[1] = stop[1] = (mins[1] + maxs[1])*0.5f;
	stop[2] = start[2] - 2*STEPSIZE;
	trace = gi.trace (start, vec3_origin, vec3_origin, stop, ent, MASK_MONSTERSOLID);

	if (trace.fraction == 1.0)
		return false;
	mid = bottom = trace.endpos[2];
	
// the corners must be within 16 of the midpoint	
	for	(x=0 ; x<=1 ; x++)
		for	(y=0 ; y<=1 ; y++)
		{
			start[0] = stop[0] = x ? maxs[0] : mins[0];
			start[1] = stop[1] = y ? maxs[1] : mins[1];
			
			trace = gi.trace (start, vec3_origin, vec3_origin, stop, ent, MASK_MONSTERSOLID);
			
			if (trace.fraction != 1.0 && trace.endpos[2] > bottom)
				bottom = trace.endpos[2];
			if (trace.fraction == 1.0 || mid - trace.endpos[2] > STEPSIZE)
				return false;
		}

	c_yes++;
	return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq %rdi, %rbx
movss 0xc(%rdi), %xmm2
addss 0xd4(%rdi), %xmm2
movsd 0x4(%rdi), %xmm0
movsd 0xcc(%rdi), %xmm3
addps %xmm0, %xmm3
movaps %xmm3, %xmm1
shufps $0x55, %xmm3, %xmm1     # xmm1 = xmm1[1,1],xmm3[1,1]
movaps %xmm1, 0x70(%rsp)
movsd 0xd8(%rdi), %xmm1
addps %xmm0, %xmm1
movaps %xmm1, 0x50(%rsp)
shufps $0x55, %xmm1, %xmm1     # xmm1 = xmm1[1,1,1,1]
movaps %xmm1, 0x60(%rsp)
movss 0x13f12(%rip), %xmm0    # 0x51c34
movss %xmm2, 0x18(%rsp)
addss %xmm2, %xmm0
leaq 0x20(%rsp), %r14
movss %xmm0, 0x8(%r14)
movaps %xmm3, 0x40(%rsp)
movss %xmm3, 0x1c(%rsp)
xorl %r15d, %r15d
pushq $0x2
popq %r12
movq 0x288b0(%rip), %rbp     # 0x66600
cmpl $0x2, %r15d
je 0x3df3b
movss 0x1c(%rsp), %xmm0
movss %xmm0, 0x14(%rsp)
testl %r15d, %r15d
je 0x3dd76
movaps 0x50(%rsp), %xmm0
movss %xmm0, 0x14(%rsp)
movl %r12d, %ecx
movl %r12d, %r13d
subl $0x1, %r13d
jb 0x3ddb3
movss 0x14(%rsp), %xmm0
movss %xmm0, 0x20(%rsp)
movaps 0x70(%rsp), %xmm0
cmpl $0x2, %ecx
je 0x3dd9d
movaps 0x60(%rsp), %xmm0
movss %xmm0, 0x24(%rsp)
movq %r14, %rdi
callq *0x68(%rbp)
movl %r13d, %ecx
cmpl $0x1, %eax
je 0x3dd7c
jmp 0x3ddb8
incl %r15d
jmp 0x3dd50
movq 0x286d1(%rip), %rax     # 0x66490
incl (%rax)
leaq 0x20(%rsp), %rsi
movss 0x18(%rsp), %xmm0
movss %xmm0, 0x8(%rsi)
movaps 0x40(%rsp), %xmm1
addps 0x50(%rsp), %xmm1
mulps 0x13e6e(%rip), %xmm1    # 0x51c50
leaq 0x30(%rsp), %r8
movlps %xmm1, (%r8)
movlps %xmm1, (%rsi)
addss 0x17922(%rip), %xmm0    # 0x55718
movss %xmm0, 0x8(%r8)
movl $0x2020003, (%rsp)      # imm = 0x2020003
movq 0x2895e(%rip), %rcx     # 0x66768
leaq 0x80(%rsp), %r14
movq %r14, %rdi
movq %rcx, %rdx
movq %rbx, %r9
callq *0x60(%rbp)
movss 0x8(%r14), %xmm0
xorl %eax, %eax
ucomiss 0x110fb(%rip), %xmm0    # 0x4ef28
jne 0x3de43
jp 0x3de43
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x80(%rsp), %rax
movss 0x14(%rax), %xmm0
movss %xmm0, 0x18(%rsp)
xorl %eax, %eax
pushq $0x2
popq %rcx
movq 0x28906(%rip), %r15     # 0x66768
leaq 0x20(%rsp), %r12
leaq 0x30(%rsp), %r13
cmpl $0x2, %eax
je 0x3df3b
movss 0x1c(%rsp), %xmm0
movss %xmm0, 0x14(%rsp)
movl %eax, 0x40(%rsp)
testl %eax, %eax
je 0x3de94
movaps 0x50(%rsp), %xmm0
movss %xmm0, 0x14(%rsp)
movl %ecx, %r14d
subl $0x1, %r14d
jb 0x3df2d
movss 0x14(%rsp), %xmm0
movss %xmm0, 0x30(%rsp)
movss %xmm0, 0x20(%rsp)
movaps 0x70(%rsp), %xmm0
cmpl $0x2, %ecx
je 0x3dec2
movaps 0x60(%rsp), %xmm0
movss %xmm0, 0x34(%rsp)
movss %xmm0, 0x24(%rsp)
movl $0x2020003, (%rsp)      # imm = 0x2020003
leaq 0x80(%rsp), %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r15, %rcx
movq %r13, %r8
movq %rbx, %r9
callq *0x60(%rbp)
movss 0x88(%rsp), %xmm0
xorl %eax, %eax
ucomiss 0x11027(%rip), %xmm0    # 0x4ef28
jne 0x3df09
jnp 0x3de31
movss 0x18(%rsp), %xmm0
subss 0x94(%rsp), %xmm0
ucomiss 0x177fd(%rip), %xmm0    # 0x5571c
movl %r14d, %ecx
jbe 0x3de97
jmp 0x3de31
movl 0x40(%rsp), %eax
incl %eax
pushq $0x2
popq %rcx
jmp 0x3de6c
movq 0x2874e(%rip), %rax     # 0x66690
incl (%rax)
pushq $0x1
popq %rax
jmp 0x3de31