Program: 88778
Project: 88778
Buggy source:
/** 
 * If a node has an empty in set, it is considered unreachable. Otherwise the node is examined and if any assumptions have to be corrected, a Pair containing the corrected assumptions is flowed to the reachable nodes.  If no assumptions have to be corrected then no information other than the in set is propagated to the reachable nodes. <p> Pair serves no other purpose than to keep the analysis flowing for as long as needed.  The final results are accumulated in the localToConstant map.
 */
protected void flowThrough(Object in,Unit s,List fallOut,List branchOuts){
  FlowSet fin=(FlowSet)((FlowSet)in).clone();
  if (fin.isEmpty())   return;
  Pair pair=processDefinitionStmt(s);
  if (pair != null)   fin.add(pair);
  if (!s.branches() && s.fallsThrough()) {
    Iterator fallOutIt=fallOut.iterator();
    while (fallOutIt.hasNext()) {
      FlowSet fallSet=(FlowSet)fallOutIt.next();
      fallSet.union(fin);
    }
    return;
  }
  boolean conservative=true;
  boolean fall=false;
  boolean branch=false;
  FlowSet oneBranch=null;
  IFSTMT: {
    if (s instanceof IfStmt) {
      IfStmt ifStmt=(IfStmt)s;
      Value cond=ifStmt.getCondition();
      Constant constant=SEvaluator.getFuzzyConstantValueOf(cond,localToConstant);
      if (constant instanceof BottomConstant)       break IFSTMT;
      if (constant instanceof TopConstant)       return;
      conservative=false;
      Constant trueC=IntConstant.v(1);
      Constant falseC=IntConstant.v(0);
      if (constant.equals(trueC)) {
        branch=true;
        GotoStmt gotoStmt=Jimple.v().newGotoStmt(ifStmt.getTargetBox());
        stmtToReplacement.put(ifStmt,gotoStmt);
      }
      if (constant.equals(falseC)) {
        fall=true;
        deadStmts.add(ifStmt);
      }
    }
  }
  TABLESWITCHSTMT: {
    if (s instanceof TableSwitchStmt) {
      TableSwitchStmt table=(TableSwitchStmt)s;
      Value keyV=table.getKey();
      Constant keyC=SEvaluator.getFuzzyConstantValueOf(keyV,localToConstant);
      if (keyC instanceof BottomConstant)       break TABLESWITCHSTMT;
      if (keyC instanceof TopConstant)       return;
      if (!(keyC instanceof IntConstant))       break TABLESWITCHSTMT;
      conservative=false;
      int key=((IntConstant)keyC).value;
      int low=table.getLowIndex();
      int high=table.getHighIndex();
      int index=key - low;
      UnitBox branchBox=null;
      if (index < 0 || index > high)       branchBox=table.getDefaultTargetBox();
 else       branchBox=table.getTargetBox(index);
      GotoStmt gotoStmt=Jimple.v().newGotoStmt(branchBox);
      stmtToReplacement.put(table,gotoStmt);
      List unitBoxes=table.getUnitBoxes();
      int setIndex=unitBoxes.indexOf(branchBox);
      oneBranch=(FlowSet)branchOuts.get(setIndex);
    }
  }
  LOOKUPSWITCHSTMT: {
    if (s instanceof LookupSwitchStmt) {
      LookupSwitchStmt lookup=(LookupSwitchStmt)s;
      Value keyV=lookup.getKey();
      Constant keyC=SEvaluator.getFuzzyConstantValueOf(keyV,localToConstant);
      if (keyC instanceof BottomConstant)       break LOOKUPSWITCHSTMT;
      if (keyC instanceof TopConstant)       return;
      if (!(keyC instanceof IntConstant))       break LOOKUPSWITCHSTMT;
      conservative=false;
      int index=lookup.getLookupValues().indexOf(keyC);
      UnitBox branchBox=null;
      if (index == -1)       branchBox=lookup.getDefaultTargetBox();
 else       branchBox=lookup.getTargetBox(index);
      GotoStmt gotoStmt=Jimple.v().newGotoStmt(branchBox);
      stmtToReplacement.put(lookup,gotoStmt);
      List unitBoxes=lookup.getUnitBoxes();
      int setIndex=unitBoxes.indexOf(branchBox);
      oneBranch=(FlowSet)branchOuts.get(setIndex);
    }
  }
  if (conservative) {
    fall=s.fallsThrough();
    branch=s.branches();
  }
  if (fall) {
    Iterator fallOutIt=fallOut.iterator();
    while (fallOutIt.hasNext()) {
      FlowSet fallSet=(FlowSet)fallOutIt.next();
      fallSet.union(fin);
    }
  }
  if (branch) {
    Iterator branchOutsIt=branchOuts.iterator();
    while (branchOutsIt.hasNext()) {
      FlowSet branchSet=(FlowSet)branchOutsIt.next();
      branchSet.union(fin);
    }
  }
  if (oneBranch != null) {
    oneBranch.union(fin);
  }
}

