// File: /workspace/github_cpp_makefile_star2_O1/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 $0x48, %rsp
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x7525d(%rip), %rsi     # 0xf6ca0
movq %rbx, %rdi
callq 0x22a80
testq %rax, %rax
je 0x81c47
movq %rax, %r15
movq (%r14), %rax
movq 0x8(%r14), %rcx
subq %rax, %rcx
shrq $0x3, %rcx
imull $0xaaaaaaab, %ecx, %ecx # imm = 0xAAAAAAAB
testl %ecx, %ecx
jle 0x81c38
xorl %ebp, %ebp
movss 0x748a3(%rip), %xmm2    # 0xf6320
movq %rsp, %r13
xorl %r12d, %r12d
movq 0x18(%r14), %rcx
movq 0x20(%r14), %rdx
subq %rcx, %rdx
shrq $0x3, %rdx
imull $0xaaaaaaab, %edx, %edx # imm = 0xAAAAAAAB
movslq %edx, %rdx
cmpq %rdx, %r12
jl 0x81aa9
leaq 0x75819(%rip), %rcx     # 0xf72c0
jmp 0x81aac
addq %rbp, %rcx
movq 0x80(%r14), %rsi
movq 0x78(%r14), %rdx
subq %rdx, %rsi
shrq $0x3, %rsi
imull $0xaaaaaaab, %esi, %esi # imm = 0xAAAAAAAB
movslq %esi, %rsi
cmpq %rsi, %r12
jl 0x81ad5
leaq 0xebbad(%rip), %rdx     # 0x16d680
jmp 0x81ad8
addq %rbp, %rdx
movsd 0x10(%rax,%rbp), %xmm0
movhpd (%rcx), %xmm0           # xmm0 = xmm0[0],mem[0]
cvtpd2ps %xmm0, %xmm0
movupd (%rax,%rbp), %xmm1
cvtpd2ps %xmm1, %xmm1
unpcklpd %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
movapd %xmm1, (%rsp)
movupd (%rdx), %xmm0
cvtpd2ps %xmm0, %xmm0
movupd 0x8(%rcx), %xmm1
cvtpd2ps %xmm1, %xmm1
unpcklpd %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
movapd %xmm1, 0x10(%rsp)
xorps %xmm0, %xmm0
cvtsd2ss 0x10(%rdx), %xmm0
movss %xmm0, 0x20(%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 0x81b4a
xorps %xmm0, %xmm0
cvtsd2ss (%rax,%r12,8), %xmm0
movss %xmm0, 0x24(%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 0x81b79
xorps %xmm0, %xmm0
cvtsi2ssl (%rax,%r12,4), %xmm0
movss %xmm0, 0x28(%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 0x81ba8
xorps %xmm0, %xmm0
cvtsi2ssl (%rax,%r12,4), %xmm0
movss %xmm0, 0x2c(%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 0x81bd7
xorps %xmm0, %xmm0
cvtsd2ss (%rax,%r12,8), %xmm0
movss %xmm0, 0x30(%rsp)
movl $0x0, 0x3c(%rsp)
movq $0x0, 0x34(%rsp)
movl $0x4, %esi
movl $0x10, %edx
movq %r13, %rdi
movq %r15, %rcx
callq 0x23250
cmpq $0x10, %rax
jne 0x81c5c
incq %r12
movq (%r14), %rax
movq 0x8(%r14), %rcx
subq %rax, %rcx
shrq $0x3, %rcx
imull $0xaaaaaaab, %ecx, %ecx # imm = 0xAAAAAAAB
movslq %ecx, %rcx
addq $0x18, %rbp
cmpq %rcx, %r12
movss 0x746ee(%rip), %xmm2    # 0xf6320
jl 0x81a83
movq %r15, %rdi
callq 0x22880
movl $0x1, %ebp
jmp 0x81c72
leaq 0x757bc(%rip), %rdi     # 0xf740a
xorl %ebp, %ebp
movq %rbx, %rsi
xorl %eax, %eax
callq 0xa2c4e
jmp 0x81c72
leaq 0x757cd(%rip), %rdi     # 0xf7430
xorl %ebp, %ebp
movl %r12d, %esi
movq %rbx, %rdx
xorl %eax, %eax
callq 0xa2c4e
movl %ebp, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop