private byte[] convert0() throws IOException {
    ArrayList<PositionList.Entry> sortedPositions = buildSortedPositions();
    ArrayList<LocalList.Entry> methodArgs = extractMethodArguments();

    emitHeader(sortedPositions, methodArgs);

    // TODO: Make this mark be the actual prologue end.
    output.writeByte(DBG_SET_PROLOGUE_END);

    if (annotateTo != null || debugPrint != null) {
      annotate(1, String.format("%04x: prologue end", address));
    }

    int positionsSz = sortedPositions.size();
    int localsSz = locals.size();

    // Current index in sortedPositions
    int curPositionIdx = 0;
    // Current index in locals
    int curLocalIdx = 0;

    for (; ; ) {
      /*
       * Emit any information for the current address.
       */

      curLocalIdx = emitLocalsAtAddress(curLocalIdx);
      curPositionIdx = emitPositionsAtAddress(curPositionIdx, sortedPositions);

      /*
       * Figure out what the next important address is.
       */

      int nextAddrL = Integer.MAX_VALUE; // local variable
      int nextAddrP = Integer.MAX_VALUE; // position (line number)

      if (curLocalIdx < localsSz) {
        nextAddrL = locals.get(curLocalIdx).getAddress();
      }

      if (curPositionIdx < positionsSz) {
        nextAddrP = sortedPositions.get(curPositionIdx).getAddress();
      }

      int next = Math.min(nextAddrP, nextAddrL);

      // No next important address == done.
      if (next == Integer.MAX_VALUE) {
        break;
      }

      /*
       * If the only work remaining are local ends at the end of the
       * block, stop here. Those are implied anyway.
       */
      if (next == codeSize && nextAddrL == Integer.MAX_VALUE && nextAddrP == Integer.MAX_VALUE) {
        break;
      }

      if (next == nextAddrP) {
        // Combined advance PC + position entry
        emitPosition(sortedPositions.get(curPositionIdx++));
      } else {
        emitAdvancePc(next - address);
      }
    }

    emitEndSequence();

    return output.toByteArray();
  }
Converts and produces annotations on a stream. Does not write actual bits to the {@code
AnnotatedOutput}.

@param prefix {@code null-ok;} prefix to attach to each line of output
@param debugPrint {@code null-ok;} if specified, an alternate output for annotations
@param out {@code null-ok;} if specified, where annotations should go
@param consume whether to claim to have consumed output for {@code out}
@return {@code non-null;} encoded output
android/android_framework/dex-maker/src/main/java/com/android/dx/dex/file/DebugInfoEncoder.java