// File: /workspace/github_cpp_makefile_star2_O2/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:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
cmpb $0x1, 0x5c(%rdi)
jne 0x56f8
movq %rdi, %rbx
movb $0x0, 0x5c(%rdi)
movl 0x4(%rdi), %eax
cmpq $0x5, %rax
ja 0x56f8
movsd 0x10(%rbx), %xmm0
divsd 0x4166(%rip), %xmm0     # 0x9438
movsd %xmm0, (%rsp)
leaq 0x4242(%rip), %rcx      # 0x9520
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
pushq $0x78
popq %rdi
callq 0x2190
movq %rax, %r14
movsd 0x18(%rbx), %xmm0
movsd 0x20(%rbx), %xmm1
movl 0x8(%rbx), %ecx
pushq $0x1
popq %rdx
movq %rax, %rdi
movq %rbx, %rsi
xorl %r8d, %r8d
xorl %r9d, %r9d
movsd (%rsp), %xmm2
callq 0x5780
jmp 0x55b8
pushq $0x78
popq %rdi
callq 0x2190
movq %rax, %r15
movsd 0x38(%rbx), %xmm0
movsd 0x40(%rbx), %xmm1
movl 0x8(%rbx), %ecx
addl $0xc, %ecx
pushq $0x2
popq %rdx
pushq $0x1
popq %r8
movq %rax, %rdi
movq %rbx, %rsi
xorl %r9d, %r9d
movsd (%rsp), %xmm2
callq 0x5780
leaq 0x60(%rbx), %r14
leaq 0x8(%rsp), %rsi
movq %r15, (%rsi)
movq %r14, %rdi
callq 0x5a28
pushq $0x78
popq %rdi
callq 0x2190
movq %rax, %r15
movsd 0x28(%rbx), %xmm0
movsd 0x30(%rbx), %xmm1
movl 0x8(%rbx), %ecx
addl $0x8, %ecx
pushq $0x4
popq %rdx
pushq $0x2
popq %r8
pushq $0x1
popq %r9
movq %rax, %rdi
movq %rbx, %rsi
movsd (%rsp), %xmm2
callq 0x5780
leaq 0x8(%rsp), %rsi
movq %r15, (%rsi)
movq %r14, %rdi
callq 0x5a28
pushq $0x78
popq %rdi
callq 0x2190
movq %rax, %r15
movsd 0x18(%rbx), %xmm0
movsd 0x20(%rbx), %xmm1
movl 0x8(%rbx), %ecx
pushq $0x5
popq %rdx
pushq $0x2
popq %r9
movq %rax, %rdi
movq %rbx, %rsi
xorl %r8d, %r8d
movsd (%rsp), %xmm2
callq 0x5780
leaq 0x8(%rsp), %rsi
movq %r15, (%rsi)
movq %r14, %rdi
callq 0x5a28
pushq $0x78
popq %rdi
callq 0x2190
movq %rax, %r15
movq 0x60(%rbx), %rax
movq (%rax), %rax
movsd 0x28(%rax), %xmm0
movsd 0x30(%rax), %xmm1
movl 0x8(%rbx), %ecx
addl $0x7, %ecx
pushq $0x1
popq %r8
pushq $0x3
popq %r9
movq %r15, %rdi
movq %rbx, %rsi
xorl %edx, %edx
movsd (%rsp), %xmm2
callq 0x5780
jmp 0x56e8
pushq $0x78
popq %rdi
callq 0x2190
movq %rax, %r15
movsd 0x38(%rbx), %xmm0
movsd 0x40(%rbx), %xmm1
movl 0x8(%rbx), %ecx
addl $0xe, %ecx
pushq $0x5
popq %rdx
movq %rax, %rdi
movq %rbx, %rsi
xorl %r8d, %r8d
xorl %r9d, %r9d
movsd (%rsp), %xmm2
callq 0x5780
leaq 0x60(%rbx), %r14
leaq 0x8(%rsp), %rsi
movq %r15, (%rsi)
movq %r14, %rdi
callq 0x5a28
pushq $0x78
popq %rdi
callq 0x2190
movq %rax, %r15
movsd 0x28(%rbx), %xmm0
movsd 0x30(%rbx), %xmm1
movl 0x8(%rbx), %ecx
addl $0x6, %ecx
pushq $0x2
popq %rdx
pushq $0x1
popq %r8
movq %rax, %rdi
movq %rbx, %rsi
movl %r8d, %r9d
movsd (%rsp), %xmm2
callq 0x5780
leaq 0x8(%rsp), %rsi
movq %r15, (%rsi)
movq %r14, %rdi
callq 0x5a28
pushq $0x78
popq %rdi
callq 0x2190
movq %rax, %r15
movq 0x60(%rbx), %rax
movq (%rax), %rax
movsd 0x38(%rax), %xmm0
movsd 0x40(%rax), %xmm1
movl 0x8(%rbx), %ecx
incl %ecx
pushq $0x1
popq %r8
pushq $0x2
popq %r9
movq %r15, %rdi
movq %rbx, %rsi
xorl %edx, %edx
movsd (%rsp), %xmm2
callq 0x5780
jmp 0x56e8
pushq $0x78
popq %rdi
callq 0x2190
movq %rax, %r15
movsd 0x28(%rbx), %xmm0
movsd 0x30(%rbx), %xmm1
movl 0x8(%rbx), %ecx
addl $0x6, %ecx
pushq $0x4
popq %rdx
movq %rax, %rdi
movq %rbx, %rsi
xorl %r8d, %r8d
xorl %r9d, %r9d
movsd (%rsp), %xmm2
callq 0x5780
leaq 0x60(%rbx), %r14
leaq 0x8(%rsp), %rsi
movq %r15, (%rsi)
movq %r14, %rdi
callq 0x5a28
pushq $0x78
popq %rdi
callq 0x2190
movq %rax, %r15
movq 0x60(%rbx), %rax
movq (%rax), %rax
movsd 0x38(%rax), %xmm0
movsd 0x40(%rax), %xmm1
movl 0x8(%rbx), %ecx
addl $0xe, %ecx
pushq $0x3
popq %rdx
pushq $0x1
popq %r8
movq %r15, %rdi
movq %rbx, %rsi
movl %r8d, %r9d
movsd (%rsp), %xmm2
callq 0x5780
jmp 0x56e8
pushq $0x78
popq %rdi
callq 0x2190
movq %rax, %r14
movsd 0x18(%rbx), %xmm0
movsd 0x20(%rbx), %xmm1
movl 0x8(%rbx), %ecx
addl $0xa, %ecx
movq %rax, %rdi
movq %rbx, %rsi
xorl %edx, %edx
xorl %r8d, %r8d
xorl %r9d, %r9d
movsd (%rsp), %xmm2
callq 0x5780
addq $0x60, %rbx
leaq 0x8(%rsp), %rsi
movq %r14, (%rsi)
movq %rbx, %rdi
jmp 0x56f3
pushq $0x78
popq %rdi
callq 0x2190
movq %rax, %r15
movsd 0x38(%rbx), %xmm0
movsd 0x40(%rbx), %xmm1
movl 0x8(%rbx), %ecx
addl $0xc, %ecx
pushq $0x5
popq %rdx
pushq $0x2
popq %r8
movq %rax, %rdi
movq %rbx, %rsi
xorl %r9d, %r9d
movsd (%rsp), %xmm2
callq 0x5780
leaq 0x60(%rbx), %r14
leaq 0x8(%rsp), %rsi
movq %r15, (%rsi)
movq %r14, %rdi
callq 0x5a28
pushq $0x78
popq %rdi
callq 0x2190
movq %rax, %r15
movq 0x60(%rbx), %rax
movq (%rax), %rax
movsd 0x38(%rax), %xmm0
movsd 0x40(%rax), %xmm1
movl 0x8(%rbx), %ecx
pushq $0x4
popq %rdx
pushq $0x1
popq %r9
movq %r15, %rdi
movq %rbx, %rsi
xorl %r8d, %r8d
movsd (%rsp), %xmm2
callq 0x5780
leaq 0x8(%rsp), %rsi
movq %r15, (%rsi)
movq %r14, %rdi
callq 0x5a28
pushq $0x78
popq %rdi
callq 0x2190
movq %rax, %r15
movq 0x60(%rbx), %rax
movq 0x8(%rax), %rax
movsd 0x38(%rax), %xmm0
movsd 0x40(%rax), %xmm1
movl 0x8(%rbx), %ecx
addl $0x8, %ecx
pushq $0x3
popq %rdx
pushq $0x1
popq %r8
pushq $0x2
popq %r9
movq %r15, %rdi
movq %rbx, %rsi
movsd (%rsp), %xmm2
callq 0x5780
leaq 0x8(%rsp), %rsi
movq %r15, (%rsi)
movq %r14, %rdi
callq 0x5a28
pushq $0x78
popq %rdi
callq 0x2190
movq %rax, %r15
movq 0x60(%rbx), %rax
movq (%rax), %rax
movsd 0x38(%rax), %xmm0
movsd 0x40(%rax), %xmm1
movl 0x8(%rbx), %ecx
addl $0xf, %ecx
pushq $0x2
popq %r8
pushq $0x3
popq %r9
movq %r15, %rdi
movq %rbx, %rsi
xorl %edx, %edx
movsd (%rsp), %xmm2
callq 0x5780
leaq 0x8(%rsp), %rsi
movq %r15, (%rsi)
movq %r14, %rdi
callq 0x5a28
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
jmp 0x5727
jmp 0x5727
jmp 0x5727
jmp 0x5727
jmp 0x5727
jmp 0x5727
jmp 0x5727
jmp 0x5727
jmp 0x5727
jmp 0x5727
jmp 0x5718
movq %rax, %rbx
pushq $0x78
popq %rsi
movq %r14, %rdi
jmp 0x5730
jmp 0x5727
jmp 0x5727
movq %rax, %rbx
pushq $0x78
popq %rsi
movq %r15, %rdi
callq 0x21a0
movq %rbx, %rdi
callq 0x2300
nop