// File: tomfunkhouser[P]gaps/pkgs/R3Surfels/R3SurfelBlock.cpp
// Function: gaps::R3SurfelBlock::UpdateFlags()
void R3SurfelBlock::
UpdateFlags(void)
{
  // Read block
  if (database) database->ReadBlock(this);

  // Reset flags
  flags.Remove(R3_SURFEL_BLOCK_HAS_ACTIVE_FLAG);
  flags.Remove(R3_SURFEL_BLOCK_HAS_NORMALS_FLAG);
  flags.Remove(R3_SURFEL_BLOCK_HAS_AERIAL_FLAG);
  flags.Remove(R3_SURFEL_BLOCK_HAS_TERRESTRIAL_FLAG);

  // Update flags
  for (int i = 0; i < nsurfels; i++) {
    if (surfels[i].IsActive()) flags.Add(R3_SURFEL_BLOCK_HAS_ACTIVE_FLAG);
    if (surfels[i].HasNormal()) flags.Add(R3_SURFEL_BLOCK_HAS_NORMALS_FLAG);
    if (surfels[i].HasTangent()) flags.Add(R3_SURFEL_BLOCK_HAS_TANGENTS_FLAG);
    if (surfels[i].IsAerial()) flags.Add(R3_SURFEL_BLOCK_HAS_AERIAL_FLAG);
    else flags.Add(R3_SURFEL_BLOCK_HAS_TERRESTRIAL_FLAG);
  }

  // Release block
  if (database) database->ReleaseBlock(this);

  // Mark flags uptodate
  flags.Add(R3_SURFEL_BLOCK_FLAGS_UPTODATE_FLAG);
}

// Assembly:
subq $0xb8, %rsp
movq %rdi, 0xb0(%rsp)
movq 0xb0(%rsp), %rax
movq %rax, 0x50(%rsp)
cmpq $0x0, 0x98(%rax)
je 0x4ace7
movq 0x50(%rsp), %rsi
movq 0x98(%rsi), %rdi
callq 0x31140
movq 0x50(%rsp), %rax
addq $0x88, %rax
movq %rax, 0x30(%rsp)
leaq 0xa8(%rsp), %rdi
movl $0x40, %esi
callq 0x1b970
movq 0x30(%rsp), %rdi
movq 0xa8(%rsp), %rsi
callq 0x31a80
movq 0x50(%rsp), %rax
addq $0x88, %rax
movq %rax, 0x38(%rsp)
leaq 0xa0(%rsp), %rdi
movl $0x80, %esi
callq 0x1b970
movq 0x38(%rsp), %rdi
movq 0xa0(%rsp), %rsi
callq 0x31a80
movq 0x50(%rsp), %rax
addq $0x88, %rax
movq %rax, 0x40(%rsp)
leaq 0x98(%rsp), %rdi
movl $0x10, %esi
callq 0x1b970
movq 0x40(%rsp), %rdi
movq 0x98(%rsp), %rsi
callq 0x31a80
movq 0x50(%rsp), %rax
addq $0x88, %rax
movq %rax, 0x48(%rsp)
leaq 0x90(%rsp), %rdi
movl $0x20, %esi
callq 0x1b970
movq 0x48(%rsp), %rdi
movq 0x90(%rsp), %rsi
callq 0x31a80
movl $0x0, 0x8c(%rsp)
movq 0x50(%rsp), %rcx
movl 0x8c(%rsp), %eax
cmpl 0x8(%rcx), %eax
jge 0x4af61
movq 0x50(%rsp), %rax
movq (%rax), %rdi
movslq 0x8c(%rsp), %rax
imulq $0x30, %rax, %rax
addq %rax, %rdi
callq 0x4fef0
cmpl $0x0, %eax
je 0x4ae2c
movq 0x50(%rsp), %rax
addq $0x88, %rax
movq %rax, 0x28(%rsp)
leaq 0x80(%rsp), %rdi
movl $0x40, %esi
callq 0x1b970
movq 0x28(%rsp), %rdi
movq 0x80(%rsp), %rsi
callq 0x1c2d0
movq 0x50(%rsp), %rax
movq (%rax), %rdi
movslq 0x8c(%rsp), %rax
imulq $0x30, %rax, %rax
addq %rax, %rdi
callq 0x4ff10
cmpl $0x0, %eax
je 0x4ae7b
movq 0x50(%rsp), %rax
addq $0x88, %rax
movq %rax, 0x20(%rsp)
leaq 0x78(%rsp), %rdi
movl $0x80, %esi
callq 0x1b970
movq 0x20(%rsp), %rdi
movq 0x78(%rsp), %rsi
callq 0x1c2d0
movq 0x50(%rsp), %rax
movq (%rax), %rdi
movslq 0x8c(%rsp), %rax
imulq $0x30, %rax, %rax
addq %rax, %rdi
callq 0x4ff30
cmpl $0x0, %eax
je 0x4aeca
movq 0x50(%rsp), %rax
addq $0x88, %rax
movq %rax, 0x18(%rsp)
leaq 0x70(%rsp), %rdi
movl $0x8, %esi
callq 0x1b970
movq 0x18(%rsp), %rdi
movq 0x70(%rsp), %rsi
callq 0x1c2d0
movq 0x50(%rsp), %rax
movq (%rax), %rdi
movslq 0x8c(%rsp), %rax
imulq $0x30, %rax, %rax
addq %rax, %rdi
callq 0x44d90
cmpl $0x0, %eax
je 0x4af1b
movq 0x50(%rsp), %rax
addq $0x88, %rax
movq %rax, 0x10(%rsp)
leaq 0x68(%rsp), %rdi
movl $0x10, %esi
callq 0x1b970
movq 0x10(%rsp), %rdi
movq 0x68(%rsp), %rsi
callq 0x1c2d0
jmp 0x4af49
movq 0x50(%rsp), %rax
addq $0x88, %rax
movq %rax, 0x8(%rsp)
leaq 0x60(%rsp), %rdi
movl $0x20, %esi
callq 0x1b970
movq 0x8(%rsp), %rdi
movq 0x60(%rsp), %rsi
callq 0x1c2d0
jmp 0x4af4b
movl 0x8c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x8c(%rsp)
jmp 0x4adc2
movq 0x50(%rsp), %rax
cmpq $0x0, 0x98(%rax)
je 0x4af81
movq 0x50(%rsp), %rsi
movq 0x98(%rsi), %rdi
callq 0x311c0
movq 0x50(%rsp), %rax
addq $0x88, %rax
movq %rax, (%rsp)
leaq 0x58(%rsp), %rdi
movl $0x4, %esi
callq 0x1b970
movq (%rsp), %rdi
movq 0x58(%rsp), %rsi
callq 0x1c2d0
addq $0xb8, %rsp
retq
nopw %cs:(%rax,%rax)