Program: 12071
Project: 12071
Buggy source:
private void findPassedParameters(){
  Set<AbstractVariable> passedParametersG1=extractPassedParameters(pdg1,mappedNodesG1);
  Set<AbstractVariable> passedParametersG2=extractPassedParameters(pdg2,mappedNodesG2);
  for (  PDGNodeMapping nodeMapping : maximumStateWithMinimumDifferences.getNodeMappings()) {
    PDGNode nodeG1=nodeMapping.getNodeG1();
    PDGNode nodeG2=nodeMapping.getNodeG2();
    List<AbstractVariable> nonAnonymousDeclaredVariablesG1=new ArrayList<AbstractVariable>();
    Iterator<AbstractVariable> declaredVariableIteratorG1=nodeG1.getDeclaredVariableIterator();
    while (declaredVariableIteratorG1.hasNext()) {
      AbstractVariable declaredVariableG1=declaredVariableIteratorG1.next();
      String key1=declaredVariableG1.getVariableBindingKey();
      String declaringType1=key1.substring(0,key1.indexOf("String_Node_Str"));
      if (!declaringType1.contains("String_Node_Str")) {
        nonAnonymousDeclaredVariablesG1.add(declaredVariableG1);
      }
    }
    List<AbstractVariable> nonAnonymousDeclaredVariablesG2=new ArrayList<AbstractVariable>();
    Iterator<AbstractVariable> declaredVariableIteratorG2=nodeG2.getDeclaredVariableIterator();
    while (declaredVariableIteratorG2.hasNext()) {
      AbstractVariable declaredVariableG2=declaredVariableIteratorG2.next();
      String key2=declaredVariableG2.getVariableBindingKey();
      String declaringType2=key2.substring(0,key2.indexOf("String_Node_Str"));
      if (!declaringType2.contains("String_Node_Str")) {
        nonAnonymousDeclaredVariablesG2.add(declaredVariableG2);
      }
    }
    int min=Math.min(nonAnonymousDeclaredVariablesG1.size(),nonAnonymousDeclaredVariablesG2.size());
    for (int i=0; i < min; i++) {
      AbstractVariable declaredVariableG1=nonAnonymousDeclaredVariablesG1.get(i);
      AbstractVariable declaredVariableG2=nonAnonymousDeclaredVariablesG2.get(i);
      ArrayList<AbstractVariable> declaredVariables=new ArrayList<AbstractVariable>();
      declaredVariables.add(declaredVariableG1);
      declaredVariables.add(declaredVariableG2);
      declaredLocalVariablesInMappedNodes.put(declaredVariableG1.getVariableBindingKey(),declaredVariables);
    }
    Set<AbstractVariable> dataDependences1=nodeG1.incomingDataDependencesFromNodesDeclaringVariables();
    Set<AbstractVariable> dataDependences2=nodeG2.incomingDataDependencesFromNodesDeclaringVariables();
    dataDependences1.retainAll(passedParametersG1);
    dataDependences2.retainAll(passedParametersG2);
    for (    ArrayList<AbstractVariable> variableDeclarations : commonPassedParameters.values()) {
      AbstractVariable variableDeclaration1=variableDeclarations.get(0);
      AbstractVariable variableDeclaration2=variableDeclarations.get(1);
      dataDependences1.remove(variableDeclaration1);
      dataDependences2.remove(variableDeclaration2);
    }
    if (dataDependences1.size() == dataDependences2.size()) {
      List<AbstractVariable> variables1=new ArrayList<AbstractVariable>(dataDependences1);
      List<AbstractVariable> variables2=new ArrayList<AbstractVariable>(dataDependences2);
      for (int i=0; i < variables1.size(); i++) {
        AbstractVariable variable1=variables1.get(i);
        AbstractVariable variable2=variables2.get(i);
        if (passedParametersG1.contains(variable1) && passedParametersG2.contains(variable2)) {
          ArrayList<AbstractVariable> variableDeclarations=new ArrayList<AbstractVariable>();
          variableDeclarations.add(variable1);
          variableDeclarations.add(variable2);
          commonPassedParameters.put(variable1.getVariableBindingKey(),variableDeclarations);
          passedParametersG1.remove(variable1);
          passedParametersG2.remove(variable2);
        }
      }
    }
  }
  this.passedParametersG1.addAll(passedParametersG1);
  this.passedParametersG2.addAll(passedParametersG2);
}

