Program: 62182
Project: 62182
Buggy source:
protected List<GraphTargetItem> printGraph(List<GraphPart> visited,List<Object> localData,Stack<GraphTargetItem> stack,List<GraphPart> allParts,GraphPart parent,GraphPart part,List<GraphPart> stopPart,List<Loop> loops,List<GraphTargetItem> ret){
  if (stopPart == null) {
    stopPart=new ArrayList<>();
  }
  if (visited.contains(part)) {
  }
 else {
    visited.add(part);
  }
  if (ret == null) {
    ret=new ArrayList<>();
  }
  boolean debugMode=true;
  if (debugMode) {
    System.err.println("String_Node_Str" + part);
  }
  if (part == null) {
    return ret;
  }
  part=checkPart(localData,part);
  if (part == null) {
    return ret;
  }
  if (part.ignored) {
    return ret;
  }
  List<GraphPart> loopContinues=getLoopsContinues(loops);
  boolean isLoop=false;
  Loop currentLoop=null;
  for (  Loop el : loops) {
    if ((el.loopContinue == part) && (el.phase == 0)) {
      currentLoop=el;
      currentLoop.phase=1;
      isLoop=true;
      break;
    }
  }
  if (debugMode) {
    System.err.println("String_Node_Str" + loops.size());
  }
  for (int l=loops.size() - 1; l >= 0; l--) {
    Loop el=loops.get(l);
    if (el == currentLoop) {
      if (debugMode) {
        System.err.println("String_Node_Str" + el);
      }
      continue;
    }
    if (el.phase != 1) {
      if (debugMode) {
      }
      continue;
    }
    if (el.loopBreak == part) {
      ret.add(new BreakItem(null,el.id));
      return ret;
    }
    if (el.loopPreContinue == part) {
      ret.add(new ContinueItem(null,el.id));
      return ret;
    }
    if (el.loopContinue == part) {
      ret.add(new ContinueItem(null,el.id));
      return ret;
    }
  }
  if (stopPart.contains(part)) {
    return ret;
  }
  if ((part != null) && (code.size() <= part.start)) {
    ret.add(new ScriptEndItem());
    return ret;
  }
  if (currentLoop != null) {
    currentLoop.used=true;
  }
  List<GraphTargetItem> currentRet=ret;
  UniversalLoopItem loopItem=null;
  if (isLoop) {
    loopItem=new UniversalLoopItem(null,currentLoop);
    currentRet.add(loopItem);
    loopItem.commands=new ArrayList<>();
    currentRet=loopItem.commands;
  }
  boolean parseNext=true;
  List<GraphTargetItem> output=new ArrayList<>();
  List<GraphPart> parts=new ArrayList<>();
  if (part instanceof GraphPartMulti) {
    parts=((GraphPartMulti)part).parts;
  }
 else {
    parts.add(part);
  }
  int end=part.end;
  for (  GraphPart p : parts) {
    end=p.end;
    int start=p.start;
    try {
      output.addAll(code.translatePart(p,localData,stack,start,end));
      if ((end >= code.size() - 1) && p.nextParts.isEmpty()) {
        output.add(new ScriptEndItem());
      }
    }
 catch (    Exception ex) {
      Logger.getLogger(Graph.class.getName()).log(Level.SEVERE,"String_Node_Str",ex);
      return ret;
    }
  }
  if (part.nextParts.size() == 2) {
    if ((stack.size() >= 2) && (stack.get(stack.size() - 1) instanceof NotItem) && (((NotItem)(stack.get(stack.size() - 1))).getOriginal().getNotCoerced() == stack.get(stack.size() - 2).getNotCoerced())) {
      currentRet.addAll(output);
      GraphPart sp0=getNextNoJump(part.nextParts.get(0));
      GraphPart sp1=getNextNoJump(part.nextParts.get(1));
      boolean reversed=false;
      loopContinues=getLoopsContinues(loops);
      loopContinues.add(part);
      if (sp1.leadsTo(code,sp0,loops)) {
      }
 else       if (sp0.leadsTo(code,sp1,loops)) {
        reversed=true;
      }
      GraphPart next=reversed ? sp0 : sp1;
      GraphTargetItem ti;
      if ((ti=checkLoop(next,stopPart,loops)) != null) {
        currentRet.add(ti);
      }
 else {
        List<GraphPart> stopPart2=new ArrayList<>(stopPart);
        stopPart2.add(reversed ? sp1 : sp0);
        printGraph(visited,localData,stack,allParts,parent,next,stopPart2,loops);
        GraphTargetItem second=stack.pop();
        GraphTargetItem first=stack.pop();
        if (!reversed) {
          AndItem a=new AndItem(null,first,second);
          stack.push(a);
          a.firstPart=part;
          if (second instanceof AndItem) {
            a.firstPart=((AndItem)second).firstPart;
          }
          if (second instanceof OrItem) {
            a.firstPart=((OrItem)second).firstPart;
          }
        }
 else {
          OrItem o=new OrItem(null,first,second);
          stack.push(o);
          o.firstPart=part;
          if (second instanceof AndItem) {
            o.firstPart=((AndItem)second).firstPart;
          }
          if (second instanceof OrItem) {
            o.firstPart=((OrItem)second).firstPart;
          }
        }
        next=reversed ? sp1 : sp0;
        if ((ti=checkLoop(next,stopPart,loops)) != null) {
          currentRet.add(ti);
        }
 else {
          currentRet.addAll(printGraph(visited,localData,stack,allParts,parent,next,stopPart,loops));
        }
      }
      parseNext=false;
    }
 else     if ((stack.size() >= 2) && (stack.get(stack.size() - 1).getNotCoerced() == stack.get(stack.size() - 2).getNotCoerced())) {
      currentRet.addAll(output);
      GraphPart sp0=getNextNoJump(part.nextParts.get(0));
      GraphPart sp1=getNextNoJump(part.nextParts.get(1));
      boolean reversed=false;
      loopContinues=getLoopsContinues(loops);
      loopContinues.add(part);
      if (sp1.leadsTo(code,sp0,loops)) {
      }
 else       if (sp0.leadsTo(code,sp1,loops)) {
        reversed=true;
      }
      GraphPart next=reversed ? sp0 : sp1;
      GraphTargetItem ti;
      if ((ti=checkLoop(next,stopPart,loops)) != null) {
        currentRet.add(ti);
      }
 else {
        List<GraphPart> stopPart2=new ArrayList<>(stopPart);
        stopPart2.add(reversed ? sp1 : sp0);
        printGraph(visited,localData,stack,allParts,parent,next,stopPart2,loops);
        GraphTargetItem second=stack.pop();
        GraphTargetItem first=stack.pop();
        if (reversed) {
          AndItem a=new AndItem(null,first,second);
          stack.push(a);
          a.firstPart=part;
          if (second instanceof AndItem) {
            a.firstPart=((AndItem)second).firstPart;
          }
          if (second instanceof OrItem) {
            a.firstPart=((AndItem)second).firstPart;
          }
        }
 else {
          OrItem o=new OrItem(null,first,second);
          stack.push(o);
          o.firstPart=part;
          if (second instanceof OrItem) {
            o.firstPart=((OrItem)second).firstPart;
          }
          if (second instanceof OrItem) {
            o.firstPart=((OrItem)second).firstPart;
          }
        }
        next=reversed ? sp1 : sp0;
        if ((ti=checkLoop(next,stopPart,loops)) != null) {
          currentRet.add(ti);
        }
 else {
          currentRet.addAll(printGraph(visited,localData,stack,allParts,parent,next,stopPart,loops));
        }
      }
      parseNext=false;
    }
  }
  if (parseNext) {
    List<GraphTargetItem> retCheck=check(code,localData,allParts,stack,parent,part,stopPart,loops,output);
    if (retCheck != null) {
      if (!retCheck.isEmpty()) {
        currentRet.addAll(retCheck);
      }
      return ret;
    }
 else {
      currentRet.addAll(output);
    }
    if (part.nextParts.size() == 2) {
      GraphTargetItem expr=stack.pop();
      if (expr instanceof LogicalOpItem) {
        expr=((LogicalOpItem)expr).invert();
      }
 else {
        expr=new NotItem(null,expr);
      }
      GraphPart next=getNextCommonPart(part,loops);
      @SuppressWarnings("String_Node_Str") Stack<GraphTargetItem> trueStack=(Stack<GraphTargetItem>)stack.clone();
      @SuppressWarnings("String_Node_Str") Stack<GraphTargetItem> falseStack=(Stack<GraphTargetItem>)stack.clone();
      int trueStackSizeBefore=trueStack.size();
      int falseStackSizeBefore=falseStack.size();
      List<GraphTargetItem> onTrue=new ArrayList<>();
      boolean isEmpty=part.nextParts.get(0) == part.nextParts.get(1);
      if (isEmpty) {
        next=part.nextParts.get(0);
      }
      List<GraphPart> stopPart2=new ArrayList<>(stopPart);
      if (next != null) {
        stopPart2.add(next);
      }
      if (!isEmpty) {
        onTrue=printGraph(visited,localData,trueStack,allParts,part,part.nextParts.get(1),stopPart2,loops);
      }
      List<GraphTargetItem> onFalse=new ArrayList<>();
      if (!isEmpty) {
        onFalse=printGraph(visited,localData,falseStack,allParts,part,part.nextParts.get(0),stopPart2,loops);
      }
      if (isEmpty(onTrue) && isEmpty(onFalse) && (trueStack.size() > trueStackSizeBefore)&& (falseStack.size() > falseStackSizeBefore)) {
        stack.push(new TernarOpItem(null,expr,trueStack.pop(),falseStack.pop()));
      }
 else {
        currentRet.add(new IfItem(null,expr,onTrue,onFalse));
      }
      if (next != null) {
        printGraph(visited,localData,stack,allParts,part,next,stopPart,loops,currentRet);
      }
    }
 else     if (part.nextParts.size() == 1) {
      printGraph(visited,localData,stack,allParts,part,part.nextParts.get(0),stopPart,loops,currentRet);
    }
  }
  if (isLoop) {
    currentLoop.phase=2;
    LoopItem li=loopItem;
    boolean loopTypeFound=false;
    checkContinueAtTheEnd(loopItem.commands,currentLoop);
    if (!loopTypeFound && (!loopItem.commands.isEmpty())) {
      if (loopItem.commands.get(0) instanceof IfItem) {
        IfItem ifi=(IfItem)loopItem.commands.get(0);
        List<GraphTargetItem> bodyBranch=null;
        boolean inverted=false;
        if ((ifi.onTrue.size() == 1) && (ifi.onTrue.get(0) instanceof BreakItem)) {
          BreakItem bi=(BreakItem)ifi.onTrue.get(0);
          if (bi.loopId == currentLoop.id) {
            bodyBranch=ifi.onFalse;
            inverted=true;
          }
        }
 else         if ((ifi.onFalse.size() == 1) && (ifi.onFalse.get(0) instanceof BreakItem)) {
          BreakItem bi=(BreakItem)ifi.onFalse.get(0);
          if (bi.loopId == currentLoop.id) {
            bodyBranch=ifi.onTrue;
          }
        }
        if (bodyBranch != null) {
          int index=ret.indexOf(loopItem);
          ret.remove(index);
          List<GraphTargetItem> exprList=new ArrayList<>();
          GraphTargetItem expr=ifi.expression;
          if (inverted) {
            if (expr instanceof LogicalOpItem) {
              expr=((LogicalOpItem)expr).invert();
            }
 else {
              expr=new NotItem(null,expr);
            }
          }
          exprList.add(expr);
          List<GraphTargetItem> commands=new ArrayList<>();
          commands.addAll(bodyBranch);
          loopItem.commands.remove(0);
          commands.addAll(loopItem.commands);
          checkContinueAtTheEnd(commands,currentLoop);
          List<GraphTargetItem> finalComm=new ArrayList<>();
          if (currentLoop.loopPreContinue != null) {
            GraphPart backup=currentLoop.loopPreContinue;
            currentLoop.loopPreContinue=null;
            List<GraphPart> stopPart2=new ArrayList<>(stopPart);
            stopPart2.add(currentLoop.loopContinue);
            finalComm=printGraph(visited,localData,new Stack<GraphTargetItem>(),allParts,null,backup,stopPart2,loops);
            currentLoop.loopPreContinue=backup;
            checkContinueAtTheEnd(finalComm,currentLoop);
          }
          if (!finalComm.isEmpty()) {
            ret.add(index,li=new ForTreeItem(null,currentLoop,new ArrayList<GraphTargetItem>(),exprList.get(exprList.size() - 1),finalComm,commands));
          }
 else {
            ret.add(index,li=new WhileItem(null,currentLoop,exprList,commands));
          }
          loopTypeFound=true;
        }
      }
    }
    if (!loopTypeFound && (!loopItem.commands.isEmpty())) {
      if (loopItem.commands.get(loopItem.commands.size() - 1) instanceof IfItem) {
        IfItem ifi=(IfItem)loopItem.commands.get(loopItem.commands.size() - 1);
        List<GraphTargetItem> bodyBranch=null;
        boolean inverted=false;
        if ((ifi.onTrue.size() == 1) && (ifi.onTrue.get(0) instanceof BreakItem)) {
          BreakItem bi=(BreakItem)ifi.onTrue.get(0);
          if (bi.loopId == currentLoop.id) {
            bodyBranch=ifi.onFalse;
            inverted=true;
          }
        }
 else         if ((ifi.onFalse.size() == 1) && (ifi.onFalse.get(0) instanceof BreakItem)) {
          BreakItem bi=(BreakItem)ifi.onFalse.get(0);
          if (bi.loopId == currentLoop.id) {
            bodyBranch=ifi.onTrue;
          }
        }
        if (bodyBranch != null) {
          int index=ret.indexOf(loopItem);
          ret.remove(index);
          List<GraphTargetItem> exprList=new ArrayList<>();
          GraphTargetItem expr=ifi.expression;
          if (inverted) {
            if (expr instanceof LogicalOpItem) {
              expr=((LogicalOpItem)expr).invert();
            }
 else {
              expr=new NotItem(null,expr);
            }
          }
          checkContinueAtTheEnd(bodyBranch,currentLoop);
          List<GraphTargetItem> commands=new ArrayList<>();
          loopItem.commands.remove(loopItem.commands.size() - 1);
          if (!bodyBranch.isEmpty()) {
          }
 else {
            commands.addAll(loopItem.commands);
            commands.addAll(bodyBranch);
            exprList.add(expr);
            checkContinueAtTheEnd(commands,currentLoop);
            ret.add(index,li=new DoWhileItem(null,currentLoop,commands,exprList));
          }
          loopTypeFound=true;
        }
      }
    }
    if (!loopTypeFound) {
      if (currentLoop.loopPreContinue != null) {
        loopTypeFound=true;
        GraphPart backup=currentLoop.loopPreContinue;
        currentLoop.loopPreContinue=null;
        List<GraphPart> stopPart2=new ArrayList<>(stopPart);
        stopPart2.add(currentLoop.loopContinue);
        List<GraphTargetItem> finalComm=printGraph(visited,localData,new Stack<GraphTargetItem>(),allParts,null,backup,stopPart2,loops);
        currentLoop.loopPreContinue=backup;
        checkContinueAtTheEnd(finalComm,currentLoop);
        if (!finalComm.isEmpty()) {
          if (finalComm.get(finalComm.size() - 1) instanceof IfItem) {
            IfItem ifi=(IfItem)finalComm.get(finalComm.size() - 1);
            boolean ok=false;
            boolean invert=false;
            if (((ifi.onTrue.size() == 1) && (ifi.onTrue.get(0) instanceof BreakItem) && (((BreakItem)ifi.onTrue.get(0)).loopId == currentLoop.id)) && ((ifi.onTrue.size() == 1) && (ifi.onFalse.get(0) instanceof ContinueItem) && (((ContinueItem)ifi.onFalse.get(0)).loopId == currentLoop.id))) {
              ok=true;
              invert=true;
            }
            if (((ifi.onTrue.size() == 1) && (ifi.onTrue.get(0) instanceof ContinueItem) && (((ContinueItem)ifi.onTrue.get(0)).loopId == currentLoop.id)) && ((ifi.onTrue.size() == 1) && (ifi.onFalse.get(0) instanceof BreakItem) && (((BreakItem)ifi.onFalse.get(0)).loopId == currentLoop.id))) {
              ok=true;
            }
            if (ok) {
              finalComm.remove(finalComm.size() - 1);
              int index=ret.indexOf(loopItem);
              ret.remove(index);
              List<GraphTargetItem> exprList=new ArrayList<>(finalComm);
              GraphTargetItem expr=ifi.expression;
              if (invert) {
                if (expr instanceof LogicalOpItem) {
                  expr=((LogicalOpItem)expr).invert();
                }
 else {
                  expr=new NotItem(null,expr);
                }
              }
              exprList.add(expr);
              ret.add(index,li=new DoWhileItem(null,currentLoop,loopItem.commands,exprList));
            }
          }
        }
      }
    }
    if (!loopTypeFound) {
      checkContinueAtTheEnd(loopItem.commands,currentLoop);
    }
    GraphTargetItem replaced=checkLoop(li,localData,loops);
    if (replaced != li) {
      int index=ret.indexOf(li);
      ret.remove(index);
      if (replaced != null) {
        ret.add(index,replaced);
      }
    }
    if (currentLoop.loopBreak != null) {
      ret.addAll(printGraph(visited,localData,stack,allParts,part,currentLoop.loopBreak,stopPart,loops));
    }
  }
  return ret;
}

