// File: /workspace/github_cpp_makefile_star2_O2/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, %r14
movq %rdi, %rbx
leaq 0x8(%rdi), %r15
pushq $0x4
popq %rsi
pushq $0x1
popq %rdx
movq %r15, %rdi
movq %r14, %rcx
callq 0x137d0
cmpq $0x1, %rax
jne 0x2cae6
leaq 0x28(%rbx), %rdi
pushq $0x38
popq %rsi
pushq $0x1
popq %rdx
movq %r14, %rcx
callq 0x137d0
cmpq $0x1, %rax
jne 0x2caef
leaq 0x80(%rbx), %rdi
pushq $0x8
popq %rsi
pushq $0x1
popq %rdx
movq %r14, %rcx
callq 0x137d0
cmpq $0x1, %rax
jne 0x2caf8
leaq 0x88(%rbx), %rdi
pushq $0x8
popq %rsi
pushq $0x1
popq %rdx
movq %r14, %rcx
callq 0x137d0
cmpq $0x1, %rax
jne 0x2cb01
movslq (%r15), %rbp
pushq $0x30
popq %rcx
movq %rbp, %rax
mulq %rcx
pushq $-0x1
popq %rdi
cmovnoq %rax, %rdi
movq %rdi, (%rsp)
callq 0x13030
movq %rax, %r13
testq %rbp, %rbp
je 0x2ca8b
imulq $0x30, %rbp, %rbp
xorl %r12d, %r12d
leaq (%r12,%r13), %rdi
callq 0x29118
addq $0x30, %r12
cmpq %r12, %rbp
jne 0x2ca79
movq %r13, (%rbx)
xorl %r13d, %r13d
pushq $0x1
popq %rbp
pushq $0x30
popq %r12
movl (%r15), %eax
subl %r13d, %eax
jle 0x2cb11
movl %r13d, %ecx
imulq $0x30, %rcx, %rdi
addq (%rbx), %rdi
movslq %eax, %rdx
movq %r12, %rsi
movq %r14, %rcx
callq 0x137d0
addl %eax, %r13d
testl %eax, %eax
jg 0x2ca98
leaq 0x9c5d6(%rip), %rdi     # 0xc909c
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x9ce26
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x2cadc
callq 0x136a0
andq $0x0, (%rbx)
andl $0x0, 0x8(%rbx)
jmp 0x2cb11
leaq 0x9c50f(%rip), %rdi     # 0xc8ffc
jmp 0x2cb08
leaq 0x9c528(%rip), %rdi     # 0xc901e
jmp 0x2cb08
leaq 0x9c54c(%rip), %rdi     # 0xc904b
jmp 0x2cb08
leaq 0x9c56e(%rip), %rdi     # 0xc9076
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x9ce26
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq %r13, %rdi
movq (%rsp), %rsi
callq 0x139f0
movq %rbx, %rdi
callq 0x138f0
nop