// File: /workspace/github_cpp_makefile_star2_O1/ddunbar[P]PDSample/./quasisampler_prototype.h
// Function: Quasisampler::buildAdaptiveSubdivision(unsigned int)
void buildAdaptiveSubdivision( unsigned minSubdivisionLevel = 6 )
  {
    root = new TileNode(width,height);
    
    // Since we are approximating the MAX within each tile by the values at
    // a few key points, we must provide a sufficiently dense initial
    // tiling. This would not be necessary with a more thorough scan of each
    // tile.
    subdivideAll(minSubdivisionLevel);

    TileLeafIterator it(root);
    TileNode *tmp;

    // Recursively subdivide all triangles until each triangle's
    // required level is reached.
    unsigned level;
    do {
      level = it->getLevel();
      
      if ( it->isSamplingType() ) // Sampling tiles are infinitesimal
      {
        if ( level < getReqSubdivisionLevel(getImportanceAt_bounded(it->getP1())) )
        {
          tmp = *it;
          tmp->refine();
        }
      }
      else
      {
        if ( 
          ( level < getReqSubdivisionLevel(getImportanceAt_bounded(it->getP1())) ) ||
          ( level < getReqSubdivisionLevel(getImportanceAt_bounded(it->getP2())) ) ||
          ( level < getReqSubdivisionLevel(getImportanceAt_bounded(it->getP3())) ) ||
          ( level < getReqSubdivisionLevel(getImportanceAt_bounded(it->getCenter())) )
          )
        {
          tmp = *it;
          tmp->refine();
        }
      }
    } while ( it.next() );
  }

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %esi, %ebp
movq %rdi, %rbx
movl $0x78, %edi
callq 0x21a0
movq %rax, %r14
movsd 0x10(%rbx), %xmm0
movsd 0x18(%rbx), %xmm1
movq %rax, %rdi
callq 0x5c12
movq %r14, 0x8(%rbx)
movq %rbx, %rdi
movl %ebp, %esi
callq 0x5d3a
movq 0x8(%rbx), %r14
cmpb $0x0, 0x5c(%r14)
jne 0x58c1
movq 0x60(%r14), %rax
movq (%rax), %r14
cmpb $0x1, 0x5c(%r14)
jne 0x58b3
xorpd %xmm3, %xmm3
movl (%r14), %ebp
cmpl $0x1, 0x4(%r14)
movsd 0x18(%r14), %xmm0
movsd 0x20(%r14), %xmm1
ja 0x591c
xorl %edi, %edi
ucomisd %xmm3, %xmm0
jb 0x590a
movsd 0x10(%rbx), %xmm2
ucomisd %xmm0, %xmm2
jbe 0x590a
ucomisd %xmm3, %xmm1
jb 0x590a
movsd 0x18(%rbx), %xmm2
ucomisd %xmm1, %xmm2
jbe 0x590a
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x10(%rax)
movl %eax, %edi
callq 0x5db6
cmpl %eax, %ebp
jae 0x59f0
jmp 0x59e8
xorl %edi, %edi
ucomisd %xmm3, %xmm0
jb 0x594b
movsd 0x10(%rbx), %xmm2
ucomisd %xmm0, %xmm2
jbe 0x594b
ucomisd %xmm3, %xmm1
jb 0x594b
movsd 0x18(%rbx), %xmm2
ucomisd %xmm1, %xmm2
jbe 0x594b
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x10(%rax)
movl %eax, %edi
callq 0x5db6
cmpl %eax, %ebp
jb 0x59e8
movsd 0x28(%r14), %xmm0
xorl %edi, %edi
xorpd %xmm2, %xmm2
ucomisd %xmm2, %xmm0
jb 0x5997
movsd 0x10(%rbx), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x5997
movsd 0x30(%r14), %xmm1
ucomisd %xmm2, %xmm1
jb 0x5997
movsd 0x18(%rbx), %xmm2
ucomisd %xmm1, %xmm2
jbe 0x5997
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x10(%rax)
movl %eax, %edi
callq 0x5db6
cmpl %eax, %ebp
jb 0x59e8
movsd 0x38(%r14), %xmm0
xorl %edi, %edi
xorpd %xmm2, %xmm2
ucomisd %xmm2, %xmm0
jb 0x59df
movsd 0x10(%rbx), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x59df
movsd 0x40(%r14), %xmm1
ucomisd %xmm2, %xmm1
jb 0x59df
movsd 0x18(%rbx), %xmm2
ucomisd %xmm1, %xmm2
jbe 0x59df
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x10(%rax)
movl %eax, %edi
callq 0x5db6
cmpl %eax, %ebp
jae 0x5a1a
movq %r14, %rdi
callq 0x5e10
movq %r14, %rdi
callq 0x66e8
testq %rax, %rax
je 0x5a08
movq %rax, %r14
cmpb $0x1, 0x5c(%rax)
jne 0x59f0
jmp 0x5a0b
xorl %r14d, %r14d
testq %r14, %r14
xorpd %xmm3, %xmm3
jne 0x58c5
jmp 0x5a80
movupd 0x18(%r14), %xmm0
movupd 0x28(%r14), %xmm1
addpd %xmm0, %xmm1
movupd 0x38(%r14), %xmm0
addpd %xmm1, %xmm0
divpd 0x4ac4(%rip), %xmm0     # 0xa500
xorl %edi, %edi
xorpd %xmm2, %xmm2
ucomisd %xmm2, %xmm0
jb 0x590a
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
ucomisd %xmm2, %xmm1
setae %al
movupd 0x10(%rbx), %xmm2
movapd %xmm0, %xmm3
cmpltpd %xmm2, %xmm3
movmskpd %xmm3, %ecx
andb %cl, %al
shrb %cl
andb %cl, %al
cmpb $0x1, %al
je 0x58ff
jmp 0x590a
popq %rbx
popq %r14
popq %rbp
retq
movq %rax, %rbx
movl $0x78, %esi
movq %r14, %rdi
callq 0x21b0
movq %rbx, %rdi
callq 0x2310
nop