Fixed version (ground truth):
/** 
 * If a node has an empty in set, it is considered unreachable. Otherwise the node is examined and if any assumptions have to be corrected, a Pair containing the corrected assumptions is flowed to the reachable nodes.  If no assumptions have to be corrected then no information other than the in set is propagated to the reachable nodes. <p> Pair serves no other purpose than to keep the analysis flowing for as long as needed.  The final results are accumulated in the localToConstant map.
 */
protected void flowThrough(Object in,Unit s,List fallOut,List branchOuts){
  FlowSet fin=(FlowSet)((FlowSet)in).clone();
  if (fin.isEmpty())   return;
  Pair pair=processDefinitionStmt(s);
  if (pair != null)   fin.add(pair);
  if (!s.branches() && s.fallsThrough()) {
    Iterator fallOutIt=fallOut.iterator();
    while (fallOutIt.hasNext()) {
      FlowSet fallSet=(FlowSet)fallOutIt.next();
      fallSet.union(fin);
    }
    return;
  }
  boolean conservative=true;
  boolean fall=false;
  boolean branch=false;
  FlowSet oneBranch=null;
  IFSTMT: {
    if (s instanceof IfStmt) {
      IfStmt ifStmt=(IfStmt)s;
      Value cond=ifStmt.getCondition();
      Constant constant=SEvaluator.getFuzzyConstantValueOf(cond,localToConstant);
      if (constant instanceof BottomConstant) {
        deadStmts.remove(ifStmt);
        stmtToReplacement.remove(ifStmt);
        break IFSTMT;
      }
      if (constant instanceof TopConstant)       return;
      conservative=false;
      Constant trueC=IntConstant.v(1);
      Constant falseC=IntConstant.v(0);
      if (constant.equals(trueC)) {
        branch=true;
        GotoStmt gotoStmt=Jimple.v().newGotoStmt(ifStmt.getTargetBox());
        stmtToReplacement.put(ifStmt,gotoStmt);
      }
      if (constant.equals(falseC)) {
        fall=true;
        deadStmts.add(ifStmt);
      }
    }
  }
  TABLESWITCHSTMT: {
    if (s instanceof TableSwitchStmt) {
      TableSwitchStmt table=(TableSwitchStmt)s;
      Value keyV=table.getKey();
      Constant keyC=SEvaluator.getFuzzyConstantValueOf(keyV,localToConstant);
      if (keyC instanceof BottomConstant) {
        stmtToReplacement.remove(table);
        break TABLESWITCHSTMT;
      }
      if (keyC instanceof TopConstant)       return;
      if (!(keyC instanceof IntConstant))       break TABLESWITCHSTMT;
      conservative=false;
      int key=((IntConstant)keyC).value;
      int low=table.getLowIndex();
      int high=table.getHighIndex();
      int index=key - low;
      UnitBox branchBox=null;
      if (index < 0 || index > high)       branchBox=table.getDefaultTargetBox();
 else       branchBox=table.getTargetBox(index);
      GotoStmt gotoStmt=Jimple.v().newGotoStmt(branchBox);
      stmtToReplacement.put(table,gotoStmt);
      List unitBoxes=table.getUnitBoxes();
      int setIndex=unitBoxes.indexOf(branchBox);
      oneBranch=(FlowSet)branchOuts.get(setIndex);
    }
  }
  LOOKUPSWITCHSTMT: {
    if (s instanceof LookupSwitchStmt) {
      LookupSwitchStmt lookup=(LookupSwitchStmt)s;
      Value keyV=lookup.getKey();
      Constant keyC=SEvaluator.getFuzzyConstantValueOf(keyV,localToConstant);
      if (keyC instanceof BottomConstant) {
        stmtToReplacement.remove(lookup);
        break LOOKUPSWITCHSTMT;
      }
      if (keyC instanceof TopConstant)       return;
      if (!(keyC instanceof IntConstant))       break LOOKUPSWITCHSTMT;
      conservative=false;
      int index=lookup.getLookupValues().indexOf(keyC);
      UnitBox branchBox=null;
      if (index == -1)       branchBox=lookup.getDefaultTargetBox();
 else       branchBox=lookup.getTargetBox(index);
      GotoStmt gotoStmt=Jimple.v().newGotoStmt(branchBox);
      stmtToReplacement.put(lookup,gotoStmt);
      List unitBoxes=lookup.getUnitBoxes();
      int setIndex=unitBoxes.indexOf(branchBox);
      oneBranch=(FlowSet)branchOuts.get(setIndex);
    }
  }
  if (conservative) {
    fall=s.fallsThrough();
    branch=s.branches();
  }
  if (fall) {
    Iterator fallOutIt=fallOut.iterator();
    while (fallOutIt.hasNext()) {
      FlowSet fallSet=(FlowSet)fallOutIt.next();
      fallSet.union(fin);
    }
  }
  if (branch) {
    Iterator branchOutsIt=branchOuts.iterator();
    while (branchOutsIt.hasNext()) {
      FlowSet branchSet=(FlowSet)branchOutsIt.next();
      branchSet.union(fin);
    }
  }
  if (oneBranch != null) {
    oneBranch.union(fin);
  }
}