/* If String has only pad spaces, then 0 is returned. If String has no pad spaces or valid decimal digits, then 0 is returned. */
EFI_STATUS InternalShellStrDecimalToUint64(IN CONST CHAR16 *String, OUT UINT64 *Value, IN CONST BOOLEAN StopAtSpace)
/* If String has only pad spaces, then 0 is returned. If String has no pad spaces or valid decimal digits, then 0 is returned. */
EFI_STATUS InternalShellStrDecimalToUint64(IN CONST CHAR16 *String, OUT UINT64 *Value, IN CONST BOOLEAN StopAtSpace)
{
  UINT64  Result;
  if ((String == NULL) || (StrSize (String) == 0) || (Value == NULL)) {
    return (EFI_INVALID_PARAMETER);
  }
  while ((*String == L' ') || (*String == L'\t')) {
    String++;
  }
  while (*String == L'0') {
    String++;
  }
  Result = 0;
  if (StopAtSpace && (*String == L' ')) {
    *Value = Result;
    return (EFI_SUCCESS);
  }
  while (ShellIsDecimalDigitCharacter (*String)) {
    if (!(Result <= (DivU64x32 ((((UINT64) ~0) - (*String - L'0')), 10)))) {
      return (EFI_DEVICE_ERROR);
    }
    Result = MultU64x32 (Result, 10) + (*String - L'0');
    String++;
    if (StopAtSpace && (*String == L' ')) {
      break;
    }
  }
  *Value = Result;
  return (EFI_SUCCESS);
}