class StoreChainOptimizer extends BodyTransformer {

  public StoreChainOptimizer(Singletons.Global g) {
  }

  public static StoreChainOptimizer v() {
    return G.v().soot_baf_toolkits_base_StoreChainOptimizer();
  }

  @Override
  protected void internalTransform(Body b, String phaseName, Map<String, String> options) {<FILL_FUNCTION_BODY>}
}

    // We keep track of all the stored values
    Map<Local, Pair<Unit, Unit>> stores = new HashMap<Local, Pair<Unit, Unit>>();
    Set<Unit> toRemove = new HashSet<Unit>();

    Unit lastPush = null;
    for (Unit u : b.getUnits()) {
      // If we can jump here from somewhere, do not modify this code
      if (!u.getBoxesPointingToThis().isEmpty()) {
        stores.clear();
        lastPush = null;
      } else if (u instanceof PushInst) {
        // Emulate pushing stuff on the stack
        lastPush = u;
      } else if (u instanceof StoreInst && lastPush != null) {
        StoreInst si = (StoreInst) u;
        Pair<Unit, Unit> pushStorePair = stores.get(si.getLocal());
        if (pushStorePair != null) {
          // We can remove the push and the store
          toRemove.add(pushStorePair.getO1());
          toRemove.add(pushStorePair.getO2());
        }

        stores.put(si.getLocal(), new Pair<Unit, Unit>(lastPush, u));
      } else {
        // We're outside of the trivial initialization chain
        stores.clear();
        lastPush = null;
      }
    }

    b.getUnits().removeAll(toRemove);
  
<methods>public non-sealed void <init>() ,public final void transform(soot.Body, java.lang.String, Map<java.lang.String,java.lang.String>) ,public final void transform(soot.Body, java.lang.String) ,public final void transform(soot.Body) <variables>private static final Map<java.lang.String,java.lang.String> enabledOnlyMap