anchor.diff:    implicit none
     private &
          LocateCandidate, MAX_LOCATE_SUBDIVISIONS, LOCATE_EPS, &
  -       newton_refine_solve, split_candidate
  +       newton_refine_solve, split_candidate, allocate_candidates, &
  +       update_candidates
     public newton_refine, locate_point
   
     ! For ``locate_point``.
  
positive.code:     real(c_double), intent(out) :: s_val, t_val
      ! Variables outside of signature.
      real(c_double) :: point(1, 2)
      integer(c_int) :: sub_index, cand_index
      integer(c_int) :: num_candidates, num_next_candidates
      type(LocateCandidate), allocatable :: candidates(:), next_candidates(:)
      logical(c_bool) :: predicate
      real(c_double) :: s_approx, t_approx
      real(c_double) :: actual(1, 2)
  
      point(1, :) = [x_val, y_val]
      ! Start out with the full curve.
      allocate(candidates(1))
      candidates(1) = LocateCandidate(1.0_dp, 1.0_dp, 1.0_dp, nodes)
      num_candidates = 1
      s_val = LOCATE_MISS
  
      do sub_index = 1, MAX_LOCATE_SUBDIVISIONS + 1
         num_next_candidates = 0
         ! Allocate maximum amount of space needed.
         allocate(next_candidates(4 * num_candidates))
         do cand_index = 1, num_candidates
            call contains_nd( &
                 num_nodes, 2, candidates(cand_index)%nodes, &
                 point(1, :), predicate)
            if (predicate) then
               num_next_candidates = num_next_candidates + 4
               call split_candidate( &
                    num_nodes, degree, candidates(cand_index), &
                    num_next_candidates, next_candidates)
            end if
         end do
  
         ! If there are no more candidates, we are done.
         if (num_next_candidates == 0) then
            return
         end if
  
         ! NOTE: This may copy empty slots, but this is OK since we track
         !       `num_candidates` separately.
         call move_alloc(next_candidates, candidates)
         num_candidates = num_next_candidates
  
      end do
  
negative.code:     ! We divide by `3n` rather than `n` since we have tracked thrice the
      ! centroid rather than the centroid itself (to avoid round-off until
      ! right now).
      if (is_even) then
         ! NOTE: We "exclude" this block from ``lcov`` because it can never
         !       be invoked while ``MAX_LOCATE_SUBDIVISIONS`` is even.
         s_approx = ( &
              sum(candidates_odd(:num_candidates)%centroid_x) / &
              (3.0_dp * num_candidates))  ! LCOV_EXCL_LINE
         t_approx = ( &
              sum(candidates_odd(:num_candidates)%centroid_y) / &
              (3.0_dp * num_candidates))  ! LCOV_EXCL_LINE
      else
         s_approx = ( &
              sum(candidates_even(:num_candidates)%centroid_x) / &
              (3.0_dp * num_candidates))
         t_approx = ( &
              sum(candidates_even(:num_candidates)%centroid_y) / &
              (3.0_dp * num_candidates))
      end if
  
      call newton_refine( &
           num_nodes, nodes, degree, x_val, y_val, &
  