private static boolean calculateParamsAreInOrder(RopMethod method, final int paramSize) {
    final boolean[] paramsAreInOrder = {true};
    final int initialRegCount = method.getBlocks().getRegCount();

    /*
     * We almost could just check the first block here, but the
     * {@code cf} layer will put in a second move-param in a
     * subsequent block in the case of synchronized methods.
     */
    method
        .getBlocks()
        .forEachInsn(
            new Insn.BaseVisitor() {
              @Override
              public void visitPlainCstInsn(PlainCstInsn insn) {
                if (insn.getOpcode().getOpcode() == RegOps.MOVE_PARAM) {
                  int param = ((CstInteger) insn.getConstant()).getValue();

                  paramsAreInOrder[0] =
                      paramsAreInOrder[0]
                          && ((initialRegCount - paramSize + param) == insn.getResult().getReg());
                }
              }
            });

    return paramsAreInOrder[0];
  }
Checks to see if the move-param instructions that occur in this method happen to slot the
params in an order at the top of the stack frame that matches dalvik's calling conventions.
This will alway result in "true" for methods that have run through the SSA optimizer.

@param paramSize size, in register units, of all the parameters to this method
android/android_framework/dex-maker/src/main/java/com/android/dx/dex/code/RopTranslator.java