class DuplicateCatchAllTrapRemover extends BodyTransformer {

  public DuplicateCatchAllTrapRemover(Singletons.Global g) {
  }

  public static DuplicateCatchAllTrapRemover v() {
    return soot.G.v().soot_toolkits_exceptions_DuplicateCatchAllTrapRemover();
  }

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

  /**
   * Checks whether the given trap covers the given unit, i.e., there is an exceptional control flow from the given unit to
   * the given trap
   *
   * @param b
   *          The body containing the unit and the trap
   * @param trap
   *          The trap
   * @param unit
   *          The unit
   * @return True if there can be an exceptional control flow from the given unit to the given trap
   */
  private boolean trapCoversUnit(Body b, Trap trap, Unit unit) {
    for (Iterator<Unit> unitIt = b.getUnits().iterator(trap.getBeginUnit(), trap.getEndUnit()); unitIt.hasNext();) {
      Unit u = unitIt.next();
      if (u == unit) {
        return true;
      }
    }
    return false;
  }

}

    // Find two traps that use java.lang.Throwable as their type and that
    // span the same code region
    for (Iterator<Trap> t1It = b.getTraps().snapshotIterator(); t1It.hasNext();) {
      Trap t1 = t1It.next();
      if (t1.getException().getName().equals(Scene.v().getBaseExceptionType().toString())) {
        for (Iterator<Trap> t2It = b.getTraps().snapshotIterator(); t2It.hasNext();) {
          Trap t2 = t2It.next();
          if (t1 != t2 && t1.getBeginUnit() == t2.getBeginUnit() && t1.getEndUnit() == t2.getEndUnit()
              && t2.getException().getName().equals(Scene.v().getBaseExceptionType().toString())) {
            // Both traps (t1, t2) span the same code and catch java.lang.Throwable.
            // Check if one trap jumps to a target that then jumps to the target of
            // the other trap.
            for (Trap t3 : b.getTraps()) {
              if (t3 != t1 && t3 != t2 && t3.getException().getName().equals(Scene.v().getBaseExceptionType().toString())) {
                if (trapCoversUnit(b, t3, t1.getHandlerUnit()) && t3.getHandlerUnit() == t2.getHandlerUnit()) {
                  // c -> t1 -> t3 -> t2 && c -> t2
                  b.getTraps().remove(t2);
                  break;
                } else if (trapCoversUnit(b, t3, t2.getHandlerUnit()) && t3.getHandlerUnit() == t1.getHandlerUnit()) {
                  // c -> t2 -> t3 -> t1 && c -> t1
                  b.getTraps().remove(t1);
                  break;
                }
              }

            }
          }
        }
      }
    }
  
<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