// File: 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:
subq $0x3c8, %rsp            # imm = 0x3C8
movq 0x3d8(%rsp), %rax
movq 0x3d0(%rsp), %rax
movq %rdi, 0x3c0(%rsp)
movq %rsi, 0x3b8(%rsp)
movq %rdx, 0x3b0(%rsp)
movq %rcx, 0x3a8(%rsp)
movsd %xmm0, 0x3a0(%rsp)
movq %r8, 0x398(%rsp)
movq %r9, 0x390(%rsp)
movq 0x3c0(%rsp), %rax
movq %rax, 0x40(%rsp)
movq (%rax), %rdi
movq 0x3d8(%rsp), %rsi
callq 0x17fd0
movq %rax, 0x388(%rsp)
movq 0x388(%rsp), %rdi
movq 0x388(%rsp), %rsi
callq 0x94680
leaq 0x16a20f(%rip), %rax    # 0x1864f0
movsd (%rax), %xmm1
callq 0x1b080
cmpl $0x0, %eax
je 0x1c3b7
movq 0x40(%rsp), %rax
movq (%rax), %rsi
movq 0x3d8(%rsp), %rdx
leaq 0x370(%rsp), %rdi
callq 0x37790
movq 0x40(%rsp), %rdi
movq 0x3b8(%rsp), %rsi
leaq 0x370(%rsp), %rdx
callq 0x1d2a0
movsd %xmm0, 0x368(%rsp)
movsd 0x368(%rsp), %xmm0
ucomisd 0x3a0(%rsp), %xmm0
jb 0x1c3b2
movsd 0x368(%rsp), %xmm1
movq 0x398(%rsp), %rax
movsd (%rax), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x1c3b2
movq 0x3a8(%rsp), %rax
movl $0x3, (%rax)
movq 0x3d8(%rsp), %rcx
movq 0x3a8(%rsp), %rax
movq %rcx, 0x18(%rax)
movq 0x3a8(%rsp), %rdi
addq $0x20, %rdi
leaq 0x370(%rsp), %rsi
callq 0x935a0
movsd 0x368(%rsp), %xmm0
movq 0x398(%rsp), %rax
movsd %xmm0, (%rax)
jmp 0x1d297
movq 0x40(%rsp), %rax
movq (%rax), %rdi
movq 0x3d8(%rsp), %rsi
callq 0x18070
movq %rax, 0x360(%rsp)
movq 0x360(%rsp), %rdi
movq 0x3b8(%rsp), %rsi
callq 0x30850
movsd %xmm0, 0x358(%rsp)
movsd 0x358(%rsp), %xmm0
mulsd 0x358(%rsp), %xmm0
movsd %xmm0, 0x350(%rsp)
movsd 0x350(%rsp), %xmm0
movq 0x398(%rsp), %rax
ucomisd (%rax), %xmm0
jb 0x1c429
jmp 0x1d297
movq 0x40(%rsp), %rax
movq 0x3b8(%rsp), %rcx
movq %rcx, 0x38(%rsp)
movq (%rax), %rdi
movq 0x3d8(%rsp), %rsi
callq 0x3a630
movq 0x40(%rsp), %rdi
movq 0x38(%rsp), %rsi
movq %rax, %rdx
movq 0x398(%rsp), %rax
movsd (%rax), %xmm0
callq 0x1d390
movsd %xmm0, 0x348(%rsp)
movsd 0x348(%rsp), %xmm0
movq 0x398(%rsp), %rax
ucomisd (%rax), %xmm0
jb 0x1c48e
jmp 0x1d297
cmpq $0x0, 0x390(%rsp)
je 0x1c4d7
movq 0x40(%rsp), %rcx
movq 0x390(%rsp), %rax
movq 0x3b8(%rsp), %rdi
movq 0x3b0(%rsp), %rsi
movq (%rcx), %rdx
movq 0x3d8(%rsp), %rcx
movq 0x3d0(%rsp), %r8
callq *%rax
cmpl $0x0, %eax
jne 0x1c4d5
jmp 0x1d297
jmp 0x1c4d7
movq 0x40(%rsp), %rax
movq (%rax), %rdi
movq 0x3d8(%rsp), %rsi
xorl %edx, %edx
callq 0x17a60
movq %rax, %rcx
movq 0x40(%rsp), %rax
movq %rcx, 0x340(%rsp)
movq (%rax), %rdi
movq 0x3d8(%rsp), %rsi
movl $0x1, %edx
callq 0x17a60
movq %rax, %rcx
movq 0x40(%rsp), %rax
movq %rcx, 0x338(%rsp)
movq (%rax), %rdi
movq 0x3d8(%rsp), %rsi
movl $0x2, %edx
callq 0x17a60
movq %rax, %rcx
movq 0x40(%rsp), %rax
movq %rcx, 0x330(%rsp)
movq (%rax), %rdi
movq 0x340(%rsp), %rsi
callq 0x17a40
movq %rax, %rcx
movq 0x40(%rsp), %rax
movq %rcx, 0x328(%rsp)
movq (%rax), %rdi
movq 0x338(%rsp), %rsi
callq 0x17a40
movq %rax, %rcx
movq 0x40(%rsp), %rax
movq %rcx, 0x320(%rsp)
movq (%rax), %rdi
movq 0x330(%rsp), %rsi
callq 0x17a40
movq %rax, 0x318(%rsp)
movq 0x3b8(%rsp), %rax
movq %rax, 0x30(%rsp)
movsd 0x358(%rsp), %xmm0
movq 0x388(%rsp), %rsi
leaq 0x2e8(%rsp), %rdi
callq 0x17f90
movq 0x30(%rsp), %rsi
leaq 0x300(%rsp), %rdi
leaq 0x2e8(%rsp), %rdx
callq 0x93e70
movq 0x320(%rsp), %rsi
movq 0x328(%rsp), %rdx
leaq 0x2d0(%rsp), %rdi
callq 0x93270
leaq 0x2d0(%rsp), %rdi
callq 0x947d0
movq 0x40(%rsp), %rax
movq (%rax), %rdi
movq 0x3d8(%rsp), %rsi
callq 0x17fd0
movq %rax, %rsi
leaq 0x2b8(%rsp), %rdi
leaq 0x2d0(%rsp), %rdx
callq 0x94eb0
movq 0x328(%rsp), %rsi
leaq 0x298(%rsp), %rdi
leaq 0x2b8(%rsp), %rdx
callq 0x90650
leaq 0x298(%rsp), %rdi
leaq 0x300(%rsp), %rsi
callq 0x30850
movsd %xmm0, 0x290(%rsp)
movq 0x318(%rsp), %rsi
movq 0x320(%rsp), %rdx
leaq 0x278(%rsp), %rdi
callq 0x93270
leaq 0x278(%rsp), %rdi
callq 0x947d0
movq 0x40(%rsp), %rax
movq (%rax), %rdi
movq 0x3d8(%rsp), %rsi
callq 0x17fd0
movq %rax, %rsi
leaq 0x260(%rsp), %rdi
leaq 0x278(%rsp), %rdx
callq 0x94eb0
movq 0x320(%rsp), %rsi
leaq 0x240(%rsp), %rdi
leaq 0x260(%rsp), %rdx
callq 0x90650
leaq 0x240(%rsp), %rdi
leaq 0x300(%rsp), %rsi
callq 0x30850
movsd %xmm0, 0x238(%rsp)
movq 0x328(%rsp), %rsi
movq 0x318(%rsp), %rdx
leaq 0x220(%rsp), %rdi
callq 0x93270
leaq 0x220(%rsp), %rdi
callq 0x947d0
movq 0x40(%rsp), %rax
movq (%rax), %rdi
movq 0x3d8(%rsp), %rsi
callq 0x17fd0
movq %rax, %rsi
leaq 0x208(%rsp), %rdi
leaq 0x220(%rsp), %rdx
callq 0x94eb0
movq 0x318(%rsp), %rsi
leaq 0x1e8(%rsp), %rdi
leaq 0x208(%rsp), %rdx
callq 0x90650
leaq 0x1e8(%rsp), %rdi
leaq 0x300(%rsp), %rsi
callq 0x30850
movsd %xmm0, 0x1e0(%rsp)
movsd 0x290(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x1c935
movsd 0x238(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x1c935
movsd 0x1e0(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x1c935
movsd 0x350(%rsp), %xmm0
ucomisd 0x3a0(%rsp), %xmm0
jb 0x1c930
movq 0x3a8(%rsp), %rax
movl $0x3, (%rax)
movq 0x3d8(%rsp), %rcx
movq 0x3a8(%rsp), %rax
movq %rcx, 0x18(%rax)
movq 0x3a8(%rsp), %rdi
addq $0x20, %rdi
leaq 0x300(%rsp), %rsi
callq 0x935a0
movsd 0x350(%rsp), %xmm0
movq 0x398(%rsp), %rax
movsd %xmm0, (%rax)
movsd 0x290(%rsp), %xmm1
movsd 0x238(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x1c8c5
movsd 0x290(%rsp), %xmm1
movsd 0x1e0(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x1c893
movq 0x40(%rsp), %rax
movq (%rax), %rdi
movq 0x3d8(%rsp), %rsi
xorl %edx, %edx
callq 0x218b0
movq %rax, 0x28(%rsp)
jmp 0x1c8b2
movq 0x40(%rsp), %rax
movq (%rax), %rdi
movq 0x3d8(%rsp), %rsi
movl $0x2, %edx
callq 0x218b0
movq %rax, 0x28(%rsp)
movq 0x28(%rsp), %rcx
movq 0x3a8(%rsp), %rax
movq %rcx, 0x10(%rax)
jmp 0x1c92e
movsd 0x238(%rsp), %xmm1
movsd 0x1e0(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x1c8fe
movq 0x40(%rsp), %rax
movq (%rax), %rdi
movq 0x3d8(%rsp), %rsi
movl $0x1, %edx
callq 0x218b0
movq %rax, 0x20(%rsp)
jmp 0x1c91d
movq 0x40(%rsp), %rax
movq (%rax), %rdi
movq 0x3d8(%rsp), %rsi
movl $0x2, %edx
callq 0x218b0
movq %rax, 0x20(%rsp)
movq 0x20(%rsp), %rcx
movq 0x3a8(%rsp), %rax
movq %rcx, 0x10(%rax)
jmp 0x1c930
jmp 0x1d295
xorps %xmm0, %xmm0
ucomisd 0x290(%rsp), %xmm0
jbe 0x1cc5a
movq 0x320(%rsp), %rsi
movq 0x328(%rsp), %rdx
leaq 0x1c8(%rsp), %rdi
callq 0x93270
leaq 0x1c8(%rsp), %rdi
callq 0x94250
movsd %xmm0, 0x1c0(%rsp)
movsd 0x1c0(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x1cc58
movsd 0x1c0(%rsp), %xmm0
leaq 0x1c8(%rsp), %rdi
callq 0x95280
movq 0x328(%rsp), %rdx
leaq 0x1a8(%rsp), %rdi
leaq 0x300(%rsp), %rsi
callq 0x93270
leaq 0x1c8(%rsp), %rdi
leaq 0x1a8(%rsp), %rsi
callq 0x94680
movsd %xmm0, 0x1a0(%rsp)
xorps %xmm0, %xmm0
ucomisd 0x1a0(%rsp), %xmm0
jb 0x1ca9a
movq 0x40(%rsp), %rdi
movq 0x3b8(%rsp), %rsi
movq 0x328(%rsp), %rdx
callq 0x1d2a0
movsd %xmm0, 0x198(%rsp)
movsd 0x198(%rsp), %xmm0
ucomisd 0x3a0(%rsp), %xmm0
jb 0x1ca95
movsd 0x198(%rsp), %xmm1
movq 0x398(%rsp), %rax
movsd (%rax), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x1ca95
movq 0x3a8(%rsp), %rax
movl $0x1, (%rax)
movq 0x340(%rsp), %rcx
movq 0x3a8(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x328(%rsp), %rsi
movq 0x3a8(%rsp), %rdi
addq $0x20, %rdi
callq 0x935a0
movsd 0x198(%rsp), %xmm0
movq 0x398(%rsp), %rax
movsd %xmm0, (%rax)
jmp 0x1cc56
movsd 0x1a0(%rsp), %xmm0
ucomisd 0x1c0(%rsp), %xmm0
jb 0x1cb59
movq 0x40(%rsp), %rdi
movq 0x3b8(%rsp), %rsi
movq 0x320(%rsp), %rdx
callq 0x1d2a0
movsd %xmm0, 0x190(%rsp)
movsd 0x190(%rsp), %xmm0
ucomisd 0x3a0(%rsp), %xmm0
jb 0x1cb54
movsd 0x190(%rsp), %xmm1
movq 0x398(%rsp), %rax
movsd (%rax), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x1cb54
movq 0x3a8(%rsp), %rax
movl $0x1, (%rax)
movq 0x338(%rsp), %rcx
movq 0x3a8(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x320(%rsp), %rsi
movq 0x3a8(%rsp), %rdi
addq $0x20, %rdi
callq 0x935a0
movsd 0x190(%rsp), %xmm0
movq 0x398(%rsp), %rax
movsd %xmm0, (%rax)
jmp 0x1cc54
movq 0x328(%rsp), %rax
movq %rax, 0x18(%rsp)
movsd 0x1a0(%rsp), %xmm0
leaq 0x160(%rsp), %rdi
leaq 0x1c8(%rsp), %rsi
callq 0x17f90
movq 0x18(%rsp), %rsi
leaq 0x178(%rsp), %rdi
leaq 0x160(%rsp), %rdx
callq 0x934d0
movq 0x40(%rsp), %rdi
movq 0x3b8(%rsp), %rsi
leaq 0x178(%rsp), %rdx
callq 0x1d2a0
movsd %xmm0, 0x158(%rsp)
movsd 0x158(%rsp), %xmm0
ucomisd 0x3a0(%rsp), %xmm0
jb 0x1cc52
movsd 0x158(%rsp), %xmm1
movq 0x398(%rsp), %rax
movsd (%rax), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x1cc52
movq 0x40(%rsp), %rax
movq 0x3a8(%rsp), %rcx
movl $0x2, (%rcx)
movq (%rax), %rdi
movq 0x3d8(%rsp), %rsi
xorl %edx, %edx
callq 0x218b0
movq %rax, %rcx
movq 0x3a8(%rsp), %rax
movq %rcx, 0x10(%rax)
movq 0x3a8(%rsp), %rdi
addq $0x20, %rdi
leaq 0x178(%rsp), %rsi
callq 0x935a0
movsd 0x158(%rsp), %xmm0
movq 0x398(%rsp), %rax
movsd %xmm0, (%rax)
jmp 0x1cc54
jmp 0x1cc56
jmp 0x1cc58
jmp 0x1cc5a
xorps %xmm0, %xmm0
ucomisd 0x238(%rsp), %xmm0
jbe 0x1cf86
movq 0x318(%rsp), %rsi
movq 0x320(%rsp), %rdx
leaq 0x140(%rsp), %rdi
callq 0x93270
leaq 0x140(%rsp), %rdi
callq 0x94250
movsd %xmm0, 0x138(%rsp)
movsd 0x138(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x1cf84
movsd 0x138(%rsp), %xmm0
leaq 0x140(%rsp), %rdi
callq 0x95280
movq 0x320(%rsp), %rdx
leaq 0x120(%rsp), %rdi
leaq 0x300(%rsp), %rsi
callq 0x93270
leaq 0x140(%rsp), %rdi
leaq 0x120(%rsp), %rsi
callq 0x94680
movsd %xmm0, 0x118(%rsp)
xorps %xmm0, %xmm0
ucomisd 0x118(%rsp), %xmm0
jb 0x1cdbf
movq 0x40(%rsp), %rdi
movq 0x3b8(%rsp), %rsi
movq 0x320(%rsp), %rdx
callq 0x1d2a0
movsd %xmm0, 0x110(%rsp)
movsd 0x110(%rsp), %xmm0
ucomisd 0x3a0(%rsp), %xmm0
jb 0x1cdba
movsd 0x110(%rsp), %xmm1
movq 0x398(%rsp), %rax
movsd (%rax), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x1cdba
movq 0x3a8(%rsp), %rax
movl $0x1, (%rax)
movq 0x338(%rsp), %rcx
movq 0x3a8(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x320(%rsp), %rsi
movq 0x3a8(%rsp), %rdi
addq $0x20, %rdi
callq 0x935a0
movsd 0x110(%rsp), %xmm0
movq 0x398(%rsp), %rax
movsd %xmm0, (%rax)
jmp 0x1cf82
movsd 0x118(%rsp), %xmm0
ucomisd 0x138(%rsp), %xmm0
jb 0x1ce7e
movq 0x40(%rsp), %rdi
movq 0x3b8(%rsp), %rsi
movq 0x318(%rsp), %rdx
callq 0x1d2a0
movsd %xmm0, 0x108(%rsp)
movsd 0x108(%rsp), %xmm0
ucomisd 0x3a0(%rsp), %xmm0
jb 0x1ce79
movsd 0x108(%rsp), %xmm1
movq 0x398(%rsp), %rax
movsd (%rax), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x1ce79
movq 0x3a8(%rsp), %rax
movl $0x1, (%rax)
movq 0x330(%rsp), %rcx
movq 0x3a8(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x318(%rsp), %rsi
movq 0x3a8(%rsp), %rdi
addq $0x20, %rdi
callq 0x935a0
movsd 0x108(%rsp), %xmm0
movq 0x398(%rsp), %rax
movsd %xmm0, (%rax)
jmp 0x1cf80
movq 0x320(%rsp), %rax
movq %rax, 0x10(%rsp)
movsd 0x118(%rsp), %xmm0
leaq 0xd8(%rsp), %rdi
leaq 0x140(%rsp), %rsi
callq 0x17f90
movq 0x10(%rsp), %rsi
leaq 0xf0(%rsp), %rdi
leaq 0xd8(%rsp), %rdx
callq 0x934d0
movq 0x40(%rsp), %rdi
movq 0x3b8(%rsp), %rsi
leaq 0xf0(%rsp), %rdx
callq 0x1d2a0
movsd %xmm0, 0xd0(%rsp)
movsd 0xd0(%rsp), %xmm0
ucomisd 0x3a0(%rsp), %xmm0
jb 0x1cf7e
movsd 0xd0(%rsp), %xmm1
movq 0x398(%rsp), %rax
movsd (%rax), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x1cf7e
movq 0x40(%rsp), %rax
movq 0x3a8(%rsp), %rcx
movl $0x2, (%rcx)
movq (%rax), %rdi
movq 0x3d8(%rsp), %rsi
movl $0x1, %edx
callq 0x218b0
movq %rax, %rcx
movq 0x3a8(%rsp), %rax
movq %rcx, 0x10(%rax)
movq 0x3a8(%rsp), %rdi
addq $0x20, %rdi
leaq 0xf0(%rsp), %rsi
callq 0x935a0
movsd 0xd0(%rsp), %xmm0
movq 0x398(%rsp), %rax
movsd %xmm0, (%rax)
jmp 0x1cf80
jmp 0x1cf82
jmp 0x1cf84
jmp 0x1cf86
xorps %xmm0, %xmm0
ucomisd 0x1e0(%rsp), %xmm0
jbe 0x1d293
movq 0x328(%rsp), %rsi
movq 0x318(%rsp), %rdx
leaq 0xb8(%rsp), %rdi
callq 0x93270
leaq 0xb8(%rsp), %rdi
callq 0x94250
movsd %xmm0, 0xb0(%rsp)
movsd 0xb0(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x1d291
movsd 0xb0(%rsp), %xmm0
leaq 0xb8(%rsp), %rdi
callq 0x95280
movq 0x318(%rsp), %rdx
leaq 0x98(%rsp), %rdi
leaq 0x300(%rsp), %rsi
callq 0x93270
leaq 0xb8(%rsp), %rdi
leaq 0x98(%rsp), %rsi
callq 0x94680
movsd %xmm0, 0x90(%rsp)
xorps %xmm0, %xmm0
ucomisd 0x90(%rsp), %xmm0
jb 0x1d0eb
movq 0x40(%rsp), %rdi
movq 0x3b8(%rsp), %rsi
movq 0x318(%rsp), %rdx
callq 0x1d2a0
movsd %xmm0, 0x88(%rsp)
movsd 0x88(%rsp), %xmm0
ucomisd 0x3a0(%rsp), %xmm0
jb 0x1d0e6
movsd 0x88(%rsp), %xmm1
movq 0x398(%rsp), %rax
movsd (%rax), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x1d0e6
movq 0x3a8(%rsp), %rax
movl $0x1, (%rax)
movq 0x330(%rsp), %rcx
movq 0x3a8(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x318(%rsp), %rsi
movq 0x3a8(%rsp), %rdi
addq $0x20, %rdi
callq 0x935a0
movsd 0x88(%rsp), %xmm0
movq 0x398(%rsp), %rax
movsd %xmm0, (%rax)
jmp 0x1d28f
movsd 0x90(%rsp), %xmm0
ucomisd 0xb0(%rsp), %xmm0
jb 0x1d1aa
movq 0x40(%rsp), %rdi
movq 0x3b8(%rsp), %rsi
movq 0x328(%rsp), %rdx
callq 0x1d2a0
movsd %xmm0, 0x80(%rsp)
movsd 0x80(%rsp), %xmm0
ucomisd 0x3a0(%rsp), %xmm0
jb 0x1d1a5
movsd 0x80(%rsp), %xmm1
movq 0x398(%rsp), %rax
movsd (%rax), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x1d1a5
movq 0x3a8(%rsp), %rax
movl $0x1, (%rax)
movq 0x340(%rsp), %rcx
movq 0x3a8(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x328(%rsp), %rsi
movq 0x3a8(%rsp), %rdi
addq $0x20, %rdi
callq 0x935a0
movsd 0x80(%rsp), %xmm0
movq 0x398(%rsp), %rax
movsd %xmm0, (%rax)
jmp 0x1d28d
movq 0x318(%rsp), %rax
movq %rax, 0x8(%rsp)
movsd 0x90(%rsp), %xmm0
leaq 0x50(%rsp), %rdi
leaq 0xb8(%rsp), %rsi
callq 0x17f90
movq 0x8(%rsp), %rsi
leaq 0x68(%rsp), %rdi
leaq 0x50(%rsp), %rdx
callq 0x934d0
movq 0x40(%rsp), %rdi
movq 0x3b8(%rsp), %rsi
leaq 0x68(%rsp), %rdx
callq 0x1d2a0
movsd %xmm0, 0x48(%rsp)
movsd 0x48(%rsp), %xmm0
ucomisd 0x3a0(%rsp), %xmm0
jb 0x1d28b
movsd 0x48(%rsp), %xmm1
movq 0x398(%rsp), %rax
movsd (%rax), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x1d28b
movq 0x40(%rsp), %rax
movq 0x3a8(%rsp), %rcx
movl $0x2, (%rcx)
movq (%rax), %rdi
movq 0x3d8(%rsp), %rsi
movl $0x2, %edx
callq 0x218b0
movq %rax, %rcx
movq 0x3a8(%rsp), %rax
movq %rcx, 0x10(%rax)
movq 0x3a8(%rsp), %rdi
addq $0x20, %rdi
leaq 0x68(%rsp), %rsi
callq 0x935a0
movsd 0x48(%rsp), %xmm0
movq 0x398(%rsp), %rax
movsd %xmm0, (%rax)
jmp 0x1d28d
jmp 0x1d28f
jmp 0x1d291
jmp 0x1d293
jmp 0x1d295
jmp 0x1d297
addq $0x3c8, %rsp            # imm = 0x3C8
retq
nop