// File: tomfunkhouser[P]gaps/pkgs/R3Shapes/R3MeshSearchTree.cpp
// Function: gaps::R3MeshSearchTree::FindAll(gaps::R3Point const&, gaps::R3Vector const&, gaps::RNArray<gaps::R3MeshIntersection*>&, double, double, int (*)(gaps::R3Point const&, gaps::R3Vector const&, gaps::R3Mesh*, gaps::R3MeshFace*, void*), void*, gaps::R3MeshFace*) const
void R3MeshSearchTree::
FindAll(const R3Point& query_position, const R3Vector& query_normal, RNArray<R3MeshIntersection *>& hits, 
  RNScalar min_distance_squared, RNScalar max_distance_squared, 
  int (*IsCompatible)(const R3Point&, const R3Vector&, R3Mesh *, R3MeshFace *, void *), void *compatible_data,
  R3MeshFace *face) const
{
  // Initialize hit info
  R3MeshIntersection hit;
  hit.type = R3_MESH_NULL_TYPE;

  // 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)) {
      hit.type = R3_MESH_FACE_TYPE;
      hit.face = face;
      hit.point = p;
    }
  }
  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
    const R3Vector& face_normal = mesh->FaceNormal(face);
    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) {
        hit.type = R3_MESH_FACE_TYPE;
        hit.vertex = NULL;
        hit.edge = NULL;
        hit.face = face;
        hit.point = plane_point;
        hit.t = sqrt(plane_distance_squared);
      }
    }
    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)) {
              hit.type = R3_MESH_VERTEX_TYPE;
              hit.vertex = v0;
              hit.edge = mesh->EdgeOnVertex(hit.vertex, face);
              hit.face = face;
              hit.point = p0;
              hit.t = sqrt(distance_squared);
              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)) {
              hit.type = R3_MESH_VERTEX_TYPE;
              hit.vertex = v1;
              hit.edge = mesh->EdgeOnVertex(hit.vertex, face);
              hit.face = face;
              hit.point = p1;
              hit.t = sqrt(distance_squared);
              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)) {
              hit.type = R3_MESH_EDGE_TYPE;
              hit.vertex = NULL;
              hit.edge = mesh->EdgeOnFace(face, 0);
              hit.face = face;
              hit.point = point;
              hit.t = sqrt(distance_squared);
              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)) {
              hit.type = R3_MESH_VERTEX_TYPE;
              hit.vertex = v1;
              hit.edge = mesh->EdgeOnVertex(hit.vertex, face);
              hit.face = face;
              hit.point = p1;
              hit.t = sqrt(distance_squared);
              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)) {
              hit.type = R3_MESH_VERTEX_TYPE;
              hit.vertex = v2;
              hit.edge = mesh->EdgeOnVertex(hit.vertex, face);
              hit.face = face;
              hit.point = p2;
              hit.t = sqrt(distance_squared);
              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)) {
              hit.type = R3_MESH_EDGE_TYPE;
              hit.vertex = NULL;
              hit.edge = mesh->EdgeOnFace(face, 1);
              hit.face = face;
              hit.point = point;
              hit.t = sqrt(distance_squared);
              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)) {
              hit.type = R3_MESH_VERTEX_TYPE;
              hit.vertex = v2;
              hit.edge = mesh->EdgeOnVertex(hit.vertex, face);
              hit.face = face;
              hit.point = p2;
              hit.t = sqrt(distance_squared);
              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)) {
              hit.type = R3_MESH_VERTEX_TYPE;
              hit.vertex = v0;
              hit.edge = mesh->EdgeOnVertex(hit.vertex, face);
              hit.face = face;
              hit.point = p0;
              hit.t = sqrt(distance_squared);
              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)) {
              hit.type = R3_MESH_EDGE_TYPE;
              hit.vertex = NULL;
              hit.edge = mesh->EdgeOnFace(face, 2);
              hit.face = face;
              hit.point = point;
              hit.t = sqrt(distance_squared);
              max_distance_squared = distance_squared;
            }
          }
        }
      }
    }
  }
  
  // Insert hit
  if (hit.type != R3_MESH_NULL_TYPE) {
    hits.Insert(new R3MeshIntersection(hit));
  }
}

// Assembly:
subq $0x428, %rsp            # imm = 0x428
movq 0x430(%rsp), %rax
movq %rdi, 0x420(%rsp)
movq %rsi, 0x418(%rsp)
movq %rdx, 0x410(%rsp)
movq %rcx, 0x408(%rsp)
movsd %xmm0, 0x400(%rsp)
movsd %xmm1, 0x3f8(%rsp)
movq %r8, 0x3f0(%rsp)
movq %r9, 0x3e8(%rsp)
movq 0x420(%rsp), %rax
movq %rax, 0x40(%rsp)
leaq 0x3a8(%rsp), %rdi
callq 0x17ed0
movq 0x40(%rsp), %rax
movl $0x0, 0x3a8(%rsp)
movq (%rax), %rdi
movq 0x430(%rsp), %rsi
callq 0x17fd0
movq %rax, 0x3a0(%rsp)
movq 0x3a0(%rsp), %rdi
movq 0x3a0(%rsp), %rsi
callq 0x94680
leaq 0x167ed1(%rip), %rax    # 0x1864f0
movsd (%rax), %xmm1
callq 0x1b080
cmpl $0x0, %eax
je 0x1e6d6
movq 0x40(%rsp), %rax
movq (%rax), %rsi
movq 0x430(%rsp), %rdx
leaq 0x388(%rsp), %rdi
callq 0x37790
movq 0x40(%rsp), %rdi
movq 0x418(%rsp), %rsi
leaq 0x388(%rsp), %rdx
callq 0x1d2a0
movsd %xmm0, 0x380(%rsp)
movsd 0x380(%rsp), %xmm0
ucomisd 0x400(%rsp), %xmm0
jb 0x1e6d1
movsd 0x380(%rsp), %xmm1
movsd 0x3f8(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x1e6d1
movl $0x3, 0x3a8(%rsp)
movq 0x430(%rsp), %rax
movq %rax, 0x3c0(%rsp)
leaq 0x3a8(%rsp), %rdi
addq $0x20, %rdi
leaq 0x388(%rsp), %rsi
callq 0x935a0
jmp 0x1f71d
movq 0x40(%rsp), %rax
movq (%rax), %rdi
movq 0x430(%rsp), %rsi
callq 0x18070
movq %rax, 0x378(%rsp)
movq 0x378(%rsp), %rdi
movq 0x418(%rsp), %rsi
callq 0x30850
movsd %xmm0, 0x370(%rsp)
movsd 0x370(%rsp), %xmm0
mulsd 0x370(%rsp), %xmm0
movsd %xmm0, 0x368(%rsp)
movsd 0x368(%rsp), %xmm0
ucomisd 0x3f8(%rsp), %xmm0
jb 0x1e745
jmp 0x1f788
movq 0x40(%rsp), %rax
movq 0x418(%rsp), %rcx
movq %rcx, 0x38(%rsp)
movq (%rax), %rdi
movq 0x430(%rsp), %rsi
callq 0x3a630
movq 0x40(%rsp), %rdi
movq 0x38(%rsp), %rsi
movq %rax, %rdx
movsd 0x3f8(%rsp), %xmm0
callq 0x1d390
movsd %xmm0, 0x360(%rsp)
movsd 0x360(%rsp), %xmm0
ucomisd 0x3f8(%rsp), %xmm0
jb 0x1e7a4
jmp 0x1f788
cmpq $0x0, 0x3f0(%rsp)
je 0x1e7ed
movq 0x40(%rsp), %rcx
movq 0x3f0(%rsp), %rax
movq 0x418(%rsp), %rdi
movq 0x410(%rsp), %rsi
movq (%rcx), %rdx
movq 0x430(%rsp), %rcx
movq 0x3e8(%rsp), %r8
callq *%rax
cmpl $0x0, %eax
jne 0x1e7eb
jmp 0x1f788
jmp 0x1e7ed
movq 0x40(%rsp), %rax
movq (%rax), %rdi
movq 0x430(%rsp), %rsi
xorl %edx, %edx
callq 0x17a60
movq %rax, %rcx
movq 0x40(%rsp), %rax
movq %rcx, 0x358(%rsp)
movq (%rax), %rdi
movq 0x430(%rsp), %rsi
movl $0x1, %edx
callq 0x17a60
movq %rax, %rcx
movq 0x40(%rsp), %rax
movq %rcx, 0x350(%rsp)
movq (%rax), %rdi
movq 0x430(%rsp), %rsi
movl $0x2, %edx
callq 0x17a60
movq %rax, %rcx
movq 0x40(%rsp), %rax
movq %rcx, 0x348(%rsp)
movq (%rax), %rdi
movq 0x358(%rsp), %rsi
callq 0x17a40
movq %rax, %rcx
movq 0x40(%rsp), %rax
movq %rcx, 0x340(%rsp)
movq (%rax), %rdi
movq 0x350(%rsp), %rsi
callq 0x17a40
movq %rax, %rcx
movq 0x40(%rsp), %rax
movq %rcx, 0x338(%rsp)
movq (%rax), %rdi
movq 0x348(%rsp), %rsi
callq 0x17a40
movq %rax, %rcx
movq 0x40(%rsp), %rax
movq %rcx, 0x330(%rsp)
movq (%rax), %rdi
movq 0x430(%rsp), %rsi
callq 0x17fd0
movq %rax, 0x328(%rsp)
movq 0x418(%rsp), %rax
movq %rax, 0x30(%rsp)
movsd 0x370(%rsp), %xmm0
movq 0x328(%rsp), %rsi
leaq 0x2f8(%rsp), %rdi
callq 0x17f90
movq 0x30(%rsp), %rsi
leaq 0x310(%rsp), %rdi
leaq 0x2f8(%rsp), %rdx
callq 0x93e70
movq 0x338(%rsp), %rsi
movq 0x340(%rsp), %rdx
leaq 0x2e0(%rsp), %rdi
callq 0x93270
leaq 0x2e0(%rsp), %rdi
callq 0x947d0
movq 0x40(%rsp), %rax
movq (%rax), %rdi
movq 0x430(%rsp), %rsi
callq 0x17fd0
movq %rax, %rsi
leaq 0x2c8(%rsp), %rdi
leaq 0x2e0(%rsp), %rdx
callq 0x94eb0
movq 0x340(%rsp), %rsi
leaq 0x2a8(%rsp), %rdi
leaq 0x2c8(%rsp), %rdx
callq 0x90650
leaq 0x2a8(%rsp), %rdi
leaq 0x310(%rsp), %rsi
callq 0x30850
movsd %xmm0, 0x2a0(%rsp)
movq 0x330(%rsp), %rsi
movq 0x338(%rsp), %rdx
leaq 0x288(%rsp), %rdi
callq 0x93270
leaq 0x288(%rsp), %rdi
callq 0x947d0
movq 0x40(%rsp), %rax
movq (%rax), %rdi
movq 0x430(%rsp), %rsi
callq 0x17fd0
movq %rax, %rsi
leaq 0x270(%rsp), %rdi
leaq 0x288(%rsp), %rdx
callq 0x94eb0
movq 0x338(%rsp), %rsi
leaq 0x250(%rsp), %rdi
leaq 0x270(%rsp), %rdx
callq 0x90650
leaq 0x250(%rsp), %rdi
leaq 0x310(%rsp), %rsi
callq 0x30850
movsd %xmm0, 0x248(%rsp)
movq 0x340(%rsp), %rsi
movq 0x330(%rsp), %rdx
leaq 0x230(%rsp), %rdi
callq 0x93270
leaq 0x230(%rsp), %rdi
callq 0x947d0
movq 0x40(%rsp), %rax
movq (%rax), %rdi
movq 0x430(%rsp), %rsi
callq 0x17fd0
movq %rax, %rsi
leaq 0x218(%rsp), %rdi
leaq 0x230(%rsp), %rdx
callq 0x94eb0
movq 0x330(%rsp), %rsi
leaq 0x1f8(%rsp), %rdi
leaq 0x218(%rsp), %rdx
callq 0x90650
leaq 0x1f8(%rsp), %rdi
leaq 0x310(%rsp), %rsi
callq 0x30850
movsd %xmm0, 0x1f0(%rsp)
movsd 0x2a0(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x1eb8b
movsd 0x248(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x1eb8b
movsd 0x1f0(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x1eb8b
movsd 0x368(%rsp), %xmm0
ucomisd 0x400(%rsp), %xmm0
jb 0x1eb86
movl $0x3, 0x3a8(%rsp)
movq $0x0, 0x3b0(%rsp)
movq $0x0, 0x3b8(%rsp)
movq 0x430(%rsp), %rax
movq %rax, 0x3c0(%rsp)
leaq 0x3a8(%rsp), %rdi
addq $0x20, %rdi
leaq 0x310(%rsp), %rsi
callq 0x935a0
movsd 0x368(%rsp), %xmm0
callq 0xf390
movsd %xmm0, 0x3e0(%rsp)
jmp 0x1f71b
xorps %xmm0, %xmm0
ucomisd 0x2a0(%rsp), %xmm0
jbe 0x1ef6d
movq 0x338(%rsp), %rsi
movq 0x340(%rsp), %rdx
leaq 0x1d8(%rsp), %rdi
callq 0x93270
leaq 0x1d8(%rsp), %rdi
callq 0x94250
movsd %xmm0, 0x1d0(%rsp)
movsd 0x1d0(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x1ef6b
movsd 0x1d0(%rsp), %xmm0
leaq 0x1d8(%rsp), %rdi
callq 0x95280
movq 0x340(%rsp), %rdx
leaq 0x1b8(%rsp), %rdi
leaq 0x310(%rsp), %rsi
callq 0x93270
leaq 0x1d8(%rsp), %rdi
leaq 0x1b8(%rsp), %rsi
callq 0x94680
movsd %xmm0, 0x1b0(%rsp)
xorps %xmm0, %xmm0
ucomisd 0x1b0(%rsp), %xmm0
jb 0x1ed39
movq 0x40(%rsp), %rdi
movq 0x418(%rsp), %rsi
movq 0x340(%rsp), %rdx
callq 0x1d2a0
movsd %xmm0, 0x1a8(%rsp)
movsd 0x1a8(%rsp), %xmm0
ucomisd 0x400(%rsp), %xmm0
jb 0x1ed34
movsd 0x1a8(%rsp), %xmm1
movsd 0x3f8(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x1ed34
movq 0x40(%rsp), %rax
movl $0x1, 0x3a8(%rsp)
movq 0x358(%rsp), %rcx
movq %rcx, 0x3b0(%rsp)
movq (%rax), %rdi
movq 0x3b0(%rsp), %rsi
movq 0x430(%rsp), %rdx
xorl %ecx, %ecx
callq 0x3aae0
movq %rax, 0x3b8(%rsp)
movq 0x430(%rsp), %rax
movq %rax, 0x3c0(%rsp)
movq 0x340(%rsp), %rsi
leaq 0x3a8(%rsp), %rdi
addq $0x20, %rdi
callq 0x935a0
movsd 0x1a8(%rsp), %xmm0
callq 0xf390
movsd %xmm0, 0x3e0(%rsp)
movsd 0x1a8(%rsp), %xmm0
movsd %xmm0, 0x3f8(%rsp)
jmp 0x1ef69
movsd 0x1b0(%rsp), %xmm0
ucomisd 0x1d0(%rsp), %xmm0
jb 0x1ee41
movq 0x40(%rsp), %rdi
movq 0x418(%rsp), %rsi
movq 0x338(%rsp), %rdx
callq 0x1d2a0
movsd %xmm0, 0x1a0(%rsp)
movsd 0x1a0(%rsp), %xmm0
ucomisd 0x400(%rsp), %xmm0
jb 0x1ee3c
movsd 0x1a0(%rsp), %xmm1
movsd 0x3f8(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x1ee3c
movq 0x40(%rsp), %rax
movl $0x1, 0x3a8(%rsp)
movq 0x350(%rsp), %rcx
movq %rcx, 0x3b0(%rsp)
movq (%rax), %rdi
movq 0x3b0(%rsp), %rsi
movq 0x430(%rsp), %rdx
xorl %ecx, %ecx
callq 0x3aae0
movq %rax, 0x3b8(%rsp)
movq 0x430(%rsp), %rax
movq %rax, 0x3c0(%rsp)
movq 0x338(%rsp), %rsi
leaq 0x3a8(%rsp), %rdi
addq $0x20, %rdi
callq 0x935a0
movsd 0x1a0(%rsp), %xmm0
callq 0xf390
movsd %xmm0, 0x3e0(%rsp)
movsd 0x1a0(%rsp), %xmm0
movsd %xmm0, 0x3f8(%rsp)
jmp 0x1ef67
movq 0x340(%rsp), %rax
movq %rax, 0x28(%rsp)
movsd 0x1b0(%rsp), %xmm0
leaq 0x170(%rsp), %rdi
leaq 0x1d8(%rsp), %rsi
callq 0x17f90
movq 0x28(%rsp), %rsi
leaq 0x188(%rsp), %rdi
leaq 0x170(%rsp), %rdx
callq 0x934d0
movq 0x40(%rsp), %rdi
movq 0x418(%rsp), %rsi
leaq 0x188(%rsp), %rdx
callq 0x1d2a0
movsd %xmm0, 0x168(%rsp)
movsd 0x168(%rsp), %xmm0
ucomisd 0x400(%rsp), %xmm0
jb 0x1ef65
movsd 0x168(%rsp), %xmm1
movsd 0x3f8(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x1ef65
movq 0x40(%rsp), %rax
movl $0x2, 0x3a8(%rsp)
movq $0x0, 0x3b0(%rsp)
movq (%rax), %rdi
movq 0x430(%rsp), %rsi
xorl %edx, %edx
callq 0x218b0
movq %rax, 0x3b8(%rsp)
movq 0x430(%rsp), %rax
movq %rax, 0x3c0(%rsp)
leaq 0x3a8(%rsp), %rdi
addq $0x20, %rdi
leaq 0x188(%rsp), %rsi
callq 0x935a0
movsd 0x168(%rsp), %xmm0
callq 0xf390
movsd %xmm0, 0x3e0(%rsp)
movsd 0x168(%rsp), %xmm0
movsd %xmm0, 0x3f8(%rsp)
jmp 0x1ef67
jmp 0x1ef69
jmp 0x1ef6b
jmp 0x1ef6d
xorps %xmm0, %xmm0
ucomisd 0x248(%rsp), %xmm0
jbe 0x1f352
movq 0x330(%rsp), %rsi
movq 0x338(%rsp), %rdx
leaq 0x150(%rsp), %rdi
callq 0x93270
leaq 0x150(%rsp), %rdi
callq 0x94250
movsd %xmm0, 0x148(%rsp)
movsd 0x148(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x1f350
movsd 0x148(%rsp), %xmm0
leaq 0x150(%rsp), %rdi
callq 0x95280
movq 0x338(%rsp), %rdx
leaq 0x130(%rsp), %rdi
leaq 0x310(%rsp), %rsi
callq 0x93270
leaq 0x150(%rsp), %rdi
leaq 0x130(%rsp), %rsi
callq 0x94680
movsd %xmm0, 0x128(%rsp)
xorps %xmm0, %xmm0
ucomisd 0x128(%rsp), %xmm0
jb 0x1f11b
movq 0x40(%rsp), %rdi
movq 0x418(%rsp), %rsi
movq 0x338(%rsp), %rdx
callq 0x1d2a0
movsd %xmm0, 0x120(%rsp)
movsd 0x120(%rsp), %xmm0
ucomisd 0x400(%rsp), %xmm0
jb 0x1f116
movsd 0x120(%rsp), %xmm1
movsd 0x3f8(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x1f116
movq 0x40(%rsp), %rax
movl $0x1, 0x3a8(%rsp)
movq 0x350(%rsp), %rcx
movq %rcx, 0x3b0(%rsp)
movq (%rax), %rdi
movq 0x3b0(%rsp), %rsi
movq 0x430(%rsp), %rdx
xorl %ecx, %ecx
callq 0x3aae0
movq %rax, 0x3b8(%rsp)
movq 0x430(%rsp), %rax
movq %rax, 0x3c0(%rsp)
movq 0x338(%rsp), %rsi
leaq 0x3a8(%rsp), %rdi
addq $0x20, %rdi
callq 0x935a0
movsd 0x120(%rsp), %xmm0
callq 0xf390
movsd %xmm0, 0x3e0(%rsp)
movsd 0x120(%rsp), %xmm0
movsd %xmm0, 0x3f8(%rsp)
jmp 0x1f34e
movsd 0x128(%rsp), %xmm0
ucomisd 0x148(%rsp), %xmm0
jb 0x1f223
movq 0x40(%rsp), %rdi
movq 0x418(%rsp), %rsi
movq 0x330(%rsp), %rdx
callq 0x1d2a0
movsd %xmm0, 0x118(%rsp)
movsd 0x118(%rsp), %xmm0
ucomisd 0x400(%rsp), %xmm0
jb 0x1f21e
movsd 0x118(%rsp), %xmm1
movsd 0x3f8(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x1f21e
movq 0x40(%rsp), %rax
movl $0x1, 0x3a8(%rsp)
movq 0x348(%rsp), %rcx
movq %rcx, 0x3b0(%rsp)
movq (%rax), %rdi
movq 0x3b0(%rsp), %rsi
movq 0x430(%rsp), %rdx
xorl %ecx, %ecx
callq 0x3aae0
movq %rax, 0x3b8(%rsp)
movq 0x430(%rsp), %rax
movq %rax, 0x3c0(%rsp)
movq 0x330(%rsp), %rsi
leaq 0x3a8(%rsp), %rdi
addq $0x20, %rdi
callq 0x935a0
movsd 0x118(%rsp), %xmm0
callq 0xf390
movsd %xmm0, 0x3e0(%rsp)
movsd 0x118(%rsp), %xmm0
movsd %xmm0, 0x3f8(%rsp)
jmp 0x1f34c
movq 0x338(%rsp), %rax
movq %rax, 0x20(%rsp)
movsd 0x128(%rsp), %xmm0
leaq 0xe8(%rsp), %rdi
leaq 0x150(%rsp), %rsi
callq 0x17f90
movq 0x20(%rsp), %rsi
leaq 0x100(%rsp), %rdi
leaq 0xe8(%rsp), %rdx
callq 0x934d0
movq 0x40(%rsp), %rdi
movq 0x418(%rsp), %rsi
leaq 0x100(%rsp), %rdx
callq 0x1d2a0
movsd %xmm0, 0xe0(%rsp)
movsd 0xe0(%rsp), %xmm0
ucomisd 0x400(%rsp), %xmm0
jb 0x1f34a
movsd 0xe0(%rsp), %xmm1
movsd 0x3f8(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x1f34a
movq 0x40(%rsp), %rax
movl $0x2, 0x3a8(%rsp)
movq $0x0, 0x3b0(%rsp)
movq (%rax), %rdi
movq 0x430(%rsp), %rsi
movl $0x1, %edx
callq 0x218b0
movq %rax, 0x3b8(%rsp)
movq 0x430(%rsp), %rax
movq %rax, 0x3c0(%rsp)
leaq 0x3a8(%rsp), %rdi
addq $0x20, %rdi
leaq 0x100(%rsp), %rsi
callq 0x935a0
movsd 0xe0(%rsp), %xmm0
callq 0xf390
movsd %xmm0, 0x3e0(%rsp)
movsd 0xe0(%rsp), %xmm0
movsd %xmm0, 0x3f8(%rsp)
jmp 0x1f34c
jmp 0x1f34e
jmp 0x1f350
jmp 0x1f352
xorps %xmm0, %xmm0
ucomisd 0x1f0(%rsp), %xmm0
jbe 0x1f719
movq 0x340(%rsp), %rsi
movq 0x330(%rsp), %rdx
leaq 0xc8(%rsp), %rdi
callq 0x93270
leaq 0xc8(%rsp), %rdi
callq 0x94250
movsd %xmm0, 0xc0(%rsp)
movsd 0xc0(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x1f717
movsd 0xc0(%rsp), %xmm0
leaq 0xc8(%rsp), %rdi
callq 0x95280
movq 0x330(%rsp), %rdx
leaq 0xa8(%rsp), %rdi
leaq 0x310(%rsp), %rsi
callq 0x93270
leaq 0xc8(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
callq 0x94680
movsd %xmm0, 0xa0(%rsp)
xorps %xmm0, %xmm0
ucomisd 0xa0(%rsp), %xmm0
jb 0x1f500
movq 0x40(%rsp), %rdi
movq 0x418(%rsp), %rsi
movq 0x330(%rsp), %rdx
callq 0x1d2a0
movsd %xmm0, 0x98(%rsp)
movsd 0x98(%rsp), %xmm0
ucomisd 0x400(%rsp), %xmm0
jb 0x1f4fb
movsd 0x98(%rsp), %xmm1
movsd 0x3f8(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x1f4fb
movq 0x40(%rsp), %rax
movl $0x1, 0x3a8(%rsp)
movq 0x348(%rsp), %rcx
movq %rcx, 0x3b0(%rsp)
movq (%rax), %rdi
movq 0x3b0(%rsp), %rsi
movq 0x430(%rsp), %rdx
xorl %ecx, %ecx
callq 0x3aae0
movq %rax, 0x3b8(%rsp)
movq 0x430(%rsp), %rax
movq %rax, 0x3c0(%rsp)
movq 0x330(%rsp), %rsi
leaq 0x3a8(%rsp), %rdi
addq $0x20, %rdi
callq 0x935a0
movsd 0x98(%rsp), %xmm0
callq 0xf390
movsd %xmm0, 0x3e0(%rsp)
movsd 0x98(%rsp), %xmm0
movsd %xmm0, 0x3f8(%rsp)
jmp 0x1f715
movsd 0xa0(%rsp), %xmm0
ucomisd 0xc0(%rsp), %xmm0
jb 0x1f608
movq 0x40(%rsp), %rdi
movq 0x418(%rsp), %rsi
movq 0x340(%rsp), %rdx
callq 0x1d2a0
movsd %xmm0, 0x90(%rsp)
movsd 0x90(%rsp), %xmm0
ucomisd 0x400(%rsp), %xmm0
jb 0x1f603
movsd 0x90(%rsp), %xmm1
movsd 0x3f8(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x1f603
movq 0x40(%rsp), %rax
movl $0x1, 0x3a8(%rsp)
movq 0x358(%rsp), %rcx
movq %rcx, 0x3b0(%rsp)
movq (%rax), %rdi
movq 0x3b0(%rsp), %rsi
movq 0x430(%rsp), %rdx
xorl %ecx, %ecx
callq 0x3aae0
movq %rax, 0x3b8(%rsp)
movq 0x430(%rsp), %rax
movq %rax, 0x3c0(%rsp)
movq 0x340(%rsp), %rsi
leaq 0x3a8(%rsp), %rdi
addq $0x20, %rdi
callq 0x935a0
movsd 0x90(%rsp), %xmm0
callq 0xf390
movsd %xmm0, 0x3e0(%rsp)
movsd 0x90(%rsp), %xmm0
movsd %xmm0, 0x3f8(%rsp)
jmp 0x1f713
movq 0x330(%rsp), %rax
movq %rax, 0x18(%rsp)
movsd 0xa0(%rsp), %xmm0
leaq 0x60(%rsp), %rdi
leaq 0xc8(%rsp), %rsi
callq 0x17f90
movq 0x18(%rsp), %rsi
leaq 0x78(%rsp), %rdi
leaq 0x60(%rsp), %rdx
callq 0x934d0
movq 0x40(%rsp), %rdi
movq 0x418(%rsp), %rsi
leaq 0x78(%rsp), %rdx
callq 0x1d2a0
movsd %xmm0, 0x58(%rsp)
movsd 0x58(%rsp), %xmm0
ucomisd 0x400(%rsp), %xmm0
jb 0x1f711
movsd 0x58(%rsp), %xmm1
movsd 0x3f8(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x1f711
movq 0x40(%rsp), %rax
movl $0x2, 0x3a8(%rsp)
movq $0x0, 0x3b0(%rsp)
movq (%rax), %rdi
movq 0x430(%rsp), %rsi
movl $0x2, %edx
callq 0x218b0
movq %rax, 0x3b8(%rsp)
movq 0x430(%rsp), %rax
movq %rax, 0x3c0(%rsp)
leaq 0x3a8(%rsp), %rdi
addq $0x20, %rdi
leaq 0x78(%rsp), %rsi
callq 0x935a0
movsd 0x58(%rsp), %xmm0
callq 0xf390
movsd %xmm0, 0x3e0(%rsp)
movsd 0x58(%rsp), %xmm0
movsd %xmm0, 0x3f8(%rsp)
jmp 0x1f713
jmp 0x1f715
jmp 0x1f717
jmp 0x1f719
jmp 0x1f71b
jmp 0x1f71d
cmpl $0x0, 0x3a8(%rsp)
je 0x1f788
movq 0x408(%rsp), %rax
movq %rax, 0x8(%rsp)
movl $0x40, %edi
callq 0xf4c0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x10(%rsp)
leaq 0x3a8(%rsp), %rsi
callq 0x21a10
jmp 0x1f758
movq 0x10(%rsp), %rsi
movq 0x8(%rsp), %rdi
callq 0x219e0
jmp 0x1f788
movq 0x10(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x50(%rsp)
movl %eax, 0x4c(%rsp)
movl $0x40, %esi
callq 0xf4d0
jmp 0x1f790
addq $0x428, %rsp            # imm = 0x428
retq
movq 0x50(%rsp), %rdi
callq 0xf890
nopw (%rax,%rax)