// File: tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Grid.cpp
// Function: gaps::R3Grid::ReadFile(char const*)
int R3Grid::
ReadFile(const char *filename)
{
  // Parse input filename extension
  const char *extension;
  if (!(extension = strrchr(filename, '.'))) {
    printf("Filename %s has no extension (e.g., .ply)\n", filename);
    return 0;
  }

  // Read file of appropriate type
  int status = 0;
  if (!strncmp(extension, ".grd", 4)) 
    status = ReadGridFile(filename);
  else if (!strncmp(extension, ".phi", 4)) 
    status = ReadDelphiFile(filename);
  else if (!strncmp(extension, ".vox", 4)) 
    status = ReadVoxelFile(filename);
  else if (!strncmp(extension, ".ins", 4)) 
    status = ReadInsightFile(filename);
  else if (!strncmp(extension, ".dx", 3)) 
    status = ReadDXFile(filename);
  else if (!strncmp(extension, ".map", 4)) 
    status = ReadCCP4File(filename);
  else if (!strncmp(extension, ".raw", 4)) 
    status = ReadRawFile(filename);
  else {
    RNFail("Unable to read file %s (unrecognized extension: %s)\n", filename, extension);
    return 0;
  }

  // Return status
  return status;
}

// Assembly:
subq $0x38, %rsp
movq %rdi, 0x28(%rsp)
movq %rsi, 0x20(%rsp)
movq 0x28(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x20(%rsp), %rdi
movl $0x2e, %esi
callq 0xf580
movq %rax, 0x18(%rsp)
cmpq $0x0, %rax
jne 0x62d92
movq 0x20(%rsp), %rsi
leaq 0xd05d7(%rip), %rdi     # 0x133355
movb $0x0, %al
callq 0xf070
movl $0x0, 0x34(%rsp)
jmp 0x62f2f
movl $0x0, 0x14(%rsp)
movq 0x18(%rsp), %rdi
leaq 0xd152d(%rip), %rsi     # 0x1342d3
movl $0x4, %edx
callq 0xf230
cmpl $0x0, %eax
jne 0x62dcd
movq 0x8(%rsp), %rdi
movq 0x20(%rsp), %rsi
callq 0x62f40
movl %eax, 0x14(%rsp)
jmp 0x62f27
movq 0x18(%rsp), %rdi
leaq 0xd14ff(%rip), %rsi     # 0x1342d8
movl $0x4, %edx
callq 0xf230
cmpl $0x0, %eax
jne 0x62e00
movq 0x8(%rsp), %rdi
movq 0x20(%rsp), %rsi
callq 0x62fd0
movl %eax, 0x14(%rsp)
jmp 0x62f25
movq 0x18(%rsp), %rdi
leaq 0xd14d1(%rip), %rsi     # 0x1342dd
movl $0x4, %edx
callq 0xf230
cmpl $0x0, %eax
jne 0x62e33
movq 0x8(%rsp), %rdi
movq 0x20(%rsp), %rsi
callq 0x63ba0
movl %eax, 0x14(%rsp)
jmp 0x62f23
movq 0x18(%rsp), %rdi
leaq 0xd14a3(%rip), %rsi     # 0x1342e2
movl $0x4, %edx
callq 0xf230
cmpl $0x0, %eax
jne 0x62e66
movq 0x8(%rsp), %rdi
movq 0x20(%rsp), %rsi
callq 0x63e10
movl %eax, 0x14(%rsp)
jmp 0x62f21
movq 0x18(%rsp), %rdi
leaq 0xd1475(%rip), %rsi     # 0x1342e7
movl $0x3, %edx
callq 0xf230
cmpl $0x0, %eax
jne 0x62e99
movq 0x8(%rsp), %rdi
movq 0x20(%rsp), %rsi
callq 0x649a0
movl %eax, 0x14(%rsp)
jmp 0x62f1f
movq 0x18(%rsp), %rdi
leaq 0xd1446(%rip), %rsi     # 0x1342eb
movl $0x4, %edx
callq 0xf230
cmpl $0x0, %eax
jne 0x62ec9
movq 0x8(%rsp), %rdi
movq 0x20(%rsp), %rsi
callq 0x65110
movl %eax, 0x14(%rsp)
jmp 0x62f1d
movq 0x18(%rsp), %rdi
leaq 0xd141b(%rip), %rsi     # 0x1342f0
movl $0x4, %edx
callq 0xf230
cmpl $0x0, %eax
jne 0x62ef9
movq 0x8(%rsp), %rdi
movq 0x20(%rsp), %rsi
callq 0x65620
movl %eax, 0x14(%rsp)
jmp 0x62f1b
movq 0x20(%rsp), %rsi
movq 0x18(%rsp), %rdx
leaq 0xd04a1(%rip), %rdi     # 0x1333ab
movb $0x0, %al
callq 0xd4f30
movl $0x0, 0x34(%rsp)
jmp 0x62f2f
jmp 0x62f1d
jmp 0x62f1f
jmp 0x62f21
jmp 0x62f23
jmp 0x62f25
jmp 0x62f27
movl 0x14(%rsp), %eax
movl %eax, 0x34(%rsp)
movl 0x34(%rsp), %eax
addq $0x38, %rsp
retq
nopl (%rax,%rax)