// File: tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Grid.cpp
// Function: gaps::R3Grid::ReadInsightFile(char const*)
int R3Grid::
ReadInsightFile(const char *filename)
{
  // Delphi writes insight files as follows.
  // Each fortran write appears as <leading_record_size> data <trailing_record_size>
  // write(14)toplbl
  // write(14)ivary,nbyte,intdat,extent,extent,extent,
  //   xang,yang,zang,xstart,xend,ystart,yend,zstart,
  //   zend,intx,inty,intz
  // do 9041 k = 1,igrid
  //   do 9042 j = 1,igrid
  //     write(14)(phimap(i,j,k),i=1,igrid)

  // Open file
  FILE *fp = fopen(filename, "rb");
  if (!fp) {
    RNFail("Unable to open insight file %s\n", filename);
    return 0;
  }

  // Read leading record size for toplbl
  int toplbl_record_size;
  if (fread(&toplbl_record_size, sizeof(int), 1, fp) != 1) {
    RNFail("Unable to read toplbl_record_size from insight file: %s", filename);
    return 0;
  }
  else if (toplbl_record_size != 60) {
    RNFail("Wrong toplbl record size (%d) in insight file: %s\n", toplbl_record_size, filename);
    return 0;
  }

  // Read toplbl from file 
  char toplabel[128];
  if (fread(toplabel, sizeof(char), 60, fp) != 60) {
    RNFail("Unable to read toplabel from insight file: %s\n", filename);
    return 0;
  }

  // Read trailing record size for toplbl
  if (fread(&toplbl_record_size, sizeof(int), 1, fp) != 1) {
    RNFail("Unable to read toplbl_record_size from insight file: %s", filename);
    return 0;
  }
  else if (toplbl_record_size != 60) {
    RNFail("Wrong toplbl record size (%d) in insight file: %s\n", toplbl_record_size, filename);
    return 0;
  }

  // Read leading record size for ivary-intervals
  int ivary_record_size;
  if (fread(&ivary_record_size, sizeof(int), 1, fp) != 1) {
    RNFail("Unable to read ivary_record_size from insight file: %s", filename);
    return 0;
  }
  else if (ivary_record_size != 72) {
    RNFail("Wrong ivary record size (%d) in insight file: %s\n", ivary_record_size, filename);
    return 0;
  }

  // Read ivary (0 means x varies most quickly)
  int ivary;
  if (fread(&ivary, sizeof(int), 1, fp) != 1) {
    RNFail("Unable to read ivary from insight file");
    return 0;
  }

  // Read nbyte (# of bytes in data (per entry?)
  int nbyte;
  if (fread(&nbyte, sizeof(int), 1, fp) != 1) {
    RNFail("Unable to read nbyte from insight file");
    return 0;
  }

  // Read intdat (0 means floating point)
  int intdat;
  if (fread(&intdat, sizeof(int), 1, fp) != 1) {
    RNFail("Unable to read intdat from insight file");
    return 0;
  }

  // Read extent
  float extent[3];
  if (fread(extent, sizeof(float), 3, fp) != 3) {
    RNFail("Unable to read extent from insight file");
    return 0;
  }

  // Read unit cell angle (90,90,90)
  float unit_cell_angle[3];
  if (fread(unit_cell_angle, sizeof(float), 3, fp) != 3) {
    RNFail("Unable to read cell angle from insight file");
    return 0;
  }

  // Read start and end values
  float start[3], end[3];
  for (int i = 0; i < 3; i++) {
    if (fread(&start[i], sizeof(float), 1, fp) != 1) {
      RNFail("Unable to read start coordinate from insight file");
      return 0;
    }
    if (fread(&end[i], sizeof(float), 1, fp) != 1) {
      RNFail("Unable to read end coordinate from insight file");
      return 0;
    }
  }

  // Read grid resolution
  int intervals[3];
  if (fread(intervals, sizeof(int), 3, fp) != 3) {
    RNFail("Unable to read number of intervals from insight file");
    return 0;
  }

  // Read trailing record size for ivary-intervals
  if (fread(&ivary_record_size, sizeof(int), 1, fp) != 1) {
    RNFail("Unable to read ivary_record_size from insight file: %s", filename);
    return 0;
  }
  else if (ivary_record_size != 72) {
    RNFail("Wrong ivary record size (%d) in insight file: %s\n", ivary_record_size, filename);
    return 0;
  }

  // Determine resolution
  int res[3];
  res[0] = intervals[0]+1;
  res[1] = intervals[1]+1;
  res[2] = intervals[2]+1;

  // Check standard values
  if ((ivary != 0) || (nbyte != 4) || (intdat != 0) ||
      (unit_cell_angle[0] != 90) || (unit_cell_angle[1] != 90) || (unit_cell_angle[2] != 90)) {
    RNFail("Problem with header info in insight file: %d %d %d (should be 0 4 0 90 90 90)\n", 
           ivary, nbyte, intdat, unit_cell_angle[0], unit_cell_angle[1], unit_cell_angle[2]);
    return 0;
  }

#if 0
  printf("%d %d %d   (%g %g %g)   (%g %g %g)    (%g %g %g) (%g %g %g)    (%d %d %d)   (%d %d %d)\n",
    ivary, nbyte, intdat,
    extent[0], extent[1], extent[2],
    unit_cell_angle[0], unit_cell_angle[1], unit_cell_angle[2],
    start[0], start[1], start[2],
    end[0], end[1], end[2],
    intervals[0], intervals[1], intervals[2], 
    res[0], res[1], res[2]);
#endif

  // Re-allocate grid values
  int new_size = res[0] * res[1] * res[2];
  if (!grid_values || (new_size > grid_size)) { 
    if (grid_values) delete [] grid_values;
    grid_values = new RNScalar [ new_size ];
    assert(grid_values);
  }
  // Update grid resolution variables
  grid_resolution[0] = res[0];
  grid_resolution[1] = res[1];
  grid_resolution[2] = res[2];
  grid_row_size = grid_resolution[0];
  grid_sheet_size = grid_row_size * grid_resolution[1];
  grid_size = grid_sheet_size * grid_resolution[2];
  if (grid_size <= 0) {
    RNFail("Invalid grid size (%d) in file", grid_size);
    return 0;
  }

  // Read grid values
  RNScalar *grid_valuesp = grid_values;
  for (int k = 0; k < grid_resolution[2]; k++) {
    for (int j = 0; j < grid_resolution[1]; j++) {
      // Read leading record size for grid row
      unsigned int row_record_size;
      if (fread(&row_record_size, sizeof(int), 1, fp) != 1) {
        RNFail("Unable to read row_record_size from insight file: %s", filename);
        return 0;
      }
      else if (row_record_size != grid_resolution[0]*sizeof(float)) {
        RNFail("Wrong row record size (%d) in insight file: %s\n", row_record_size, filename);
        return 0;
      }

      // Read row
      for (int i = 0; i < grid_resolution[0]; i++) {
        float value;
        if (fread(&value, sizeof(float), 1, fp) != 1) {
          RNFail("Unable to read grid value %d of %d from file", i, grid_size);
          return 0;
        }
        else {
          *(grid_valuesp++) = (RNScalar) value;
        }
      }

      // Read trailing record size for grid row
      if (fread(&row_record_size, sizeof(int), 1, fp) != 1) {
        RNFail("Unable to read row_record_size from insight file: %s", filename);
        return 0;
      }
      else if (row_record_size != grid_resolution[0]*sizeof(float)) {
        RNFail("Wrong row record size (%d) in insight file: %s\n", row_record_size, filename);
        return 0;
      }
    }
  }

  // Make sure at end of file
  int count = 0;
  char dummytrailer;
  while (fread(&dummytrailer, sizeof(char), 1, fp) == 1) count++;
  if (count != 0) {
    RNFail("%d bytes of extra data at end of delphi file %s\n", count, filename);
    return 0;
  }

  // Determine world-grid transformation
  R3Point start_point(start[0]*extent[0], start[1]*extent[1], start[2]*extent[2]);
  R3Point end_point(end[0]*extent[0], end[1]*extent[1], end[2]*extent[2]);
  R3Box world_box(start_point, end_point);
  SetWorldToGridTransformation(world_box);

  // Close file
  fclose(fp);

  // Return number of grid values read
  return grid_size;
}

// Assembly:
subq $0x1d8, %rsp            # imm = 0x1D8
movq %rdi, 0x1c8(%rsp)
movq %rsi, 0x1c0(%rsp)
movq 0x1c8(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x1c0(%rsp), %rdi
leaq 0xcf796(%rip), %rsi     # 0x1335d9
callq 0xf5e0
movq %rax, 0x1b8(%rsp)
cmpq $0x0, 0x1b8(%rsp)
jne 0x63e81
movq 0x1c0(%rsp), %rsi
leaq 0xd0bfc(%rip), %rdi     # 0x134a66
movb $0x0, %al
callq 0xd4f30
movl $0x0, 0x1d4(%rsp)
jmp 0x64987
movq 0x1b8(%rsp), %rcx
leaq 0x1b4(%rsp), %rdi
movl $0x4, %esi
movl $0x1, %edx
callq 0xf780
cmpq $0x1, %rax
je 0x63ecc
movq 0x1c0(%rsp), %rsi
leaq 0xd0bd1(%rip), %rdi     # 0x134a86
movb $0x0, %al
callq 0xd4f30
movl $0x0, 0x1d4(%rsp)
jmp 0x64987
cmpl $0x3c, 0x1b4(%rsp)
je 0x63f03
movl 0x1b4(%rsp), %esi
movq 0x1c0(%rsp), %rdx
leaq 0xd0bd2(%rip), %rdi     # 0x134abe
movb $0x0, %al
callq 0xd4f30
movl $0x0, 0x1d4(%rsp)
jmp 0x64987
jmp 0x63f05
leaq 0x130(%rsp), %rdi
movq 0x1b8(%rsp), %rcx
movl $0x1, %esi
movl $0x3c, %edx
callq 0xf780
cmpq $0x3c, %rax
je 0x63f50
movq 0x1c0(%rsp), %rsi
leaq 0xd0bb8(%rip), %rdi     # 0x134af1
movb $0x0, %al
callq 0xd4f30
movl $0x0, 0x1d4(%rsp)
jmp 0x64987
movq 0x1b8(%rsp), %rcx
leaq 0x1b4(%rsp), %rdi
movl $0x4, %esi
movl $0x1, %edx
callq 0xf780
cmpq $0x1, %rax
je 0x63f9b
movq 0x1c0(%rsp), %rsi
leaq 0xd0b02(%rip), %rdi     # 0x134a86
movb $0x0, %al
callq 0xd4f30
movl $0x0, 0x1d4(%rsp)
jmp 0x64987
cmpl $0x3c, 0x1b4(%rsp)
je 0x63fd2
movl 0x1b4(%rsp), %esi
movq 0x1c0(%rsp), %rdx
leaq 0xd0b03(%rip), %rdi     # 0x134abe
movb $0x0, %al
callq 0xd4f30
movl $0x0, 0x1d4(%rsp)
jmp 0x64987
jmp 0x63fd4
movq 0x1b8(%rsp), %rcx
leaq 0x12c(%rsp), %rdi
movl $0x4, %esi
movl $0x1, %edx
callq 0xf780
cmpq $0x1, %rax
je 0x6401f
movq 0x1c0(%rsp), %rsi
leaq 0xd0b18(%rip), %rdi     # 0x134b20
movb $0x0, %al
callq 0xd4f30
movl $0x0, 0x1d4(%rsp)
jmp 0x64987
cmpl $0x48, 0x12c(%rsp)
je 0x64056
movl 0x12c(%rsp), %esi
movq 0x1c0(%rsp), %rdx
leaq 0xd0b18(%rip), %rdi     # 0x134b57
movb $0x0, %al
callq 0xd4f30
movl $0x0, 0x1d4(%rsp)
jmp 0x64987
jmp 0x64058
movq 0x1b8(%rsp), %rcx
leaq 0x128(%rsp), %rdi
movl $0x4, %esi
movl $0x1, %edx
callq 0xf780
cmpq $0x1, %rax
je 0x6409b
leaq 0xd0b05(%rip), %rdi     # 0x134b89
movb $0x0, %al
callq 0xd4f30
movl $0x0, 0x1d4(%rsp)
jmp 0x64987
movq 0x1b8(%rsp), %rcx
leaq 0x124(%rsp), %rdi
movl $0x4, %esi
movl $0x1, %edx
callq 0xf780
cmpq $0x1, %rax
je 0x640de
leaq 0xd0ae9(%rip), %rdi     # 0x134bb0
movb $0x0, %al
callq 0xd4f30
movl $0x0, 0x1d4(%rsp)
jmp 0x64987
movq 0x1b8(%rsp), %rcx
leaq 0x120(%rsp), %rdi
movl $0x4, %esi
movl $0x1, %edx
callq 0xf780
cmpq $0x1, %rax
je 0x64121
leaq 0xd0acd(%rip), %rdi     # 0x134bd7
movb $0x0, %al
callq 0xd4f30
movl $0x0, 0x1d4(%rsp)
jmp 0x64987
leaq 0x114(%rsp), %rdi
movq 0x1b8(%rsp), %rcx
movl $0x4, %esi
movl $0x3, %edx
callq 0xf780
cmpq $0x3, %rax
je 0x64164
leaq 0xd0ab2(%rip), %rdi     # 0x134bff
movb $0x0, %al
callq 0xd4f30
movl $0x0, 0x1d4(%rsp)
jmp 0x64987
leaq 0x108(%rsp), %rdi
movq 0x1b8(%rsp), %rcx
movl $0x4, %esi
movl $0x3, %edx
callq 0xf780
cmpq $0x3, %rax
je 0x641a7
leaq 0xd0a97(%rip), %rdi     # 0x134c27
movb $0x0, %al
callq 0xd4f30
movl $0x0, 0x1d4(%rsp)
jmp 0x64987
movl $0x0, 0xec(%rsp)
cmpl $0x3, 0xec(%rsp)
jge 0x6427c
movslq 0xec(%rsp), %rax
leaq 0xfc(%rsp), %rdi
shlq $0x2, %rax
addq %rax, %rdi
movq 0x1b8(%rsp), %rcx
movl $0x4, %esi
movl $0x1, %edx
callq 0xf780
cmpq $0x1, %rax
je 0x64212
leaq 0xd0a58(%rip), %rdi     # 0x134c53
movb $0x0, %al
callq 0xd4f30
movl $0x0, 0x1d4(%rsp)
jmp 0x64987
movslq 0xec(%rsp), %rax
leaq 0xf0(%rsp), %rdi
shlq $0x2, %rax
addq %rax, %rdi
movq 0x1b8(%rsp), %rcx
movl $0x4, %esi
movl $0x1, %edx
callq 0xf780
cmpq $0x1, %rax
je 0x64264
leaq 0xd0a38(%rip), %rdi     # 0x134c85
movb $0x0, %al
callq 0xd4f30
movl $0x0, 0x1d4(%rsp)
jmp 0x64987
jmp 0x64266
movl 0xec(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xec(%rsp)
jmp 0x641b2
leaq 0xe0(%rsp), %rdi
movq 0x1b8(%rsp), %rcx
movl $0x4, %esi
movl $0x3, %edx
callq 0xf780
cmpq $0x3, %rax
je 0x642bf
leaq 0xd0a0d(%rip), %rdi     # 0x134cb5
movb $0x0, %al
callq 0xd4f30
movl $0x0, 0x1d4(%rsp)
jmp 0x64987
movq 0x1b8(%rsp), %rcx
leaq 0x12c(%rsp), %rdi
movl $0x4, %esi
movl $0x1, %edx
callq 0xf780
cmpq $0x1, %rax
je 0x6430a
movq 0x1c0(%rsp), %rsi
leaq 0xd082d(%rip), %rdi     # 0x134b20
movb $0x0, %al
callq 0xd4f30
movl $0x0, 0x1d4(%rsp)
jmp 0x64987
cmpl $0x48, 0x12c(%rsp)
je 0x64341
movl 0x12c(%rsp), %esi
movq 0x1c0(%rsp), %rdx
leaq 0xd082d(%rip), %rdi     # 0x134b57
movb $0x0, %al
callq 0xd4f30
movl $0x0, 0x1d4(%rsp)
jmp 0x64987
jmp 0x64343
movl 0xe0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xd4(%rsp)
movl 0xe4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xd8(%rsp)
movl 0xe8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xdc(%rsp)
cmpl $0x0, 0x128(%rsp)
jne 0x643de
cmpl $0x4, 0x124(%rsp)
jne 0x643de
cmpl $0x0, 0x120(%rsp)
jne 0x643de
movss 0x108(%rsp), %xmm0
movss 0xcfb3f(%rip), %xmm1    # 0x133ee4
ucomiss %xmm1, %xmm0
jne 0x643de
jp 0x643de
movss 0x10c(%rsp), %xmm0
movss 0xcfb27(%rip), %xmm1    # 0x133ee4
ucomiss %xmm1, %xmm0
jne 0x643de
jp 0x643de
movss 0x110(%rsp), %xmm0
movss 0xcfb0f(%rip), %xmm1    # 0x133ee4
ucomiss %xmm1, %xmm0
jne 0x643de
jp 0x643de
jmp 0x64438
movl 0x128(%rsp), %esi
movl 0x124(%rsp), %edx
movl 0x120(%rsp), %ecx
movss 0x108(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
movss 0x10c(%rsp), %xmm1
cvtss2sd %xmm1, %xmm1
movss 0x110(%rsp), %xmm2
cvtss2sd %xmm2, %xmm2
leaq 0xd08c9(%rip), %rdi     # 0x134cea
movb $0x3, %al
callq 0xd4f30
movl $0x0, 0x1d4(%rsp)
jmp 0x64987
movq 0x28(%rsp), %rax
movl 0xd4(%rsp), %ecx
imull 0xd8(%rsp), %ecx
imull 0xdc(%rsp), %ecx
movl %ecx, 0xd0(%rsp)
cmpq $0x0, 0x230(%rax)
je 0x64479
movq 0x28(%rsp), %rcx
movl 0xd0(%rsp), %eax
cmpl 0x24c(%rcx), %eax
jle 0x644e3
movq 0x28(%rsp), %rax
cmpq $0x0, 0x230(%rax)
je 0x644ab
movq 0x28(%rsp), %rax
movq 0x230(%rax), %rax
movq %rax, 0x20(%rsp)
cmpq $0x0, %rax
je 0x644a9
movq 0x20(%rsp), %rdi
callq 0xf670
jmp 0x644ab
movslq 0xd0(%rsp), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0xf030
movq %rax, %rcx
movq 0x28(%rsp), %rax
movq %rcx, 0x230(%rax)
movq 0x28(%rsp), %rax
movl 0xd4(%rsp), %ecx
movl %ecx, 0x238(%rax)
movl 0xd8(%rsp), %ecx
movl %ecx, 0x23c(%rax)
movl 0xdc(%rsp), %ecx
movl %ecx, 0x240(%rax)
movl 0x238(%rax), %ecx
movl %ecx, 0x244(%rax)
movl 0x244(%rax), %ecx
imull 0x23c(%rax), %ecx
movl %ecx, 0x248(%rax)
movl 0x248(%rax), %ecx
imull 0x240(%rax), %ecx
movl %ecx, 0x24c(%rax)
cmpl $0x0, 0x24c(%rax)
jg 0x64573
movq 0x28(%rsp), %rax
movl 0x24c(%rax), %esi
leaq 0xcfe1d(%rip), %rdi     # 0x134379
movb $0x0, %al
callq 0xd4f30
movl $0x0, 0x1d4(%rsp)
jmp 0x64987
movq 0x28(%rsp), %rax
movq 0x230(%rax), %rax
movq %rax, 0xc8(%rsp)
movl $0x0, 0xc4(%rsp)
movq 0x28(%rsp), %rcx
movl 0xc4(%rsp), %eax
cmpl 0x240(%rcx), %eax
jge 0x647e1
movl $0x0, 0xc0(%rsp)
movq 0x28(%rsp), %rcx
movl 0xc0(%rsp), %eax
cmpl 0x23c(%rcx), %eax
jge 0x647c9
movq 0x1b8(%rsp), %rcx
leaq 0xbc(%rsp), %rdi
movl $0x4, %esi
movl $0x1, %edx
callq 0xf780
cmpq $0x1, %rax
je 0x64618
movq 0x1c0(%rsp), %rsi
leaq 0xd0738(%rip), %rdi     # 0x134d39
movb $0x0, %al
callq 0xd4f30
movl $0x0, 0x1d4(%rsp)
jmp 0x64987
movq 0x28(%rsp), %rcx
movl 0xbc(%rsp), %eax
movslq 0x238(%rcx), %rcx
shlq $0x2, %rcx
cmpq %rcx, %rax
je 0x64661
movl 0xbc(%rsp), %esi
movq 0x1c0(%rsp), %rdx
leaq 0xd0724(%rip), %rdi     # 0x134d6e
movb $0x0, %al
callq 0xd4f30
movl $0x0, 0x1d4(%rsp)
jmp 0x64987
jmp 0x64663
movl $0x0, 0xb8(%rsp)
movq 0x28(%rsp), %rcx
movl 0xb8(%rsp), %eax
cmpl 0x238(%rcx), %eax
jge 0x6471b
movq 0x1b8(%rsp), %rcx
leaq 0xb4(%rsp), %rdi
movl $0x4, %esi
movl $0x1, %edx
callq 0xf780
cmpq $0x1, %rax
je 0x646db
movq 0x28(%rsp), %rax
movl 0xb8(%rsp), %esi
movl 0x24c(%rax), %edx
leaq 0xcfd07(%rip), %rdi     # 0x1343cb
movb $0x0, %al
callq 0xd4f30
movl $0x0, 0x1d4(%rsp)
jmp 0x64987
movss 0xb4(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
movq 0xc8(%rsp), %rax
movq %rax, %rcx
addq $0x8, %rcx
movq %rcx, 0xc8(%rsp)
movsd %xmm0, (%rax)
jmp 0x64705
movl 0xb8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xb8(%rsp)
jmp 0x6466e
movq 0x1b8(%rsp), %rcx
leaq 0xbc(%rsp), %rdi
movl $0x4, %esi
movl $0x1, %edx
callq 0xf780
cmpq $0x1, %rax
je 0x64766
movq 0x1c0(%rsp), %rsi
leaq 0xd05ea(%rip), %rdi     # 0x134d39
movb $0x0, %al
callq 0xd4f30
movl $0x0, 0x1d4(%rsp)
jmp 0x64987
movq 0x28(%rsp), %rcx
movl 0xbc(%rsp), %eax
movslq 0x238(%rcx), %rcx
shlq $0x2, %rcx
cmpq %rcx, %rax
je 0x647af
movl 0xbc(%rsp), %esi
movq 0x1c0(%rsp), %rdx
leaq 0xd05d6(%rip), %rdi     # 0x134d6e
movb $0x0, %al
callq 0xd4f30
movl $0x0, 0x1d4(%rsp)
jmp 0x64987
jmp 0x647b1
jmp 0x647b3
movl 0xc0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc0(%rsp)
jmp 0x645b5
jmp 0x647cb
movl 0xc4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc4(%rsp)
jmp 0x64592
movl $0x0, 0xb0(%rsp)
movq 0x1b8(%rsp), %rcx
leaq 0xaf(%rsp), %rdi
movl $0x1, %edx
movq %rdx, %rsi
callq 0xf780
cmpq $0x1, %rax
jne 0x64822
movl 0xb0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xb0(%rsp)
jmp 0x647ec
cmpl $0x0, 0xb0(%rsp)
je 0x64859
movl 0xb0(%rsp), %esi
movq 0x1c0(%rsp), %rdx
leaq 0xd007b(%rip), %rdi     # 0x1348bd
movb $0x0, %al
callq 0xd4f30
movl $0x0, 0x1d4(%rsp)
jmp 0x64987
movss 0xfc(%rsp), %xmm0
movss 0x100(%rsp), %xmm1
movss 0x114(%rsp), %xmm3
movss 0x118(%rsp), %xmm2
mulss %xmm3, %xmm0
cvtss2sd %xmm0, %xmm0
mulss %xmm2, %xmm1
cvtss2sd %xmm1, %xmm1
movss 0x104(%rsp), %xmm2
movss 0x11c(%rsp), %xmm3
mulss %xmm3, %xmm2
cvtss2sd %xmm2, %xmm2
leaq 0x90(%rsp), %rdi
movq %rdi, 0x8(%rsp)
callq 0x6eb50
movss 0xf0(%rsp), %xmm0
movss 0xf4(%rsp), %xmm1
movss 0x114(%rsp), %xmm3
movss 0x118(%rsp), %xmm2
mulss %xmm3, %xmm0
cvtss2sd %xmm0, %xmm0
mulss %xmm2, %xmm1
cvtss2sd %xmm1, %xmm1
movss 0xf8(%rsp), %xmm2
movss 0x11c(%rsp), %xmm3
mulss %xmm3, %xmm2
cvtss2sd %xmm2, %xmm2
leaq 0x78(%rsp), %rdi
movq %rdi, 0x10(%rsp)
callq 0x6eb50
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
leaq 0x40(%rsp), %rdi
movq %rdi, 0x18(%rsp)
callq 0x42940
movq 0x28(%rsp), %rdi
movq 0x18(%rsp), %rsi
callq 0x559e0
jmp 0x64940
movq 0x1b8(%rsp), %rdi
callq 0xf4b0
jmp 0x6494f
movq 0x28(%rsp), %rax
movl 0x24c(%rax), %eax
movl %eax, 0x1d4(%rsp)
leaq 0x40(%rsp), %rdi
callq 0x36a80
jmp 0x64987
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x38(%rsp)
movl %eax, 0x34(%rsp)
leaq 0x40(%rsp), %rdi
callq 0x36a80
jmp 0x64996
movl 0x1d4(%rsp), %eax
addq $0x1d8, %rsp            # imm = 0x1D8
retq
movq 0x38(%rsp), %rdi
callq 0xf890