// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Graphics/R3Scene.cpp
// Function: gaps::WritePrincetonNode(gaps::R3Scene const*, gaps::R3SceneNode const*, gaps::R3Transformation const&, _IO_FILE*, char const*)
static int
WritePrincetonNode(const R3Scene *scene, const R3SceneNode *node,
  const R3Transformation& parent_transformation,
  FILE *fp, const char *indent)
{
  // Compute indent
  int nindent = strlen(indent);
  char *child_indent = new char [nindent + 3];
  strcpy(child_indent, indent);
  child_indent[nindent] = ' ';
  child_indent[nindent+1] = ' ';
  child_indent[nindent+2] = '\0';

  // Compute transformation
  R3Affine transformation = R3identity_affine;
  transformation.Transform(parent_transformation);
  transformation.Transform(node->Transformation());

  // Don't write root separately, unless transformed
  RNBoolean print_node = (node != scene->Root()) || (!node->Transformation().IsIdentity());
  if (print_node) {
    // Write group start
    fprintf(fp, "\n");
    if (!node->Name()) fprintf(fp, "%sbegin -1\n", indent);
    else fprintf(fp, "%sgroup %s -1\n", indent, node->Name());

    // Write node transformation
    const R4Matrix& m = node->Transformation().Matrix();
    fprintf(fp, "%s%g %g %g %g\n", child_indent, m[0][0], m[0][1], m[0][2], m[0][3]);
    fprintf(fp, "%s%g %g %g %g\n", child_indent, m[1][0], m[1][1], m[1][2], m[1][3]);
    fprintf(fp, "%s%g %g %g %g\n", child_indent, m[2][0], m[2][1], m[2][2], m[2][3]);
    fprintf(fp, "%s%g %g %g %g\n", child_indent, m[3][0], m[3][1], m[3][2], m[3][3]);
  }
  
  // Write elements
  for (int i = 0; i < node->NElements(); i++) {
    R3SceneElement *element = node->Element(i);
    if (!WritePrincetonElement(scene, element, transformation, fp, child_indent)) return 0;
  }

  // Write references
  for (int i = 0; i < node->NReferences(); i++) {
    R3SceneReference *reference = node->Reference(i);
    if (!WritePrincetonReference(scene, reference, transformation, fp, child_indent)) return 0;
  }

  // Write children
  for (int i = 0; i < node->NChildren(); i++) {
    R3SceneNode *child = node->Child(i);
    if (!WritePrincetonNode(scene, child, transformation, fp, child_indent)) return 0;
  }

  // Write end
  if (print_node) fprintf(fp, "%send\n", indent);

  // Delete child indent buffer
  delete [] child_indent;

  // Return success
  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1d8, %rsp            # imm = 0x1D8
movq %r8, %r12
movq %rcx, %rbp
movq %rdx, 0x68(%rsp)
movq %rsi, %r13
movq %rdi, 0x70(%rsp)
movq %r8, %rdi
callq 0x21370
movq %rax, %r15
movq %rax, %r14
shlq $0x20, %r14
movabsq $0x300000000, %rdi      # imm = 0x300000000
addq %r14, %rdi
sarq $0x20, %rdi
callq 0x21040
movq %rax, %rbx
movq %rax, %rdi
movq %r12, 0x58(%rsp)
movq %r12, %rsi
callq 0x21810
movslq %r15d, %rax
movb $0x20, %cl
movb %cl, (%rbx,%rax)
movabsq $0x100000000, %rax      # imm = 0x100000000
addq %r14, %rax
sarq $0x20, %rax
movb %cl, (%rbx,%rax)
movabsq $0x200000000, %rax      # imm = 0x200000000
addq %r14, %rax
sarq $0x20, %rax
movq %rbx, 0x28(%rsp)
movb $0x0, (%rbx,%rax)
leaq 0x104d9d(%rip), %rsi    # 0x1366a0
leaq 0xc8(%rsp), %r15
movq %r15, %rdi
callq 0x34464
movq %r15, %rdi
movq 0x68(%rsp), %rsi
callq 0x66dfe
leaq 0x58(%r13), %rbx
leaq 0xc8(%rsp), %rdi
movq %rbx, %rsi
callq 0x669c2
movq 0x70(%rsp), %rax
cmpq %r13, (%rax)
je 0x3196d
pushq $0xa
popq %rdi
movq %rbp, %rsi
callq 0x21bb0
movq 0x1a0(%r13), %rcx
testq %rcx, %rcx
je 0x31987
leaq 0x94e05(%rip), %rsi     # 0xc6761
movq %rbp, %rdi
movq 0x58(%rsp), %rdx
xorl %eax, %eax
callq 0x21da0
jmp 0x3199d
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x10(%rax)
testl %eax, %eax
je 0x3193e
movl $0x0, 0x54(%rsp)
jmp 0x31a73
leaq 0x94dc7(%rip), %rsi     # 0xc6755
movq %rbp, %rdi
movq 0x58(%rsp), %rdx
xorl %eax, %eax
callq 0x21da0
movsd 0x60(%r13), %xmm0
movsd 0x68(%r13), %xmm1
movsd 0x70(%r13), %xmm2
movsd 0x78(%r13), %xmm3
leaq 0x94db4(%rip), %rbx     # 0xc6770
movq %rbp, %rdi
movq %rbx, %rsi
movq 0x28(%rsp), %r14
movq %r14, %rdx
movb $0x4, %al
callq 0x21da0
movsd 0x80(%r13), %xmm0
movsd 0x88(%r13), %xmm1
movsd 0x90(%r13), %xmm2
movsd 0x98(%r13), %xmm3
movq %rbp, %rdi
movq %rbx, %rsi
movq %r14, %rdx
movb $0x4, %al
callq 0x21da0
movsd 0xa0(%r13), %xmm0
movsd 0xa8(%r13), %xmm1
movsd 0xb0(%r13), %xmm2
movsd 0xb8(%r13), %xmm3
movq %rbp, %rdi
movq %rbx, %rsi
movq %r14, %rdx
movb $0x4, %al
callq 0x21da0
movsd 0xc0(%r13), %xmm0
movsd 0xc8(%r13), %xmm1
movsd 0xd0(%r13), %xmm2
movsd 0xd8(%r13), %xmm3
movq %rbp, %rdi
movq %rbx, %rsi
movq %r14, %rdx
movb $0x4, %al
callq 0x21da0
movb $0x1, %al
movl %eax, 0x54(%rsp)
xorl %ecx, %ecx
movq %r13, 0x80(%rsp)
movq %rbp, 0x78(%rsp)
movslq 0x3c(%r13), %rax
cmpq %rax, %rcx
jge 0x32121
movq 0x30(%r13), %rax
movq %rcx, 0x88(%rsp)
movq (%rax,%rcx,8), %r12
movq 0x8(%r12), %rax
pushq $-0x1
popq %rcx
movl %ecx, 0x24(%rsp)
testq %rax, %rax
je 0x31ab7
movl 0x8(%rax), %eax
movl %eax, 0x24(%rsp)
xorl %ecx, %ecx
movslq 0x1c(%r12), %rax
cmpq %rax, %rcx
jge 0x32109
movq 0x10(%r12), %rax
movq %rcx, 0x68(%rsp)
movq (%rax,%rcx,8), %r15
movq (%r15), %rax
movq %r15, %rdi
callq *0xb8(%rax)
movl %eax, %ebx
callq 0x63c70
cmpl %eax, %ebx
jne 0x31b2f
movsd 0x8(%r15), %xmm0
movsd 0x10(%r15), %xmm1
movsd 0x18(%r15), %xmm2
movsd 0x20(%r15), %xmm3
movsd 0x28(%r15), %xmm4
movsd 0x30(%r15), %xmm5
movq %rbp, %rdi
leaq 0x94c6c(%rip), %rsi     # 0xc6786
movq 0x28(%rsp), %rdx
movl 0x24(%rsp), %ecx
movb $0x6, %al
callq 0x21da0
jmp 0x31d9d
movq (%r15), %rax
movq %r15, %rdi
callq *0xb8(%rax)
movl %eax, %ebx
callq 0x6294c
cmpl %eax, %ebx
jne 0x31c00
leaq 0x8(%r15), %rsi
leaq 0x30(%rsp), %rdi
callq 0x6b884
leaq 0x20(%r15), %rsi
leaq 0xb0(%rsp), %rdi
callq 0x6c044
leaq 0x38(%r15), %rsi
leaq 0x98(%rsp), %rdi
callq 0x6c044
movsd 0x30(%rsp), %xmm0
movsd 0x38(%rsp), %xmm1
movsd 0x40(%rsp), %xmm2
movsd 0xb0(%rsp), %xmm3
movsd 0xb8(%rsp), %xmm4
movsd 0xc0(%rsp), %xmm5
movsd 0x98(%rsp), %xmm6
movsd 0xa0(%rsp), %xmm7
movsd 0xa8(%rsp), %xmm8
movups 0x68(%r15), %xmm9
movsd 0x78(%r15), %xmm10
movsd %xmm10, 0x18(%rsp)
movups %xmm9, 0x8(%rsp)
movsd %xmm8, (%rsp)
movq %rbp, %rdi
leaq 0x94bbc(%rip), %rsi     # 0xc67a7
movq 0x28(%rsp), %rdx
movl 0x24(%rsp), %ecx
movb $0x8, %al
callq 0x21da0
jmp 0x31d9d
movq (%r15), %rax
movq %r15, %rdi
callq *0xb8(%rax)
movl %eax, %ebx
callq 0x618ec
cmpl %eax, %ebx
jne 0x31c5c
leaq 0x8(%r15), %rsi
leaq 0x30(%rsp), %rdi
callq 0x6b884
movsd 0x30(%rsp), %xmm0
movsd 0x38(%rsp), %xmm1
movsd 0x40(%rsp), %xmm2
movsd 0x20(%r15), %xmm3
movq %rbp, %rdi
leaq 0x94b97(%rip), %rsi     # 0xc67de
movq 0x28(%rsp), %rdx
movl 0x24(%rsp), %ecx
movb $0x4, %al
callq 0x21da0
jmp 0x31d9d
movq (%r15), %rax
movq %r15, %rdi
callq *0xb8(%rax)
movl %eax, %ebx
callq 0x61d58
cmpl %eax, %ebx
jne 0x31cf7
leaq 0x8(%r15), %rsi
leaq 0x30(%rsp), %rdi
callq 0x6aee4
leaq 0x20(%r15), %rdi
leaq 0x960d0(%rip), %rsi     # 0xc7d60
callq 0x6c2ae
leaq 0xfd45c(%rip), %rax     # 0x12f0f8
movsd (%rax), %xmm1
addsd 0x93828(%rip), %xmm0    # 0xc54d0
ucomisd %xmm1, %xmm0
ja 0x31cbc
xorpd 0x9387a(%rip), %xmm1    # 0xc5530
ucomisd %xmm0, %xmm1
jbe 0x31cca
leaq 0x94b39(%rip), %rdi     # 0xc67fc
xorl %eax, %eax
callq 0x7e83e
movsd 0x30(%rsp), %xmm0
movsd 0x38(%rsp), %xmm1
movsd 0x40(%rsp), %xmm2
movsd 0x50(%r15), %xmm4
movsd 0x78(%r15), %xmm3
movq %rbp, %rdi
leaq 0x94b2a(%rip), %rsi     # 0xc681c
jmp 0x31d8d
movq (%r15), %rax
movq %r15, %rdi
callq *0xb8(%rax)
movl %eax, %ebx
callq 0x622ac
cmpl %eax, %ebx
jne 0x31daa
leaq 0x8(%r15), %rsi
leaq 0x30(%rsp), %rdi
callq 0x6aee4
leaq 0x20(%r15), %rdi
leaq 0x96035(%rip), %rsi     # 0xc7d60
callq 0x6c2ae
leaq 0xfd3c1(%rip), %rax     # 0x12f0f8
movsd (%rax), %xmm1
addsd 0x9378d(%rip), %xmm0    # 0xc54d0
ucomisd %xmm1, %xmm0
ja 0x31d57
xorpd 0x937df(%rip), %xmm1    # 0xc5530
ucomisd %xmm0, %xmm1
jbe 0x31d65
leaq 0x94add(%rip), %rdi     # 0xc683b
xorl %eax, %eax
callq 0x7e83e
movsd 0x30(%rsp), %xmm0
movsd 0x38(%rsp), %xmm1
movsd 0x40(%rsp), %xmm2
movsd 0x50(%r15), %xmm4
movsd 0x78(%r15), %xmm3
movq %rbp, %rdi
leaq 0x94ad2(%rip), %rsi     # 0xc685f
movq 0x28(%rsp), %rdx
movl 0x24(%rsp), %ecx
movb $0x5, %al
callq 0x21da0
movq 0x68(%rsp), %rcx
incq %rcx
jmp 0x31ab9
movq (%r15), %rax
movq %r15, %rdi
callq *0xb8(%rax)
movl %eax, %ebx
callq 0x5dcf8
cmpl %eax, %ebx
jne 0x31f73
pushq $0x68
popq %rdi
callq 0x218d0
movq %rax, 0x48(%rsp)
leaq 0x30(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x35b5e
movq 0x48(%rsp), %rdi
movq %rbx, %rsi
callq 0x6098e
pushq $0x68
popq %rdi
callq 0x218d0
movq %rax, 0x60(%rsp)
leaq 0x30(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
pushq $0x1
popq %rdx
xorl %ecx, %ecx
callq 0x35b5e
movq 0x60(%rsp), %rdi
movq %rbx, %rsi
callq 0x6098e
pushq $0x68
popq %rdi
callq 0x218d0
movq %rax, %rbx
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movq %r15, %rsi
pushq $0x1
popq %rcx
movl %ecx, %edx
callq 0x35b5e
movq %rbx, %rdi
movq %r14, %rsi
callq 0x6098e
pushq $0x68
popq %rdi
callq 0x218d0
movq %rax, %r13
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movq %r15, %rsi
xorl %edx, %edx
pushq $0x1
popq %rcx
callq 0x35b5e
movq %r13, %rdi
movq %r14, %rsi
callq 0x6098e
movq 0xc8(%rsp), %rax
leaq 0xc8(%rsp), %rdi
callq *0x18(%rax)
movl %eax, %r15d
movq 0xc8(%rsp), %rax
leaq 0xc8(%rsp), %rdi
callq *0x18(%rax)
testl %r15d, %r15d
movq %r13, %r15
movq 0x48(%rsp), %rbp
cmoveq %rbp, %r15
cmoveq %r13, %rbp
testl %eax, %eax
movq 0x60(%rsp), %rax
movq %rax, %r13
cmoveq %rbx, %r13
cmoveq %rax, %rbx
movsd (%r15), %xmm0
movsd 0x8(%r15), %xmm1
movsd 0x10(%r15), %xmm2
movsd (%rbx), %xmm3
movsd 0x8(%rbx), %xmm4
movsd 0x10(%rbx), %xmm5
movsd (%r13), %xmm6
movsd 0x8(%r13), %xmm7
movsd 0x10(%r13), %xmm8
movsd %xmm8, (%rsp)
movq 0x78(%rsp), %rdi
leaq 0x94979(%rip), %rsi     # 0xc6882
movq 0x28(%rsp), %rbx
movq %rbx, %rdx
movl 0x24(%rsp), %r14d
movl %r14d, %ecx
movb $0x8, %al
callq 0x21da0
movsd (%r15), %xmm0
movsd 0x8(%r15), %xmm1
movsd 0x10(%r15), %xmm2
movsd (%r13), %xmm3
movsd 0x8(%r13), %xmm4
movsd 0x10(%r13), %xmm5
movsd (%rbp), %xmm6
movsd 0x8(%rbp), %xmm7
movsd 0x10(%rbp), %xmm8
movq 0x78(%rsp), %rbp
movsd %xmm8, (%rsp)
movq %rbp, %rdi
leaq 0x9491a(%rip), %rsi     # 0xc6882
movq %rbx, %rdx
movl %r14d, %ecx
jmp 0x31bf4
movq (%r15), %rax
movq %r15, %rdi
callq *0xb8(%rax)
movl %eax, %ebx
callq 0x608c4
cmpl %eax, %ebx
jne 0x31ff9
movq 0x8(%r15), %rbx
movq 0x10(%r15), %r14
movq 0x18(%r15), %r15
movq 0xc8(%rsp), %rax
leaq 0xc8(%rsp), %rdi
callq *0x18(%rax)
testl %eax, %eax
movq %r15, %rax
cmoveq %rbx, %rax
cmoveq %r15, %rbx
movsd (%rax), %xmm0
movsd 0x8(%rax), %xmm1
movsd 0x10(%rax), %xmm2
movsd (%r14), %xmm3
movsd 0x8(%r14), %xmm4
movsd 0x10(%r14), %xmm5
movsd (%rbx), %xmm6
movsd 0x8(%rbx), %xmm7
movsd 0x10(%rbx), %xmm8
movsd %xmm8, (%rsp)
movq %rbp, %rdi
leaq 0x9488e(%rip), %rsi     # 0xc6882
jmp 0x31beb
movq (%r15), %rax
movq %r15, %rdi
callq *0xb8(%rax)
movl %eax, %ebx
callq 0x5f048
cmpl %eax, %ebx
jne 0x320e8
xorl %ecx, %ecx
movq %r12, 0x90(%rsp)
movslq 0x24(%r15), %rax
cmpq %rax, %rcx
jge 0x31d9d
movq %rbp, %rbx
movq 0x18(%r15), %rax
movq %rcx, 0x48(%rsp)
movq (%rax,%rcx,8), %r13
movq 0xc8(%rsp), %rax
leaq 0xc8(%rsp), %r12
movq %r12, %rdi
callq *0x18(%rax)
xorl %ecx, %ecx
testl %eax, %eax
setne %cl
shll $0x4, %ecx
movq 0x8(%r13,%rcx), %r14
movq 0x10(%r13), %rbp
movq 0xc8(%rsp), %rax
movq %r12, %rdi
callq *0x18(%rax)
xorl %ecx, %ecx
testl %eax, %eax
sete %cl
shll $0x4, %ecx
movq 0x8(%r13,%rcx), %rax
movsd (%r14), %xmm0
movsd 0x8(%r14), %xmm1
movsd 0x10(%r14), %xmm2
movsd (%rbp), %xmm3
movsd 0x8(%rbp), %xmm4
movsd 0x10(%rbp), %xmm5
movsd (%rax), %xmm6
movsd 0x8(%rax), %xmm7
movsd 0x10(%rax), %xmm8
movsd %xmm8, (%rsp)
movq %rbx, %rbp
movq %rbx, %rdi
leaq 0x947bf(%rip), %rsi     # 0xc6882
movq 0x28(%rsp), %rdx
movl 0x24(%rsp), %ecx
movb $0x8, %al
callq 0x21da0
movq 0x48(%rsp), %rcx
incq %rcx
movq 0x90(%rsp), %r12
jmp 0x3201e
movq (%r15), %rax
movq %r15, %rdi
callq *0xb8(%rax)
leaq 0x947b3(%rip), %rdi     # 0xc68ae
movl %eax, %esi
xorl %eax, %eax
callq 0x7e83e
jmp 0x31d9d
movq 0x88(%rsp), %rcx
incq %rcx
movq 0x80(%rsp), %r13
jmp 0x31a82
leaq 0x947c1(%rip), %rbx     # 0xc68e9
xorl %r14d, %r14d
movslq 0x4c(%r13), %rax
cmpq %rax, %r14
jge 0x32162
movq 0x40(%r13), %rax
movq (%rax,%r14,8), %rax
movq (%rax), %rax
movq 0x148(%rax), %rcx
testq %rcx, %rcx
je 0x3219e
movq %rbp, %rdi
movq %rbx, %rsi
movq 0x28(%rsp), %rdx
xorl %eax, %eax
callq 0x21da0
incq %r14
jmp 0x3212b
xorl %r14d, %r14d
leaq 0xc8(%rsp), %rbx
movslq 0x2c(%r13), %rax
cmpq %rax, %r14
jge 0x321b0
movq 0x20(%r13), %rax
movq (%rax,%r14,8), %rsi
movq 0x70(%rsp), %rdi
movq %rbx, %rdx
movq %rbp, %rcx
movq 0x28(%rsp), %r8
callq 0x31867
incq %r14
testl %eax, %eax
jne 0x3216d
xorl %ebx, %ebx
jmp 0x321da
xorl %ebx, %ebx
leaq 0x9472c(%rip), %rdi     # 0xc68d3
xorl %eax, %eax
callq 0x7e764
jmp 0x321da
cmpb $0x0, 0x54(%rsp)
je 0x321cd
leaq 0x945c1(%rip), %rsi     # 0xc677f
movq %rbp, %rdi
movq 0x58(%rsp), %rdx
xorl %eax, %eax
callq 0x21da0
movq 0x28(%rsp), %rdi
callq 0x21c20
pushq $0x1
popq %rbx
leaq 0xc8(%rsp), %rdi
callq 0x66856
movl %ebx, %eax
addq $0x1d8, %rsp            # imm = 0x1D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x32231
jmp 0x32231
jmp 0x32231
jmp 0x32231
movq %rax, %r14
movq %rbx, %rdi
jmp 0x32225
movq %rax, %r14
movq %r13, %rdi
jmp 0x32225
movq %rax, %r14
movq 0x60(%rsp), %rdi
jmp 0x32225
movq %rax, %r14
movq 0x48(%rsp), %rdi
pushq $0x68
popq %rsi
callq 0x218f0
jmp 0x32234
jmp 0x32231
movq %rax, %r14
leaq 0xc8(%rsp), %rdi
callq 0x66856
movq %r14, %rdi
callq 0x220e0