private void outputBlock(BasicBlock block, int nextLabel) {
    // Append the code address for this block.
    CodeAddress startAddress = addresses.getStart(block);
    output.add(startAddress);

    // Append the local variable state for the block.
    if (locals != null) {
      RegisterSpecSet starts = locals.getStarts(block);
      output.add(new LocalSnapshot(startAddress.getPosition(), starts));
    }

    /*
     * Choose and append an output instruction for each original
     * instruction.
     */
    translationVisitor.setBlock(block, addresses.getLast(block));
    block.getInsns().forEach(translationVisitor);

    // Insert the block end code address.
    output.add(addresses.getEnd(block));

    // Set up for end-of-block activities.

    int succ = block.getPrimarySuccessor();
    Insn lastInsn = block.getLastInsn();

    /*
     * Check for (and possibly correct for) a non-optimal choice of
     * which block will get output next.
     */

    if ((succ >= 0) && (succ != nextLabel)) {
      /*
       * The block has a "primary successor" and that primary
       * successor isn't the next block to be output.
       */
      Rop lastRop = lastInsn.getOpcode();
      if ((lastRop.getBranchingness() == Rop.BRANCH_IF)
          && (block.getSecondarySuccessor() == nextLabel)) {
        /*
         * The block ends with an "if" of some sort, and its
         * secondary successor (the "then") is in fact the
         * next block to output. So, reverse the sense of
         * the test, so that we can just emit the next block
         * without an interstitial goto.
         */
        output.reverseBranch(1, addresses.getStart(succ));
      } else {
        /*
         * Our only recourse is to add a goto here to get the
         * flow to be correct.
         */
        TargetInsn insn =
            new TargetInsn(
                Dops.GOTO,
                lastInsn.getPosition(),
                RegisterSpecList.EMPTY,
                addresses.getStart(succ));
        output.add(insn);
      }
    }
  }
Helper for {@link #outputInstructions}, which does the processing and output of one block.

@param block {@code non-null;} the block to process and output
@param nextLabel {@code >= -1;} the next block that will be processed, or {@code -1} if there
    is no next block
android/android_framework/dex-maker/src/main/java/com/android/dx/dex/code/RopTranslator.java