// File: /workspace/github_cpp_makefile_star2_O2/ddunbar[P]PDSample/PDSampling.cpp
// Function: PureSampler::complete()
void PureSampler::complete()
{
	Vec2 pt = randomPoint();
	ScallopedRegion *rgn = new ScallopedRegion(pt, radius*2, radius*4);
	RegionMap regions;
	WeightedDiscretePDF<int> regionsPDF;

	addPoint(pt);
	regions[(int) points.size()-1] = rgn;
	regionsPDF.insert((int) points.size()-1, rgn->area);

	while (regions.size()) {
		int idx = regionsPDF.choose(m_rng.getFloatL());
		
		pt = getTiled(((*regions.find(idx)).second)->sample(m_rng));
		rgn = new ScallopedRegion(pt, radius*2, radius*4);

		findNeighbors(pt, radius*8);
		for (IntVector::const_iterator it=m_neighbors.begin(); it!=m_neighbors.end(); it++) {
			int nIdx = *it;
			Vec2 &n = points[nIdx];
			
			rgn->subtractDisk(pt+getTiled(n-pt), radius*4);

			RegionMap::iterator entry = regions.find(nIdx);
			if (entry!=regions.end()) {
				ScallopedRegion *nRgn = (*entry).second;
				nRgn->subtractDisk(n+getTiled(pt-n), radius*2);

				if (nRgn->isEmpty()) {
					regions.erase(entry);
					regionsPDF.remove(nIdx);
					delete nRgn;
				} else {
					regionsPDF.update(nIdx, nRgn->area);
				}
			}
		}

		addPoint(pt);

		if (!rgn->isEmpty()) {
			regions[(int) points.size()-1] = rgn;
			regionsPDF.insert((int) points.size()-1, rgn->area);
		} else {
			delete rgn;
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rdi, %rbx
callq 0x2f7c
leaq 0x18(%rsp), %r15
movlps %xmm0, (%r15)
pushq $0x10
popq %rdi
callq 0x2190
movq %rax, %r14
movss 0x13d0(%rbx), %xmm1
movaps %xmm1, %xmm0
addss %xmm1, %xmm0
mulss 0x5319(%rip), %xmm1     # 0x947c
movss 0x5325(%rip), %xmm2     # 0x9490
movq %rax, %rdi
movq %r15, %rsi
callq 0x78e0
leaq 0x50(%rsp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
andq $0x0, 0x10(%rsp)
movsd 0x18(%rsp), %xmm0
movq %rbx, %rdi
callq 0x30c0
movq 0x13c0(%rbx), %rax
subq 0x13b8(%rbx), %rax
shrq $0x3, %rax
decl %eax
leaq 0x24(%rsp), %rsi
movl %eax, (%rsi)
leaq 0x48(%rsp), %rdi
callq 0x4886
movq %r14, (%rax)
movq 0x13c0(%rbx), %rsi
subq 0x13b8(%rbx), %rsi
shrq $0x3, %rsi
decl %esi
movss 0xc(%r14), %xmm0
leaq 0x10(%rsp), %rdi
callq 0x48d4
leaq 0x8(%rbx), %r14
leaq 0x18(%rsp), %r15
movq %r14, 0x40(%rsp)
cmpq $0x0, 0x70(%rsp)
je 0x4444
movq %r14, %rdi
callq 0x274a
leaq 0x10(%rsp), %rdi
callq 0x49dc
movl %eax, 0x24(%rsp)
leaq 0x48(%rsp), %rdi
leaq 0x24(%rsp), %rsi
callq 0x6726
movq 0x28(%rax), %rdi
movq %r14, %rsi
callq 0x7b78
movq %rbx, %rdi
callq 0x2fb6
movlps %xmm0, 0x18(%rsp)
pushq $0x10
popq %rdi
callq 0x2190
movq %rax, %r12
movss 0x13d0(%rbx), %xmm1
movaps %xmm1, %xmm0
addss %xmm1, %xmm0
mulss 0x5212(%rip), %xmm1     # 0x947c
movq %rax, %rdi
movq %r15, %rsi
movss 0x5218(%rip), %xmm2     # 0x9490
callq 0x78e0
movss 0x13d0(%rbx), %xmm0
mulss 0x5207(%rip), %xmm0     # 0x9494
movq %rbx, %rdi
movq %r15, %rsi
callq 0x3166
movq %r12, 0x28(%rsp)
movq 0x1390(%rbx), %r13
cmpq 0x1398(%rbx), %r13
je 0x43ae
movslq (%r13), %r12
movl %r12d, 0xc(%rsp)
movq 0x13b8(%rbx), %r14
movsd 0x18(%rsp), %xmm1
movaps %xmm1, 0x30(%rsp)
movsd (%r14,%r12,8), %xmm0
subps %xmm1, %xmm0
movq %rbx, %rdi
callq 0x2fb6
addps 0x30(%rsp), %xmm0
movss 0x13d0(%rbx), %xmm1
mulss 0x518a(%rip), %xmm1     # 0x947c
movq 0x28(%rsp), %rdi
callq 0x7998
leaq 0x48(%rsp), %rdi
leaq 0xc(%rsp), %rsi
callq 0x6726
movq %rax, %r15
leaq 0x50(%rsp), %rax
cmpq %rax, %r15
je 0x43a5
movq 0x28(%r15), %rbp
movsd (%r14,%r12,8), %xmm1
movaps %xmm1, 0x30(%rsp)
movsd 0x18(%rsp), %xmm0
subps %xmm1, %xmm0
movq %rbx, %rdi
callq 0x2fb6
addps 0x30(%rsp), %xmm0
movss 0x13d0(%rbx), %xmm1
addss %xmm1, %xmm1
movq %rbp, %rdi
callq 0x7998
movq (%rbp), %rax
movq 0x8(%rax), %rcx
cmpq (%rax), %rcx
je 0x4377
movl 0xc(%rsp), %esi
movss 0xc(%rbp), %xmm0
leaq 0x10(%rsp), %rdi
callq 0x4ba2
jmp 0x43a5
leaq 0x48(%rsp), %rdi
movq %r15, %rsi
callq 0x675a
movl 0xc(%rsp), %esi
leaq 0x10(%rsp), %rdi
callq 0x4aac
movq %rbp, %rdi
callq 0x797a
movq %rbp, %rdi
pushq $0x10
popq %rsi
callq 0x21a0
addq $0x4, %r13
jmp 0x42a4
movsd 0x18(%rsp), %xmm0
movq %rbx, %rdi
callq 0x30c0
movq 0x40(%rsp), %r14
leaq 0x18(%rsp), %r15
movq 0x28(%rsp), %r12
movq (%r12), %rax
movq 0x8(%rax), %rcx
cmpq (%rax), %rcx
je 0x442c
movq 0x13c0(%rbx), %rax
subq 0x13b8(%rbx), %rax
shrq $0x3, %rax
decl %eax
movl %eax, 0xc(%rsp)
leaq 0x48(%rsp), %rdi
leaq 0xc(%rsp), %rsi
callq 0x4886
movq %r12, (%rax)
movq 0x13c0(%rbx), %rsi
subq 0x13b8(%rbx), %rsi
shrq $0x3, %rsi
decl %esi
movss 0xc(%r12), %xmm0
leaq 0x10(%rsp), %rdi
callq 0x48d4
jmp 0x41fe
movq %r12, %rdi
callq 0x797a
movq %r12, %rdi
pushq $0x10
popq %rsi
callq 0x21a0
jmp 0x41fe
leaq 0x10(%rsp), %rdi
callq 0x4c32
leaq 0x48(%rsp), %rdi
callq 0x4dc4
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x4495
movq %rax, %rbx
pushq $0x10
popq %rsi
movq %r14, %rdi
callq 0x21a0
jmp 0x44ac
jmp 0x4495
jmp 0x4495
movq %rax, %rbx
pushq $0x10
popq %rsi
movq %r12, %rdi
callq 0x21a0
jmp 0x4498
jmp 0x4495
jmp 0x4495
jmp 0x4495
jmp 0x4495
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x4c32
leaq 0x48(%rsp), %rdi
callq 0x4dc4
movq %rbx, %rdi
callq 0x2300