/* This function divides the 64-bit signed value Dividend by the 64-bit signed value Divisor and generates a 64-bit signed quotient. If Remainder is not NULL, then the 64-bit signed remainder is returned in Remainder. This function returns the 64-bit signed quotient. */
INT64 EFIAPI InternalMathDivRemS64x64(IN INT64 Dividend, IN INT64 Divisor, OUT INT64 *Remainder OPTIONAL)
/* This function divides the 64-bit signed value Dividend by the 64-bit signed value Divisor and generates a 64-bit signed quotient. If Remainder is not NULL, then the 64-bit signed remainder is returned in Remainder. This function returns the 64-bit signed quotient. */
INT64 EFIAPI InternalMathDivRemS64x64(IN INT64 Dividend, IN INT64 Divisor, OUT INT64 *Remainder OPTIONAL)
{
  INT64  Quot;
  Quot = InternalMathDivRemU64x64 (
           (UINT64)(Dividend >= 0 ? Dividend : -Dividend),
           (UINT64)(Divisor >= 0 ? Divisor : -Divisor),
           (UINT64 *)Remainder
           );
  if ((Remainder != NULL) && (Dividend < 0)) {
    *Remainder = -*Remainder;
  }
  return (Dividend ^ Divisor) >= 0 ? Quot : -Quot;
}