Program: 12158
Project: 12158
Buggy source:
private List<CFGNode> process(List<CFGNode> previousNodes,CompositeStatementObject composite){
  for (  AbstractStatement abstractStatement : composite.getStatements()) {
    if (abstractStatement instanceof StatementObject) {
      StatementObject statement=(StatementObject)abstractStatement;
      CFGNode currentNode=new CFGNode(statement);
      nodes.add(currentNode);
      createTopDownFlow(previousNodes,currentNode);
      ArrayList<CFGNode> currentNodes=new ArrayList<CFGNode>();
      currentNodes.add(currentNode);
      previousNodes=currentNodes;
    }
 else     if (abstractStatement instanceof CompositeStatementObject) {
      CompositeStatementObject compositeStatement=(CompositeStatementObject)abstractStatement;
      if (compositeStatement.getStatement() instanceof Block) {
        previousNodes=process(previousNodes,compositeStatement);
      }
 else       if (isLoop(compositeStatement)) {
        CFGBranchNode currentNode=new CFGBranchLoopNode(compositeStatement);
        nodes.add(currentNode);
        createTopDownFlow(previousNodes,currentNode);
        previousNodes=new ArrayList<CFGNode>();
        ArrayList<CFGNode> currentNodes=new ArrayList<CFGNode>();
        currentNodes.add(currentNode);
        previousNodes.addAll(process(currentNodes,compositeStatement));
        for (        CFGNode previousNode : previousNodes) {
          Flow flow=new Flow(previousNode,currentNode);
          if (previousNode instanceof CFGBranchNode) {
            flow.setFalseControlFlow(true);
          }
          flow.setLoopbackFlow(true);
          edges.add(flow);
        }
        if (previousNodes.size() > 1) {
          for (          CFGBranchConditionalNode conditionalNode : unjoinedConditionalNodes) {
            conditionalNode.setJoinNode(currentNode);
          }
          unjoinedConditionalNodes.clear();
        }
        previousNodes=currentNodes;
      }
 else       if (compositeStatement.getStatement() instanceof DoStatement) {
        List<CFGNode> tmpNodes=previousNodes;
        previousNodes=process(previousNodes,compositeStatement);
        CFGBranchNode currentNode=new CFGBranchDoLoopNode(compositeStatement);
        nodes.add(currentNode);
        createTopDownFlow(previousNodes,currentNode);
        CFGNode topNode=getCommonNextNode(tmpNodes);
        Flow flow=new Flow(currentNode,topNode);
        flow.setTrueControlFlow(true);
        flow.setLoopbackFlow(true);
        edges.add(flow);
        ArrayList<CFGNode> currentNodes=new ArrayList<CFGNode>();
        currentNodes.add(currentNode);
        previousNodes=currentNodes;
      }
 else       if (compositeStatement.getStatement() instanceof IfStatement) {
        previousNodes=processIfStatement(previousNodes,compositeStatement);
      }
    }
  }
  return previousNodes;
}

Fixed version (ground truth):
private List<CFGNode> process(List<CFGNode> previousNodes,CompositeStatementObject composite){
  int i=0;
  for (  AbstractStatement abstractStatement : composite.getStatements()) {
    if (abstractStatement instanceof StatementObject) {
      StatementObject statement=(StatementObject)abstractStatement;
      CFGNode currentNode=new CFGNode(statement);
      nodes.add(currentNode);
      createTopDownFlow(previousNodes,currentNode);
      ArrayList<CFGNode> currentNodes=new ArrayList<CFGNode>();
      currentNodes.add(currentNode);
      previousNodes=currentNodes;
    }
 else     if (abstractStatement instanceof CompositeStatementObject) {
      CompositeStatementObject compositeStatement=(CompositeStatementObject)abstractStatement;
      if (compositeStatement.getStatement() instanceof Block) {
        previousNodes=process(previousNodes,compositeStatement);
      }
 else       if (isLoop(compositeStatement)) {
        CFGBranchNode currentNode=new CFGBranchLoopNode(compositeStatement);
        nodes.add(currentNode);
        createTopDownFlow(previousNodes,currentNode);
        previousNodes=new ArrayList<CFGNode>();
        ArrayList<CFGNode> currentNodes=new ArrayList<CFGNode>();
        currentNodes.add(currentNode);
        previousNodes.addAll(process(currentNodes,compositeStatement));
        for (        CFGNode previousNode : previousNodes) {
          Flow flow=new Flow(previousNode,currentNode);
          if (previousNode instanceof CFGBranchNode) {
            flow.setFalseControlFlow(true);
          }
          flow.setLoopbackFlow(true);
          edges.add(flow);
        }
        if (previousNodes.size() > 1) {
          List<CFGBranchConditionalNode> conditionalNodes=unjoinedConditionalNodes.pop();
          for (          CFGBranchConditionalNode conditionalNode : conditionalNodes) {
            conditionalNode.setJoinNode(currentNode);
          }
        }
        previousNodes=currentNodes;
      }
 else       if (compositeStatement.getStatement() instanceof DoStatement) {
        List<CFGNode> tmpNodes=previousNodes;
        previousNodes=process(previousNodes,compositeStatement);
        CFGBranchNode currentNode=new CFGBranchDoLoopNode(compositeStatement);
        nodes.add(currentNode);
        createTopDownFlow(previousNodes,currentNode);
        CFGNode topNode=getCommonNextNode(tmpNodes);
        Flow flow=new Flow(currentNode,topNode);
        flow.setTrueControlFlow(true);
        flow.setLoopbackFlow(true);
        edges.add(flow);
        ArrayList<CFGNode> currentNodes=new ArrayList<CFGNode>();
        currentNodes.add(currentNode);
        previousNodes=currentNodes;
      }
 else       if (compositeStatement.getStatement() instanceof IfStatement) {
        int action=PUSH_NEW_LIST;
        List<AbstractStatement> statements=composite.getStatements();
        if (statements.size() == 1)         action=JOIN_TOP_LIST;
 else         if (statements.size() > 1) {
          AbstractStatement previousStatement=null;
          if (i >= 1)           previousStatement=statements.get(i - 1);
          if (statements.get(statements.size() - 1).equals(compositeStatement)) {
            if (previousStatement != null && previousStatement.getStatement() instanceof IfStatement)             action=JOIN_SECOND_FROM_TOP_LIST;
 else             action=JOIN_TOP_LIST;
          }
 else {
            if (previousStatement != null && previousStatement.getStatement() instanceof IfStatement)             action=PLACE_NEW_LIST_SECOND_FROM_TOP;
 else             action=PUSH_NEW_LIST;
          }
        }
        previousNodes=processIfStatement(previousNodes,compositeStatement,action);
      }
    }
    i++;
  }
  return previousNodes;
}