// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/R3Surfels/R3SurfelConstraint.cpp
// Function: gaps::R3SurfelViewConstraint::R3SurfelViewConstraint(gaps::R3SurfelImage const&, double, double, gaps::R2Grid const*, int)
R3SurfelViewConstraint::
R3SurfelViewConstraint(
  const R3SurfelImage& image,
  RNLength neardist, RNLength fardist, 
  const R2Grid *image_mask,
  RNBoolean must_be_inside_frustum)
  : frustum(image.Frustum()),
    world_to_camera(image.Extrinsics()),
    w(image.ImageWidth()), h(image.ImageHeight()),
    fx(image.XFocal()), fy(image.YFocal()),
    cx(image.ImageCenter().X()), cy(image.ImageCenter().Y()),
    neardist(neardist), fardist(fardist),
    image_mask(image_mask),
    must_be_inside_frustum(must_be_inside_frustum)
{
  // Compute default image center
  if (this->cx <= 0) this->cx = 0.5*w;
  if (this->cy <= 0) this->cy = 0.5*h;

  // Compute default near and far distances
  if (this->neardist <= 0) this->neardist = RN_EPSILON;
  if (this->fardist <= 0) this->fardist = RN_INFINITY;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %ecx, %ebp
movq %rdx, %r14
movsd %xmm1, 0x18(%rsp)
movsd %xmm0, 0x10(%rsp)
movq %rsi, %r15
movq %rdi, %rbx
leaq 0xfdf46(%rip), %rax     # 0x12f3a8
movq %rax, (%rdi)
leaq 0x10379c(%rip), %rax    # 0x134c08
movsd (%rax), %xmm0
movsd %xmm0, 0x28(%rsp)
leaq 0x10379b(%rip), %rax    # 0x134c18
movsd (%rax), %xmm0
movsd %xmm0, 0x20(%rsp)
addq $0x78, %rsi
leaq 0x30(%rsp), %rdi
callq 0x864ac
movsd 0xb0(%r15), %xmm2
xorpd %xmm1, %xmm1
ucomisd %xmm2, %xmm1
xorpd %xmm0, %xmm0
jae 0x314cd
xorps %xmm0, %xmm0
cvtsi2sdl 0x98(%r15), %xmm0
mulsd 0xacc80(%rip), %xmm0    # 0xde140
divsd %xmm2, %xmm0
callq 0x13410
xorpd %xmm1, %xmm1
leaq 0x8(%rbx), %r12
movsd 0xb8(%r15), %xmm2
ucomisd %xmm2, %xmm1
jae 0x3150d
movsd %xmm0, 0x8(%rsp)
xorps %xmm0, %xmm0
cvtsi2sdl 0x9c(%r15), %xmm0
mulsd 0xacc46(%rip), %xmm0    # 0xde140
divsd %xmm2, %xmm0
callq 0x13410
movapd %xmm0, %xmm1
movsd 0x8(%rsp), %xmm0
leaq 0x60(%r15), %rcx
leaq 0x30(%r15), %r13
leaq 0x30(%rsp), %rdx
movq %r12, %rdi
movq %r13, %rsi
movsd 0x28(%rsp), %xmm2
movsd 0x20(%rsp), %xmm3
callq 0x6b818
leaq 0x150(%rbx), %rdi
movq %r13, %rsi
callq 0x714b6
movl 0x98(%r15), %ecx
movl %ecx, 0x1d0(%rbx)
movl 0x9c(%r15), %eax
movl %eax, 0x1d4(%rbx)
movups 0xb0(%r15), %xmm0
movups %xmm0, 0x1d8(%rbx)
movsd 0xa0(%r15), %xmm2
movsd %xmm2, 0x1e8(%rbx)
movsd 0xa8(%r15), %xmm0
movsd %xmm0, 0x1f0(%rbx)
movsd 0x10(%rsp), %xmm4
movsd %xmm4, 0x1f8(%rbx)
movsd 0x18(%rsp), %xmm3
movsd %xmm3, 0x200(%rbx)
movq %r14, 0x208(%rbx)
movl %ebp, 0x210(%rbx)
xorpd %xmm1, %xmm1
ucomisd %xmm2, %xmm1
jb 0x315d5
xorps %xmm2, %xmm2
cvtsi2sd %ecx, %xmm2
mulsd 0xacb73(%rip), %xmm2    # 0xde140
movsd %xmm2, 0x1e8(%rbx)
ucomisd %xmm0, %xmm1
jb 0x315f2
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0xacb56(%rip), %xmm0    # 0xde140
movsd %xmm0, 0x1f0(%rbx)
xorpd %xmm0, %xmm0
ucomisd %xmm4, %xmm0
jb 0x3160f
leaq 0x103605(%rip), %rax    # 0x134c08
movsd (%rax), %xmm1
movsd %xmm1, 0x1f8(%rbx)
ucomisd %xmm3, %xmm0
jb 0x31628
leaq 0x1035fc(%rip), %rax    # 0x134c18
movsd (%rax), %xmm0
movsd %xmm0, 0x200(%rbx)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq %r12, %rdi
callq 0x6ede0
movq %rbx, %rdi
callq 0x138b0