// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3MeshSearchTree.cpp
// Function: gaps::R3MeshSearchTree::FindClosest(gaps::R3Point const&, gaps::R3Vector const&, gaps::R3MeshIntersection&, double, double&, int (*)(gaps::R3Point const&, gaps::R3Vector const&, gaps::R3Mesh*, gaps::R3MeshFace*, void*), void*, gaps::R3MeshFace*) const
void R3MeshSearchTree::
FindClosest(const R3Point& query_position, const R3Vector& query_normal, R3MeshIntersection& closest, 
  RNScalar min_distance_squared, RNScalar& max_distance_squared, 
  int (*IsCompatible)(const R3Point&, const R3Vector&, R3Mesh *, R3MeshFace *, void *), void *compatible_data,
  R3MeshFace *face) const
{
  // Check face normal
  const R3Vector& face_normal = mesh->FaceNormal(face);
  if (RNIsZero(face_normal.Dot(face_normal))) {
    // Face is degenerate -- assume centroid is closest point on face
    R3Point p = mesh->FaceCentroid(face);
    RNScalar distance_squared = DistanceSquared(query_position, p);
    if ((distance_squared >= min_distance_squared) && (distance_squared < max_distance_squared)) {
      closest.type = R3_MESH_FACE_TYPE;
      closest.face = face;
      closest.point = p;
      max_distance_squared = distance_squared;
    }
  }
  else {  
    // Check distance to plane
    const R3Plane& plane = mesh->FacePlane(face);
    RNScalar plane_signed_distance = R3SignedDistance(plane, query_position);
    RNScalar plane_distance_squared = plane_signed_distance * plane_signed_distance;
    if (plane_distance_squared >= max_distance_squared) return;

    // Check distance to bounding box
    RNScalar bbox_distance_squared = DistanceSquared(query_position, mesh->FaceBBox(face), max_distance_squared);
    if (bbox_distance_squared >= max_distance_squared) return;

    // Check compatibility 
    if (IsCompatible) {
      if (!(*IsCompatible)(query_position, query_normal, mesh, face, compatible_data)) return;
    }

    // Get face vertices
    R3MeshVertex *v0 = mesh->VertexOnFace(face, 0);
    R3MeshVertex *v1 = mesh->VertexOnFace(face, 1);
    R3MeshVertex *v2 = mesh->VertexOnFace(face, 2);

    // Get vertex positions
    const R3Point& p0 = mesh->VertexPosition(v0);
    const R3Point& p1 = mesh->VertexPosition(v1);
    const R3Point& p2 = mesh->VertexPosition(v2);

    // Project query point onto face plane
    R3Point plane_point = query_position - plane_signed_distance * face_normal;

    // Check sides of edges
    R3Vector e0 = p1 - p0;
    e0.Normalize();
    R3Vector n0 = mesh->FaceNormal(face) % e0;
    R3Plane s0(p0, n0);
    RNScalar b0 = R3SignedDistance(s0, plane_point);
    R3Vector e1 = p2 - p1;
    e1.Normalize();
    R3Vector n1 = mesh->FaceNormal(face) % e1;
    R3Plane s1(p1, n1);
    RNScalar b1 = R3SignedDistance(s1, plane_point);
    R3Vector e2 = p0 - p2;
    e2.Normalize();
    R3Vector n2 = mesh->FaceNormal(face) % e2;
    R3Plane s2(p2, n2);
    RNScalar b2 = R3SignedDistance(s2, plane_point);

    // Consider plane_point's position in relation to edges of the triangle
    if ((b0 >= 0) && (b1 >= 0) && (b2 >= 0)) {
      // Point is inside face
      if (plane_distance_squared >= min_distance_squared) {
        closest.type = R3_MESH_FACE_TYPE;
        closest.face = face;
        closest.point = plane_point;
        max_distance_squared = plane_distance_squared;
        if (b0 < b1) closest.edge = (b0 < b2) ? mesh->EdgeOnFace(face, 0) : mesh->EdgeOnFace(face, 2);
        else closest.edge = (b1 < b2) ? mesh->EdgeOnFace(face, 1) : mesh->EdgeOnFace(face, 2);
      }
    }
    else {
      // Point is outside face -- check each edge
      if (b0 < 0) {
        // Outside edge0
        R3Vector edge_vector = p1 - p0;
        RNScalar edge_length = edge_vector.Length();
        if (edge_length > 0) {
          edge_vector /= edge_length;
          R3Vector point_vector = plane_point - p0;
          RNScalar t = edge_vector.Dot(point_vector);
          if (t <= 0) {
            RNScalar distance_squared = DistanceSquared(query_position, p0);
            if ((distance_squared >= min_distance_squared) && (distance_squared < max_distance_squared)) {
              closest.type = R3_MESH_VERTEX_TYPE;
              closest.vertex = v0;
              closest.point = p0;
              max_distance_squared = distance_squared;
            }
          }
          else if (t >= edge_length) {
            RNScalar distance_squared = DistanceSquared(query_position, p1);
            if ((distance_squared >= min_distance_squared) && (distance_squared < max_distance_squared)) {
              closest.type = R3_MESH_VERTEX_TYPE;
              closest.vertex = v1;
              closest.point = p1;
              max_distance_squared = distance_squared;
            }
          }
          else {
            R3Point point = p0 + t * edge_vector;
            RNScalar distance_squared = DistanceSquared(query_position, point);
            if ((distance_squared >= min_distance_squared) && (distance_squared < max_distance_squared)) {
              closest.type = R3_MESH_EDGE_TYPE;
              closest.edge = mesh->EdgeOnFace(face, 0);
              closest.point = point;
              max_distance_squared = distance_squared;
            }
          }
        }
      }
      if (b1 < 0) {
        // Outside edge1
        R3Vector edge_vector = p2 - p1;
        RNScalar edge_length = edge_vector.Length();
        if (edge_length > 0) {
          edge_vector /= edge_length;
          R3Vector point_vector = plane_point - p1;
          RNScalar t = edge_vector.Dot(point_vector);
          if (t <= 0) {
            RNScalar distance_squared = DistanceSquared(query_position, p1);
            if ((distance_squared >= min_distance_squared) && (distance_squared < max_distance_squared)) {
              closest.type = R3_MESH_VERTEX_TYPE;
              closest.vertex = v1;
              closest.point = p1;
              max_distance_squared = distance_squared;
            }
          }
          else if (t >= edge_length) {
            RNScalar distance_squared = DistanceSquared(query_position, p2);
            if ((distance_squared >= min_distance_squared) && (distance_squared < max_distance_squared)) {
              closest.type = R3_MESH_VERTEX_TYPE;
              closest.vertex = v2;
              closest.point = p2;
              max_distance_squared = distance_squared;
            }
          }
          else {
            R3Point point = p1 + t * edge_vector;
            RNScalar distance_squared = DistanceSquared(query_position, point);
            if ((distance_squared >= min_distance_squared) && (distance_squared < max_distance_squared)) {
              closest.type = R3_MESH_EDGE_TYPE;
              closest.edge = mesh->EdgeOnFace(face, 1);
              closest.point = point;
              max_distance_squared = distance_squared;
            }
          }
        }
      }
      if (b2 < 0) {
        // Outside edge2
        R3Vector edge_vector = p0 - p2;
        RNScalar edge_length = edge_vector.Length();
        if (edge_length > 0) {
          edge_vector /= edge_length;
          R3Vector point_vector = plane_point - p2;
          RNScalar t = edge_vector.Dot(point_vector);
          if (t <= 0) {
            RNScalar distance_squared = DistanceSquared(query_position, p2);
            if ((distance_squared >= min_distance_squared) && (distance_squared < max_distance_squared)) {
              closest.type = R3_MESH_VERTEX_TYPE;
              closest.vertex = v2;
              closest.point = p2;
              max_distance_squared = distance_squared;
            }
          }
          else if (t >= edge_length) {
            RNScalar distance_squared = DistanceSquared(query_position, p0);
            if ((distance_squared >= min_distance_squared) && (distance_squared < max_distance_squared)) {
              closest.type = R3_MESH_VERTEX_TYPE;
              closest.vertex = v0;
              closest.point = p0;
              max_distance_squared = distance_squared;
            }
          }
          else {
            R3Point point = p2 + t * edge_vector;
            RNScalar distance_squared = DistanceSquared(query_position, point);
            if ((distance_squared >= min_distance_squared) && (distance_squared < max_distance_squared)) {
              closest.type = R3_MESH_EDGE_TYPE;
              closest.edge = mesh->EdgeOnFace(face, 2);
              closest.point = point;
              max_distance_squared = distance_squared;
            }
          }
        }
      }
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1d8, %rsp            # imm = 0x1D8
movq %r9, %rbx
movq %r8, 0x8(%rsp)
movsd %xmm0, 0x18(%rsp)
movq %rcx, 0x20(%rsp)
movq %rdx, %r14
movq %rsi, %r12
movq %rdi, %rbp
movq 0x218(%rsp), %r15
testb $0x4, 0xa8(%r15)
jne 0x16729
movq (%rbp), %rdi
movq (%rdi), %rax
movq %r15, %rsi
callq *0x2c8(%rax)
leaq 0x38(%r15), %r13
movq %r13, %rdi
movq %r13, %rsi
callq 0x515fe
leaq 0xd9469(%rip), %rax     # 0xefba8
movsd (%rax), %xmm1
movapd 0x938e5(%rip), %xmm2    # 0xaa030
xorpd %xmm1, %xmm2
ucomisd %xmm2, %xmm0
jb 0x16809
ucomisd %xmm0, %xmm1
jb 0x16809
movq (%rbp), %rsi
leaq 0xe8(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rdx
callq 0x24280
movsd (%r12), %xmm0
movsd 0x8(%r12), %xmm1
subsd (%rbx), %xmm0
subsd 0x8(%rbx), %xmm1
movsd 0x10(%r12), %xmm2
subsd 0x10(%rbx), %xmm2
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
mulsd %xmm2, %xmm2
addsd %xmm0, %xmm2
ucomisd 0x18(%rsp), %xmm2
jb 0x171fd
movq 0x8(%rsp), %rax
movsd (%rax), %xmm0
ucomisd %xmm2, %xmm0
jbe 0x171fd
movq 0x20(%rsp), %rdi
movl $0x3, (%rdi)
movq %r15, 0x18(%rdi)
addq $0x20, %rdi
leaq 0xe8(%rsp), %rsi
movsd %xmm2, 0x18(%rsp)
callq 0x50c3c
movq 0x8(%rsp), %rax
movsd 0x18(%rsp), %xmm0
movsd %xmm0, (%rax)
jmp 0x171fd
testb $0x4, 0xa8(%r15)
jne 0x16823
movq (%rbp), %rdi
movq (%rdi), %rax
movq %r15, %rsi
callq *0x2c8(%rax)
movq %r13, %rdi
movq %r12, %rsi
callq 0x2101b
movsd %xmm0, 0x28(%rsp)
mulsd %xmm0, %xmm0
movq 0x8(%rsp), %rax
movsd %xmm0, 0x10(%rsp)
ucomisd (%rax), %xmm0
jae 0x171fd
movq (%rbp), %rdi
movq %r15, %rsi
callq 0x25d8e
movq 0x8(%rsp), %rcx
movsd (%rcx), %xmm0
movsd %xmm0, 0x38(%rsp)
movq %r12, %rsi
movq %rax, %rdx
callq 0x17242
ucomisd 0x38(%rsp), %xmm0
jae 0x171fd
testq %rbx, %rbx
je 0x168a3
movq 0x210(%rsp), %r8
movq (%rbp), %rdx
movq %r12, %rdi
movq %r14, %rsi
movq %r15, %rcx
callq *%rbx
testl %eax, %eax
je 0x171fd
movq 0x8(%r15), %rax
movq 0x10(%r15), %rdx
movq 0x18(%r15), %rcx
movq %rax, 0x50(%rsp)
leaq 0x18(%rax), %r14
movq %rdx, 0x40(%rsp)
leaq 0x18(%rdx), %r15
movq %rcx, 0x48(%rsp)
leaq 0x18(%rcx), %rax
movq %rax, 0x38(%rsp)
leaq 0xe8(%rsp), %rbx
movq %rbx, %rdi
movq %r13, %rsi
movsd 0x28(%rsp), %xmm0
callq 0x51d36
leaq 0x88(%rsp), %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x512f5
leaq 0x138(%rsp), %rbx
movq %rbx, %rdi
movq %r15, 0x60(%rsp)
movq %r15, %rsi
movq 0x218(%rsp), %r15
movq %r14, 0x28(%rsp)
movq %r14, %rdx
callq 0x50b30
movq %rbx, %rdi
callq 0x51688
testb $0x4, 0xa8(%r15)
jne 0x16945
movq (%rbp), %rdi
movq (%rdi), %rax
movq %r15, %rsi
callq *0x2c8(%rax)
leaq 0x180(%rsp), %rbx
leaq 0x138(%rsp), %rdx
movq %rbx, %rdi
movq %r13, %rsi
callq 0x51cba
leaq 0xe8(%rsp), %r14
movq %r14, %rdi
movq 0x28(%rsp), %rsi
movq %rbx, %rdx
callq 0x4f44e
leaq 0x88(%rsp), %rsi
movq %r14, %rdi
callq 0x2101b
movsd %xmm0, 0x68(%rsp)
leaq 0x120(%rsp), %rbx
movq %rbx, %rdi
movq 0x38(%rsp), %rsi
movq 0x60(%rsp), %rdx
callq 0x50b30
movq %rbx, %rdi
callq 0x51688
testb $0x4, 0xa8(%r15)
jne 0x169ca
movq (%rbp), %rdi
movq (%rdi), %rax
movq %r15, %rsi
callq *0x2c8(%rax)
leaq 0x168(%rsp), %rbx
leaq 0x120(%rsp), %rdx
movq %rbx, %rdi
movq %r13, %rsi
callq 0x51cba
leaq 0x1b8(%rsp), %r14
movq %r14, %rdi
movq 0x60(%rsp), %rsi
movq %rbx, %rdx
callq 0x4f44e
leaq 0x88(%rsp), %rsi
movq %r14, %rdi
callq 0x2101b
movsd %xmm0, 0x58(%rsp)
leaq 0x108(%rsp), %rbx
movq %rbx, %rdi
movq 0x28(%rsp), %rsi
movq 0x38(%rsp), %rdx
callq 0x50b30
movq %rbx, %rdi
callq 0x51688
testb $0x4, 0xa8(%r15)
jne 0x16a4f
movq (%rbp), %rdi
movq (%rdi), %rax
movq %r15, %rsi
callq *0x2c8(%rax)
leaq 0x150(%rsp), %rbx
leaq 0x108(%rsp), %rdx
movq %rbx, %rdi
movq %r13, %rsi
callq 0x51cba
leaq 0x198(%rsp), %r14
movq %r14, %rdi
movq 0x38(%rsp), %r13
movq %r13, %rsi
movq %rbx, %rdx
callq 0x4f44e
leaq 0x88(%rsp), %rsi
movq %r14, %rdi
callq 0x2101b
xorpd %xmm2, %xmm2
movsd 0x68(%rsp), %xmm4
ucomisd %xmm2, %xmm4
movsd 0x58(%rsp), %xmm3
jb 0x16b3c
ucomisd %xmm2, %xmm3
jb 0x16b3c
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x16b3c
movsd 0x10(%rsp), %xmm1
ucomisd 0x18(%rsp), %xmm1
jb 0x171fd
movsd %xmm0, 0x30(%rsp)
movq 0x20(%rsp), %rbx
movl $0x3, (%rbx)
movq %r15, 0x18(%rbx)
leaq 0x20(%rbx), %rdi
leaq 0x88(%rsp), %rsi
callq 0x50c3c
movsd 0x68(%rsp), %xmm2
movsd 0x58(%rsp), %xmm1
movq 0x8(%rsp), %rax
movsd 0x10(%rsp), %xmm0
movsd %xmm0, (%rax)
xorl %eax, %eax
ucomisd %xmm2, %xmm1
jbe 0x16c7a
movsd 0x30(%rsp), %xmm0
ucomisd %xmm2, %xmm0
setbe %al
shll $0x4, %eax
movq 0x20(%r15,%rax), %rax
jmp 0x16c8c
ucomisd %xmm4, %xmm2
movq 0x60(%rsp), %rbp
movsd %xmm0, 0x30(%rsp)
jbe 0x16da3
leaq 0x70(%rsp), %rbx
movq %rbx, %rdi
movq %rbp, %rsi
movq 0x28(%rsp), %rdx
callq 0x50b30
movq %rbx, %rdi
callq 0x5146c
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x16d97
leaq 0x70(%rsp), %rbx
movq %rbx, %rdi
movsd %xmm0, 0x10(%rsp)
callq 0x51f94
leaq 0xd0(%rsp), %r14
leaq 0x88(%rsp), %rsi
movq %r14, %rdi
movq 0x28(%rsp), %rdx
callq 0x50b30
movq %rbx, %rdi
movq %r14, %rsi
callq 0x515fe
xorpd %xmm1, %xmm1
ucomisd %xmm0, %xmm1
jae 0x16c95
ucomisd 0x10(%rsp), %xmm0
jae 0x16d0f
leaq 0xb8(%rsp), %rbx
leaq 0x70(%rsp), %rsi
movq %rbx, %rdi
callq 0x51d36
leaq 0xa0(%rsp), %r14
movq %r14, %rdi
movq 0x28(%rsp), %rsi
movq %rbx, %rdx
callq 0x50c19
movsd (%r12), %xmm0
movsd 0x8(%r12), %xmm1
subsd (%r14), %xmm0
subsd 0x8(%r14), %xmm1
movsd 0x10(%r12), %xmm2
subsd 0x10(%r14), %xmm2
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
mulsd %xmm2, %xmm2
addsd %xmm0, %xmm2
ucomisd 0x18(%rsp), %xmm2
jb 0x16d97
movq 0x8(%rsp), %rax
movsd (%rax), %xmm0
ucomisd %xmm2, %xmm0
jbe 0x16d97
movq 0x20(%rsp), %rcx
movl $0x2, (%rcx)
movq 0x20(%r15), %rax
movq %rax, 0x10(%rcx)
leaq 0x20(%rcx), %rdi
leaq 0xa0(%rsp), %rsi
jmp 0x16d7d
movsd 0x30(%rsp), %xmm0
ucomisd %xmm1, %xmm0
setbe %al
movq 0x28(%r15,%rax,8), %rax
movq %rax, 0x10(%rbx)
jmp 0x171fd
movsd (%r12), %xmm0
movsd 0x8(%r12), %xmm1
movq 0x50(%rsp), %rax
subsd 0x18(%rax), %xmm0
subsd 0x20(%rax), %xmm1
movsd 0x10(%r12), %xmm2
subsd 0x28(%rax), %xmm2
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
mulsd %xmm2, %xmm2
addsd %xmm0, %xmm2
ucomisd 0x18(%rsp), %xmm2
jb 0x16d97
movq 0x8(%rsp), %rax
movsd (%rax), %xmm0
ucomisd %xmm2, %xmm0
jbe 0x16d97
movq 0x20(%rsp), %rax
movl $0x1, (%rax)
movq 0x50(%rsp), %rcx
movq %rcx, 0x8(%rax)
leaq 0x20(%rax), %rdi
movq 0x28(%rsp), %rsi
jmp 0x16d7d
movsd (%r12), %xmm0
movsd 0x8(%r12), %xmm1
movq 0x40(%rsp), %rax
subsd 0x18(%rax), %xmm0
subsd 0x20(%rax), %xmm1
movsd 0x10(%r12), %xmm2
subsd 0x28(%rax), %xmm2
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
mulsd %xmm2, %xmm2
addsd %xmm0, %xmm2
ucomisd 0x18(%rsp), %xmm2
jb 0x16d97
movq 0x8(%rsp), %rax
movsd (%rax), %xmm0
ucomisd %xmm2, %xmm0
jbe 0x16d97
movq 0x20(%rsp), %rax
movl $0x1, (%rax)
movq 0x40(%rsp), %rcx
movq %rcx, 0x8(%rax)
leaq 0x20(%rax), %rdi
movq %rbp, %rsi
movsd %xmm2, 0x10(%rsp)
callq 0x50c3c
movq 0x8(%rsp), %rax
movsd 0x10(%rsp), %xmm0
movsd %xmm0, (%rax)
movsd 0x30(%rsp), %xmm0
movsd 0x58(%rsp), %xmm3
xorpd %xmm1, %xmm1
ucomisd %xmm3, %xmm1
jbe 0x16fde
leaq 0x70(%rsp), %rbx
movq %rbx, %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0x50b30
movq %rbx, %rdi
callq 0x5146c
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x16fd8
leaq 0x70(%rsp), %rbx
movq %rbx, %rdi
movsd %xmm0, 0x10(%rsp)
callq 0x51f94
leaq 0xd0(%rsp), %r14
leaq 0x88(%rsp), %rsi
movq %r14, %rdi
movq %rbp, %rdx
callq 0x50b30
movq %rbx, %rdi
movq %r14, %rsi
callq 0x515fe
xorpd %xmm1, %xmm1
ucomisd %xmm0, %xmm1
jae 0x16ed4
ucomisd 0x10(%rsp), %xmm0
jae 0x16f4c
leaq 0xb8(%rsp), %rbx
leaq 0x70(%rsp), %rsi
movq %rbx, %rdi
callq 0x51d36
leaq 0xa0(%rsp), %r14
movq %r14, %rdi
movq %rbp, %rsi
movq %rbx, %rdx
callq 0x50c19
movsd (%r12), %xmm0
movsd 0x8(%r12), %xmm1
subsd (%r14), %xmm0
subsd 0x8(%r14), %xmm1
movsd 0x10(%r12), %xmm2
subsd 0x10(%r14), %xmm2
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
mulsd %xmm2, %xmm2
addsd %xmm0, %xmm2
ucomisd 0x18(%rsp), %xmm2
jb 0x16fd4
movq 0x8(%rsp), %rax
movsd (%rax), %xmm0
ucomisd %xmm2, %xmm0
jbe 0x16fd4
movq 0x20(%rsp), %rcx
movl $0x2, (%rcx)
movq 0x28(%r15), %rax
movq %rax, 0x10(%rcx)
leaq 0x20(%rcx), %rdi
leaq 0xa0(%rsp), %rsi
jmp 0x16fba
movsd (%r12), %xmm0
movsd 0x8(%r12), %xmm1
movq 0x40(%rsp), %rax
subsd 0x18(%rax), %xmm0
subsd 0x20(%rax), %xmm1
movsd 0x10(%r12), %xmm2
subsd 0x28(%rax), %xmm2
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
mulsd %xmm2, %xmm2
addsd %xmm0, %xmm2
ucomisd 0x18(%rsp), %xmm2
jb 0x16fd4
movq 0x8(%rsp), %rax
movsd (%rax), %xmm0
ucomisd %xmm2, %xmm0
jbe 0x16fd4
movq 0x20(%rsp), %rax
movl $0x1, (%rax)
movq 0x40(%rsp), %rcx
movq %rcx, 0x8(%rax)
leaq 0x20(%rax), %rdi
movq %rbp, %rsi
jmp 0x16fba
movsd (%r12), %xmm0
movsd 0x8(%r12), %xmm1
movq 0x48(%rsp), %rax
subsd 0x18(%rax), %xmm0
subsd 0x20(%rax), %xmm1
movsd 0x10(%r12), %xmm2
subsd 0x28(%rax), %xmm2
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
mulsd %xmm2, %xmm2
addsd %xmm0, %xmm2
ucomisd 0x18(%rsp), %xmm2
jb 0x16fd4
movq 0x8(%rsp), %rax
movsd (%rax), %xmm0
ucomisd %xmm2, %xmm0
jbe 0x16fd4
movq 0x20(%rsp), %rax
movl $0x1, (%rax)
movq 0x48(%rsp), %rcx
movq %rcx, 0x8(%rax)
leaq 0x20(%rax), %rdi
movq %r13, %rsi
movsd %xmm2, 0x10(%rsp)
callq 0x50c3c
movq 0x8(%rsp), %rax
movsd 0x10(%rsp), %xmm0
movsd %xmm0, (%rax)
xorpd %xmm1, %xmm1
movsd 0x30(%rsp), %xmm0
ucomisd %xmm0, %xmm1
jbe 0x171fd
leaq 0x70(%rsp), %rbx
movq %rbx, %rdi
movq 0x28(%rsp), %rsi
movq %r13, %rdx
callq 0x50b30
movq %rbx, %rdi
callq 0x5146c
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x171fd
leaq 0x70(%rsp), %rbx
movq %rbx, %rdi
movsd %xmm0, 0x10(%rsp)
callq 0x51f94
leaq 0xd0(%rsp), %r14
leaq 0x88(%rsp), %rsi
movq %r14, %rdi
movq %r13, %rdx
callq 0x50b30
movq %rbx, %rdi
movq %r14, %rsi
callq 0x515fe
xorpd %xmm1, %xmm1
ucomisd %xmm0, %xmm1
jae 0x1710d
ucomisd 0x10(%rsp), %xmm0
jae 0x17188
leaq 0xb8(%rsp), %rbx
leaq 0x70(%rsp), %rsi
movq %rbx, %rdi
callq 0x51d36
leaq 0xa0(%rsp), %r14
movq %r14, %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x50c19
movsd (%r12), %xmm0
movsd 0x8(%r12), %xmm1
subsd (%r14), %xmm0
subsd 0x8(%r14), %xmm1
movsd 0x10(%r12), %xmm2
subsd 0x10(%r14), %xmm2
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
mulsd %xmm2, %xmm2
addsd %xmm0, %xmm2
ucomisd 0x18(%rsp), %xmm2
jb 0x171fd
movq 0x8(%rsp), %rax
movsd (%rax), %xmm0
ucomisd %xmm2, %xmm0
jbe 0x171fd
movq 0x20(%rsp), %rdi
movl $0x2, (%rdi)
movq 0x30(%r15), %rax
movq %rax, 0x10(%rdi)
addq $0x20, %rdi
leaq 0xa0(%rsp), %rsi
jmp 0x167ea
movsd (%r12), %xmm0
movsd 0x8(%r12), %xmm1
movq 0x48(%rsp), %rax
subsd 0x18(%rax), %xmm0
subsd 0x20(%rax), %xmm1
movsd 0x10(%r12), %xmm2
subsd 0x28(%rax), %xmm2
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
mulsd %xmm2, %xmm2
addsd %xmm0, %xmm2
ucomisd 0x18(%rsp), %xmm2
jb 0x171fd
movq 0x8(%rsp), %rax
movsd (%rax), %xmm0
ucomisd %xmm2, %xmm0
jbe 0x171fd
movq 0x20(%rsp), %rdi
movl $0x1, (%rdi)
movq 0x48(%rsp), %rax
movq %rax, 0x8(%rdi)
addq $0x20, %rdi
movq %r13, %rsi
jmp 0x167ea
movsd (%r12), %xmm0
movsd 0x8(%r12), %xmm1
movq 0x50(%rsp), %rax
subsd 0x18(%rax), %xmm0
subsd 0x20(%rax), %xmm1
movsd 0x10(%r12), %xmm2
subsd 0x28(%rax), %xmm2
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
mulsd %xmm2, %xmm2
addsd %xmm0, %xmm2
ucomisd 0x18(%rsp), %xmm2
jb 0x171fd
movq 0x8(%rsp), %rax
movsd (%rax), %xmm0
ucomisd %xmm2, %xmm0
jbe 0x171fd
movq 0x20(%rsp), %rdi
movl $0x1, (%rdi)
movq 0x50(%rsp), %rax
movq %rax, 0x8(%rdi)
addq $0x20, %rdi
movq 0x28(%rsp), %rsi
jmp 0x167ea
addq $0x1d8, %rsp            # imm = 0x1D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop