// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/R3Surfels/R3SurfelConstraint.cpp
// Function: gaps::R3SurfelGridConstraint::Check(gaps::R3Point const&) const
int R3SurfelGridConstraint::
Check(const R3Point& point) const
{
  // Get grid value
  RNScalar grid_value = grid_operand;
  if (grid_value_type != R3_SURFEL_CONSTRAINT_OPERAND) grid_value = grid->WorldValue(point);
  if (grid_value == R2_GRID_UNKNOWN_VALUE) return R3_SURFEL_CONSTRAINT_FAIL;

  // Get surfel value
  RNScalar surfel_value = surfel_operand;
  if (surfel_value_type == R3_SURFEL_CONSTRAINT_X) surfel_value = point.X();
  else if (surfel_value_type == R3_SURFEL_CONSTRAINT_Y) surfel_value = point.Y();
  else if (surfel_value_type == R3_SURFEL_CONSTRAINT_Z) surfel_value = point.Z();

  // Compare values
  switch (comparison_type) {
  case R3_SURFEL_CONSTRAINT_NOT_EQUAL: 
    return (RNIsNotEqual(surfel_value, grid_value, epsilon)) ?
      R3_SURFEL_CONSTRAINT_PASS : R3_SURFEL_CONSTRAINT_FAIL;
  case R3_SURFEL_CONSTRAINT_EQUAL: 
    return (RNIsEqual(surfel_value, grid_value, epsilon)) ?
      R3_SURFEL_CONSTRAINT_PASS : R3_SURFEL_CONSTRAINT_FAIL;
  case R3_SURFEL_CONSTRAINT_GREATER: 
    return (RNIsGreater(surfel_value, grid_value, epsilon)) ?
      R3_SURFEL_CONSTRAINT_PASS : R3_SURFEL_CONSTRAINT_FAIL;
  case R3_SURFEL_CONSTRAINT_GREATER_OR_EQUAL: 
    return (RNIsGreaterOrEqual(surfel_value, grid_value, epsilon)) ?
      R3_SURFEL_CONSTRAINT_PASS : R3_SURFEL_CONSTRAINT_FAIL;
  case R3_SURFEL_CONSTRAINT_LESS: 
    return (RNIsLess(surfel_value, grid_value, epsilon)) ?
      R3_SURFEL_CONSTRAINT_PASS : R3_SURFEL_CONSTRAINT_FAIL;
  case R3_SURFEL_CONSTRAINT_LESS_OR_EQUAL: 
    return (RNIsLessOrEqual(surfel_value, grid_value, epsilon)) ?
      R3_SURFEL_CONSTRAINT_PASS : R3_SURFEL_CONSTRAINT_FAIL;
  }

  // Did not pass test
  return R3_SURFEL_CONSTRAINT_FAIL;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r14
movq %rdi, %rbx
cmpl $0x0, 0x18(%rdi)
je 0x30cc0
movq 0x8(%rbx), %r15
movsd (%r14), %xmm0
movsd 0x8(%r14), %xmm1
movsd 0x10(%r14), %xmm2
movq %rsp, %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x77cba
movsd (%r12), %xmm0
movsd 0x8(%r12), %xmm1
movsd 0x10(%r12), %xmm2
movq %r15, %rdi
callq 0x776bc
jmp 0x30cc5
movsd 0x28(%rbx), %xmm0
xorl %eax, %eax
ucomisd 0xae5d1(%rip), %xmm0    # 0xdf2a0
jne 0x30cd7
jnp 0x30dc6
movl 0x14(%rbx), %ecx
cmpl $0x4, %ecx
je 0x30cf5
cmpl $0x3, %ecx
je 0x30cef
cmpl $0x2, %ecx
je 0x30cf9
leaq 0x20(%rbx), %r14
jmp 0x30cf9
addq $0x8, %r14
jmp 0x30cf9
addq $0x10, %r14
movl 0x10(%rbx), %ecx
cmpq $0x5, %rcx
ja 0x30dc6
movsd (%r14), %xmm1
leaq 0xae596(%rip), %rax     # 0xdf2a8
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movsd 0x30(%rbx), %xmm2
subsd %xmm0, %xmm1
movapd 0xad674(%rip), %xmm0    # 0xde3a0
xorpd %xmm2, %xmm0
xorl %ecx, %ecx
ucomisd %xmm1, %xmm0
seta %cl
addl %ecx, %ecx
ucomisd %xmm2, %xmm1
movl $0x2, %eax
cmovbel %ecx, %eax
jmp 0x30dc6
movsd 0x30(%rbx), %xmm2
xorpd 0xad64a(%rip), %xmm2    # 0xde3a0
subsd %xmm0, %xmm1
xorl %eax, %eax
ucomisd %xmm1, %xmm2
jmp 0x30d6d
subsd %xmm0, %xmm1
xorl %eax, %eax
ucomisd 0x30(%rbx), %xmm1
seta %al
jmp 0x30dc4
subsd %xmm0, %xmm1
movsd 0x30(%rbx), %xmm0
xorpd 0xad61d(%rip), %xmm0    # 0xde3a0
xorl %eax, %eax
ucomisd %xmm0, %xmm1
jmp 0x30dc1
movsd 0x30(%rbx), %xmm2
subsd %xmm0, %xmm1
xorl %ecx, %ecx
ucomisd %xmm1, %xmm2
setae %cl
xorpd 0xad5fb(%rip), %xmm2    # 0xde3a0
addl %ecx, %ecx
xorl %eax, %eax
ucomisd %xmm2, %xmm1
cmovael %ecx, %eax
jmp 0x30dc6
movsd 0x30(%rbx), %xmm2
subsd %xmm0, %xmm1
xorl %eax, %eax
ucomisd %xmm1, %xmm2
setae %al
addl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq