// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Surfels/R3SurfelBlock.cpp
// Function: gaps::R3SurfelBlock::R3SurfelBlock(gaps::R3SurfelPointSet const*)
R3SurfelBlock::
R3SurfelBlock(const R3SurfelPointSet *set)
  : surfels(NULL),
    nsurfels(set->NPoints()),
    position_origin(set->Centroid()),
    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 points
  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();
    }

    // Create 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
movq %rdi, %rbx
andq $0x0, (%rdi)
movq %rsi, %r14
movl 0x10(%rsi), %eax
movl %eax, 0x8(%rdi)
addq $0x10, %rdi
movq %rdi, 0x20(%rsp)
callq 0x2f6e6
leaq 0x28(%rbx), %rdi
movq %r14, 0x10(%rsp)
leaq 0x18(%r14), %rsi
movq %rdi, 0x18(%rsp)
callq 0x63ce6
andq $0x0, 0x60(%rbx)
movq %rbx, 0x8(%rsp)
addq $0x68, %rbx
movsd 0x9e965(%rip), %xmm0    # 0xc8168
movsd 0x9e965(%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 0x29ad4
movq 0x10(%rsp), %rcx
movups 0x50(%rcx), %xmm0
movups %xmm0, (%rbx)
movq 0x8(%rsp), %rcx
movsd 0x68(%rcx), %xmm0
movsd 0x70(%rcx), %xmm1
ucomisd %xmm1, %xmm0
ja 0x2989b
addsd %xmm1, %xmm0
mulsd 0x9e8a7(%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 0x298ad
movq 0x8(%rsp), %rax
movq %r13, (%rax)
xorl %r12d, %r12d
leaq 0x48(%rsp), %r14
xorl %r13d, %r13d
xorl %ecx, %ecx
movq 0x10(%rsp), %rax
movslq 0x10(%rax), %rax
cmpq %rax, %rcx
jge 0x29ad4
movq %rcx, 0x28(%rsp)
movq 0x10(%rsp), %rax
movq 0x8(%rax), %r15
leaq (%r15,%r13), %rbx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x16310
leaq 0x30(%rsp), %rbp
movq %rbp, %rdi
movq 0x20(%rsp), %rsi
callq 0x2d0b2
leaq 0x60(%rsp), %rdi
movq %r14, %rsi
movq %rbp, %rdx
callq 0x7890d
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2d0ce
leaq 0x30(%rsp), %rdi
movq %rbx, %rsi
callq 0x2d118
movq 0x8(%rsp), %rbp
movq (%rbp), %r14
cvtsd2ss 0x70(%rsp), %xmm0
cvtpd2ps 0x60(%rsp), %xmm1
movlpd %xmm1, (%r14,%r12)
movss %xmm0, 0x8(%r14,%r12)
cvtsd2ss 0x48(%rsp), %xmm0
cvtsd2ss 0x50(%rsp), %xmm1
leaq (%r14,%r12), %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(%r15,%r13), %rax
movzwl 0x1c(%rax), %ecx
cvtsi2ss %ecx, %xmm0
movss 0x9f454(%rip), %xmm2    # 0xc8e00
mulss %xmm2, %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x9f40c(%rip), %xmm3    # 0xc8dc8
mulsd %xmm3, %xmm0
movsd 0x9e770(%rip), %xmm4    # 0xc8138
addsd %xmm4, %xmm0
cvtsd2ss %xmm0, %xmm0
movss 0x9f400(%rip), %xmm5    # 0xc8dd8
movaps %xmm5, %xmm1
minss %xmm0, %xmm1
cvttss2si %xmm1, %ecx
movw %cx, 0x1c(%r14,%r12)
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(%r14,%r12)
movzwl 0x28(%rax), %ecx
cvtsi2sd %ecx, %xmm0
movsd 0x9f3aa(%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(%r14,%r12)
movswl 0x2a(%rax), %eax
cvtsi2sd %eax, %xmm0
divsd %xmm2, %xmm0
cvtsd2ss %xmm0, %xmm0
movq %rbx, %rdi
callq 0x2947a
movq 0x8(%r15,%r13), %rax
movb 0x2c(%rax), %cl
movb %cl, 0x2c(%r14,%r12)
movb 0x2d(%rax), %cl
movb %cl, 0x2d(%r14,%r12)
movb 0x2e(%rax), %al
movb %al, 0x2e(%r14,%r12)
movq (%r15,%r13), %rax
movq 0x8(%r15,%r13), %rcx
cvtss2sd 0xc(%rcx), %xmm0
addsd 0x60(%rax), %xmm0
subsd 0x60(%rbp), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0xc(%r14,%r12)
movq 0x20(%rcx), %rax
movq %rax, 0x20(%r14,%r12)
movb 0x2f(%rcx), %al
andb $0x7f, %al
movb %al, 0x2f(%r14,%r12)
movq 0x28(%rsp), %rcx
incq %rcx
addq $0x10, %r13
addq $0x30, %r12
leaq 0x48(%rsp), %r14
jmp 0x298d4
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x29afb
jmp 0x29afb
jmp 0x29afb
jmp 0x29afb
movq %rax, %r14
movq %r13, %rdi
movq %rbx, %rsi
callq 0x139f0
jmp 0x29afe
movq %rax, %r14
movq 0x18(%rsp), %rdi
callq 0x649ae
movq %r14, %rdi
callq 0x138f0