// File: tomfunkhouser[P]gaps/apps/scninfo/scninfo.cpp
// Function: PrintScene(gaps::R3Scene*)
static int
PrintScene(R3Scene *scene)
{
  // Print scene stuff
  const R3Camera& camera = scene->Camera();
  const R3Box& bbox = scene->BBox();
  R3Point centroid = scene->Centroid();
  printf("Scene ...\n");
  printf("  # Nodes = %d\n", scene->NNodes());
  printf("  # Lights = %d\n", scene->NLights());
  printf("  # Materials = %d\n", scene->NMaterials());
  printf("  # Brdfs = %d\n", scene->NBrdfs());
  printf("  # Textures = %d\n", scene->NTextures());
  printf("  # Referenced scenes = %d\n", scene->NReferencedScenes());
  printf("  Camera = %g %g %g   %g %g %g   %g %g %g  %g\n", 
    camera.Origin().X(), camera.Origin().Y(), camera.Origin().Z(),
    camera.Towards().X(), camera.Towards().Y(), camera.Towards().Z(),
    camera.Up().X(), camera.Up().Y(), camera.Up().Z(),
    camera.YFOV());
  printf("  BBox = ( %g %g %g ) ( %g %g %g )\n", 
    bbox[0][0], bbox[0][1], bbox[0][2], 
    bbox[1][0], bbox[1][1], bbox[1][2]);
  printf("  Centroid = %g %g %g\n", 
    centroid[0], centroid[1], centroid[2]);
  printf("\n");

  // Print nodes and elements and references in a hierarchy
  if (print_nodes || print_elements || print_references) {
    printf("Nodes ...\n");
    PrintNodes(scene, scene->Root(), 0, 0);
  }

  // Print lights
  if (print_lights) {
    printf("Lights ...\n");
    for (int i = 0; i < scene->NLights(); i++) {
      R3Light *light = scene->Light(i);
      PrintLight(light, i, 1);
    }
  }

  // Print brdfs
  if (print_brdfs) {
    printf("Brdfs ...\n");
    for (int i = 0; i < scene->NBrdfs(); i++) {
      R3Brdf *brdf = scene->Brdf(i);
      PrintBrdf(brdf, i, 1);
    }
  }

  // Print textures
  if (print_textures) {
    printf("Textures ...\n");
    for (int i = 0; i < scene->NTextures(); i++) {
      R2Texture *texture = scene->Texture(i);
      PrintTexture(texture, i, 1);
    }
  }

  // Print materials
  if (print_materials) {
    printf("Materials ...\n");
    for (int i = 0; i < scene->NMaterials(); i++) {
      R3Material *material = scene->Material(i);
      PrintMaterial(material, i, 1);
    }
  }

  // Return success
  return 1;
}

