private int parseTableswitch(int offset, Visitor visitor) {
    int at = (offset + 4) & ~3; // "at" skips the padding.

    // Collect the padding.
    int padding = 0;
    for (int i = offset + 1; i < at; i++) {
      padding = (padding << 8) | bytes.getUnsignedByte(i);
    }

    int defaultTarget = offset + bytes.getInt(at);
    int low = bytes.getInt(at + 4);
    int high = bytes.getInt(at + 8);
    int count = high - low + 1;
    at += 12;

    if (low > high) {
      throw new SimException("low / high inversion");
    }

    SwitchList cases = new SwitchList(count);
    for (int i = 0; i < count; i++) {
      int target = offset + bytes.getInt(at);
      at += 4;
      cases.add(low + i, target);
    }
    cases.setDefaultTarget(defaultTarget);
    cases.removeSuperfluousDefaults();
    cases.setImmutable();

    int length = at - offset;
    visitor.visitSwitch(ByteOps.LOOKUPSWITCH, offset, length, cases, padding);

    return length;
  }
Helper to deal with {@code tableswitch}.

@param offset the offset to the {@code tableswitch} opcode itself
@param visitor {@code non-null;} visitor to use
@return instruction length, in bytes
android/android_framework/dex-maker/src/main/java/com/android/dx/cf/code/BytecodeArray.java