Program: 62126
Project: 62126
Buggy source:
@Override protected List<GraphTargetItem> check(GraphSource code,List<Object> localData,List<GraphPart> allParts,Stack<GraphTargetItem> stack,GraphPart parent,GraphPart part,List<GraphPart> stopPart,List<Loop> loops,List<GraphTargetItem> output,Loop currentLoop){
  if (!output.isEmpty()) {
    if (output.get(output.size() - 1) instanceof StoreRegisterTreeItem) {
      StoreRegisterTreeItem str=(StoreRegisterTreeItem)output.get(output.size() - 1);
      if (str.value instanceof EnumerateTreeItem) {
        output.remove(output.size() - 1);
      }
    }
  }
  List<GraphTargetItem> ret=null;
  if ((part.nextParts.size() == 2) && (!stack.isEmpty()) && (stack.peek() instanceof StrictEqTreeItem)) {
    GraphTargetItem switchedObject=null;
    if (!output.isEmpty()) {
      if (output.get(output.size() - 1) instanceof StoreRegisterTreeItem) {
        switchedObject=((StoreRegisterTreeItem)output.get(output.size() - 1)).value;
      }
    }
    if (switchedObject == null) {
      switchedObject=new DirectValueTreeItem(null,-1,new Null(),null);
    }
    HashMap<Integer,GraphTargetItem> caseValuesMap=new HashMap<>();
    int pos=0;
    StrictEqTreeItem set=(StrictEqTreeItem)stack.pop();
    caseValuesMap.put(pos,set.rightSide);
    if (set.leftSide instanceof StoreRegisterTreeItem) {
      switchedObject=((StoreRegisterTreeItem)set.leftSide).value;
    }
    List<GraphPart> caseBodyParts=new ArrayList<>();
    caseBodyParts.add(part.nextParts.get(0));
    GraphTargetItem top=null;
    int cnt=1;
    while (part.nextParts.size() > 1 && part.nextParts.get(1).getHeight() > 1 && code.get(part.nextParts.get(1).end >= code.size() ? code.size() - 1 : part.nextParts.get(1).end) instanceof ActionIf && ((top=translatePartGetStack(localData,part.nextParts.get(1),stack)) instanceof StrictEqTreeItem)) {
      cnt++;
      part=part.nextParts.get(1);
      pos++;
      caseBodyParts.add(part.nextParts.get(0));
      set=(StrictEqTreeItem)top;
      caseValuesMap.put(pos,set.rightSide);
    }
    if (cnt == 1) {
      stack.push(set);
    }
 else {
      part=part.nextParts.get(1);
      GraphPart defaultPart=part;
      List<GraphPart> defaultAndLastPart=new ArrayList<>();
      defaultAndLastPart.add(defaultPart);
      defaultAndLastPart.add(caseBodyParts.get(caseBodyParts.size() - 1));
      GraphPart defaultPart2=getCommonPart(defaultAndLastPart,loops);
      List<GraphTargetItem> defaultCommands=new ArrayList<>();
      List<GraphPart> stopPart2=new ArrayList<>(stopPart);
      stopPart2.add(defaultPart2);
      defaultCommands=printGraph(new ArrayList<GraphPart>(),localData,stack,allParts,null,defaultPart,stopPart2,loops);
      List<GraphPart> loopContinues=new ArrayList<>();
      for (      Loop l : loops) {
        if (l.loopContinue != null) {
          loopContinues.add(l.loopContinue);
        }
      }
      List<GraphPart> breakParts=new ArrayList<>();
      GraphPart breakPart=getMostCommonPart(caseBodyParts,loops);
      if ((defaultPart2 != breakPart) && (defaultCommands.isEmpty())) {
        defaultPart=defaultPart2;
      }
      List<GraphTargetItem> caseValues=new ArrayList<>();
      for (int i=0; i < caseBodyParts.size(); i++) {
        if (caseValuesMap.containsKey(i)) {
          caseValues.add(caseValuesMap.get(i));
        }
 else {
          continue;
        }
      }
      List<List<GraphTargetItem>> caseCommands=new ArrayList<>();
      GraphPart next=null;
      next=breakPart;
      GraphTargetItem ti=checkLoop(next,stopPart,loops);
      currentLoop=new Loop(loops.size(),null,next);
      loops.add(currentLoop);
      List<Integer> valuesMapping=new ArrayList<>();
      List<GraphPart> caseBodies=new ArrayList<>();
      for (int i=0; i < caseValues.size(); i++) {
        GraphPart cur=caseBodyParts.get(i);
        if (!caseBodies.contains(cur)) {
          caseBodies.add(cur);
        }
        valuesMapping.add(caseBodies.indexOf(cur));
      }
      if (defaultPart == breakPart) {
        defaultPart=null;
      }
      if ((defaultPart != null) && (defaultCommands.isEmpty())) {
        List<GraphPart> stopPart2x=new ArrayList<>(stopPart);
        stopPart2x.add(next);
        defaultCommands=printGraph(new ArrayList<GraphPart>(),localData,stack,allParts,null,defaultPart,stopPart2x,loops);
      }
      List<GraphPart> ignored=new ArrayList<>();
      for (      Loop l : loops) {
        ignored.add(l.loopContinue);
      }
      for (int i=0; i < caseBodies.size(); i++) {
        List<GraphTargetItem> cc=new ArrayList<>();
        GraphPart nextCase=null;
        nextCase=next;
        if (next != null) {
          if (i < caseBodies.size() - 1) {
            if (!caseBodies.get(i).leadsTo(code,caseBodies.get(i + 1),loops)) {
              cc.add(new BreakItem(null,currentLoop.id));
            }
 else {
              nextCase=caseBodies.get(i + 1);
            }
          }
 else           if (!defaultCommands.isEmpty()) {
            if (!caseBodies.get(i).leadsTo(code,defaultPart,loops)) {
              cc.add(new BreakItem(null,currentLoop.id));
            }
 else {
              nextCase=defaultPart;
            }
          }
        }
        List<GraphPart> stopPart2x=new ArrayList<>(stopPart);
        for (        GraphPart b : caseBodies) {
          if (b != caseBodies.get(i)) {
            stopPart2x.add(b);
          }
        }
        if (defaultPart != null) {
          stopPart2x.add(defaultPart);
        }
        if (breakPart != null) {
          stopPart2x.add(breakPart);
        }
        cc.addAll(0,printGraph(new ArrayList<GraphPart>(),localData,stack,allParts,null,caseBodies.get(i),stopPart2x,loops));
        if (cc.size() >= 2) {
          if (cc.get(cc.size() - 1) instanceof BreakItem) {
            if ((cc.get(cc.size() - 2) instanceof ContinueItem) || (cc.get(cc.size() - 2) instanceof BreakItem)) {
              cc.remove(cc.size() - 1);
            }
          }
        }
        caseCommands.add(cc);
      }
      ret=new ArrayList<>();
      if (!output.isEmpty()) {
        if (output.get(output.size() - 1) instanceof StoreRegisterTreeItem) {
          output.remove(output.size() - 1);
        }
      }
      ret.addAll(output);
      SwitchItem sti=new SwitchItem(null,currentLoop,switchedObject,caseValues,caseCommands,defaultCommands,valuesMapping);
      ret.add(sti);
      if (next != null) {
        if (ti != null) {
          ret.add(ti);
        }
 else {
          ret.addAll(printGraph(new ArrayList<GraphPart>(),localData,stack,allParts,null,next,stopPart,loops));
        }
      }
    }
  }
  return ret;
}

