Program: 12162
Project: 12162
Buggy source:
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;
}

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();
        CompositeStatementObject parent=statements.get(0).getParent();
        if (parent.getStatement() instanceof Block)         parent=parent.getParent();
        if (statements.size() == 1) {
          action=JOIN_TOP_LIST;
          if (parent != null) {
            if (isLoop(parent))             action=PUSH_NEW_LIST;
 else             if (parent.getStatement() instanceof DoStatement)             action=PLACE_NEW_LIST_SECOND_FROM_TOP;
          }
        }
 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;
              if (parent != null && (isLoop(parent) || parent.getStatement() instanceof DoStatement))               action=PLACE_NEW_LIST_SECOND_FROM_TOP;
            }
 else {
              action=JOIN_TOP_LIST;
              if (parent != null && (isLoop(parent) || parent.getStatement() instanceof DoStatement))               action=PUSH_NEW_LIST;
            }
          }
 else {
            if (previousStatement != null && previousStatement.getStatement() instanceof IfStatement)             action=PLACE_NEW_LIST_SECOND_FROM_TOP;
 else {
              action=PUSH_NEW_LIST;
              if (parent != null && parent.getStatement() instanceof DoStatement && statements.get(0).getStatement() instanceof IfStatement)               action=PLACE_NEW_LIST_SECOND_FROM_TOP;
            }
          }
        }
        previousNodes=processIfStatement(previousNodes,compositeStatement,action);
      }
    }
    i++;
  }
  return previousNodes;
}