// File: tomfunkhouser[P]gaps/apps/msh2df/msh2df.cpp
// Function: WritePoints(gaps::RNArray<Point*> const&, char const*)
static int
WritePoints(const RNArray<Point *>& points, const char *filename)
{
  // Start statistics
  RNTime start_time;
  start_time.Read();

  // Open file
  FILE *fp = fopen(output_points_filename, "wb");
  if (!fp) {
    RNFail("Unable to open points file %s\n", filename);
    return 0;
  }
  
  // Write points 
  float coordinates[6];
  for (int i = 0; i < points.NEntries(); i++) {
    Point *point = points.Kth(i);
    coordinates[0] = point->position.X();
    coordinates[1] = point->position.Y();
    coordinates[2] = point->position.Z();
    coordinates[3] = point->normal.X();
    coordinates[4] = point->normal.Y();
    coordinates[5] = point->normal.Z();
    if (fwrite(coordinates, sizeof(float), 6, fp) != (unsigned int) 6) {
      RNFail("Unable to write point to output file %s\n", filename);
      return FALSE;
    }
  }

  // Close file
  fclose(fp);
  
  // Print statistics
  if (print_verbose) {
    printf("Wrote points to %s ...\n", filename);
    printf("  Time = %.2f seconds\n", start_time.Elapsed());
    printf("  # Points = %d\n", points.NEntries());
    fflush(stdout);
  }

  // Return success
  return 1;
}

// Assembly:
subq $0x68, %rsp
movq %rdi, 0x58(%rsp)
movq %rsi, 0x50(%rsp)
leaq 0x40(%rsp), %rdi
callq 0xddf30
leaq 0x40(%rsp), %rdi
callq 0x17860
movq 0x171c2f(%rip), %rdi    # 0x1865d8
leaq 0x12ba87(%rip), %rsi    # 0x140437
callq 0xf5e0
movq %rax, 0x38(%rsp)
cmpq $0x0, 0x38(%rsp)
jne 0x149e2
movq 0x50(%rsp), %rsi
leaq 0x12ba6c(%rip), %rdi    # 0x14043a
movb $0x0, %al
callq 0xe2150
movl $0x0, 0x64(%rsp)
jmp 0x14b61
movl $0x0, 0x1c(%rsp)
movl 0x1c(%rsp), %eax
movl %eax, 0xc(%rsp)
movq 0x58(%rsp), %rdi
callq 0x178e0
movl %eax, %ecx
movl 0xc(%rsp), %eax
cmpl %ecx, %eax
jge 0x14af2
movq 0x58(%rsp), %rdi
movl 0x1c(%rsp), %esi
callq 0x18860
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rdi
callq 0x178f0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x20(%rsp)
movq 0x10(%rsp), %rdi
callq 0x17900
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x24(%rsp)
movq 0x10(%rsp), %rdi
callq 0x17910
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x28(%rsp)
movq 0x10(%rsp), %rdi
addq $0x18, %rdi
callq 0x1a270
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x2c(%rsp)
movq 0x10(%rsp), %rdi
addq $0x18, %rdi
callq 0x1a280
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x30(%rsp)
movq 0x10(%rsp), %rdi
addq $0x18, %rdi
callq 0x1a290
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x34(%rsp)
leaq 0x20(%rsp), %rdi
movq 0x38(%rsp), %rcx
movl $0x4, %esi
movl $0x6, %edx
callq 0xf980
cmpq $0x6, %rax
je 0x14ae0
movq 0x50(%rsp), %rsi
leaq 0x12b98d(%rip), %rdi    # 0x140459
movb $0x0, %al
callq 0xe2150
movl $0x0, 0x64(%rsp)
jmp 0x14b61
jmp 0x14ae2
movl 0x1c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1c(%rsp)
jmp 0x149ea
movq 0x38(%rsp), %rdi
callq 0xf4b0
cmpl $0x0, 0x171af5(%rip)    # 0x1865f8
je 0x14b59
movq 0x50(%rsp), %rsi
leaq 0x12b971(%rip), %rdi    # 0x140482
movb $0x0, %al
callq 0xf070
leaq 0x40(%rsp), %rdi
callq 0xddff0
leaq 0x12b6fa(%rip), %rdi    # 0x140223
movb $0x1, %al
callq 0xf070
movq 0x58(%rsp), %rdi
callq 0x178e0
movl %eax, %esi
leaq 0x12b8c8(%rip), %rdi    # 0x14040b
movb $0x0, %al
callq 0xf070
movq 0x16843f(%rip), %rax    # 0x17cf90
movq (%rax), %rdi
callq 0xf5d0
movl $0x1, 0x64(%rsp)
movl 0x64(%rsp), %eax
addq $0x68, %rsp
retq
nopw (%rax,%rax)