// File: /workspace/github_cpp_makefile_star2_O3/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 0x742cc(%rip), %rsi     # 0xf4c8d
movq %rbx, %rdi
callq 0x22a70
testq %rax, %rax
je 0x80bc5
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 0x80bb6
xorl %ebp, %ebp
movss 0x73915(%rip), %xmm2    # 0xf4310
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 0x80a27
leaq 0x7488b(%rip), %rcx     # 0xf52b0
jmp 0x80a2a
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 0x80a53
leaq 0xeac1f(%rip), %rdx     # 0x16b670
jmp 0x80a56
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 0x80ac8
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 0x80af7
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 0x80b26
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 0x80b55
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 0x23240
cmpq $0x10, %rax
jne 0x80bda
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 0x73760(%rip), %xmm2    # 0xf4310
jl 0x80a01
movq %r15, %rdi
callq 0x22880
movl $0x1, %ebp
jmp 0x80bf0
leaq 0x74806(%rip), %rdi     # 0xf53d2
xorl %ebp, %ebp
movq %rbx, %rsi
xorl %eax, %eax
callq 0xa172a
jmp 0x80bf0
leaq 0x74817(%rip), %rdi     # 0xf53f8
xorl %ebp, %ebp
movl %r12d, %esi
movq %rbx, %rdx
xorl %eax, %eax
callq 0xa172a
movl %ebp, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop