// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Grid.cpp
// Function: gaps::R3Grid::WriteDXFile(char const*) const
int R3Grid::
WriteDXFile(const char *filename) const
{
  // Open file
  FILE *fp = fopen(filename, "w");
  if (!fp) {
    RNFail("Unable to open file %s", filename);
    return 0;
  }

  // Print header lines
  const R3Box bbox = WorldBox();
  const RNScalar delta = GridToWorldScaleFactor();
  fprintf(fp, "object 1 class gridpositions counts %d %d %d\n", XResolution(), YResolution(), ZResolution());
  fprintf(fp, "origin %lf %lf %lf\n", bbox[0][0], bbox[0][1], bbox[0][2]);
  fprintf(fp, "delta %lf 0 0\ndelta 0 %lf 0\ndelta 0 0 %lf\n", delta, delta, delta);
  fprintf(fp, "\nobject 2 class gridconnections counts %d %d %d\n", XResolution(), YResolution(), ZResolution());
  fprintf(fp, "\nobject 3 class array type double rank 0 items %d data follows\n", (XResolution() * YResolution() * ZResolution()));

  // Print values
  for (int i = 0; i < XResolution(); i++) {
    for (int j = 0; j < YResolution(); j++) {
      for (int k = 0; k < ZResolution(); k++) {
	fprintf(fp, "%lf\n", GridValue(i, j, k));
      }
    }
  }

  // Print trailer lines
  fprintf(fp, "\nend\n");

  // Close file
  fclose(fp);

  // Return OK status
  return grid_size;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rsi, %r15
movq %rdi, %rbx
leaq 0x64a88(%rip), %rsi     # 0x98769
movq %r15, %rdi
callq 0xe550
testq %rax, %rax
je 0x33e5a
movq %rax, %r14
leaq 0x10(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rsi
callq 0x365d4
movsd 0x228(%rbx), %xmm0
movsd %xmm0, 0x8(%rsp)
movl 0x238(%rbx), %edx
movl 0x23c(%rbx), %ecx
movl 0x240(%rbx), %r8d
leaq 0x65653(%rip), %rsi     # 0x99380
xorl %ebp, %ebp
movq %r14, %rdi
xorl %eax, %eax
callq 0xe6a0
movsd 0x8(%r15), %xmm0
movsd 0x10(%r15), %xmm1
movsd 0x18(%r15), %xmm2
leaq 0x6565c(%rip), %rsi     # 0x993ae
movq %r14, %rdi
movb $0x3, %al
callq 0xe6a0
leaq 0x6565f(%rip), %rsi     # 0x993c2
movq %r14, %rdi
movsd 0x8(%rsp), %xmm0
movaps %xmm0, %xmm1
movaps %xmm0, %xmm2
movb $0x3, %al
callq 0xe6a0
movl 0x238(%rbx), %edx
movl 0x23c(%rbx), %ecx
movl 0x240(%rbx), %r8d
leaq 0x6565a(%rip), %rsi     # 0x993ed
movq %r14, %rdi
xorl %eax, %eax
callq 0xe6a0
movl 0x23c(%rbx), %edx
imull 0x238(%rbx), %edx
imull 0x240(%rbx), %edx
leaq 0x65666(%rip), %rsi     # 0x9941e
movq %r14, %rdi
xorl %eax, %eax
callq 0xe6a0
leaq 0x6561f(%rip), %r15     # 0x993e8
cmpl 0x238(%rbx), %ebp
jge 0x33e2b
xorl %r12d, %r12d
cmpl 0x23c(%rbx), %r12d
jge 0x33e27
xorl %r13d, %r13d
cmpl 0x240(%rbx), %r13d
jge 0x33e22
movq 0x230(%rbx), %rax
movl 0x248(%rbx), %ecx
imull %r13d, %ecx
movl 0x244(%rbx), %edx
imull %r12d, %edx
addl %ebp, %ecx
addl %edx, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movq %r14, %rdi
movq %r15, %rsi
movb $0x1, %al
callq 0xe6a0
incl %r13d
jmp 0x33de0
incl %r12d
jmp 0x33dd4
incl %ebp
jmp 0x33dc9
leaq 0x6562c(%rip), %rdi     # 0x9945e
pushq $0x5
popq %rsi
pushq $0x1
popq %rdx
movq %r14, %rcx
callq 0xe8e0
movq %r14, %rdi
callq 0xe440
movl 0x24c(%rbx), %ebx
leaq 0x10(%rsp), %rdi
callq 0x25832
jmp 0x33e6d
leaq 0x5f509(%rip), %rdi     # 0x9336a
xorl %ebx, %ebx
movq %r15, %rsi
xorl %eax, %eax
callq 0x681ca
movl %ebx, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq