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

  // Write points
  float buf[16];
  for (int i = 0; i < NPoints(); i++) {
    const R3Point& p = PointPosition(i);
    const R3Vector& n = PointNormal(i);
    const RNRgb& c = PointColor(i);
    buf[0] = p[0]; buf[1] = p[1]; buf[2] = p[2];
    buf[3] = n[0]; buf[4] = n[1]; buf[5] = n[2];
    buf[6] = c[0]; buf[7] = c[1]; buf[8] = c[2];
    buf[9] = PointTimestamp(i);
    buf[10] = PointCategoryIdentifier(i);
    buf[11] = PointInstanceIdentifier(i);
    buf[12] = PointValue(i);
    buf[13] = buf[14] = buf[15] = 0;
    if (fwrite(buf, sizeof(float), 16, fp) != (unsigned int) 16) {
      RNFail("Unable to write point %d to %s\n", i, filename);
      return 0;
    }
  }

  // Close file
  fclose(fp);

  // Return success
  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rsi, %r12
movq %rdi, %r14
leaq 0x67572(%rip), %rsi     # 0xdcc2d
movq %r12, %rdi
callq 0x22a70
testq %rax, %rax
je 0x7587c
movq %rax, %r15
movq %r12, 0x8(%rsp)
xorl %r13d, %r13d
pushq $0x18
popq %rbp
movss 0x66c0e(%rip), %xmm2    # 0xdc2f0
pushq $0x10
popq %rbx
xorl %r12d, %r12d
movq (%r14), %rcx
movq 0x8(%r14), %rax
subq %rcx, %rax
cqto
idivq %rbp
cltq
cmpq %rax, %r12
jge 0x75891
movq 0x18(%r14), %rsi
movq 0x20(%r14), %rax
subq %rsi, %rax
cqto
idivq %rbp
cltq
cmpq %rax, %r12
jl 0x75722
leaq 0x67b30(%rip), %rsi     # 0xdd250
jmp 0x75725
addq %r13, %rsi
movq 0x80(%r14), %rax
movq 0x78(%r14), %rdi
subq %rdi, %rax
cqto
idivq %rbp
cltq
cmpq %rax, %r12
jl 0x75748
leaq 0xe4f4a(%rip), %rdi     # 0x15a690
jmp 0x7574b
addq %r13, %rdi
movsd 0x10(%rcx,%r13), %xmm0
movhpd (%rsi), %xmm0           # xmm0 = xmm0[0],mem[0]
cvtpd2ps %xmm0, %xmm0
movupd (%rcx,%r13), %xmm1
cvtpd2ps %xmm1, %xmm1
unpcklpd %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
movapd %xmm1, 0x10(%rsp)
movupd (%rdi), %xmm0
cvtpd2ps %xmm0, %xmm0
movupd 0x8(%rsi), %xmm1
cvtpd2ps %xmm1, %xmm1
unpcklpd %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
movapd %xmm1, 0x20(%rsp)
cvtsd2ss 0x10(%rdi), %xmm0
movss %xmm0, 0x30(%rsp)
movq 0x90(%r14), %rax
movq 0x98(%r14), %rcx
subq %rax, %rcx
shrq $0x3, %rcx
movslq %ecx, %rcx
movaps %xmm2, %xmm0
cmpq %rcx, %r12
jge 0x757ba
cvtsd2ss (%rax,%r12,8), %xmm0
movss %xmm0, 0x34(%rsp)
movq 0xa8(%r14), %rax
movq 0xb0(%r14), %rcx
subq %rax, %rcx
shrq $0x2, %rcx
movslq %ecx, %rcx
movaps %xmm2, %xmm0
cmpq %rcx, %r12
jge 0x757e6
cvtsi2ssl (%rax,%r12,4), %xmm0
movss %xmm0, 0x38(%rsp)
movq 0xc0(%r14), %rax
movq 0xc8(%r14), %rcx
subq %rax, %rcx
shrq $0x2, %rcx
movslq %ecx, %rcx
movaps %xmm2, %xmm0
cmpq %rcx, %r12
jge 0x75812
cvtsi2ssl (%rax,%r12,4), %xmm0
movss %xmm0, 0x3c(%rsp)
movq 0xf0(%r14), %rax
movq 0xf8(%r14), %rcx
subq %rax, %rcx
shrq $0x3, %rcx
movslq %ecx, %rcx
movaps %xmm2, %xmm0
cmpq %rcx, %r12
jge 0x7583e
cvtsd2ss (%rax,%r12,8), %xmm0
movss %xmm0, 0x40(%rsp)
andl $0x0, 0x4c(%rsp)
andq $0x0, 0x44(%rsp)
leaq 0x10(%rsp), %rdi
pushq $0x4
popq %rsi
movq %rbx, %rdx
movq %r15, %rcx
callq 0x23270
cmpq $0x10, %rax
jne 0x7589e
incq %r12
addq $0x18, %r13
movss 0x66a79(%rip), %xmm2    # 0xdc2f0
jmp 0x756e8
leaq 0x67aef(%rip), %rdi     # 0xdd372
xorl %ebx, %ebx
movq %r12, %rsi
xorl %eax, %eax
callq 0x93dbe
jmp 0x758b6
movq %r15, %rdi
callq 0x22890
pushq $0x1
popq %rbx
jmp 0x758b6
leaq 0x67af3(%rip), %rdi     # 0xdd398
xorl %ebx, %ebx
movl %r12d, %esi
movq 0x8(%rsp), %rdx
xorl %eax, %eax
callq 0x93dbe
movl %ebx, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop