anchor.diff:      real(c_double) :: uniques(2, num_points)
       integer(c_int) :: num_lower, num_upper
       real(c_double) :: lower(2, num_points), upper(2, num_points)
  -    integer(c_int) :: i, j
  +    integer(c_int) :: i
       real(c_double) :: result_
   
  -    ! First make sure all the points are unique to exact precision.
  -    num_uniques = 0
  -    unique_loop: do i = 1, num_points
  -       point1(1, :) = points(:, i)
  -       do j = 1, num_uniques
  -          if (all(point1(1, :) == uniques(:, j))) then
  -             cycle unique_loop
  -          end if
  -       end do
  -       ! If we haven't cycled, then we know it is unique.
  -       num_uniques = num_uniques + 1
  -       uniques(:, num_uniques) = points(:, i)
  -    end do unique_loop
  +    uniques = points
  +    call sort_in_place(num_points, uniques, num_uniques)
   
       ! In the "boring" case that we have fewer than 2 points, return.
       if (num_uniques == 0) then
  
positive.code: 
    end subroutine min_index
  
    subroutine sort_in_place(num_points, points)
  
      ! NOTE: This is a helper for ``convex_hull``. This does a simple quadratic
      !       sort (i.e. it is suboptimal) because it expects the number of
      !       points to be small.
  
      integer(c_int), intent(in) :: num_points
      real(c_double), intent(inout) :: points(2, num_points)
      ! Variables outside of signature.
      integer(c_int) :: i, match
      real(c_double) :: swap(2)
  
      do i = 1, num_points - 1
         call min_index(num_points + 1 - i, points(:, i:), match)
         ! Shift ``match`` based on the slice ``points(:, i:)``.
         match = match + i - 1
         if (match /= i) then
            swap = points(:, i)
            points(:, i) = points(:, match)
            points(:, match) = swap
         end if
      end do
  
    end subroutine sort_in_place
  
negative.code:        polygon(:, 1) = uniques(:, 1)
         return
      end if
  
      ! First create a "lower" convex hull
      num_lower = 0
  