private static int wordCount(RegisterSpecList regs) {
    int sz = regs.size();

    if (sz > MAX_NUM_OPS) {
      // It can't possibly fit.
      return -1;
    }

    int result = 0;

    for (int i = 0; i < sz; i++) {
      RegisterSpec one = regs.get(i);
      result += one.getCategory();
      /*
       * The check below adds (category - 1) to the register, to
       * account for the fact that the second half of a
       * category-2 register has to be represented explicitly in
       * the result.
       */
      if (!unsignedFitsInNibble(one.getReg() + one.getCategory() - 1)) {
        return -1;
      }
    }

    return (result <= MAX_NUM_OPS) ? result : -1;
  }
Gets the number of words required for the given register list, where category-2 values count as
two words. Return {@code -1} if the list requires more than five words or contains registers
that need more than a nibble to identify them.

@param regs {@code non-null;} the register list in question
@return {@code >= -1;} the number of words required, or {@code -1} if the list couldn't
    possibly fit in this format
android/android_framework/dex-maker/src/main/java/com/android/dx/dex/code/form/Form35c.java