// File: tomfunkhouser[P]gaps/apps/scn2cam/scn2cam.cpp
// Function: ReadScene(char*)
static R3Scene *
ReadScene(char *filename)
{
  // Start statistics
  RNTime start_time;
  start_time.Read();

  // Allocate scene
  scene = new R3Scene();
  if (!scene) {
    RNFail("Unable to allocate scene for %s\n", filename);
    return NULL;
  }

  // Read scene from file
  if (!scene->ReadFile(filename)) {
    delete scene;
    return NULL;
  }

  // Remove references and transformations
  scene->RemoveReferences();
  scene->RemoveTransformations();

  // Print statistics
  if (print_verbose) {
    printf("Read scene from %s ...\n", filename);
    printf("  Time = %.2f seconds\n", start_time.Elapsed());
    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 models = %d\n", scene->NReferencedScenes());
    fflush(stdout);
  }

  // Return scene
  return scene;
}

// Assembly:
subq $0x48, %rsp
movq %rdi, 0x38(%rsp)
leaq 0x28(%rsp), %rdi
movq %rdi, 0x8(%rsp)
callq 0x11bad0
movq 0x8(%rsp), %rdi
callq 0x321a0
movl $0x160, %edi            # imm = 0x160
callq 0x239b0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x10(%rsp)
callq 0x36d80
jmp 0x28d6e
movq 0x10(%rsp), %rax
movq %rax, 0x206ebe(%rip)    # 0x22fc38
cmpq $0x0, 0x206eb6(%rip)    # 0x22fc38
jne 0x28dc7
movq 0x38(%rsp), %rsi
leaq 0x192671(%rip), %rdi    # 0x1bb401
movb $0x0, %al
callq 0x120a50
movq $0x0, 0x40(%rsp)
jmp 0x28f2a
movq 0x10(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x20(%rsp)
movl %eax, 0x1c(%rsp)
movl $0x160, %esi            # imm = 0x160
callq 0x239d0
jmp 0x28f34
movq 0x206e6a(%rip), %rdi    # 0x22fc38
movq 0x38(%rsp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x393e0
cmpl $0x0, %eax
jne 0x28e17
movq 0x206e50(%rip), %rax    # 0x22fc38
movq %rax, (%rsp)
cmpq $0x0, %rax
je 0x28e09
movq (%rsp), %rdi
callq 0x37000
movq (%rsp), %rdi
movl $0x160, %esi            # imm = 0x160
callq 0x239d0
movq $0x0, 0x40(%rsp)
jmp 0x28f2a
movq 0x206e1a(%rip), %rdi    # 0x22fc38
callq 0x37db0
movq 0x206e0e(%rip), %rdi    # 0x22fc38
callq 0x38190
cmpl $0x0, 0x206d7e(%rip)    # 0x22fbb4
je 0x28f1e
movq 0x38(%rsp), %rsi
leaq 0x1925da(%rip), %rdi    # 0x1bb422
movb $0x0, %al
callq 0x23090
leaq 0x28(%rsp), %rdi
callq 0x11bb90
leaq 0x1925da(%rip), %rdi    # 0x1bb43a
movb $0x1, %al
callq 0x23090
movq 0x206dca(%rip), %rdi    # 0x22fc38
callq 0x321c0
movl %eax, %esi
leaq 0x1925d5(%rip), %rdi    # 0x1bb451
movb $0x0, %al
callq 0x23090
movq 0x206dae(%rip), %rdi    # 0x22fc38
callq 0x321e0
movl %eax, %esi
leaq 0x1925c9(%rip), %rdi    # 0x1bb461
movb $0x0, %al
callq 0x23090
movq 0x206d92(%rip), %rdi    # 0x22fc38
callq 0x32200
movl %eax, %esi
leaq 0x1925be(%rip), %rdi    # 0x1bb472
movb $0x0, %al
callq 0x23090
movq 0x206d76(%rip), %rdi    # 0x22fc38
callq 0x32220
movl %eax, %esi
leaq 0x1925b6(%rip), %rdi    # 0x1bb486
movb $0x0, %al
callq 0x23090
movq 0x206d5a(%rip), %rdi    # 0x22fc38
callq 0x32240
movl %eax, %esi
leaq 0x1925aa(%rip), %rdi    # 0x1bb496
movb $0x0, %al
callq 0x23090
movq 0x206d3e(%rip), %rdi    # 0x22fc38
callq 0x32260
movl %eax, %esi
leaq 0x1925a1(%rip), %rdi    # 0x1bb4a9
movb $0x0, %al
callq 0x23090
movq 0x20007a(%rip), %rax    # 0x228f90
movq (%rax), %rdi
callq 0x23bc0
movq 0x206d13(%rip), %rax    # 0x22fc38
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rax
addq $0x48, %rsp
retq
movq 0x20(%rsp), %rdi
callq 0x24250
nop