// File: FreeSlave[P]vhlt/hlrad/lerp.cpp
// Function: FindSquares(localtriangulation_t*)
static void FindSquares (localtriangulation_t *lt)
{
	int i;
	localtriangulation_t::Wedge *w;
	std::vector< std::pair< vec_t, int > > dists;

	if ((int)lt->sortedwedges.size () <= 2)
	{
		return;
	}

	dists.resize ((int)lt->sortedwedges.size ());
	for (i = 0; i < (int)lt->sortedwedges.size (); i++)
	{
		w = &lt->sortedwedges[i];
		dists[i].first = DotProduct (w->leftspot, w->leftdirection);
		dists[i].second = i;
	}
	std::sort (dists.begin (), dists.end ());

	for (i = 0; i < (int)lt->sortedwedges.size (); i++)
	{
		TryMakeSquare (lt, dists[i].second);
		TryMakeSquare (lt, (dists[i].second - 2 + (int)lt->sortedwedges.size ()) % (int)lt->sortedwedges.size ());
	}
}

// Assembly:
subq $0x98, %rsp
movq %rdi, 0x90(%rsp)
leaq 0x68(%rsp), %rdi
callq 0x22530
movq 0x90(%rsp), %rdi
addq $0x70, %rdi
callq 0x1f6c0
cmpl $0x2, %eax
jg 0x1c81c
movl $0x1, 0x64(%rsp)
jmp 0x1ca94
movq 0x90(%rsp), %rdi
addq $0x70, %rdi
callq 0x1f6c0
movslq %eax, %rsi
leaq 0x68(%rsp), %rdi
callq 0x22650
jmp 0x1c83c
movl $0x0, 0x8c(%rsp)
movl 0x8c(%rsp), %eax
movl %eax, 0x3c(%rsp)
movq 0x90(%rsp), %rdi
addq $0x70, %rdi
callq 0x1f6c0
movq %rax, %rcx
movl 0x3c(%rsp), %eax
cmpl %ecx, %eax
jge 0x1c96a
movq 0x90(%rsp), %rdi
addq $0x70, %rdi
movslq 0x8c(%rsp), %rsi
callq 0x21b80
movq %rax, 0x80(%rsp)
movq 0x80(%rsp), %rax
movss 0x8(%rax), %xmm1
movq 0x80(%rsp), %rax
movss 0x14(%rax), %xmm2
movq 0x80(%rsp), %rax
movss 0xc(%rax), %xmm0
movq 0x80(%rsp), %rax
mulss 0x18(%rax), %xmm0
mulss %xmm2, %xmm1
addss %xmm0, %xmm1
movq 0x80(%rsp), %rax
movss 0x10(%rax), %xmm0
movq 0x80(%rsp), %rax
movss 0x1c(%rax), %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, 0x34(%rsp)
movslq 0x8c(%rsp), %rsi
leaq 0x68(%rsp), %rdi
callq 0x226f0
movss 0x34(%rsp), %xmm0
movss %xmm0, (%rax)
movl 0x8c(%rsp), %eax
movl %eax, 0x38(%rsp)
movslq 0x8c(%rsp), %rsi
leaq 0x68(%rsp), %rdi
callq 0x226f0
movl 0x38(%rsp), %ecx
movl %ecx, 0x4(%rax)
movl 0x8c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x8c(%rsp)
jmp 0x1c847
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x58(%rsp)
movl %eax, 0x54(%rsp)
leaq 0x68(%rsp), %rdi
callq 0x227b0
jmp 0x1caa6
leaq 0x68(%rsp), %rdi
movq %rdi, 0x28(%rsp)
callq 0x22750
movq 0x28(%rsp), %rdi
movq %rax, 0x48(%rsp)
callq 0x22780
movq %rax, 0x40(%rsp)
movq 0x48(%rsp), %rdi
movq 0x40(%rsp), %rsi
callq 0x22710
jmp 0x1c99e
movl $0x0, 0x8c(%rsp)
movl 0x8c(%rsp), %eax
movl %eax, 0x24(%rsp)
movq 0x90(%rsp), %rdi
addq $0x70, %rdi
callq 0x1f6c0
movq %rax, %rcx
movl 0x24(%rsp), %eax
cmpl %ecx, %eax
jge 0x1ca8c
movq 0x90(%rsp), %rax
movq %rax, 0x18(%rsp)
movslq 0x8c(%rsp), %rsi
leaq 0x68(%rsp), %rdi
callq 0x226f0
movq 0x18(%rsp), %rdi
movl 0x4(%rax), %esi
callq 0x1e930
jmp 0x1ca02
movq 0x90(%rsp), %rax
movq %rax, 0x8(%rsp)
movslq 0x8c(%rsp), %rsi
leaq 0x68(%rsp), %rdi
callq 0x226f0
movl 0x4(%rax), %eax
movl %eax, 0x4(%rsp)
movq 0x90(%rsp), %rdi
addq $0x70, %rdi
callq 0x1f6c0
movl 0x4(%rsp), %ecx
movl %eax, %edx
movl %ecx, %eax
movl %edx, %ecx
leal -0x2(%rax,%rcx), %eax
movl %eax, 0x14(%rsp)
movq 0x90(%rsp), %rdi
addq $0x70, %rdi
callq 0x1f6c0
movq 0x8(%rsp), %rdi
movq %rax, %rcx
movl 0x14(%rsp), %eax
cltd
idivl %ecx
movl %edx, %esi
callq 0x1e930
jmp 0x1ca74
jmp 0x1ca76
movl 0x8c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x8c(%rsp)
jmp 0x1c9a9
movl $0x0, 0x64(%rsp)
leaq 0x68(%rsp), %rdi
callq 0x227b0
addq $0x98, %rsp
retq
movq 0x58(%rsp), %rdi
callq 0x45c0