Fixed version (ground truth):
private void findPassedParameters(){
  Set<AbstractVariable> passedParametersG1=extractPassedParameters(pdg1,mappedNodesG1);
  Set<AbstractVariable> passedParametersG2=extractPassedParameters(pdg2,mappedNodesG2);
  Set<AbstractVariable> parametersToBeRemovedG1=new LinkedHashSet<AbstractVariable>();
  Set<AbstractVariable> parametersToBeRemovedG2=new LinkedHashSet<AbstractVariable>();
  for (  PDGNodeMapping nodeMapping : maximumStateWithMinimumDifferences.getNodeMappings()) {
    PDGNode nodeG1=nodeMapping.getNodeG1();
    PDGNode nodeG2=nodeMapping.getNodeG2();
    List<AbstractVariable> nonAnonymousDeclaredVariablesG1=new ArrayList<AbstractVariable>();
    Iterator<AbstractVariable> declaredVariableIteratorG1=nodeG1.getDeclaredVariableIterator();
    while (declaredVariableIteratorG1.hasNext()) {
      AbstractVariable declaredVariableG1=declaredVariableIteratorG1.next();
      String key1=declaredVariableG1.getVariableBindingKey();
      String declaringType1=key1.substring(0,key1.indexOf("String_Node_Str"));
      if (!declaringType1.contains("String_Node_Str")) {
        nonAnonymousDeclaredVariablesG1.add(declaredVariableG1);
      }
    }
    List<AbstractVariable> nonAnonymousDeclaredVariablesG2=new ArrayList<AbstractVariable>();
    Iterator<AbstractVariable> declaredVariableIteratorG2=nodeG2.getDeclaredVariableIterator();
    while (declaredVariableIteratorG2.hasNext()) {
      AbstractVariable declaredVariableG2=declaredVariableIteratorG2.next();
      String key2=declaredVariableG2.getVariableBindingKey();
      String declaringType2=key2.substring(0,key2.indexOf("String_Node_Str"));
      if (!declaringType2.contains("String_Node_Str")) {
        nonAnonymousDeclaredVariablesG2.add(declaredVariableG2);
      }
    }
    int min=Math.min(nonAnonymousDeclaredVariablesG1.size(),nonAnonymousDeclaredVariablesG2.size());
    for (int i=0; i < min; i++) {
      AbstractVariable declaredVariableG1=nonAnonymousDeclaredVariablesG1.get(i);
      AbstractVariable declaredVariableG2=nonAnonymousDeclaredVariablesG2.get(i);
      ArrayList<AbstractVariable> declaredVariables=new ArrayList<AbstractVariable>();
      declaredVariables.add(declaredVariableG1);
      declaredVariables.add(declaredVariableG2);
      VariableBindingKeyPair keyPair=new VariableBindingKeyPair(declaredVariableG1.getVariableBindingKey(),declaredVariableG2.getVariableBindingKey());
      declaredLocalVariablesInMappedNodes.put(keyPair,declaredVariables);
    }
    Set<AbstractVariable> dataDependences1=nodeG1.incomingDataDependencesFromNodesDeclaringVariables();
    Set<AbstractVariable> dataDependences2=nodeG2.incomingDataDependencesFromNodesDeclaringVariables();
    dataDependences1.retainAll(passedParametersG1);
    dataDependences2.retainAll(passedParametersG2);
    if (dataDependences1.size() == dataDependences2.size()) {
      List<AbstractVariable> variables1=new ArrayList<AbstractVariable>(dataDependences1);
      List<AbstractVariable> variables2=new ArrayList<AbstractVariable>(dataDependences2);
      for (int i=0; i < variables1.size(); i++) {
        AbstractVariable variable1=variables1.get(i);
        AbstractVariable variable2=variables2.get(i);
        if (passedParametersG1.contains(variable1) && passedParametersG2.contains(variable2)) {
          ArrayList<AbstractVariable> variableDeclarations=new ArrayList<AbstractVariable>();
          variableDeclarations.add(variable1);
          variableDeclarations.add(variable2);
          VariableBindingKeyPair keyPair=new VariableBindingKeyPair(variable1.getVariableBindingKey(),variable2.getVariableBindingKey());
          commonPassedParameters.put(keyPair,variableDeclarations);
          parametersToBeRemovedG1.add(variable1);
          parametersToBeRemovedG2.add(variable2);
        }
      }
    }
  }
  passedParametersG1.removeAll(parametersToBeRemovedG1);
  passedParametersG2.removeAll(parametersToBeRemovedG2);
  this.passedParametersG1.addAll(passedParametersG1);
  this.passedParametersG2.addAll(passedParametersG2);
}