public void replaceLastInsn(Insn insn) {
    if (insn.getOpcode().getBranchingness() == Rop.BRANCH_NONE) {
      throw new IllegalArgumentException("last insn must branch");
    }

    SsaInsn oldInsn = insns.get(insns.size() - 1);
    SsaInsn newInsn = SsaInsn.makeFromRop(insn, this);

    insns.set(insns.size() - 1, newInsn);

    parent.onInsnRemoved(oldInsn);
    parent.onInsnAdded(newInsn);
  }
Replaces the last insn in this block. The provided insn must have some branchingness.

@param insn {@code non-null;} rop-form insn to add, which must branch.
android/android_framework/dex-maker/src/main/java/com/android/dx/ssa/SsaBasicBlock.java