private static RegisterSpecList getRegs(Insn insn, RegisterSpec resultReg) {
    RegisterSpecList regs = insn.getSources();

    if (insn.getOpcode().isCommutative()
        && (regs.size() == 2)
        && (resultReg.getReg() == regs.get(1).getReg())) {

      /*
       * For commutative ops which have two register sources,
       * if the second source is the same register as the result,
       * swap the sources so that an opcode of form 12x can be selected
       * instead of one of form 23x
       */

      regs = RegisterSpecList.make(regs.get(1), regs.get(0));
    }

    if (resultReg == null) {
      return regs;
    }

    return regs.withFirst(resultReg);
  }
Gets the complete register list (result and sources) out of a given rop instruction. For insns
that are commutative, have two register sources, and have a source equal to the result, place
that source first.

@param insn {@code non-null;} instruction in question
@param resultReg {@code null-ok;} the real result to use (ignore the insn's)
@return {@code non-null;} the instruction's complete register list
android/android_framework/dex-maker/src/main/java/com/android/dx/dex/code/RopTranslator.java