// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/R3Surfels/R3SurfelDatabase.cpp
// Function: gaps::R3SurfelDatabase::ReadBlockHeader(_IO_FILE*, unsigned int, int)
int R3SurfelDatabase::
ReadBlockHeader(FILE *fp, unsigned int nblocks, int swap_endian)
{
  // Seek to start of blocks
  RNFileSeek(fp, file_blocks_offset, RN_FILE_SEEK_SET);

  // Read blocks
  char buffer[128] = { '\0' };
  for (unsigned int i = 0; i < nblocks; i++) {
    R3SurfelBlock *block = new R3SurfelBlock();
    unsigned int block_flags;
    if (!RNReadUnsignedLongLong(fp, &block->file_surfels_offset, 1, swap_endian)) return 0;
    if (!RNReadUnsignedInt(fp, &block->file_surfels_count, 1, swap_endian)) return 0;
    if (!RNReadInt(fp, &block->nsurfels, 1, swap_endian)) return 0;
    if (!RNReadDouble(fp, &block->position_origin[0], 3, swap_endian)) return 0;
    if (!RNReadDouble(fp, &block->bbox[0][0], 6, swap_endian)) return 0;
    if (!RNReadDouble(fp, &block->resolution, 1, swap_endian)) return 0;
    if (!RNReadUnsignedInt(fp, &block_flags, 1, swap_endian)) return 0;
    if (!RNReadDouble(fp, &block->timestamp_origin, 1, swap_endian)) return 0;
    if (!RNReadDouble(fp, &block->timestamp_range[0], 2, swap_endian)) return 0;
    if (!RNReadUnsignedInt(fp, &block->max_identifier, 1, swap_endian)) return 0;
    if (!RNReadUnsignedInt(fp, &block->min_identifier, 1, swap_endian)) return 0;
    if (!RNReadChar(fp, buffer, 32, swap_endian)) return 0;
    block->flags = block_flags;
    block->SetDirty(FALSE);
    block->database = this;
    block->database_index = blocks.NEntries();
    blocks.Insert(block);
  }

  // Return success
  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movl %ecx, %ebx
movl %edx, %r13d
movq %rsi, %r14
movq %rdi, %r15
movq 0x30(%rdi), %rsi
movq %r14, %rdi
xorl %edx, %edx
callq 0xad14e
xorps %xmm0, %xmm0
movaps %xmm0, 0x90(%rsp)
movaps %xmm0, 0x80(%rsp)
movaps %xmm0, 0x70(%rsp)
movaps %xmm0, 0x60(%rsp)
movaps %xmm0, 0x50(%rsp)
movaps %xmm0, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
testl %r13d, %r13d
sete %bpl
je 0x433e1
movq %r15, 0x18(%rsp)
leaq 0x40(%r15), %rax
movq %rax, 0x10(%rsp)
movl %r13d, %eax
negl %eax
movq %rax, 0x8(%rsp)
movl $0x1, %r12d
movl %r13d, %r15d
movl $0xc8, %edi
callq 0x134e0
movq %rax, %r13
movq %rax, %rdi
callq 0x2b96c
leaq 0xa8(%r13), %rsi
movq %r14, %rdi
movl $0x1, %edx
movl %ebx, %ecx
callq 0xad54f
testl %eax, %eax
je 0x433e1
leaq 0xb0(%r13), %rsi
movq %r14, %rdi
movl $0x1, %edx
movl %ebx, %ecx
callq 0xad365
testl %eax, %eax
je 0x433e1
leaq 0x8(%r13), %rsi
movq %r14, %rdi
movl $0x1, %edx
movl %ebx, %ecx
callq 0xad2da
testl %eax, %eax
je 0x433e1
leaq 0x10(%r13), %rsi
movq %r14, %rdi
movl $0x3, %edx
movl %ebx, %ecx
callq 0xad449
testl %eax, %eax
je 0x433e1
leaq 0x30(%r13), %rsi
movq %r14, %rdi
movl $0x6, %edx
movl %ebx, %ecx
callq 0xad449
testl %eax, %eax
je 0x433e1
leaq 0x80(%r13), %rsi
movq %r14, %rdi
movl $0x1, %edx
movl %ebx, %ecx
callq 0xad449
testl %eax, %eax
je 0x433e1
movq %r14, %rdi
leaq 0x4(%rsp), %rsi
movl $0x1, %edx
movl %ebx, %ecx
callq 0xad365
testl %eax, %eax
je 0x433e1
leaq 0x60(%r13), %rsi
movq %r14, %rdi
movl $0x1, %edx
movl %ebx, %ecx
callq 0xad449
testl %eax, %eax
je 0x433e1
leaq 0x68(%r13), %rsi
movq %r14, %rdi
movl $0x2, %edx
movl %ebx, %ecx
callq 0xad449
testl %eax, %eax
je 0x433e1
leaq 0x7c(%r13), %rsi
movq %r14, %rdi
movl $0x1, %edx
movl %ebx, %ecx
callq 0xad365
testl %eax, %eax
je 0x433e1
movq %r13, %rsi
addq $0x78, %rsi
movq %r14, %rdi
movl $0x1, %edx
movl %ebx, %ecx
callq 0xad365
testl %eax, %eax
je 0x433e1
movq %r14, %rdi
leaq 0x20(%rsp), %rsi
movl $0x20, %edx
movl %ebx, %ecx
callq 0xad164
testl %eax, %eax
je 0x433e1
movl 0x4(%rsp), %eax
movq %rax, 0x88(%r13)
movq %r13, %rdi
xorl %esi, %esi
callq 0x2d7ce
movq 0x18(%rsp), %rax
movq %rax, 0x98(%r13)
movl 0x4c(%rax), %edx
movl %edx, 0xa0(%r13)
movq 0x10(%rsp), %rdi
movq %r13, %rsi
callq 0xaafca
movl %r15d, %r13d
cmpl %r15d, %r12d
setae %bpl
movq 0x8(%rsp), %rax
addl %r12d, %eax
incl %eax
movl %r12d, %ecx
incl %ecx
movl %ecx, %r12d
cmpl $0x1, %eax
jne 0x43222
movzbl %bpl, %eax
andl $0x1, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movl $0xc8, %esi
movq %r13, %rdi
callq 0x134f0
movq %rbx, %rdi
callq 0x138b0