private int findAnyFittingRange(
      NormalSsaInsn insn, int rangeLength, int[] categoriesForIndex, BitSet outMovesRequired) {
    Alignment alignment = Alignment.UNSPECIFIED;

    if (DexOptions.ALIGN_64BIT_REGS_SUPPORT) {
      int regNumber = 0;
      int p64bitsAligned = 0;
      int p64bitsNotAligned = 0;
      for (int category : categoriesForIndex) {
        if (category == 2) {
          if (isEven(regNumber)) {
            p64bitsAligned++;
          } else {
            p64bitsNotAligned++;
          }
          regNumber += 2;
        } else {
          regNumber += 1;
        }
      }

      if (p64bitsNotAligned > p64bitsAligned) {
        if (isEven(paramRangeEnd)) {
          alignment = Alignment.ODD;
        } else {
          alignment = Alignment.EVEN;
        }
      } else if (p64bitsAligned > 0) {
        if (isEven(paramRangeEnd)) {
          alignment = Alignment.EVEN;
        } else {
          alignment = Alignment.ODD;
        }
      }
    }

    int rangeStart = paramRangeEnd;
    while (true) {
      rangeStart = findNextUnreservedRopReg(rangeStart, rangeLength, alignment);

      int fitWidth = fitPlanForRange(rangeStart, insn, categoriesForIndex, outMovesRequired);

      if (fitWidth >= 0) {
        break;
      }
      rangeStart++;
      outMovesRequired.clear();
    }

    return rangeStart;
  }
Finds an unreserved range that will fit the sources of the specified instruction. Does not
bother trying to center the range around an already-mapped source register;

@param insn {@code non-null;} insn to build range for
@param rangeLength {@code >=0;} length required in register units
@param categoriesForIndex {@code non-null;} indexed by source index; the category for each
    source
@param outMovesRequired {@code non-null;} an output parameter indexed by source index that will
    contain the set of sources which need moves inserted
@return the rop register that starts the fitting range
android/android_framework/dex-maker/src/main/java/com/android/dx/ssa/back/FirstFitLocalCombiningAllocator.java