// File: ddunbar[P]PDSample/./quasisampler_prototype.h
// Function: Quasisampler::TileNode::refine()
void refine()
    {
      if (!terminal) return; // Can only subdivide leaf nodes.
      
      terminal=false; // The tile now has children.
      double newscale = scale / GOLDEN_RATIO; // The scale factor between levels is constant.
      
      switch(tileType)
      {

      // Each new tile is created using the following information:
      // A pointer to its parent, the type of the new tile (a through f),
      // the origin of the new tile, the change in orientation of the new tile with
      // respect to the parent's orientation, the two bits to be pre-pended to the F-Code,
      // the parent's slot (for traversal purposes), and the new linear scale of the tile,
      // which is always the parent's scale divided by the golden ratio.

      case TileTypeA:
        children.push_back(
          new TileNode(this, TileTypeB, p1, dir+0, B00, 0, newscale));
        break;

      case TileTypeB:
        children.push_back(
          new TileNode(this, TileTypeA, p1, dir+10, B00, 0, newscale) );
        break;
        
      case TileTypeC:
        children.push_back(
          new TileNode(this, TileTypeF, p3, dir+14, B00, 0, newscale) );
        children.push_back(
          new TileNode(this, TileTypeC, p2, dir+6, B10, 1, newscale) );      
        children.push_back(
          new TileNode(this, TileTypeA, children[0]->p3, dir+1, B10, 2, newscale) );
        break;

      case TileTypeD:
        children.push_back(
          new TileNode(this, TileTypeE, p2, dir+6, B00, 0, newscale) );
        children.push_back(
          new TileNode(this, TileTypeD, children[0]->p3, dir+14, B10, 1, newscale) );
        break;

      case TileTypeE:
        children.push_back(
          new TileNode(this, TileTypeC, p3, dir+12, B10, 0, newscale) );
        children.push_back(
          new TileNode(this, TileTypeE, p2, dir+8 , B01, 1, newscale) );
        children.push_back(
          new TileNode(this, TileTypeF, p1, dir+0 , B00, 2, newscale) );
        children.push_back(
          new TileNode(this, TileTypeA, children[0]->p2, dir+7, B10, 3, newscale) );
        break;

      case TileTypeF:
        children.push_back(
          new TileNode(this, TileTypeF, p3, dir+12, B01, 0, newscale) );
        children.push_back(
          new TileNode(this, TileTypeE, children[0]->p3, dir+0, B00, 1, newscale) );
        children.push_back(
          new TileNode(this, TileTypeD, children[1]->p3, dir+8, B10, 2, newscale) );
        children.push_back(
          new TileNode(this, TileTypeA, children[0]->p3, dir+15, B01, 3, newscale) );
        break;
      }
    }