Fixed version (ground truth):
@Override protected List<GraphTargetItem> check(GraphSource code,List<Object> localData,List<GraphPart> allParts,Stack<GraphTargetItem> stack,GraphPart parent,GraphPart part,List<GraphPart> stopPart,List<Loop> loops,List<GraphTargetItem> output,Loop currentLoop){
  if (!output.isEmpty()) {
    if (output.get(output.size() - 1) instanceof StoreRegisterTreeItem) {
      StoreRegisterTreeItem str=(StoreRegisterTreeItem)output.get(output.size() - 1);
      if (str.value instanceof EnumerateTreeItem) {
        output.remove(output.size() - 1);
      }
    }
  }
  List<GraphTargetItem> ret=null;
  if ((part.nextParts.size() == 2) && (!stack.isEmpty()) && (stack.peek() instanceof StrictEqTreeItem)) {
    GraphTargetItem switchedObject=null;
    if (!output.isEmpty()) {
      if (output.get(output.size() - 1) instanceof StoreRegisterTreeItem) {
        switchedObject=((StoreRegisterTreeItem)output.get(output.size() - 1)).value;
      }
    }
    if (switchedObject == null) {
      switchedObject=new DirectValueTreeItem(null,-1,new Null(),null);
    }
    HashMap<Integer,GraphTargetItem> caseValuesMap=new HashMap<>();
    int pos=0;
    StrictEqTreeItem set=(StrictEqTreeItem)stack.pop();
    caseValuesMap.put(pos,set.rightSide);
    if (set.leftSide instanceof StoreRegisterTreeItem) {
      switchedObject=((StoreRegisterTreeItem)set.leftSide).value;
    }
    List<GraphPart> caseBodyParts=new ArrayList<>();
    caseBodyParts.add(part.nextParts.get(0));
    GraphTargetItem top=null;
    int cnt=1;
    while (part.nextParts.size() > 1 && part.nextParts.get(1).getHeight() > 1 && code.get(part.nextParts.get(1).end >= code.size() ? code.size() - 1 : part.nextParts.get(1).end) instanceof ActionIf && ((top=translatePartGetStack(localData,part.nextParts.get(1),stack)) instanceof StrictEqTreeItem)) {
      cnt++;
      part=part.nextParts.get(1);
      pos++;
      caseBodyParts.add(part.nextParts.get(0));
      set=(StrictEqTreeItem)top;
      caseValuesMap.put(pos,set.rightSide);
    }
    if (cnt == 1) {
      stack.push(set);
    }
 else {
      part=part.nextParts.get(1);
      GraphPart defaultPart=part;
      List<GraphPart> defaultAndLastPart=new ArrayList<>();
      defaultAndLastPart.add(defaultPart);
      defaultAndLastPart.add(caseBodyParts.get(caseBodyParts.size() - 1));
      GraphPart defaultPart2=getCommonPart(defaultAndLastPart,loops);
      List<GraphTargetItem> defaultCommands=new ArrayList<>();
      List<GraphPart> stopPart2=new ArrayList<>(stopPart);
      stopPart2.add(defaultPart2);
      defaultCommands=printGraph(new ArrayList<GraphPart>(),localData,stack,allParts,null,defaultPart,stopPart2,loops);
      List<GraphPart> loopContinues=new ArrayList<>();
      for (      Loop l : loops) {
        if (l.loopContinue != null) {
          loopContinues.add(l.loopContinue);
        }
      }
      List<GraphPart> breakParts=new ArrayList<>();
      List<GraphPart> mcp=new ArrayList<>();
      mcp.addAll(caseBodyParts);
      mcp.add(defaultPart2);
      GraphPart breakPart=getMostCommonPart(mcp,loops);
      if ((defaultPart2 != breakPart) && (defaultCommands.isEmpty())) {
        defaultPart=defaultPart2;
      }
      List<GraphTargetItem> caseValues=new ArrayList<>();
      for (int i=0; i < caseBodyParts.size(); i++) {
        if (caseValuesMap.containsKey(i)) {
          caseValues.add(caseValuesMap.get(i));
        }
 else {
          continue;
        }
      }
      List<List<GraphTargetItem>> caseCommands=new ArrayList<>();
      GraphPart next=null;
      next=breakPart;
      GraphTargetItem ti=checkLoop(next,stopPart,loops);
      currentLoop=new Loop(loops.size(),null,next);
      currentLoop.phase=1;
      loops.add(currentLoop);
      List<Integer> valuesMapping=new ArrayList<>();
      List<GraphPart> caseBodies=new ArrayList<>();
      for (int i=0; i < caseValues.size(); i++) {
        GraphPart cur=caseBodyParts.get(i);
        if (!caseBodies.contains(cur)) {
          caseBodies.add(cur);
        }
        valuesMapping.add(caseBodies.indexOf(cur));
      }
      if (defaultPart == breakPart) {
        defaultPart=null;
      }
      if ((defaultPart != null) && (defaultCommands.isEmpty())) {
        List<GraphPart> stopPart2x=new ArrayList<>(stopPart);
        stopPart2x.add(next);
        defaultCommands=printGraph(new ArrayList<GraphPart>(),localData,stack,allParts,null,defaultPart,stopPart2x,loops);
      }
      if (!defaultCommands.isEmpty()) {
        if (defaultCommands.get(defaultCommands.size() - 1) instanceof BreakItem) {
          BreakItem bi=(BreakItem)defaultCommands.get(defaultCommands.size() - 1);
          if (bi.loopId == currentLoop.id) {
            defaultCommands.remove(defaultCommands.size() - 1);
          }
        }
      }
      List<GraphPart> ignored=new ArrayList<>();
      for (      Loop l : loops) {
        ignored.add(l.loopContinue);
      }
      for (int i=0; i < caseBodies.size(); i++) {
        List<GraphTargetItem> cc=new ArrayList<>();
        GraphPart nextCase=null;
        nextCase=next;
        if (next != null) {
          if (i < caseBodies.size() - 1) {
            if (!caseBodies.get(i).leadsTo(code,caseBodies.get(i + 1),loops)) {
              cc.add(new BreakItem(null,currentLoop.id));
            }
 else {
              nextCase=caseBodies.get(i + 1);
            }
          }
 else           if (!defaultCommands.isEmpty()) {
            if (!caseBodies.get(i).leadsTo(code,defaultPart,loops)) {
              cc.add(new BreakItem(null,currentLoop.id));
            }
 else {
              nextCase=defaultPart;
            }
          }
        }
        List<GraphPart> stopPart2x=new ArrayList<>(stopPart);
        for (        GraphPart b : caseBodies) {
          if (b != caseBodies.get(i)) {
            stopPart2x.add(b);
          }
        }
        if (defaultPart != null) {
          stopPart2x.add(defaultPart);
        }
        if (breakPart != null) {
          stopPart2x.add(breakPart);
        }
        cc.addAll(0,printGraph(new ArrayList<GraphPart>(),localData,stack,allParts,null,caseBodies.get(i),stopPart2x,loops));
        if (cc.size() >= 2) {
          if (cc.get(cc.size() - 1) instanceof BreakItem) {
            if ((cc.get(cc.size() - 2) instanceof ContinueItem) || (cc.get(cc.size() - 2) instanceof BreakItem)) {
              cc.remove(cc.size() - 1);
            }
          }
        }
        caseCommands.add(cc);
      }
      ret=new ArrayList<>();
      if (!output.isEmpty()) {
        if (output.get(output.size() - 1) instanceof StoreRegisterTreeItem) {
          output.remove(output.size() - 1);
        }
      }
      ret.addAll(output);
      SwitchItem sti=new SwitchItem(null,currentLoop,switchedObject,caseValues,caseCommands,defaultCommands,valuesMapping);
      ret.add(sti);
      currentLoop.phase=2;
      if (next != null) {
        if (ti != null) {
          ret.add(ti);
        }
 else {
          ret.addAll(printGraph(new ArrayList<GraphPart>(),localData,stack,allParts,null,next,stopPart,loops));
        }
      }
    }
  }
  return ret;
}