// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Surfels/R3SurfelBlock.cpp
// Function: gaps::R3SurfelBlock::R3SurfelBlock(gaps::R3SurfelPointSet const*, gaps::R3Point const&, double)
R3SurfelBlock::
R3SurfelBlock(const R3SurfelPointSet *set,
  const R3Point& position_origin, RNScalar timestamp_origin)
  : surfels(NULL),
    nsurfels(set->NPoints()),
    position_origin(position_origin),
    bbox(set->BBox()),
    timestamp_origin(0),
    timestamp_range(FLT_MAX,-FLT_MAX),
    min_identifier(UINT_MAX),
    max_identifier(0),
    resolution(0),
    flags(R3_SURFEL_BLOCK_BBOX_UPTODATE_FLAG),
    data(NULL),
    database(NULL),
    database_index(-1),
    file_surfels_offset(0),
    file_surfels_count(0),
    file_read_count(0),
    node(NULL),
    opengl_id(0)
{
  // Copy surfels
  if (nsurfels > 0) {
    // Set timestamp range and origin
    this->timestamp_range = set->TimestampRange();
    if (!this->timestamp_range.IsEmpty()) {
      this->timestamp_origin = this->timestamp_range.Mid();
    }

    // Copy surfels
    surfels = new R3Surfel [ nsurfels ];
    for (int i = 0; i < set->NPoints(); i++) {
      const R3SurfelPoint *point = set->Point(i);
      R3Point position = point->Position() - position_origin.Vector();
      R3Vector normal = point->Normal();
      R3Vector tangent = point->Tangent();
      R3Surfel *surfel = &surfels[i];
      surfel->SetPosition(position[0], position[1], position[2]);
      surfel->SetNormal(normal[0], normal[1], normal[2]);
      surfel->SetTangent(tangent[0], tangent[1], tangent[2]);
      surfel->SetRadius(0, point->Radius(0));
      surfel->SetRadius(1, point->Radius(1));
      surfel->SetDepth(point->Depth());
      surfel->SetElevation(point->Elevation());
      surfel->SetColor(point->Color());
      surfel->SetTimestamp(point->Timestamp() - timestamp_origin);
      surfel->SetIdentifier(point->Identifier());
      surfel->SetAttribute(point->Attribute());
      surfel->SetFlags(point->Flags() & ~R3_SURFEL_MARKED_FLAG);
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movsd %xmm0, 0x18(%rsp)
movq %rdi, %rbx
andq $0x0, (%rdi)
movq %rsi, %r12
movl 0x10(%rsi), %eax
movl %eax, 0x8(%rdi)
addq $0x10, %rdi
movq %rdx, 0x20(%rsp)
movq %rdx, %rsi
callq 0x781cc
leaq 0x28(%rbx), %rdi
leaq 0x18(%r12), %rsi
movq %rdi, 0x10(%rsp)
callq 0x63ce6
andq $0x0, 0x60(%rbx)
movq %rbx, 0x8(%rsp)
addq $0x68, %rbx
movsd 0x9e5fa(%rip), %xmm0    # 0xc8168
movsd 0x9e5fa(%rip), %xmm1    # 0xc8170
movq %rbx, %rdi
callq 0x9c1e0
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq 0x8(%rsp), %rcx
movq %rax, 0x78(%rcx)
andq $0x0, 0x80(%rcx)
movq $0x1, 0x88(%rcx)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x90(%rcx)
orl $-0x1, 0xa0(%rcx)
movupd %xmm0, 0xa8(%rcx)
movupd %xmm0, 0xb4(%rcx)
movslq 0x8(%rcx), %rax
testq %rax, %rax
jle 0x29e42
movups 0x50(%r12), %xmm0
movups %xmm0, (%rbx)
movq 0x8(%rsp), %rcx
movsd 0x68(%rcx), %xmm0
movsd 0x70(%rcx), %xmm1
ucomisd %xmm1, %xmm0
ja 0x29c03
addsd %xmm1, %xmm0
mulsd 0x9e53f(%rip), %xmm0    # 0xc8138
movq 0x8(%rsp), %rcx
movsd %xmm0, 0x60(%rcx)
imulq $0x30, %rax, %rbx
movq %rbx, %rdi
callq 0x13030
movq %rax, %r13
xorl %r14d, %r14d
leaq (%r14,%r13), %rdi
callq 0x29118
addq $0x30, %r14
cmpq %r14, %rbx
jne 0x29c15
movq 0x8(%rsp), %rax
movq %r13, (%rax)
xorl %r14d, %r14d
leaq 0x48(%rsp), %rdi
leaq 0x30(%rsp), %r13
xorl %r15d, %r15d
xorl %ecx, %ecx
movslq 0x10(%r12), %rax
cmpq %rax, %rcx
jge 0x29e42
movq %rcx, 0x28(%rsp)
movq 0x8(%r12), %rbp
leaq (%r15,%rbp), %rbx
movq %rbx, %rsi
callq 0x16310
movq %r13, %rdi
movq 0x20(%rsp), %rsi
callq 0x2d0b2
movq %r13, %rdx
leaq 0x48(%rsp), %r13
leaq 0x60(%rsp), %rdi
movq %r13, %rsi
callq 0x7890d
movq %r13, %rdi
movq %rbx, %rsi
callq 0x2d0ce
movq %r12, %r13
leaq 0x30(%rsp), %rdi
movq %rbx, %rsi
callq 0x2d118
movq 0x8(%rsp), %rax
movq (%rax), %r12
cvtsd2ss 0x70(%rsp), %xmm0
cvtpd2ps 0x60(%rsp), %xmm1
movlpd %xmm1, (%r12,%r14)
movss %xmm0, 0x8(%r12,%r14)
cvtsd2ss 0x48(%rsp), %xmm0
cvtsd2ss 0x50(%rsp), %xmm1
leaq (%r12,%r14), %rbx
cvtsd2ss 0x58(%rsp), %xmm2
movq %rbx, %rdi
callq 0x293b6
cvtsd2ss 0x30(%rsp), %xmm0
cvtsd2ss 0x38(%rsp), %xmm1
cvtsd2ss 0x40(%rsp), %xmm2
movq %rbx, %rdi
callq 0x29418
movq 0x8(%rbp,%r15), %rax
movzwl 0x1c(%rax), %ecx
cvtsi2ss %ecx, %xmm0
movss 0x9f0f0(%rip), %xmm2    # 0xc8e00
mulss %xmm2, %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x9f0a8(%rip), %xmm3    # 0xc8dc8
mulsd %xmm3, %xmm0
movsd 0x9e40c(%rip), %xmm4    # 0xc8138
addsd %xmm4, %xmm0
cvtsd2ss %xmm0, %xmm0
movss 0x9f09c(%rip), %xmm5    # 0xc8dd8
movaps %xmm5, %xmm1
minss %xmm0, %xmm1
cvttss2si %xmm1, %ecx
movw %cx, 0x1c(%r12,%r14)
movzwl 0x1e(%rax), %ecx
cvtsi2ss %ecx, %xmm0
mulss %xmm2, %xmm0
cvtss2sd %xmm0, %xmm0
mulsd %xmm3, %xmm0
addsd %xmm4, %xmm0
cvtsd2ss %xmm0, %xmm0
movaps %xmm5, %xmm1
minss %xmm0, %xmm1
cvttss2si %xmm1, %ecx
movw %cx, 0x1e(%r12,%r14)
movzwl 0x28(%rax), %ecx
cvtsi2sd %ecx, %xmm0
movsd 0x9f046(%rip), %xmm2    # 0xc8dd0
divsd %xmm2, %xmm0
cvtsd2ss %xmm0, %xmm0
cvtss2sd %xmm0, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm4, %xmm0
cvtsd2ss %xmm0, %xmm0
movaps %xmm5, %xmm1
minss %xmm0, %xmm1
cvttss2si %xmm1, %ecx
movw %cx, 0x28(%r12,%r14)
movswl 0x2a(%rax), %eax
cvtsi2sd %eax, %xmm0
divsd %xmm2, %xmm0
cvtsd2ss %xmm0, %xmm0
movq %rbx, %rdi
callq 0x2947a
movq 0x8(%rbp,%r15), %rax
movb 0x2c(%rax), %cl
movb %cl, 0x2c(%r12,%r14)
movb 0x2d(%rax), %cl
movb %cl, 0x2d(%r12,%r14)
movb 0x2e(%rax), %al
movb %al, 0x2e(%r12,%r14)
movq (%rbp,%r15), %rax
movq 0x8(%rbp,%r15), %rcx
cvtss2sd 0xc(%rcx), %xmm0
addsd 0x60(%rax), %xmm0
subsd 0x18(%rsp), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0xc(%r12,%r14)
movq 0x20(%rcx), %rax
movq %rax, 0x20(%r12,%r14)
movb 0x2f(%rcx), %al
andb $0x7f, %al
movb %al, 0x2f(%r12,%r14)
movq 0x28(%rsp), %rcx
incq %rcx
addq $0x10, %r15
addq $0x30, %r14
movq %r13, %r12
leaq 0x48(%rsp), %rdi
leaq 0x30(%rsp), %r13
jmp 0x29c41
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x29e69
jmp 0x29e69
jmp 0x29e69
jmp 0x29e69
movq %rax, %r14
movq %r13, %rdi
movq %rbx, %rsi
callq 0x139f0
jmp 0x29e6c
movq %rax, %r14
movq 0x10(%rsp), %rdi
callq 0x649ae
movq %r14, %rdi
callq 0x138f0