// Assembly:
subq $0x348, %rsp            # imm = 0x348
movq %rdi, 0x340(%rsp)
movq 0x340(%rsp), %rax
movq %rax, 0x148(%rsp)
testb $0x1, 0x5c(%rax)
jne 0x929a
jmp 0x9eee
movq 0x148(%rsp), %rax
movb $0x0, 0x5c(%rax)
movsd 0x10(%rax), %xmm0
movsd 0xd1e5(%rip), %xmm1     # 0x16498
divsd %xmm1, %xmm0
movsd %xmm0, 0x338(%rsp)
movl 0x4(%rax), %eax
movq %rax, 0x140(%rsp)
subq $0x5, %rax
ja 0x9eee
movq 0x140(%rsp), %rax
leaq 0xd22c(%rip), %rcx      # 0x16510
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x148(%rsp), %rax
addq $0x60, %rax
movq %rax, 0x130(%rsp)
movl $0x78, %edi
callq 0x21a0
movq 0x148(%rsp), %rsi
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x138(%rsp)
movups 0x18(%rsi), %xmm0
movaps %xmm0, 0x320(%rsp)
movl 0x8(%rsi), %ecx
movsd 0x338(%rsp), %xmm2
movsd 0x320(%rsp), %xmm0
movsd 0x328(%rsp), %xmm1
movl $0x1, %edx
xorl %r9d, %r9d
movl %r9d, %r8d
callq 0xa0a0
jmp 0x935d
movq 0x130(%rsp), %rdi
movq 0x138(%rsp), %rax
movq %rax, 0x330(%rsp)
leaq 0x330(%rsp), %rsi
callq 0xb720
jmp 0x9eee
movq 0x138(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x318(%rsp)
movl %eax, 0x314(%rsp)
movl $0x78, %esi
callq 0x21b0
jmp 0x9ef6
movq 0x148(%rsp), %rax
addq $0x60, %rax
movq %rax, 0x120(%rsp)
movl $0x78, %edi
callq 0x21a0
movq 0x148(%rsp), %rsi
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x128(%rsp)
movups 0x18(%rsi), %xmm0
movaps %xmm0, 0x2f0(%rsp)
movl 0x8(%rsi), %ecx
addl $0xa, %ecx
movsd 0x338(%rsp), %xmm2
movsd 0x2f0(%rsp), %xmm0
movsd 0x2f8(%rsp), %xmm1
xorl %r9d, %r9d
movl %r9d, %edx
movl %r9d, %r8d
callq 0xa0a0
jmp 0x9423
movq 0x120(%rsp), %rdi
movq 0x128(%rsp), %rax
movq %rax, 0x308(%rsp)
leaq 0x308(%rsp), %rsi
callq 0xb720
jmp 0x9eee
movq 0x128(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x318(%rsp)
movl %eax, 0x314(%rsp)
movl $0x78, %esi
callq 0x21b0
jmp 0x9ef6
movq 0x148(%rsp), %rax
addq $0x60, %rax
movq %rax, 0x110(%rsp)
movl $0x78, %edi
callq 0x21a0
movq 0x148(%rsp), %rsi
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x118(%rsp)
movups 0x38(%rsi), %xmm0
movaps %xmm0, 0x2d0(%rsp)
movl 0x8(%rsi), %ecx
addl $0xe, %ecx
movsd 0x338(%rsp), %xmm2
movsd 0x2d0(%rsp), %xmm0
movsd 0x2d8(%rsp), %xmm1
movl $0x5, %edx
xorl %r9d, %r9d
movl %r9d, %r8d
callq 0xa0a0
jmp 0x94eb
movq 0x110(%rsp), %rdi
movq 0x118(%rsp), %rax
movq %rax, 0x2e8(%rsp)
leaq 0x2e8(%rsp), %rsi
callq 0xb720
movq 0x148(%rsp), %rax
addq $0x60, %rax
movq %rax, 0x100(%rsp)
movl $0x78, %edi
callq 0x21a0
movq 0x148(%rsp), %rsi
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x108(%rsp)
movups 0x28(%rsi), %xmm0
movaps %xmm0, 0x2b0(%rsp)
movl 0x8(%rsi), %ecx
addl $0x6, %ecx
movsd 0x338(%rsp), %xmm2
movsd 0x2b0(%rsp), %xmm0
movsd 0x2b8(%rsp), %xmm1
movl $0x2, %edx
movl $0x1, %r9d
movl %r9d, %r8d
callq 0xa0a0
jmp 0x9586
movq 0x100(%rsp), %rdi
movq 0x108(%rsp), %rax
movq %rax, 0x2c8(%rsp)
leaq 0x2c8(%rsp), %rsi
callq 0xb720
movq 0x148(%rsp), %rax
addq $0x60, %rax
movq %rax, 0xe0(%rsp)
movl $0x78, %edi
callq 0x21a0
movq 0xe0(%rsp), %rdi
movq %rax, 0xf0(%rsp)
movq %rax, 0xe8(%rsp)
xorl %eax, %eax
movl %eax, 0xfc(%rsp)
movl %eax, %esi
callq 0x8620
movq 0xf0(%rsp), %rdi
movq 0x148(%rsp), %rsi
movl 0xfc(%rsp), %edx
movq (%rax), %rax
movups 0x38(%rax), %xmm0
movaps %xmm0, 0x290(%rsp)
movl 0x8(%rsi), %ecx
incl %ecx
movsd 0x338(%rsp), %xmm2
movsd 0x290(%rsp), %xmm0
movsd 0x298(%rsp), %xmm1
movl $0x1, %r8d
movl $0x2, %r9d
callq 0xa0a0
jmp 0x964a
movq 0xe0(%rsp), %rdi
movq 0xe8(%rsp), %rax
movq %rax, 0x2a8(%rsp)
leaq 0x2a8(%rsp), %rsi
callq 0xb720
jmp 0x9eee
movq 0x118(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x318(%rsp)
movl %eax, 0x314(%rsp)
movl $0x78, %esi
callq 0x21b0
jmp 0x9ef6
movq 0x108(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x318(%rsp)
movl %eax, 0x314(%rsp)
movl $0x78, %esi
callq 0x21b0
jmp 0x9ef6
movq 0xe8(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x318(%rsp)
movl %eax, 0x314(%rsp)
movl $0x78, %esi
callq 0x21b0
jmp 0x9ef6
movq 0x148(%rsp), %rax
addq $0x60, %rax
movq %rax, 0xd0(%rsp)
movl $0x78, %edi
callq 0x21a0
movq 0x148(%rsp), %rsi
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0xd8(%rsp)
movups 0x28(%rsi), %xmm0
movaps %xmm0, 0x270(%rsp)
movl 0x8(%rsi), %ecx
addl $0x6, %ecx
movsd 0x338(%rsp), %xmm2
movsd 0x270(%rsp), %xmm0
movsd 0x278(%rsp), %xmm1
movl $0x4, %edx
xorl %r9d, %r9d
movl %r9d, %r8d
callq 0xa0a0
jmp 0x9768
movq 0xd0(%rsp), %rdi
movq 0xd8(%rsp), %rax
movq %rax, 0x288(%rsp)
leaq 0x288(%rsp), %rsi
callq 0xb720
movq 0x148(%rsp), %rax
addq $0x60, %rax
movq %rax, 0xb8(%rsp)
movl $0x78, %edi
callq 0x21a0
movq 0xb8(%rsp), %rdi
movq %rax, 0xc8(%rsp)
movq %rax, 0xc0(%rsp)
xorl %eax, %eax
movl %eax, %esi
callq 0x8620
movq 0xc8(%rsp), %rdi
movq 0x148(%rsp), %rsi
movq (%rax), %rax
movups 0x38(%rax), %xmm0
movaps %xmm0, 0x250(%rsp)
movl 0x8(%rsi), %ecx
addl $0xe, %ecx
movsd 0x338(%rsp), %xmm2
movsd 0x250(%rsp), %xmm0
movsd 0x258(%rsp), %xmm1
movl $0x3, %edx
movl $0x1, %r9d
movl %r9d, %r8d
callq 0xa0a0
jmp 0x9821
movq 0xb8(%rsp), %rdi
movq 0xc0(%rsp), %rax
movq %rax, 0x268(%rsp)
leaq 0x268(%rsp), %rsi
callq 0xb720
jmp 0x9eee
movq 0xd8(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x318(%rsp)
movl %eax, 0x314(%rsp)
movl $0x78, %esi
callq 0x21b0
jmp 0x9ef6
movq 0xc0(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x318(%rsp)
movl %eax, 0x314(%rsp)
movl $0x78, %esi
callq 0x21b0
jmp 0x9ef6
movq 0x148(%rsp), %rax
addq $0x60, %rax
movq %rax, 0xa8(%rsp)
movl $0x78, %edi
callq 0x21a0
movq 0x148(%rsp), %rsi
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0xb0(%rsp)
movups 0x38(%rsi), %xmm0
movaps %xmm0, 0x230(%rsp)
movl 0x8(%rsi), %ecx
addl $0xc, %ecx
movsd 0x338(%rsp), %xmm2
movsd 0x230(%rsp), %xmm0
movsd 0x238(%rsp), %xmm1
movl $0x2, %edx
movl $0x1, %r8d
xorl %r9d, %r9d
callq 0xa0a0
jmp 0x9917
movq 0xa8(%rsp), %rdi
movq 0xb0(%rsp), %rax
movq %rax, 0x248(%rsp)
leaq 0x248(%rsp), %rsi
callq 0xb720
movq 0x148(%rsp), %rax
addq $0x60, %rax
movq %rax, 0x98(%rsp)
movl $0x78, %edi
callq 0x21a0
movq 0x148(%rsp), %rsi
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0xa0(%rsp)
movups 0x28(%rsi), %xmm0
movaps %xmm0, 0x210(%rsp)
movl 0x8(%rsi), %ecx
addl $0x8, %ecx
movsd 0x338(%rsp), %xmm2
movsd 0x210(%rsp), %xmm0
movsd 0x218(%rsp), %xmm1
movl $0x4, %edx
movl $0x2, %r8d
movl $0x1, %r9d
callq 0xa0a0
jmp 0x99b5
movq 0x98(%rsp), %rdi
movq 0xa0(%rsp), %rax
movq %rax, 0x228(%rsp)
leaq 0x228(%rsp), %rsi
callq 0xb720
movq 0x148(%rsp), %rax
addq $0x60, %rax
movq %rax, 0x88(%rsp)
movl $0x78, %edi
callq 0x21a0
movq 0x148(%rsp), %rsi
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x90(%rsp)
movups 0x18(%rsi), %xmm0
movaps %xmm0, 0x1f0(%rsp)
movl 0x8(%rsi), %ecx
movsd 0x338(%rsp), %xmm2
movsd 0x1f0(%rsp), %xmm0
movsd 0x1f8(%rsp), %xmm1
movl $0x5, %edx
xorl %r8d, %r8d
movl $0x2, %r9d
callq 0xa0a0
jmp 0x9a4d
movq 0x88(%rsp), %rdi
movq 0x90(%rsp), %rax
movq %rax, 0x208(%rsp)
leaq 0x208(%rsp), %rsi
callq 0xb720
movq 0x148(%rsp), %rax
addq $0x60, %rax
movq %rax, 0x68(%rsp)
movl $0x78, %edi
callq 0x21a0
movq 0x68(%rsp), %rdi
movq %rax, 0x78(%rsp)
movq %rax, 0x70(%rsp)
xorl %eax, %eax
movl %eax, 0x84(%rsp)
movl %eax, %esi
callq 0x8620
movq 0x78(%rsp), %rdi
movq 0x148(%rsp), %rsi
movl 0x84(%rsp), %edx
movq (%rax), %rax
movups 0x28(%rax), %xmm0
movaps %xmm0, 0x1d0(%rsp)
movl 0x8(%rsi), %ecx
addl $0x7, %ecx
movsd 0x338(%rsp), %xmm2
movsd 0x1d0(%rsp), %xmm0
movsd 0x1d8(%rsp), %xmm1
movl $0x1, %r8d
movl $0x3, %r9d
callq 0xa0a0
jmp 0x9b03
movq 0x68(%rsp), %rdi
movq 0x70(%rsp), %rax
movq %rax, 0x1e8(%rsp)
leaq 0x1e8(%rsp), %rsi
callq 0xb720
jmp 0x9eee
movq 0xb0(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x318(%rsp)
movl %eax, 0x314(%rsp)
movl $0x78, %esi
callq 0x21b0
jmp 0x9ef6
movq 0xa0(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x318(%rsp)
movl %eax, 0x314(%rsp)
movl $0x78, %esi
callq 0x21b0
jmp 0x9ef6
movq 0x90(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x318(%rsp)
movl %eax, 0x314(%rsp)
movl $0x78, %esi
callq 0x21b0
jmp 0x9ef6
movq 0x70(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x318(%rsp)
movl %eax, 0x314(%rsp)
movl $0x78, %esi
callq 0x21b0
jmp 0x9ef6
movq 0x148(%rsp), %rax
addq $0x60, %rax
movq %rax, 0x58(%rsp)
movl $0x78, %edi
callq 0x21a0
movq 0x148(%rsp), %rsi
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x60(%rsp)
movups 0x38(%rsi), %xmm0
movaps %xmm0, 0x1b0(%rsp)
movl 0x8(%rsi), %ecx
addl $0xc, %ecx
movsd 0x338(%rsp), %xmm2
movsd 0x1b0(%rsp), %xmm0
movsd 0x1b8(%rsp), %xmm1
movl $0x5, %edx
movl $0x2, %r8d
xorl %r9d, %r9d
callq 0xa0a0
jmp 0x9c40
movq 0x58(%rsp), %rdi
movq 0x60(%rsp), %rax
movq %rax, 0x1c8(%rsp)
leaq 0x1c8(%rsp), %rsi
callq 0xb720
movq 0x148(%rsp), %rax
addq $0x60, %rax
movq %rax, 0x38(%rsp)
movl $0x78, %edi
callq 0x21a0
movq 0x38(%rsp), %rdi
movq %rax, 0x48(%rsp)
movq %rax, 0x40(%rsp)
xorl %eax, %eax
movl %eax, 0x54(%rsp)
movl %eax, %esi
callq 0x8620
movq 0x48(%rsp), %rdi
movq 0x148(%rsp), %rsi
movl 0x54(%rsp), %r8d
movq (%rax), %rax
movups 0x38(%rax), %xmm0
movaps %xmm0, 0x190(%rsp)
movl 0x8(%rsi), %ecx
movsd 0x338(%rsp), %xmm2
movsd 0x190(%rsp), %xmm0
movsd 0x198(%rsp), %xmm1
movl $0x4, %edx
movl $0x1, %r9d
callq 0xa0a0
jmp 0x9ce7
movq 0x38(%rsp), %rdi
movq 0x40(%rsp), %rax
movq %rax, 0x1a8(%rsp)
leaq 0x1a8(%rsp), %rsi
callq 0xb720
movq 0x148(%rsp), %rax
addq $0x60, %rax
movq %rax, 0x20(%rsp)
movl $0x78, %edi
callq 0x21a0
movq 0x20(%rsp), %rdi
movq %rax, 0x30(%rsp)
movq %rax, 0x28(%rsp)
movl $0x1, %esi
callq 0x8620
movq 0x30(%rsp), %rdi
movq 0x148(%rsp), %rsi
movq (%rax), %rax
movups 0x38(%rax), %xmm0
movaps %xmm0, 0x170(%rsp)
movl 0x8(%rsi), %ecx
addl $0x8, %ecx
movsd 0x338(%rsp), %xmm2
movsd 0x170(%rsp), %xmm0
movsd 0x178(%rsp), %xmm1
movl $0x3, %edx
movl $0x1, %r8d
movl $0x2, %r9d
callq 0xa0a0
jmp 0x9d8f
movq 0x20(%rsp), %rdi
movq 0x28(%rsp), %rax
movq %rax, 0x188(%rsp)
leaq 0x188(%rsp), %rsi
callq 0xb720
movq 0x148(%rsp), %rax
addq $0x60, %rax
movq %rax, (%rsp)
movl $0x78, %edi
callq 0x21a0
movq (%rsp), %rdi
movq %rax, 0x10(%rsp)
movq %rax, 0x8(%rsp)
xorl %eax, %eax
movl %eax, 0x1c(%rsp)
movl %eax, %esi
callq 0x8620
movq 0x10(%rsp), %rdi
movq 0x148(%rsp), %rsi
movl 0x1c(%rsp), %edx
movq (%rax), %rax
movups 0x38(%rax), %xmm0
movaps %xmm0, 0x150(%rsp)
movl 0x8(%rsi), %ecx
addl $0xf, %ecx
movsd 0x338(%rsp), %xmm2
movsd 0x150(%rsp), %xmm0
movsd 0x158(%rsp), %xmm1
movl $0x2, %r8d
movl $0x3, %r9d
callq 0xa0a0
jmp 0x9e37
movq (%rsp), %rdi
movq 0x8(%rsp), %rax
movq %rax, 0x168(%rsp)
leaq 0x168(%rsp), %rsi
callq 0xb720
jmp 0x9eee
movq 0x60(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x318(%rsp)
movl %eax, 0x314(%rsp)
movl $0x78, %esi
callq 0x21b0
jmp 0x9ef6
movq 0x40(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x318(%rsp)
movl %eax, 0x314(%rsp)
movl $0x78, %esi
callq 0x21b0
jmp 0x9ef6
movq 0x28(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x318(%rsp)
movl %eax, 0x314(%rsp)
movl $0x78, %esi
callq 0x21b0
jmp 0x9ef6
movq 0x8(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x318(%rsp)
movl %eax, 0x314(%rsp)
movl $0x78, %esi
callq 0x21b0
jmp 0x9ef6
addq $0x348, %rsp            # imm = 0x348
retq
movq 0x318(%rsp), %rdi
callq 0x22f0
nopw %cs:(%rax,%rax)
nopl (%rax)