// File: ddunbar[P]PDSample/PDSampling.cpp
// Function: BoundarySampler::complete()
void BoundarySampler::complete()
{
	RangeList rl(0,0);
	IntVector candidates;

	addPoint(randomPoint());
	candidates.push_back((int) points.size()-1);

	while (candidates.size()) {
		int c = m_rng.getInt32()%candidates.size();
		int index = candidates[c];
		Vec2 candidate = points[index];
		candidates[c] = candidates[candidates.size()-1];
		candidates.pop_back();

		rl.reset(0, (float) M_PI*2);
		findNeighborRanges(index, rl);
		while (rl.numRanges) {
			RangeEntry &re = rl.ranges[m_rng.getInt32()%rl.numRanges];
			float angle = re.min + (re.max-re.min)*m_rng.getFloatL();
			Vec2 pt = getTiled(Vec2(candidate.x + cos(angle)*2*radius,
									candidate.y + sin(angle)*2*radius));

			addPoint(pt);
			candidates.push_back((int) points.size()-1);

			rl.subtract(angle - (float) M_PI/3, angle + (float) M_PI/3);
		}
	}
}

// Assembly:
subq $0xf8, %rsp
movq %rdi, 0xf0(%rsp)
movq 0xf0(%rsp), %rax
movq %rax, 0x58(%rsp)
leaq 0xe0(%rsp), %rdi
xorps %xmm1, %xmm1
movaps %xmm1, %xmm0
callq 0xfc90
leaq 0xc8(%rsp), %rdi
callq 0x6a80
movq 0x58(%rsp), %rdi
callq 0x3cb0
movaps %xmm0, 0x60(%rsp)
jmp 0x565d
movq 0x58(%rsp), %rdi
movaps 0x60(%rsp), %xmm0
movlpd %xmm0, 0xc0(%rsp)
movsd 0xc0(%rsp), %xmm0
callq 0x3f10
jmp 0x5680
movq 0x58(%rsp), %rdi
addq $0x13b8, %rdi           # imm = 0x13B8
callq 0x3970
decl %eax
movl %eax, 0xb0(%rsp)
leaq 0xc8(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
callq 0x6ed0
jmp 0x56b1
jmp 0x56b3
leaq 0xc8(%rsp), %rdi
callq 0x6d30
cmpq $0x0, %rax
je 0x59f0
movq 0x58(%rsp), %rdi
addq $0x8, %rdi
callq 0x29e0
movq %rax, 0x50(%rsp)
jmp 0x56df
leaq 0xc8(%rsp), %rdi
movq %rdi, 0x48(%rsp)
callq 0x6d30
movq 0x48(%rsp), %rdi
movq %rax, %rcx
movq 0x50(%rsp), %rax
xorl %edx, %edx
divq %rcx
movl %edx, %eax
movl %eax, 0xac(%rsp)
movslq 0xac(%rsp), %rsi
callq 0x6f00
movq 0x58(%rsp), %rdi
movl (%rax), %eax
movl %eax, 0xa8(%rsp)
addq $0x13b8, %rdi           # imm = 0x13B8
movslq 0xa8(%rsp), %rsi
callq 0x3990
movq 0x48(%rsp), %rdi
movq (%rax), %rax
movq %rax, 0xa0(%rsp)
callq 0x6d30
movq 0x48(%rsp), %rdi
movq %rax, %rsi
decq %rsi
callq 0x6f00
movq 0x48(%rsp), %rdi
movl (%rax), %eax
movl %eax, 0x44(%rsp)
movslq 0xac(%rsp), %rsi
callq 0x6f00
movl 0x44(%rsp), %ecx
movq 0x48(%rsp), %rdi
movl %ecx, (%rax)
callq 0x6f20
leaq 0xe0(%rsp), %rdi
xorps %xmm0, %xmm0
movss 0x10d3d(%rip), %xmm1    # 0x164d8
callq 0xfd00
jmp 0x57a2
movq 0x58(%rsp), %rdi
movl 0xa8(%rsp), %esi
leaq 0xe0(%rsp), %rdx
callq 0x4460
jmp 0x57bd
jmp 0x57bf
cmpl $0x0, 0xe8(%rsp)
je 0x59eb
movq 0x58(%rsp), %rdi
movq 0xe0(%rsp), %rax
movq %rax, 0x30(%rsp)
addq $0x8, %rdi
callq 0x29e0
movq %rax, 0x38(%rsp)
jmp 0x57ef
movq 0x58(%rsp), %rdi
movq 0x38(%rsp), %rax
movslq 0xe8(%rsp), %rcx
xorl %edx, %edx
divq %rcx
movq 0x30(%rsp), %rax
leaq (%rax,%rdx,8), %rax
movq %rax, 0x98(%rsp)
movq 0x98(%rsp), %rax
movss (%rax), %xmm1
movss %xmm1, 0x24(%rsp)
movss 0x4(%rax), %xmm0
subss %xmm1, %xmm0
movss %xmm0, 0x28(%rsp)
addq $0x8, %rdi
callq 0x2d90
movss %xmm0, 0x2c(%rsp)
jmp 0x5849
movss 0x24(%rsp), %xmm1
movss 0x2c(%rsp), %xmm2
movss 0x28(%rsp), %xmm0
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, 0x94(%rsp)
movss 0xa0(%rsp), %xmm0
movss %xmm0, 0x1c(%rsp)
movss 0x94(%rsp), %xmm0
callq 0x6e00
movss %xmm0, 0x20(%rsp)
jmp 0x5891
movss 0x1c(%rsp), %xmm1
movq 0x58(%rsp), %rax
movss 0x20(%rsp), %xmm0
addss %xmm0, %xmm0
movss 0x13d0(%rax), %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, 0x10(%rsp)
movss 0xa4(%rsp), %xmm0
movss %xmm0, 0x14(%rsp)
movss 0x94(%rsp), %xmm0
callq 0x6e20
movss %xmm0, 0x18(%rsp)
jmp 0x58e1
movss 0x10(%rsp), %xmm0
movss 0x14(%rsp), %xmm2
movq 0x58(%rsp), %rax
movss 0x18(%rsp), %xmm1
addss %xmm1, %xmm1
movss 0x13d0(%rax), %xmm3
mulss %xmm3, %xmm1
addss %xmm2, %xmm1
leaq 0x84(%rsp), %rdi
callq 0x6b60
jmp 0x591b
movq 0x58(%rsp), %rdi
movsd 0x84(%rsp), %xmm0
callq 0x3d20
movaps %xmm0, (%rsp)
jmp 0x5934
movq 0x58(%rsp), %rdi
movaps (%rsp), %xmm0
movlpd %xmm0, 0x8c(%rsp)
movq 0x8c(%rsp), %rax
movq %rax, 0x78(%rsp)
movsd 0x78(%rsp), %xmm0
callq 0x3f10
jmp 0x5960
movq 0x58(%rsp), %rdi
addq $0x13b8, %rdi           # imm = 0x13B8
callq 0x3970
decl %eax
movl %eax, 0x74(%rsp)
leaq 0xc8(%rsp), %rdi
leaq 0x74(%rsp), %rsi
callq 0x6ed0
jmp 0x598b
movss 0x94(%rsp), %xmm1
movss 0x10b40(%rip), %xmm2    # 0x164dc
movaps %xmm1, %xmm0
subss %xmm2, %xmm0
addss %xmm2, %xmm1
leaq 0xe0(%rsp), %rdi
callq 0xff20
jmp 0x59b6
jmp 0x57bf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xb8(%rsp)
movl %eax, 0xb4(%rsp)
leaq 0xc8(%rsp), %rdi
callq 0x6b00
leaq 0xe0(%rsp), %rdi
callq 0xfd40
jmp 0x5a12
jmp 0x56b3
leaq 0xc8(%rsp), %rdi
callq 0x6b00
leaq 0xe0(%rsp), %rdi
callq 0xfd40
addq $0xf8, %rsp
retq
movq 0xb8(%rsp), %rdi
callq 0x22f0
nop