Fixed version (ground truth):
protected List<GraphTargetItem> printGraph(List<GraphPart> visited,List<Object> localData,Stack<GraphTargetItem> stack,List<GraphPart> allParts,GraphPart parent,GraphPart part,List<GraphPart> stopPart,List<Loop> loops,List<GraphTargetItem> ret){
  if (stopPart == null) {
    stopPart=new ArrayList<>();
  }
  if (visited.contains(part)) {
  }
 else {
    visited.add(part);
  }
  if (ret == null) {
    ret=new ArrayList<>();
  }
  boolean debugMode=false;
  if (debugMode) {
    System.err.println("String_Node_Str" + part);
  }
  if (part == null) {
    return ret;
  }
  part=checkPart(localData,part);
  if (part == null) {
    return ret;
  }
  if (part.ignored) {
    return ret;
  }
  List<GraphPart> loopContinues=getLoopsContinues(loops);
  boolean isLoop=false;
  Loop currentLoop=null;
  for (  Loop el : loops) {
    if ((el.loopContinue == part) && (el.phase == 0)) {
      currentLoop=el;
      currentLoop.phase=1;
      isLoop=true;
      break;
    }
  }
  if (debugMode) {
    System.err.println("String_Node_Str" + loops.size());
  }
  for (int l=loops.size() - 1; l >= 0; l--) {
    Loop el=loops.get(l);
    if (el == currentLoop) {
      if (debugMode) {
        System.err.println("String_Node_Str" + el);
      }
      continue;
    }
    if (el.phase != 1) {
      if (debugMode) {
      }
      continue;
    }
    if (el.loopBreak == part) {
      ret.add(new BreakItem(null,el.id));
      return ret;
    }
    if (el.loopPreContinue == part) {
      ret.add(new ContinueItem(null,el.id));
      return ret;
    }
    if (el.loopContinue == part) {
      ret.add(new ContinueItem(null,el.id));
      return ret;
    }
  }
  if (stopPart.contains(part)) {
    return ret;
  }
  if ((part != null) && (code.size() <= part.start)) {
    ret.add(new ScriptEndItem());
    return ret;
  }
  if (currentLoop != null) {
    currentLoop.used=true;
  }
  List<GraphTargetItem> currentRet=ret;
  UniversalLoopItem loopItem=null;
  if (isLoop) {
    loopItem=new UniversalLoopItem(null,currentLoop);
    currentRet.add(loopItem);
    loopItem.commands=new ArrayList<>();
    currentRet=loopItem.commands;
  }
  boolean parseNext=true;
  List<GraphTargetItem> output=new ArrayList<>();
  List<GraphPart> parts=new ArrayList<>();
  if (part instanceof GraphPartMulti) {
    parts=((GraphPartMulti)part).parts;
  }
 else {
    parts.add(part);
  }
  int end=part.end;
  for (  GraphPart p : parts) {
    end=p.end;
    int start=p.start;
    try {
      output.addAll(code.translatePart(p,localData,stack,start,end));
      if ((end >= code.size() - 1) && p.nextParts.isEmpty()) {
        output.add(new ScriptEndItem());
      }
    }
 catch (    Exception ex) {
      Logger.getLogger(Graph.class.getName()).log(Level.SEVERE,"String_Node_Str",ex);
      return ret;
    }
  }
  if (part.nextParts.size() == 2) {
    if ((stack.size() >= 2) && (stack.get(stack.size() - 1) instanceof NotItem) && (((NotItem)(stack.get(stack.size() - 1))).getOriginal().getNotCoerced() == stack.get(stack.size() - 2).getNotCoerced())) {
      currentRet.addAll(output);
      GraphPart sp0=getNextNoJump(part.nextParts.get(0));
      GraphPart sp1=getNextNoJump(part.nextParts.get(1));
      boolean reversed=false;
      loopContinues=getLoopsContinues(loops);
      loopContinues.add(part);
      if (sp1.leadsTo(code,sp0,loops)) {
      }
 else       if (sp0.leadsTo(code,sp1,loops)) {
        reversed=true;
      }
      GraphPart next=reversed ? sp0 : sp1;
      GraphTargetItem ti;
      if ((ti=checkLoop(next,stopPart,loops)) != null) {
        currentRet.add(ti);
      }
 else {
        List<GraphPart> stopPart2=new ArrayList<>(stopPart);
        stopPart2.add(reversed ? sp1 : sp0);
        printGraph(visited,localData,stack,allParts,parent,next,stopPart2,loops);
        GraphTargetItem second=stack.pop();
        GraphTargetItem first=stack.pop();
        if (!reversed) {
          AndItem a=new AndItem(null,first,second);
          stack.push(a);
          a.firstPart=part;
          if (second instanceof AndItem) {
            a.firstPart=((AndItem)second).firstPart;
          }
          if (second instanceof OrItem) {
            a.firstPart=((OrItem)second).firstPart;
          }
        }
 else {
          OrItem o=new OrItem(null,first,second);
          stack.push(o);
          o.firstPart=part;
          if (second instanceof AndItem) {
            o.firstPart=((AndItem)second).firstPart;
          }
          if (second instanceof OrItem) {
            o.firstPart=((OrItem)second).firstPart;
          }
        }
        next=reversed ? sp1 : sp0;
        if ((ti=checkLoop(next,stopPart,loops)) != null) {
          currentRet.add(ti);
        }
 else {
          currentRet.addAll(printGraph(visited,localData,stack,allParts,parent,next,stopPart,loops));
        }
      }
      parseNext=false;
    }
 else     if ((stack.size() >= 2) && (stack.get(stack.size() - 1).getNotCoerced() == stack.get(stack.size() - 2).getNotCoerced())) {
      currentRet.addAll(output);
      GraphPart sp0=getNextNoJump(part.nextParts.get(0));
      GraphPart sp1=getNextNoJump(part.nextParts.get(1));
      boolean reversed=false;
      loopContinues=getLoopsContinues(loops);
      loopContinues.add(part);
      if (sp1.leadsTo(code,sp0,loops)) {
      }
 else       if (sp0.leadsTo(code,sp1,loops)) {
        reversed=true;
      }
      GraphPart next=reversed ? sp0 : sp1;
      GraphTargetItem ti;
      if ((ti=checkLoop(next,stopPart,loops)) != null) {
        currentRet.add(ti);
      }
 else {
        List<GraphPart> stopPart2=new ArrayList<>(stopPart);
        stopPart2.add(reversed ? sp1 : sp0);
        printGraph(visited,localData,stack,allParts,parent,next,stopPart2,loops);
        GraphTargetItem second=stack.pop();
        GraphTargetItem first=stack.pop();
        if (reversed) {
          AndItem a=new AndItem(null,first,second);
          stack.push(a);
          a.firstPart=part;
          if (second instanceof AndItem) {
            a.firstPart=((AndItem)second).firstPart;
          }
          if (second instanceof OrItem) {
            a.firstPart=((AndItem)second).firstPart;
          }
        }
 else {
          OrItem o=new OrItem(null,first,second);
          stack.push(o);
          o.firstPart=part;
          if (second instanceof OrItem) {
            o.firstPart=((OrItem)second).firstPart;
          }
          if (second instanceof OrItem) {
            o.firstPart=((OrItem)second).firstPart;
          }
        }
        next=reversed ? sp1 : sp0;
        if ((ti=checkLoop(next,stopPart,loops)) != null) {
          currentRet.add(ti);
        }
 else {
          currentRet.addAll(printGraph(visited,localData,stack,allParts,parent,next,stopPart,loops));
        }
      }
      parseNext=false;
    }
  }
  if (parseNext) {
    List<GraphTargetItem> retCheck=check(code,localData,allParts,stack,parent,part,stopPart,loops,output);
    if (retCheck != null) {
      if (!retCheck.isEmpty()) {
        currentRet.addAll(retCheck);
      }
      return ret;
    }
 else {
      currentRet.addAll(output);
    }
    if (part.nextParts.size() == 2) {
      GraphTargetItem expr=stack.pop();
      if (expr instanceof LogicalOpItem) {
        expr=((LogicalOpItem)expr).invert();
      }
 else {
        expr=new NotItem(null,expr);
      }
      GraphPart next=getNextCommonPart(part,loops);
      @SuppressWarnings("String_Node_Str") Stack<GraphTargetItem> trueStack=(Stack<GraphTargetItem>)stack.clone();
      @SuppressWarnings("String_Node_Str") Stack<GraphTargetItem> falseStack=(Stack<GraphTargetItem>)stack.clone();
      int trueStackSizeBefore=trueStack.size();
      int falseStackSizeBefore=falseStack.size();
      List<GraphTargetItem> onTrue=new ArrayList<>();
      boolean isEmpty=part.nextParts.get(0) == part.nextParts.get(1);
      if (isEmpty) {
        next=part.nextParts.get(0);
      }
      List<GraphPart> stopPart2=new ArrayList<>(stopPart);
      if (next != null) {
        stopPart2.add(next);
      }
      if (!isEmpty) {
        onTrue=printGraph(visited,localData,trueStack,allParts,part,part.nextParts.get(1),stopPart2,loops);
      }
      List<GraphTargetItem> onFalse=new ArrayList<>();
      if (!isEmpty) {
        onFalse=printGraph(visited,localData,falseStack,allParts,part,part.nextParts.get(0),stopPart2,loops);
      }
      if (isEmpty(onTrue) && isEmpty(onFalse) && (trueStack.size() > trueStackSizeBefore)&& (falseStack.size() > falseStackSizeBefore)) {
        stack.push(new TernarOpItem(null,expr,trueStack.pop(),falseStack.pop()));
      }
 else {
        currentRet.add(new IfItem(null,expr,onTrue,onFalse));
      }
      if (next != null) {
        printGraph(visited,localData,stack,allParts,part,next,stopPart,loops,currentRet);
      }
    }
 else     if (part.nextParts.size() == 1) {
      printGraph(visited,localData,stack,allParts,part,part.nextParts.get(0),stopPart,loops,currentRet);
    }
  }
  if (isLoop) {
    currentLoop.phase=2;
    LoopItem li=loopItem;
    boolean loopTypeFound=false;
    checkContinueAtTheEnd(loopItem.commands,currentLoop);
    if (!loopTypeFound && (!loopItem.commands.isEmpty())) {
      if (loopItem.commands.get(0) instanceof IfItem) {
        IfItem ifi=(IfItem)loopItem.commands.get(0);
        List<GraphTargetItem> bodyBranch=null;
        boolean inverted=false;
        if ((ifi.onTrue.size() == 1) && (ifi.onTrue.get(0) instanceof BreakItem)) {
          BreakItem bi=(BreakItem)ifi.onTrue.get(0);
          if (bi.loopId == currentLoop.id) {
            bodyBranch=ifi.onFalse;
            inverted=true;
          }
        }
 else         if ((ifi.onFalse.size() == 1) && (ifi.onFalse.get(0) instanceof BreakItem)) {
          BreakItem bi=(BreakItem)ifi.onFalse.get(0);
          if (bi.loopId == currentLoop.id) {
            bodyBranch=ifi.onTrue;
          }
        }
        if (bodyBranch != null) {
          int index=ret.indexOf(loopItem);
          ret.remove(index);
          List<GraphTargetItem> exprList=new ArrayList<>();
          GraphTargetItem expr=ifi.expression;
          if (inverted) {
            if (expr instanceof LogicalOpItem) {
              expr=((LogicalOpItem)expr).invert();
            }
 else {
              expr=new NotItem(null,expr);
            }
          }
          exprList.add(expr);
          List<GraphTargetItem> commands=new ArrayList<>();
          commands.addAll(bodyBranch);
          loopItem.commands.remove(0);
          commands.addAll(loopItem.commands);
          checkContinueAtTheEnd(commands,currentLoop);
          List<GraphTargetItem> finalComm=new ArrayList<>();
          if (currentLoop.loopPreContinue != null) {
            GraphPart backup=currentLoop.loopPreContinue;
            currentLoop.loopPreContinue=null;
            List<GraphPart> stopPart2=new ArrayList<>(stopPart);
            stopPart2.add(currentLoop.loopContinue);
            finalComm=printGraph(visited,localData,new Stack<GraphTargetItem>(),allParts,null,backup,stopPart2,loops);
            currentLoop.loopPreContinue=backup;
            checkContinueAtTheEnd(finalComm,currentLoop);
          }
          if (!finalComm.isEmpty()) {
            ret.add(index,li=new ForTreeItem(null,currentLoop,new ArrayList<GraphTargetItem>(),exprList.get(exprList.size() - 1),finalComm,commands));
          }
 else {
            ret.add(index,li=new WhileItem(null,currentLoop,exprList,commands));
          }
          loopTypeFound=true;
        }
      }
    }
    if (!loopTypeFound && (!loopItem.commands.isEmpty())) {
      if (loopItem.commands.get(loopItem.commands.size() - 1) instanceof IfItem) {
        IfItem ifi=(IfItem)loopItem.commands.get(loopItem.commands.size() - 1);
        List<GraphTargetItem> bodyBranch=null;
        boolean inverted=false;
        if ((ifi.onTrue.size() == 1) && (ifi.onTrue.get(0) instanceof BreakItem)) {
          BreakItem bi=(BreakItem)ifi.onTrue.get(0);
          if (bi.loopId == currentLoop.id) {
            bodyBranch=ifi.onFalse;
            inverted=true;
          }
        }
 else         if ((ifi.onFalse.size() == 1) && (ifi.onFalse.get(0) instanceof BreakItem)) {
          BreakItem bi=(BreakItem)ifi.onFalse.get(0);
          if (bi.loopId == currentLoop.id) {
            bodyBranch=ifi.onTrue;
          }
        }
        if (bodyBranch != null) {
          int index=ret.indexOf(loopItem);
          ret.remove(index);
          List<GraphTargetItem> exprList=new ArrayList<>();
          GraphTargetItem expr=ifi.expression;
          if (inverted) {
            if (expr instanceof LogicalOpItem) {
              expr=((LogicalOpItem)expr).invert();
            }
 else {
              expr=new NotItem(null,expr);
            }
          }
          checkContinueAtTheEnd(bodyBranch,currentLoop);
          List<GraphTargetItem> commands=new ArrayList<>();
          loopItem.commands.remove(loopItem.commands.size() - 1);
          if (!bodyBranch.isEmpty()) {
          }
 else {
            commands.addAll(loopItem.commands);
            commands.addAll(bodyBranch);
            exprList.add(expr);
            checkContinueAtTheEnd(commands,currentLoop);
            ret.add(index,li=new DoWhileItem(null,currentLoop,commands,exprList));
          }
          loopTypeFound=true;
        }
      }
    }
    if (!loopTypeFound) {
      if (currentLoop.loopPreContinue != null) {
        loopTypeFound=true;
        GraphPart backup=currentLoop.loopPreContinue;
        currentLoop.loopPreContinue=null;
        List<GraphPart> stopPart2=new ArrayList<>(stopPart);
        stopPart2.add(currentLoop.loopContinue);
        List<GraphTargetItem> finalComm=printGraph(visited,localData,new Stack<GraphTargetItem>(),allParts,null,backup,stopPart2,loops);
        currentLoop.loopPreContinue=backup;
        checkContinueAtTheEnd(finalComm,currentLoop);
        if (!finalComm.isEmpty()) {
          if (finalComm.get(finalComm.size() - 1) instanceof IfItem) {
            IfItem ifi=(IfItem)finalComm.get(finalComm.size() - 1);
            boolean ok=false;
            boolean invert=false;
            if (((ifi.onTrue.size() == 1) && (ifi.onTrue.get(0) instanceof BreakItem) && (((BreakItem)ifi.onTrue.get(0)).loopId == currentLoop.id)) && ((ifi.onTrue.size() == 1) && (ifi.onFalse.get(0) instanceof ContinueItem) && (((ContinueItem)ifi.onFalse.get(0)).loopId == currentLoop.id))) {
              ok=true;
              invert=true;
            }
            if (((ifi.onTrue.size() == 1) && (ifi.onTrue.get(0) instanceof ContinueItem) && (((ContinueItem)ifi.onTrue.get(0)).loopId == currentLoop.id)) && ((ifi.onTrue.size() == 1) && (ifi.onFalse.get(0) instanceof BreakItem) && (((BreakItem)ifi.onFalse.get(0)).loopId == currentLoop.id))) {
              ok=true;
            }
            if (ok) {
              finalComm.remove(finalComm.size() - 1);
              int index=ret.indexOf(loopItem);
              ret.remove(index);
              List<GraphTargetItem> exprList=new ArrayList<>(finalComm);
              GraphTargetItem expr=ifi.expression;
              if (invert) {
                if (expr instanceof LogicalOpItem) {
                  expr=((LogicalOpItem)expr).invert();
                }
 else {
                  expr=new NotItem(null,expr);
                }
              }
              exprList.add(expr);
              ret.add(index,li=new DoWhileItem(null,currentLoop,loopItem.commands,exprList));
            }
          }
        }
      }
    }
    if (!loopTypeFound) {
      checkContinueAtTheEnd(loopItem.commands,currentLoop);
    }
    GraphTargetItem replaced=checkLoop(li,localData,loops);
    if (replaced != li) {
      int index=ret.indexOf(li);
      ret.remove(index);
      if (replaced != null) {
        ret.add(index,replaced);
      }
    }
    if (currentLoop.loopBreak != null) {
      ret.addAll(printGraph(visited,localData,stack,allParts,part,currentLoop.loopBreak,stopPart,loops));
    }
  }
  return ret;
}