/* Collect all the endpoints in the raw memory ranges. */
VOID CollectEndpoints(IN OUT UINT64 *Endpoints, IN OUT UINT32 *EndPointCount, IN MTRR_MEMORY_RANGE *RawMemoryRanges, IN UINT32 RawMemoryRangeCount)
/* Collect all the endpoints in the raw memory ranges. */
VOID CollectEndpoints(IN OUT UINT64 *Endpoints, IN OUT UINT32 *EndPointCount, IN MTRR_MEMORY_RANGE *RawMemoryRanges, IN UINT32 RawMemoryRangeCount)
{
  UINT32  Index;
  UINT32  RawRangeIndex;
  ASSERT ((RawMemoryRangeCount << 1) == *EndPointCount);
  for (Index = 0; Index < *EndPointCount; Index += 2) {
    RawRangeIndex        = Index >> 1;
    Endpoints[Index]     = RawMemoryRanges[RawRangeIndex].BaseAddress;
    Endpoints[Index + 1] = RawMemoryRanges[RawRangeIndex].BaseAddress + RawMemoryRanges[RawRangeIndex].Length - 1;
  }
  qsort (Endpoints, *EndPointCount, sizeof (UINT64), CompareFuncUint64);
  RemoveDuplicatesInSortedArray (Endpoints, EndPointCount);
}