private int findRopRegForLocal(int startReg, int category) {
    Alignment alignment = getAlignment(category);
    int reg = alignment.nextClearBit(usedRopRegs, startReg);

    while (true) {
      int i = 1;

      while (i < category && !usedRopRegs.get(reg + i)) {
        i++;
      }

      if (i == category) {
        return reg;
      }

      reg = alignment.nextClearBit(usedRopRegs, reg + i);
    }
  }
Finds rop registers that can be used for local variables. If {@code MIX_LOCALS_AND_OTHER} is
{@code false}, this means any rop register that has not yet been used.

@param startReg {@code >= 0;} a rop register to start the search at
@param category {@code > 0;} the register category required.
@return {@code >= 0;} start of available registers.
android/android_framework/dex-maker/src/main/java/com/android/dx/ssa/back/FirstFitLocalCombiningAllocator.java