// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/GSV/GSVScene.cpp
// Function: gaps::GSVScene::ReadFile(char const*, int)
int GSVScene::
ReadFile(const char *filename, RNBoolean read_points)
{
  // Parse input filename extension
  const char *extension;
  if (!(extension = strrchr(filename, '.'))) {
    RNFail("Filename %s has no extension (e.g., .gsv)\n", filename);
    return 0;
  }

  // Read file of appropriate type
  int status = 0;
  if (!strncmp(extension, ".txt", 4)) status = ReadASCIIFile(filename, read_points);
  else if (!strncmp(extension, ".lsr", 4)) status = ReadLaserFile(filename, read_points);
  else if (!strncmp(extension, ".gsf", 4)) status = ReadGSFFile(filename, read_points);
  else if (!strncmp(extension, ".gsv", 4)) status = ReadGSVFile(filename, read_points);
  else RNFail("Unrecognized file extension %s in %s\n", extension, filename); 
  if (status == 0) return 0;

  // Remember filename
  this->filename = RNStrdup(filename);

  // Set raw directory name
  char buffer[2048];
  strcpy(buffer, filename);
  char *bufferp = strrchr(buffer, '/');
  if (bufferp) *bufferp = '\0';
  else strcpy(buffer, ".");
  strcat(buffer, "/raw_data");
  if (RNFileExists(buffer)) {
    SetRawDataDirectoryName(buffer);
  }

  // Set cache directory name
  strcpy(buffer, filename);
  bufferp = strrchr(buffer, '/');
  if (bufferp) *bufferp = '\0';
  else strcpy(buffer, ".");
  strcat(buffer, "/gsv_data");
  if (RNFileExists(buffer)) {
    SetCacheDataDirectoryName(buffer);
  }

  // Return success
  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x808, %rsp            # imm = 0x808
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %rbx
pushq $0x2e
popq %rsi
movq %r14, %rdi
callq 0x27a30
testq %rax, %rax
je 0x31c45
movq %rax, %r15
leaq 0xfa2b8(%rip), %rsi     # 0x12be91
pushq $0x4
popq %rdx
movq %rax, %rdi
callq 0x27400
testl %eax, %eax
je 0x31c5d
leaq 0xf9e9b(%rip), %rsi     # 0x12ba8a
pushq $0x4
popq %rdx
movq %r15, %rdi
callq 0x27400
testl %eax, %eax
je 0x31c61
leaq 0xf9e8a(%rip), %rsi     # 0x12ba8f
pushq $0x4
popq %rdx
movq %r15, %rdi
callq 0x27400
testl %eax, %eax
je 0x31c65
leaq 0xf98e7(%rip), %rsi     # 0x12b502
pushq $0x4
popq %rdx
movq %r15, %rdi
callq 0x27400
testl %eax, %eax
je 0x31c69
leaq 0xf9e63(%rip), %rdi     # 0x12ba94
xorl %ebx, %ebx
movq %r15, %rsi
movq %r14, %rdx
xorl %eax, %eax
callq 0xe434a
jmp 0x31d54
leaq 0xf9e13(%rip), %rdi     # 0x12ba5f
xorl %ebx, %ebx
movq %r14, %rsi
xorl %eax, %eax
callq 0xe434a
jmp 0x31d54
pushq $0x30
jmp 0x31c6b
pushq $0x28
jmp 0x31c6b
pushq $0x38
jmp 0x31c6b
pushq $0x40
popq %rax
movq (%rbx), %rcx
movq %rbx, %rdi
movq %r14, %rsi
movl %ebp, %edx
callq *(%rcx,%rax)
testl %eax, %eax
je 0x31cad
movq %r14, %rdi
callq 0xe41b5
movq %rax, 0x18(%rbx)
movq %rsp, %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x27880
pushq $0x2f
popq %rsi
movq %r15, %rdi
callq 0x27a30
testq %rax, %rax
je 0x31cb4
movb $0x0, (%rax)
jmp 0x31cba
xorl %ebx, %ebx
jmp 0x31d54
movw $0x2e, (%rsp)
movq %rsp, %r15
movq %r15, %rdi
callq 0x27390
movabsq $0x7461645f7761722f, %rcx # imm = 0x7461645F7761722F
movq %rcx, (%rsp,%rax)
movw $0x61, 0x8(%rsp,%rax)
movq %r15, %rdi
callq 0xe391c
testl %eax, %eax
je 0x31cf1
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x31858
movq %rsp, %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x27880
pushq $0x2f
popq %rsi
movq %r15, %rdi
callq 0x27a30
testq %rax, %rax
je 0x31d14
movb $0x0, (%rax)
jmp 0x31d1a
movw $0x2e, (%rsp)
movq %rsp, %r14
movq %r14, %rdi
callq 0x27390
movabsq $0x7461645f7673672f, %rcx # imm = 0x7461645F7673672F
movq %rcx, (%rsp,%rax)
movw $0x61, 0x8(%rsp,%rax)
movq %r14, %rdi
callq 0xe391c
testl %eax, %eax
je 0x31d51
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x31888
pushq $0x1
popq %rbx
movl %ebx, %eax
addq $0x808, %rsp            # imm = 0x808
popq %rbx
popq %r14
popq %r15
popq %rbp
retq