def parse_trousers_input_args(s):
  """Parses Trspi family's input arguments.

  Given a string from of input arguments of a trousers API, the input arguments
  parsed into tokens and then convert to tuples. For example:
  "BYTE *s, unsigned *len"
  ->
  [("BYTE *", "s"), ("unsigned *", "len")]

  Args:
    s: String representation of the input arguments of a certain Trspi function.

  Returns:
    A list of tuples in form of (data type, variable name).
  """
  arr = s.split(',')
  for i, p in enumerate(arr):
    p = p.strip()
    # are stick with the variable name, e.g., UINT64 *offset, so the separator
    # could be last ' ' or '*'.
    pos = p.strip().rfind('*')
    if pos == -1:
      pos = p.rfind(' ')
      if pos == -1:
        pos = len(p)
    var_type, var_name = p[:pos + 1].strip(), p[pos + 1:].strip()
    arr[i] = (var_type, var_name)
  return arr