/* If the requested operation results in an overflow or an underflow condition, then Result is set to INT64_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */
RETURN_STATUS EFIAPI SafeInt64Sub(IN INT64 Minuend, IN INT64 Subtrahend, OUT INT64 *Result)
/* If the requested operation results in an overflow or an underflow condition, then Result is set to INT64_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */
RETURN_STATUS EFIAPI SafeInt64Sub(IN INT64 Minuend, IN INT64 Subtrahend, OUT INT64 *Result)
{
  RETURN_STATUS  Status;
  if (Result == NULL) {
    return RETURN_INVALID_PARAMETER;
  }
  if (((Subtrahend > 0) && (Minuend < (MIN_INT64 + Subtrahend))) ||
      ((Subtrahend < 0) && (Minuend > (MAX_INT64 + Subtrahend))))
  {
    *Result = INT64_ERROR;
    Status  = RETURN_BUFFER_TOO_SMALL;
  } else {
    *Result = Minuend - Subtrahend;
    Status  = RETURN_SUCCESS;
  }
  return Status;
}