private ArrayList<LocalList.Entry> extractMethodArguments() {
    ArrayList<LocalList.Entry> result = new ArrayList(desc.getParameterTypes().size());
    int argBase = getParamBase();
    BitSet seen = new BitSet(regSize - argBase);
    int sz = locals.size();

    for (int i = 0; i < sz; i++) {
      LocalList.Entry e = locals.get(i);
      int reg = e.getRegister();

      if (reg < argBase) {
        continue;
      }

      // only the lowest-start-address entry is included.
      if (seen.get(reg - argBase)) {
        continue;
      }

      seen.set(reg - argBase);
      result.add(e);
    }

    // Sort by ascending register.
    Collections.sort(
        result,
        new Comparator<LocalList.Entry>() {
          @Override
          public int compare(LocalList.Entry a, LocalList.Entry b) {
            return a.getRegister() - b.getRegister();
          }

          @Override
          public boolean equals(Object obj) {
            return obj == this;
          }
        });

    return result;
  }
Extracts method arguments from a locals list. These will be collected from the input list and
sorted by ascending register in the returned list.

@return list of non-{@code this} method argument locals, sorted by ascending register
android/android_framework/dex-maker/src/main/java/com/android/dx/dex/file/DebugInfoEncoder.java