// File: tomfunkhouser[P]gaps/pkgs/R3Surfels/R3SurfelBlock.cpp
// Function: gaps::R3SurfelBlock::R3SurfelBlock(gaps::R3Surfel const*, int, gaps::R3Point const&, double)
R3SurfelBlock::
R3SurfelBlock(const R3Surfel *surfels, int nsurfels,
  const R3Point& position_origin, RNScalar timestamp_origin)
  : surfels(NULL),
    nsurfels(nsurfels),
    position_origin(position_origin),
    bbox(FLT_MAX,FLT_MAX,FLT_MAX,-FLT_MAX,-FLT_MAX,-FLT_MAX),
    timestamp_origin(timestamp_origin),
    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)
{
  // Copy surfels
  if (nsurfels > 0) {
    this->surfels = new R3Surfel [ nsurfels ];
    for (int i = 0; i < nsurfels; i++) {
      this->surfels[i] = surfels[i];
    }
  }
}

// Assembly:
subq $0x88, %rsp
movq %rdi, 0x80(%rsp)
movq %rsi, 0x78(%rsp)
movl %edx, 0x74(%rsp)
movq %rcx, 0x68(%rsp)
movsd %xmm0, 0x60(%rsp)
movq 0x80(%rsp), %rdi
movq %rdi, 0x38(%rsp)
movq $0x0, (%rdi)
movl 0x74(%rsp), %eax
movl %eax, 0x8(%rdi)
addq $0x10, %rdi
movq 0x68(%rsp), %rsi
callq 0xf8390
movq 0x38(%rsp), %rdi
addq $0x28, %rdi
movq %rdi, 0x30(%rsp)
movsd 0x15ae1e(%rip), %xmm2   # 0x1a4190
movsd %xmm2, 0x40(%rsp)
movsd 0x15ae08(%rip), %xmm5   # 0x1a4188
movsd %xmm5, 0x48(%rsp)
movaps %xmm2, %xmm0
movaps %xmm2, %xmm1
movaps %xmm5, %xmm3
movaps %xmm5, %xmm4
callq 0xc9ee0
movq 0x38(%rsp), %rdi
movsd 0x40(%rsp), %xmm0
movsd 0x48(%rsp), %xmm1
movsd 0x60(%rsp), %xmm2
movsd %xmm2, 0x60(%rdi)
addq $0x68, %rdi
callq 0x144d90
jmp 0x493be
movq 0x38(%rsp), %rdi
movl $0xffffffff, 0x78(%rdi) # imm = 0xFFFFFFFF
movl $0x0, 0x7c(%rdi)
movq $0x0, 0x80(%rdi)
addq $0x88, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1b970
jmp 0x493ee
movq 0x38(%rsp), %rax
movq $0x0, 0x90(%rax)
movq $0x0, 0x98(%rax)
movl $0xffffffff, 0xa0(%rax) # imm = 0xFFFFFFFF
movq $0x0, 0xa8(%rax)
movl $0x0, 0xb0(%rax)
movl $0x0, 0xb4(%rax)
movq $0x0, 0xb8(%rax)
movl $0x0, 0xc0(%rax)
cmpl $0x0, 0x74(%rsp)
jle 0x4955f
movslq 0x74(%rsp), %rax
movq %rax, 0x18(%rsp)
movl $0x30, %ecx
mulq %rcx
movq %rax, %rdi
movq $-0x1, %rax
cmovoq %rax, %rdi
movq %rdi, 0x20(%rsp)
callq 0x13030
movq %rax, 0x28(%rsp)
jmp 0x49483
movq 0x18(%rsp), %rax
cmpq $0x0, %rax
je 0x494d3
movq 0x28(%rsp), %rax
movq 0x18(%rsp), %rcx
imulq $0x30, %rcx, %rdx
movq %rax, %rcx
addq %rdx, %rcx
movq %rcx, 0x8(%rsp)
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rdi
movq %rdi, (%rsp)
callq 0x47310
jmp 0x494bc
movq 0x8(%rsp), %rcx
movq (%rsp), %rax
addq $0x30, %rax
cmpq %rcx, %rax
movq %rax, 0x10(%rsp)
jne 0x494ac
movq 0x38(%rsp), %rax
movq 0x28(%rsp), %rcx
movq %rcx, (%rax)
movl $0x0, 0x50(%rsp)
movl 0x50(%rsp), %eax
cmpl 0x74(%rsp), %eax
jge 0x4955d
movq 0x38(%rsp), %rax
movq 0x78(%rsp), %rsi
movslq 0x50(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rsi
movq (%rax), %rdi
movslq 0x50(%rsp), %rax
imulq $0x30, %rax, %rax
addq %rax, %rdi
movl $0x30, %edx
callq 0x13460
movl 0x50(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x50(%rsp)
jmp 0x494e8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x58(%rsp)
movl %eax, 0x54(%rsp)
jmp 0x49567
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x58(%rsp)
movl %eax, 0x54(%rsp)
callq 0x13a90
jmp 0x49567
jmp 0x4955f
addq $0x88, %rsp
retq
movq 0x30(%rsp), %rdi
callq 0x1b990
movq 0x58(%rsp), %rdi
callq 0x13970
nopl (%rax,%rax)