// Assembly:
subq $0x168, %rsp            # imm = 0x168
movq %rdi, 0x160(%rsp)
movq 0x160(%rsp), %rdi
callq 0x29890
movq %rax, 0x158(%rsp)
movq 0x160(%rsp), %rdi
callq 0x298b0
movq %rax, 0x150(%rsp)
movq 0x160(%rsp), %rsi
leaq 0x138(%rsp), %rdi
callq 0x298d0
leaq 0x164f1c(%rip), %rdi    # 0x18c111
movb $0x0, %al
callq 0x22090
movq 0x160(%rsp), %rdi
callq 0x29900
movl %eax, %esi
leaq 0x164f0a(%rip), %rdi    # 0x18c11c
movb $0x0, %al
callq 0x22090
movq 0x160(%rsp), %rdi
callq 0x29920
movl %eax, %esi
leaq 0x164efd(%rip), %rdi    # 0x18c12c
movb $0x0, %al
callq 0x22090
movq 0x160(%rsp), %rdi
callq 0x29940
movl %eax, %esi
leaq 0x165222(%rip), %rdi    # 0x18c46e
movb $0x0, %al
callq 0x22090
movq 0x160(%rsp), %rdi
callq 0x29960
movl %eax, %esi
leaq 0x164ed4(%rip), %rdi    # 0x18c13d
movb $0x0, %al
callq 0x22090
movq 0x160(%rsp), %rdi
callq 0x29980
movl %eax, %esi
leaq 0x164ec7(%rip), %rdi    # 0x18c14d
movb $0x0, %al
callq 0x22090
movq 0x160(%rsp), %rdi
callq 0x299a0
movl %eax, %esi
leaq 0x164ebd(%rip), %rdi    # 0x18c160
movb $0x0, %al
callq 0x22090
movq 0x158(%rsp), %rdi
callq 0x299c0
movq %rax, %rdi
callq 0x299d0
movsd %xmm0, 0x70(%rsp)
movq 0x158(%rsp), %rdi
callq 0x299c0
movq %rax, %rdi
callq 0x299e0
movsd %xmm0, 0x30(%rsp)
movq 0x158(%rsp), %rdi
callq 0x299c0
movq %rax, %rdi
callq 0x299f0
movsd %xmm0, 0x38(%rsp)
movq 0x158(%rsp), %rsi
leaq 0x120(%rsp), %rdi
callq 0x29a00
leaq 0x120(%rsp), %rdi
callq 0x29a50
movsd %xmm0, 0x40(%rsp)
movq 0x158(%rsp), %rsi
leaq 0x108(%rsp), %rdi
callq 0x29a00
leaq 0x108(%rsp), %rdi
callq 0x29a60
movsd %xmm0, 0x48(%rsp)
movq 0x158(%rsp), %rsi
leaq 0xf0(%rsp), %rdi
callq 0x29a00
leaq 0xf0(%rsp), %rdi
callq 0x29a70
movsd %xmm0, 0x50(%rsp)
movq 0x158(%rsp), %rdi
callq 0x29a80
movq %rax, %rdi
callq 0x29a50
movsd %xmm0, 0x58(%rsp)
movq 0x158(%rsp), %rdi
callq 0x29a80
movq %rax, %rdi
callq 0x29a60
movsd %xmm0, 0x60(%rsp)
movq 0x158(%rsp), %rdi
callq 0x29a80
movq %rax, %rdi
callq 0x29a70
movsd %xmm0, 0x68(%rsp)
movq 0x158(%rsp), %rdi
callq 0x29aa0
movsd 0x30(%rsp), %xmm1
movsd 0x38(%rsp), %xmm2
movsd 0x40(%rsp), %xmm3
movsd 0x48(%rsp), %xmm4
movsd 0x50(%rsp), %xmm5
movsd 0x58(%rsp), %xmm6
movsd 0x60(%rsp), %xmm7
movsd 0x68(%rsp), %xmm9
movaps %xmm0, %xmm8
movsd 0x70(%rsp), %xmm0
leaq 0x164d69(%rip), %rdi    # 0x18c17c
movsd %xmm9, (%rsp)
movsd %xmm8, 0x8(%rsp)
movb $0x8, %al
callq 0x22090
movq 0x150(%rsp), %rdi
xorl %esi, %esi
callq 0x29ab0
movq %rax, %rdi
xorl %esi, %esi
callq 0x29af0
movsd %xmm0, 0x98(%rsp)
movq 0x150(%rsp), %rdi
xorl %esi, %esi
callq 0x29ab0
movq %rax, %rdi
movl $0x1, %esi
callq 0x29af0
movsd %xmm0, 0x78(%rsp)
movq 0x150(%rsp), %rdi
xorl %esi, %esi
callq 0x29ab0
movq %rax, %rdi
movl $0x2, %esi
callq 0x29af0
movsd %xmm0, 0x80(%rsp)
movq 0x150(%rsp), %rdi
movl $0x1, %esi
callq 0x29ab0
movq %rax, %rdi
xorl %esi, %esi
callq 0x29af0
movsd %xmm0, 0x88(%rsp)
movq 0x150(%rsp), %rdi
movl $0x1, %esi
callq 0x29ab0
movq %rax, %rdi
movl $0x1, %esi
callq 0x29af0
movsd %xmm0, 0x90(%rsp)
movq 0x150(%rsp), %rdi
movl $0x1, %esi
callq 0x29ab0
movq %rax, %rdi
movl $0x2, %esi
callq 0x29af0
movsd 0x78(%rsp), %xmm1
movsd 0x80(%rsp), %xmm2
movsd 0x88(%rsp), %xmm3
movsd 0x90(%rsp), %xmm4
movaps %xmm0, %xmm5
movsd 0x98(%rsp), %xmm0
leaq 0x164d7e(%rip), %rdi    # 0x18c2ae
movb $0x6, %al
callq 0x22090
leaq 0x138(%rsp), %rdi
xorl %esi, %esi
callq 0x29b10
movsd (%rax), %xmm0
movsd %xmm0, 0xa0(%rsp)
leaq 0x138(%rsp), %rdi
movl $0x1, %esi
callq 0x29b10
movsd (%rax), %xmm0
movsd %xmm0, 0xa8(%rsp)
leaq 0x138(%rsp), %rdi
movl $0x2, %esi
callq 0x29b10
movsd 0xa0(%rsp), %xmm0
movsd 0xa8(%rsp), %xmm1
movsd (%rax), %xmm2
leaq 0x164cf4(%rip), %rdi    # 0x18c295
movb $0x3, %al
callq 0x22090
leaq 0x16c153(%rip), %rdi    # 0x193702
movb $0x0, %al
callq 0x22090
cmpl $0x0, 0x1d254b(%rip)    # 0x1f9b08
jne 0x275d1
cmpl $0x0, 0x1d2546(%rip)    # 0x1f9b0c
jne 0x275d1
cmpl $0x0, 0x1d2541(%rip)    # 0x1f9b10
je 0x2760a
leaq 0x164bd3(%rip), %rdi    # 0x18c1ab
movb $0x0, %al
callq 0x22090
movq 0x160(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x160(%rsp), %rdi
callq 0x29b30
movq 0x28(%rsp), %rdi
movq %rax, %rsi
xorl %ecx, %ecx
movl %ecx, %edx
callq 0x27860
cmpl $0x0, 0x1d2503(%rip)    # 0x1f9b14
je 0x2769c
leaq 0x164b98(%rip), %rdi    # 0x18c1b6
movb $0x0, %al
callq 0x22090
movl $0x0, 0xec(%rsp)
movl 0xec(%rsp), %eax
movl %eax, 0x24(%rsp)
movq 0x160(%rsp), %rdi
callq 0x29920
movl %eax, %ecx
movl 0x24(%rsp), %eax
cmpl %ecx, %eax
jge 0x2769a
movq 0x160(%rsp), %rdi
movl 0xec(%rsp), %esi
callq 0x29b40
movq %rax, 0xe0(%rsp)
movq 0xe0(%rsp), %rdi
movl 0xec(%rsp), %esi
movl $0x1, %edx
callq 0x28800
movl 0xec(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xec(%rsp)
jmp 0x27630
jmp 0x2769c
cmpl $0x0, 0x1d2475(%rip)    # 0x1f9b18
je 0x2772e
leaq 0x164b12(%rip), %rdi    # 0x18c1c2
movb $0x0, %al
callq 0x22090
movl $0x0, 0xdc(%rsp)
movl 0xdc(%rsp), %eax
movl %eax, 0x20(%rsp)
movq 0x160(%rsp), %rdi
callq 0x29960
movl %eax, %ecx
movl 0x20(%rsp), %eax
cmpl %ecx, %eax
jge 0x2772c
movq 0x160(%rsp), %rdi
movl 0xdc(%rsp), %esi
callq 0x29b70
movq %rax, 0xd0(%rsp)
movq 0xd0(%rsp), %rdi
movl 0xdc(%rsp), %esi
movl $0x1, %edx
callq 0x28930
movl 0xdc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xdc(%rsp)
jmp 0x276c2
jmp 0x2772e
cmpl $0x0, 0x1d23e7(%rip)    # 0x1f9b1c
je 0x277c0
leaq 0x164a8b(%rip), %rdi    # 0x18c1cd
movb $0x0, %al
callq 0x22090
movl $0x0, 0xcc(%rsp)
movl 0xcc(%rsp), %eax
movl %eax, 0x1c(%rsp)
movq 0x160(%rsp), %rdi
callq 0x29980
movl %eax, %ecx
movl 0x1c(%rsp), %eax
cmpl %ecx, %eax
jge 0x277be
movq 0x160(%rsp), %rdi
movl 0xcc(%rsp), %esi
callq 0x29ba0
movq %rax, 0xc0(%rsp)
movq 0xc0(%rsp), %rdi
movl 0xcc(%rsp), %esi
movl $0x1, %edx
callq 0x28d60
movl 0xcc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xcc(%rsp)
jmp 0x27754
jmp 0x277c0
cmpl $0x0, 0x1d2359(%rip)    # 0x1f9b20
je 0x27852
leaq 0x164a07(%rip), %rdi    # 0x18c1db
movb $0x0, %al
callq 0x22090
movl $0x0, 0xbc(%rsp)
movl 0xbc(%rsp), %eax
movl %eax, 0x18(%rsp)
movq 0x160(%rsp), %rdi
callq 0x29940
movl %eax, %ecx
movl 0x18(%rsp), %eax
cmpl %ecx, %eax
jge 0x27850
movq 0x160(%rsp), %rdi
movl 0xbc(%rsp), %esi
callq 0x29bd0
movq %rax, 0xb0(%rsp)
movq 0xb0(%rsp), %rdi
movl 0xbc(%rsp), %esi
movl $0x1, %edx
callq 0x28f40
movl 0xbc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xbc(%rsp)
jmp 0x277e6
jmp 0x27852
movl $0x1, %eax
addq $0x168, %rsp            # imm = 0x168
retq
nop