/* Check whether the Range overlaps with any one in Ranges. */
BOOLEAN RangesOverlap(IN MTRR_MEMORY_RANGE *Range, IN MTRR_MEMORY_RANGE *Ranges, IN UINTN Count)
/* Check whether the Range overlaps with any one in Ranges. */
BOOLEAN RangesOverlap(IN MTRR_MEMORY_RANGE *Range, IN MTRR_MEMORY_RANGE *Ranges, IN UINTN Count)
{
  while (Count-- != 0) {
    if (  ((Range->BaseAddress <= Ranges[Count].BaseAddress) && (Ranges[Count].BaseAddress < Range->BaseAddress + Range->Length))
       || ((Ranges[Count].BaseAddress <= Range->BaseAddress) && (Range->BaseAddress < Ranges[Count].BaseAddress + Ranges[Count].Length)))
    {
      return TRUE;
    }
  }
  return FALSE;
}