// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Surfels/R3SurfelBlock.cpp
// Function: gaps::R3SurfelBlock::R3SurfelBlock(gaps::R3Point const*, int)
R3SurfelBlock::
R3SurfelBlock(const R3Point *points, int npoints)
  : surfels(NULL),
    nsurfels(npoints),
    position_origin(R3zero_point),
    bbox(FLT_MAX,FLT_MAX,FLT_MAX,-FLT_MAX,-FLT_MAX,-FLT_MAX),
    timestamp_origin(0),
    timestamp_range(FLT_MAX,-FLT_MAX),
    min_identifier(UINT_MAX),
    max_identifier(0),
    resolution(0),
    flags(0),
    data(NULL),
    database(NULL),
    database_index(-1),
    file_surfels_offset(0),
    file_surfels_count(0),
    file_read_count(0),
    node(NULL),
    opengl_id(0)
{
  // Check number of points
  if (npoints == 0) return;

  // Compute position_origin
  position_origin = R3Centroid(npoints, (R3Point *) points);

  // Compute bounding box
  for (int i = 0; i < npoints; i++) {
    bbox.Union(points[i]);
  }

  // Copy surfels
  surfels = new R3Surfel [ nsurfels ];
  for (int i = 0; i < nsurfels; i++) {
    R3Point point = points[i];
    point -= position_origin.Vector();
    R3Surfel& surfel = this->surfels[i];
    surfel.SetPosition(point.X(), point.Y(), point.Z());
    surfel.SetRadius(bbox.DiagonalLength() / npoints);
    surfel.SetColor(128, 128, 128);
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdi, %r14
andq $0x0, (%rdi)
movl %edx, %r12d
movq %rsi, 0x8(%rsp)
movl %edx, 0x8(%rdi)
addq $0x10, %rdi
leaq 0x4fc56d(%rip), %rsi    # 0x526690
movq %rdi, 0x18(%rsp)
callq 0x781cc
leaq 0x28(%r14), %rdi
movsd 0x9e02f(%rip), %xmm0    # 0xc8168
movsd 0x9e02f(%rip), %xmm3    # 0xc8170
movq %rdi, 0x10(%rsp)
movaps %xmm0, %xmm1
movaps %xmm0, %xmm2
movaps %xmm3, %xmm4
movaps %xmm3, %xmm5
callq 0x63d86
andq $0x0, 0x60(%r14)
leaq 0x68(%r14), %rdi
movsd 0x9e000(%rip), %xmm0    # 0xc8168
movsd 0x9e000(%rip), %xmm1    # 0xc8170
callq 0x9c1e0
orl $-0x1, 0x78(%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x7c(%r14)
movups %xmm0, 0x8c(%r14)
movabsq $-0x100000000, %rax     # imm = 0xFFFFFFFF00000000
movq %rax, 0x9c(%r14)
movups %xmm0, 0xa8(%r14)
movups %xmm0, 0xb4(%r14)
testl %r12d, %r12d
je 0x2a30d
leaq 0x20(%rsp), %rdi
movl %r12d, %esi
movq 0x8(%rsp), %rdx
xorl %ecx, %ecx
callq 0x4d640
leaq 0x20(%rsp), %rsi
movq 0x18(%rsp), %rdi
callq 0x784a6
xorl %r15d, %r15d
testl %r12d, %r12d
cmovgl %r12d, %r15d
movq 0x8(%rsp), %r13
subq $0x1, %r15
jb 0x2a1ff
movq 0x10(%rsp), %rdi
movq %r13, %rsi
callq 0x6464c
addq $0x18, %r13
jmp 0x2a1e6
movslq 0x8(%r14), %r13
pushq $0x30
popq %rcx
movq %r13, %rax
mulq %rcx
pushq $-0x1
popq %rdi
cmovnoq %rax, %rdi
movq %rdi, (%rsp)
callq 0x13030
movq %rax, %rbp
testl %r13d, %r13d
je 0x2a23d
imulq $0x30, %r13, %rbx
xorl %r15d, %r15d
leaq (%r15,%rbp), %rdi
callq 0x29118
addq $0x30, %r15
cmpq %r15, %rbx
jne 0x2a22b
cvtsi2sd %r12d, %xmm0
movsd %xmm0, (%rsp)
movq %rbp, (%r14)
xorl %r15d, %r15d
leaq 0x20(%rsp), %r13
leaq 0x40(%rsp), %rbp
xorl %r12d, %r12d
movslq 0x8(%r14), %rax
cmpq %rax, %r12
jge 0x2a30d
movq 0x8(%rsp), %rax
leaq (%rax,%r15), %rsi
movq %r13, %rdi
callq 0x781cc
movq %rbp, %rdi
movq 0x18(%rsp), %rsi
callq 0x2d0b2
movq %r13, %rdi
movq %rbp, %rsi
callq 0x78854
cvtsd2ss 0x30(%rsp), %xmm0
cvtpd2ps 0x20(%rsp), %xmm1
movq (%r14), %rbx
movlpd %xmm1, (%rbx,%r15,2)
movss %xmm0, 0x8(%rbx,%r15,2)
movq 0x10(%rsp), %rdi
callq 0x64300
divsd (%rsp), %xmm0
cvtsd2ss %xmm0, %xmm0
cvtss2sd %xmm0, %xmm0
mulsd 0x9eafd(%rip), %xmm0    # 0xc8dc8
addsd 0x9de65(%rip), %xmm0    # 0xc8138
cvtsd2ss %xmm0, %xmm0
movss 0x9eaf9(%rip), %xmm1    # 0xc8dd8
minss %xmm0, %xmm1
cvttss2si %xmm1, %eax
movw %ax, 0x1c(%rbx,%r15,2)
movw %ax, 0x1e(%rbx,%r15,2)
movw $0x8080, 0x2c(%rbx,%r15,2) # imm = 0x8080
movb $-0x80, 0x2e(%rbx,%r15,2)
incq %r12
addq $0x18, %r15
jmp 0x2a25a
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2a337
jmp 0x2a337
movq %rax, %r14
movq %rbp, %rdi
movq (%rsp), %rsi
callq 0x139f0
jmp 0x2a33a
jmp 0x2a337
jmp 0x2a337
jmp 0x2a337
movq %rax, %r14
movq 0x10(%rsp), %rdi
callq 0x649ae
movq %r14, %rdi
callq 0x138f0