Program: 62122
Project: 62122
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=false;
  if (debugMode) {
    System.err.println("String_Node_Str" + part + "String_Node_Str"+ part.nextParts.size());
  }
  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) {
      if (currentLoop != null) {
        currentLoop.phase=0;
      }
      ret.add(new BreakItem(null,el.id));
      return ret;
    }
    if (el.loopPreContinue == part) {
      if (currentLoop != null) {
        currentLoop.phase=0;
      }
      ret.add(new ContinueItem(null,el.id));
      return ret;
    }
    if (el.loopContinue == part) {
      if (currentLoop != null) {
        currentLoop.phase=0;
      }
      ret.add(new ContinueItem(null,el.id));
      return ret;
    }
  }
  if (stopPart.contains(part)) {
    if (currentLoop != null) {
      currentLoop.phase=0;
    }
    return ret;
  }
  if ((part != null) && (code.size() <= part.start)) {
    ret.add(new ScriptEndItem());
    return ret;
  }
  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,currentLoop);
    if (retCheck != null) {
      if (!retCheck.isEmpty()) {
        currentRet.addAll(retCheck);
      }
      parseNext=false;
    }
 else {
      currentRet.addAll(output);
    }
  }
  if (parseNext) {
    if (part.nextParts.size() > 2) {
      GraphPart next=getMostCommonPart(part.nextParts,loops);
      List<GraphPart> vis=new ArrayList<>();
      GraphTargetItem switchedItem=stack.pop();
      List<GraphTargetItem> caseValues=new ArrayList<>();
      List<List<GraphTargetItem>> caseCommands=new ArrayList<>();
      List<GraphTargetItem> defaultCommands=new ArrayList<>();
      List<Integer> valueMappings=new ArrayList<>();
      Loop swLoop=new Loop(loops.size(),null,next);
      swLoop.phase=1;
      loops.add(swLoop);
      boolean first=false;
      for (      GraphPart p : part.nextParts) {
        if (vis.contains(p)) {
          valueMappings.add(caseCommands.size() - 1);
          continue;
        }
        if (!first) {
          valueMappings.add(caseCommands.size());
        }
        List<GraphPart> stopPart2=new ArrayList<>();
        if (next != null) {
          stopPart2.add(next);
        }
 else         if (!stopPart.isEmpty()) {
          stopPart2.add(stopPart.get(stopPart.size() - 1));
        }
        for (        GraphPart p2 : part.nextParts) {
          if (p2 == p) {
            continue;
          }
          if (!stopPart2.contains(p2)) {
            stopPart2.add(p2);
          }
        }
        if (next != p) {
          if (first) {
            defaultCommands=printGraph(visited,prepareBranchLocalData(localData),stack,allParts,part,p,stopPart2,loops);
          }
 else {
            caseCommands.add(printGraph(visited,prepareBranchLocalData(localData),stack,allParts,part,p,stopPart2,loops));
          }
          vis.add(p);
        }
        first=false;
      }
      SwitchItem sw=new SwitchItem(null,null,switchedItem,caseValues,caseCommands,defaultCommands,valueMappings);
      currentRet.add(sw);
      swLoop.phase=2;
      if (next != null) {
        currentRet.addAll(printGraph(visited,localData,stack,allParts,part,next,stopPart,loops));
      }
    }
 else     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,prepareBranchLocalData(localData),trueStack,allParts,part,part.nextParts.get(1),stopPart2,loops);
      }
      List<GraphTargetItem> onFalse=new ArrayList<>();
      if (!isEmpty) {
        onFalse=printGraph(visited,prepareBranchLocalData(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) {
      boolean nextloop=false;
      for (      Loop l : loops) {
        if (part.nextParts.get(0) == l.loopContinue) {
          nextloop=true;
          break;
        }
        if (part.nextParts.get(0) == l.loopPreContinue) {
          nextloop=true;
          break;
        }
      }
      if (true) {
        printGraph(visited,localData,stack,allParts,part,part.nextParts.get(0),stopPart,loops,currentRet);
      }
    }
  }
  if (isLoop) {
    LoopItem li=loopItem;
    boolean loopTypeFound=false;
    boolean hasContinue=false;
    processIfs(loopItem.commands);
    checkContinueAtTheEnd(loopItem.commands,currentLoop);
    List<ContinueItem> continues=loopItem.getContinues();
    for (    ContinueItem c : continues) {
      if (c.loopId == currentLoop.id) {
        hasContinue=true;
        break;
      }
    }
    if (!hasContinue) {
      if (currentLoop.loopPreContinue != null) {
        List<GraphPart> stopContPart=new ArrayList<>();
        stopContPart.add(currentLoop.loopContinue);
        GraphPart precoBackup=currentLoop.loopPreContinue;
        currentLoop.loopPreContinue=null;
        loopItem.commands.addAll(printGraph(visited,localData,new Stack<GraphTargetItem>(),allParts,null,precoBackup,stopContPart,loops));
      }
    }
    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;
        boolean breakpos2=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;
          }
        }
 else         if (loopItem.commands.size() == 2 && (loopItem.commands.get(1) instanceof BreakItem)) {
          BreakItem bi=(BreakItem)loopItem.commands.get(1);
          if (bi.loopId == currentLoop.id) {
            bodyBranch=ifi.onTrue;
            breakpos2=true;
          }
        }
        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);
          if (breakpos2) {
            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<>();
          if (!bodyBranch.isEmpty()) {
            ret.add(index,loopItem);
          }
 else {
            loopItem.commands.remove(loopItem.commands.size() - 1);
            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);
    }
    currentLoop.phase=2;
    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 + "String_Node_Str"+ part.nextParts.size());
  }
  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) {
      if (currentLoop != null) {
        currentLoop.phase=0;
      }
      ret.add(new BreakItem(null,el.id));
      return ret;
    }
    if (el.loopPreContinue == part) {
      if (currentLoop != null) {
        currentLoop.phase=0;
      }
      ret.add(new ContinueItem(null,el.id));
      return ret;
    }
    if (el.loopContinue == part) {
      if (currentLoop != null) {
        currentLoop.phase=0;
      }
      ret.add(new ContinueItem(null,el.id));
      return ret;
    }
  }
  if (stopPart.contains(part)) {
    if (currentLoop != null) {
      currentLoop.phase=0;
    }
    return ret;
  }
  if ((part != null) && (code.size() <= part.start)) {
    ret.add(new ScriptEndItem());
    return ret;
  }
  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,currentLoop);
    if (retCheck != null) {
      if (!retCheck.isEmpty()) {
        currentRet.addAll(retCheck);
      }
      parseNext=false;
    }
 else {
      currentRet.addAll(output);
    }
  }
  if (parseNext) {
    if (part.nextParts.size() > 2) {
      GraphPart next=getMostCommonPart(part.nextParts,loops);
      List<GraphPart> vis=new ArrayList<>();
      GraphTargetItem switchedItem=stack.pop();
      List<GraphTargetItem> caseValues=new ArrayList<>();
      List<List<GraphTargetItem>> caseCommands=new ArrayList<>();
      List<GraphTargetItem> defaultCommands=new ArrayList<>();
      List<Integer> valueMappings=new ArrayList<>();
      Loop swLoop=new Loop(loops.size(),null,next);
      swLoop.phase=1;
      loops.add(swLoop);
      boolean first=false;
      for (      GraphPart p : part.nextParts) {
        if (vis.contains(p)) {
          valueMappings.add(caseCommands.size() - 1);
          continue;
        }
        if (!first) {
          valueMappings.add(caseCommands.size());
        }
        List<GraphPart> stopPart2=new ArrayList<>();
        if (next != null) {
          stopPart2.add(next);
        }
 else         if (!stopPart.isEmpty()) {
          stopPart2.add(stopPart.get(stopPart.size() - 1));
        }
        for (        GraphPart p2 : part.nextParts) {
          if (p2 == p) {
            continue;
          }
          if (!stopPart2.contains(p2)) {
            stopPart2.add(p2);
          }
        }
        if (next != p) {
          if (first) {
            defaultCommands=printGraph(visited,prepareBranchLocalData(localData),stack,allParts,part,p,stopPart2,loops);
          }
 else {
            caseCommands.add(printGraph(visited,prepareBranchLocalData(localData),stack,allParts,part,p,stopPart2,loops));
          }
          vis.add(p);
        }
        first=false;
      }
      SwitchItem sw=new SwitchItem(null,swLoop,switchedItem,caseValues,caseCommands,defaultCommands,valueMappings);
      currentRet.add(sw);
      swLoop.phase=2;
      if (next != null) {
        currentRet.addAll(printGraph(visited,localData,stack,allParts,part,next,stopPart,loops));
      }
    }
 else     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,prepareBranchLocalData(localData),trueStack,allParts,part,part.nextParts.get(1),stopPart2,loops);
      }
      List<GraphTargetItem> onFalse=new ArrayList<>();
      if (!isEmpty) {
        onFalse=printGraph(visited,prepareBranchLocalData(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) {
      boolean nextloop=false;
      for (      Loop l : loops) {
        if (part.nextParts.get(0) == l.loopContinue) {
          nextloop=true;
          break;
        }
        if (part.nextParts.get(0) == l.loopPreContinue) {
          nextloop=true;
          break;
        }
      }
      if (true) {
        printGraph(visited,localData,stack,allParts,part,part.nextParts.get(0),stopPart,loops,currentRet);
      }
    }
  }
  if (isLoop) {
    LoopItem li=loopItem;
    boolean loopTypeFound=false;
    boolean hasContinue=false;
    processIfs(loopItem.commands);
    checkContinueAtTheEnd(loopItem.commands,currentLoop);
    List<ContinueItem> continues=loopItem.getContinues();
    for (    ContinueItem c : continues) {
      if (c.loopId == currentLoop.id) {
        hasContinue=true;
        break;
      }
    }
    if (!hasContinue) {
      if (currentLoop.loopPreContinue != null) {
        List<GraphPart> stopContPart=new ArrayList<>();
        stopContPart.add(currentLoop.loopContinue);
        GraphPart precoBackup=currentLoop.loopPreContinue;
        currentLoop.loopPreContinue=null;
        loopItem.commands.addAll(printGraph(visited,localData,new Stack<GraphTargetItem>(),allParts,null,precoBackup,stopContPart,loops));
      }
    }
    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;
        boolean breakpos2=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;
          }
        }
 else         if (loopItem.commands.size() == 2 && (loopItem.commands.get(1) instanceof BreakItem)) {
          BreakItem bi=(BreakItem)loopItem.commands.get(1);
          if (bi.loopId == currentLoop.id) {
            bodyBranch=ifi.onTrue;
            breakpos2=true;
          }
        }
        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);
          if (breakpos2) {
            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<>();
          if (!bodyBranch.isEmpty()) {
            ret.add(index,loopItem);
          }
 else {
            loopItem.commands.remove(loopItem.commands.size() - 1);
            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);
    }
    currentLoop.phase=2;
    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;
}