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

  // Write transformation matrix
  const R4Matrix& m = transformation.Matrix();
  fprintf(fp, "%18.12f %18.12f %18.12f %18.12f\n", m[0][0], m[0][1], m[0][2], m[0][3]);
  fprintf(fp, "%18.12f %18.12f %18.12f %18.12f\n", m[1][0], m[1][1], m[1][2], m[1][3]);
  fprintf(fp, "%18.12f %18.12f %18.12f %18.12f\n", m[2][0], m[2][1], m[2][2], m[2][3]);
  fprintf(fp, "%18.12f %18.12f %18.12f %18.12f\n", m[3][0], m[3][1], m[3][2], m[3][3]);

  // Close file
  fclose(fp);

  // Return success
  return 1;
}

// Assembly:
subq $0xa8, %rsp
movq %rdi, 0x98(%rsp)
movq %rsi, 0x90(%rsp)
movq 0x98(%rsp), %rdi
leaq 0xcc54d(%rip), %rsi     # 0x1342f3
callq 0xf5e0
movq %rax, 0x88(%rsp)
cmpq $0x0, 0x88(%rsp)
jne 0x67de4
movq 0x98(%rsp), %rsi
leaq 0xcd3f1(%rip), %rdi     # 0x1351be
movb $0x0, %al
callq 0xd4f30
movl $0x0, 0xa4(%rsp)
jmp 0x6807f
movq 0x90(%rsp), %rdi
callq 0x4e2a0
movq %rax, 0x80(%rsp)
movq 0x88(%rsp), %rax
movq %rax, (%rsp)
movq 0x80(%rsp), %rdi
xorl %esi, %esi
callq 0x4e280
movsd (%rax), %xmm0
movsd %xmm0, 0x8(%rsp)
movq 0x80(%rsp), %rdi
xorl %esi, %esi
callq 0x4e280
movsd 0x8(%rax), %xmm0
movsd %xmm0, 0x10(%rsp)
movq 0x80(%rsp), %rdi
xorl %esi, %esi
callq 0x4e280
movsd 0x10(%rax), %xmm0
movsd %xmm0, 0x18(%rsp)
movq 0x80(%rsp), %rdi
xorl %esi, %esi
callq 0x4e280
movq (%rsp), %rdi
movsd 0x8(%rsp), %xmm0
movsd 0x10(%rsp), %xmm1
movsd 0x18(%rsp), %xmm2
movsd 0x18(%rax), %xmm3
leaq 0xcd361(%rip), %rsi     # 0x1351e4
movb $0x4, %al
callq 0xf730
movq 0x88(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x80(%rsp), %rdi
movl $0x1, %esi
callq 0x4e280
movsd (%rax), %xmm0
movsd %xmm0, 0x28(%rsp)
movq 0x80(%rsp), %rdi
movl $0x1, %esi
callq 0x4e280
movsd 0x8(%rax), %xmm0
movsd %xmm0, 0x30(%rsp)
movq 0x80(%rsp), %rdi
movl $0x1, %esi
callq 0x4e280
movsd 0x10(%rax), %xmm0
movsd %xmm0, 0x38(%rsp)
movq 0x80(%rsp), %rdi
movl $0x1, %esi
callq 0x4e280
movq 0x20(%rsp), %rdi
movsd 0x28(%rsp), %xmm0
movsd 0x30(%rsp), %xmm1
movsd 0x38(%rsp), %xmm2
movsd 0x18(%rax), %xmm3
leaq 0xcd2c2(%rip), %rsi     # 0x1351e4
movb $0x4, %al
callq 0xf730
movq 0x88(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x80(%rsp), %rdi
movl $0x2, %esi
callq 0x4e280
movsd (%rax), %xmm0
movsd %xmm0, 0x48(%rsp)
movq 0x80(%rsp), %rdi
movl $0x2, %esi
callq 0x4e280
movsd 0x8(%rax), %xmm0
movsd %xmm0, 0x50(%rsp)
movq 0x80(%rsp), %rdi
movl $0x2, %esi
callq 0x4e280
movsd 0x10(%rax), %xmm0
movsd %xmm0, 0x58(%rsp)
movq 0x80(%rsp), %rdi
movl $0x2, %esi
callq 0x4e280
movq 0x40(%rsp), %rdi
movsd 0x48(%rsp), %xmm0
movsd 0x50(%rsp), %xmm1
movsd 0x58(%rsp), %xmm2
movsd 0x18(%rax), %xmm3
leaq 0xcd223(%rip), %rsi     # 0x1351e4
movb $0x4, %al
callq 0xf730
movq 0x88(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0x80(%rsp), %rdi
movl $0x3, %esi
callq 0x4e280
movsd (%rax), %xmm0
movsd %xmm0, 0x68(%rsp)
movq 0x80(%rsp), %rdi
movl $0x3, %esi
callq 0x4e280
movsd 0x8(%rax), %xmm0
movsd %xmm0, 0x70(%rsp)
movq 0x80(%rsp), %rdi
movl $0x3, %esi
callq 0x4e280
movsd 0x10(%rax), %xmm0
movsd %xmm0, 0x78(%rsp)
movq 0x80(%rsp), %rdi
movl $0x3, %esi
callq 0x4e280
movq 0x60(%rsp), %rdi
movsd 0x68(%rsp), %xmm0
movsd 0x70(%rsp), %xmm1
movsd 0x78(%rsp), %xmm2
movsd 0x18(%rax), %xmm3
leaq 0xcd184(%rip), %rsi     # 0x1351e4
movb $0x4, %al
callq 0xf730
movq 0x88(%rsp), %rdi
callq 0xf4b0
movl $0x1, 0xa4(%rsp)
movl 0xa4(%rsp), %eax
addq $0xa8, %rsp
retq
nop