// File: /workspace/github_cpp_makefile_star2_O2/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, %ebp
movl %edx, %ebx
movq %rsi, %r14
movq %rdi, %r15
movq 0x30(%rdi), %rsi
xorl %r12d, %r12d
movq %r14, %rdi
xorl %edx, %edx
callq 0x9c462
xorps %xmm0, %xmm0
leaq 0x20(%rsp), %rax
movaps %xmm0, 0x70(%rax)
movaps %xmm0, 0x60(%rax)
movaps %xmm0, 0x50(%rax)
movaps %xmm0, 0x40(%rax)
movaps %xmm0, 0x30(%rax)
movaps %xmm0, 0x20(%rax)
movaps %xmm0, 0x10(%rax)
movaps %xmm0, (%rax)
movq %r15, 0x18(%rsp)
leaq 0x40(%r15), %rax
movq %rax, 0x10(%rsp)
pushq $0x1
popq %r13
cmpl %r12d, %ebx
je 0x3dc31
movl %ebx, %r15d
movl $0xc8, %edi
callq 0x134f0
movq %rax, %rbx
movq %rax, %rdi
callq 0x294bc
leaq 0xa8(%rbx), %rsi
movq %r14, %rdi
movl %r13d, %edx
movl %ebp, %ecx
callq 0x9c79a
testl %eax, %eax
je 0x3dc2e
leaq 0xb0(%rbx), %rsi
movq %r14, %rdi
movl %r13d, %edx
movl %ebp, %ecx
callq 0x9c61d
testl %eax, %eax
je 0x3dc2e
leaq 0x8(%rbx), %rsi
movq %r14, %rdi
movl %r13d, %edx
movl %ebp, %ecx
callq 0x9c5ab
testl %eax, %eax
je 0x3dc2e
leaq 0x10(%rbx), %rsi
movq %r14, %rdi
pushq $0x3
popq %rdx
movl %ebp, %ecx
callq 0x9c6cd
testl %eax, %eax
je 0x3dc2e
leaq 0x30(%rbx), %rsi
movq %r14, %rdi
pushq $0x6
popq %rdx
movl %ebp, %ecx
callq 0x9c6cd
testl %eax, %eax
je 0x3dc2e
leaq 0x80(%rbx), %rsi
movq %r14, %rdi
movl %r13d, %edx
movl %ebp, %ecx
callq 0x9c6cd
testl %eax, %eax
je 0x3dc2e
movq %r14, %rdi
leaq 0xc(%rsp), %rsi
movl %r13d, %edx
movl %ebp, %ecx
callq 0x9c61d
testl %eax, %eax
je 0x3dc2e
leaq 0x60(%rbx), %rsi
movq %r14, %rdi
movl %r13d, %edx
movl %ebp, %ecx
callq 0x9c6cd
testl %eax, %eax
je 0x3dc2e
leaq 0x68(%rbx), %rsi
movq %r14, %rdi
pushq $0x2
popq %rdx
movl %ebp, %ecx
callq 0x9c6cd
testl %eax, %eax
je 0x3dc2e
leaq 0x7c(%rbx), %rsi
movq %r14, %rdi
movl %r13d, %edx
movl %ebp, %ecx
callq 0x9c61d
testl %eax, %eax
je 0x3dc2e
movq %rbx, %rsi
addq $0x78, %rsi
movq %r14, %rdi
movl %r13d, %edx
movl %ebp, %ecx
callq 0x9c61d
testl %eax, %eax
je 0x3dc2e
movq %r14, %rdi
leaq 0x20(%rsp), %rsi
pushq $0x20
popq %rdx
movl %ebp, %ecx
callq 0x9c478
testl %eax, %eax
je 0x3dc2e
movl 0xc(%rsp), %eax
movq %rax, 0x88(%rbx)
movq %rbx, %rdi
xorl %esi, %esi
callq 0x2ac70
movq 0x18(%rsp), %rax
movq %rax, 0x98(%rbx)
movl 0x4c(%rax), %eax
movl %eax, 0xa0(%rbx)
movq 0x10(%rsp), %rdi
movq %rbx, %rsi
callq 0x1784c
incl %r12d
movl %r15d, %ebx
jmp 0x3da9d
movl %r15d, %ebx
xorl %eax, %eax
cmpl %ebx, %r12d
setae %al
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
movl $0xc8, %esi
movq %rbx, %rdi
callq 0x13500
movq %r14, %rdi
callq 0x138f0
nop