// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/R3Surfels/R3SurfelBlock.cpp
// Function: gaps::R3SurfelBlock::ReadBinary(_IO_FILE*)
int R3SurfelBlock::
ReadBinary(FILE *fp)
{
  // Read number of surfels
  if (fread(&nsurfels, sizeof(int), 1, fp) != (size_t) 1) {
    RNFail("Unable to read number of surfels\n");
    return 0;
  }

  // Read bounding box
  if (fread(&bbox, sizeof(R3Box), 1, fp) != (size_t) 1) {
    RNFail("Unable to read bounding box of surfel block\n");
    return 0;
  }

  // Read resolution
  if (fread(&resolution, sizeof(RNLength), 1, fp) != (size_t) 1) {
    RNFail("Unable to read resolution of surfel block\n");
    return 0;
  }

  // Read flags
  if (fread(&flags, sizeof(RNFlags), 1, fp) != (size_t) 1) {
    RNFail("Unable to read flags of surfel block\n");
    return 0;
  }

  // Allocate memory for surfels
  surfels = new R3Surfel [ nsurfels ];
  if (!surfels) {
    RNFail("Unable to allocate surfel block\n");
    return 0;
  }

  // Read surfels
  int count = 0;
  while (count < nsurfels) {
    int status = fread(&surfels[count], sizeof(R3Surfel), nsurfels - count, fp);
    if (status <= 0) {
      RNFail("Unable to read surfel block\n");
      delete [] surfels;
      surfels = NULL;
      nsurfels = 0;
      return 0;
    }
    count += status;
  }

  // Return success
  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x8(%rdi), %r15
movl $0x4, %esi
movl $0x1, %edx
movq %r15, %rdi
movq %rbx, %rcx
callq 0x13790
cmpq $0x1, %rax
jne 0x2fc68
leaq 0x28(%r14), %rdi
movl $0x38, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x13790
cmpq $0x1, %rax
jne 0x2fc71
leaq 0x80(%r14), %rdi
movl $0x8, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x13790
cmpq $0x1, %rax
jne 0x2fc7a
leaq 0x88(%r14), %rdi
movl $0x8, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x13790
cmpq $0x1, %rax
jne 0x2fc83
movslq (%r15), %rbp
movl $0x30, %ecx
movq %rbp, %rax
mulq %rcx
movq $-0x1, %rdi
cmovnoq %rax, %rdi
movq %rdi, (%rsp)
callq 0x13030
movq %rax, %r13
testq %rbp, %rbp
je 0x2fbf8
shlq $0x4, %rbp
leaq (%rbp,%rbp,2), %rbp
xorl %r12d, %r12d
leaq (%r12,%r13), %rdi
callq 0x2b548
addq $0x30, %r12
cmpq %r12, %rbp
jne 0x2fbe6
movq %r13, (%r14)
leaq 0xaf4aa(%rip), %r12     # 0xdf0ac
xorl %ebp, %ebp
movl (%r15), %eax
subl %ebp, %eax
jle 0x2fca4
movl %ebp, %ecx
leaq (%rcx,%rcx,2), %rdi
shlq $0x4, %rdi
addq (%r14), %rdi
movslq %eax, %rdx
movl $0x30, %esi
movq %rbx, %rcx
callq 0x13790
movq %rax, %r13
testl %r13d, %r13d
jle 0x2fc39
addl %r13d, %ebp
jmp 0x2fc5f
movq %r12, %rdi
xorl %eax, %eax
callq 0xaddb2
movq (%r14), %rdi
testq %rdi, %rdi
je 0x2fc50
callq 0x13680
movq $0x0, (%r14)
movl $0x0, 0x8(%r14)
testl %r13d, %r13d
jg 0x2fc04
xorl %ebx, %ebx
jmp 0x2fc93
leaq 0xaf39d(%rip), %rdi     # 0xdf00c
jmp 0x2fc8a
leaq 0xaf3b6(%rip), %rdi     # 0xdf02e
jmp 0x2fc8a
leaq 0xaf3da(%rip), %rdi     # 0xdf05b
jmp 0x2fc8a
leaq 0xaf3fc(%rip), %rdi     # 0xdf086
xorl %ebx, %ebx
xorl %eax, %eax
callq 0xaddb2
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x1, %ebx
jmp 0x2fc93
movq %rax, %rbx
movq %r13, %rdi
movq (%rsp), %rsi
callq 0x139b0
movq %rbx, %rdi
callq 0x138b0