def iterative_s(l, x):
  """Searches for x in sorted list l, returning the index of x or None.

  Assumes that l only contains distinct values. If l contains duplicate x
  values then an arbitrary matching index will be returned.

  Iterative implementation.
  """
  if not l:
    return
  if len(l) == 1:
    return 0 if l[0] == x else None

  low = 0
  high = len(l) - 1
  mid = (high - low) // 2

  while low <= high:
    if x > l[mid]:
      low = mid + 1
    elif x < l[mid]:
      high = mid - 1
    else:
      return mid
    mid = low + ((high - low) // 2)