Program: 12048
Project: 12048
Buggy source:
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 : getMaximumStateWithMinimumDifferences().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.incomingDataDependencesFromNodesDeclaringOrDefiningVariables();
    Set<AbstractVariable> dataDependences2=nodeG2.incomingDataDependencesFromNodesDeclaringOrDefiningVariables();
    dataDependences1.retainAll(passedParametersG1);
    dataDependences2.retainAll(passedParametersG2);
    List<AbstractVariable> variables1=new ArrayList<AbstractVariable>(dataDependences1);
    List<AbstractVariable> variables2=new ArrayList<AbstractVariable>(dataDependences2);
    if (dataDependences1.size() == dataDependences2.size()) {
      List<String> variableNames1=new ArrayList<String>();
      List<String> variableNames2=new ArrayList<String>();
      for (int i=0; i < variables1.size(); i++) {
        variableNames1.add(variables1.get(i).getVariableName());
        AbstractVariable variable2=variables2.get(i);
        String renamedVariableName=findRenamedVariableName(variable2);
        if (renamedVariableName != null)         variableNames2.add(renamedVariableName);
 else         variableNames2.add(variable2.getVariableName());
      }
      if (variableNames1.containsAll(variableNames2) && variableNames2.containsAll(variableNames1) && variableNames1.size() > 0 && variableNames2.size() > 0) {
        List<AbstractVariable> sortedVariables1=new ArrayList<AbstractVariable>();
        List<AbstractVariable> sortedVariables2=new ArrayList<AbstractVariable>();
        for (int i=0; i < variables1.size(); i++) {
          AbstractVariable variable1=variables1.get(i);
          sortedVariables1.add(variable1);
          for (int j=0; j < variables2.size(); j++) {
            AbstractVariable variable2=variables2.get(j);
            String renamedVariableName=findRenamedVariableName(variable2);
            if ((variable2.getVariableName().equals(variable1.getVariableName()) || variable1.getVariableName().equals(renamedVariableName)) && variable2.getVariableType().equals(variable1.getVariableType())) {
              sortedVariables2.add(variable2);
              break;
            }
          }
        }
        if (sortedVariables1.size() == sortedVariables2.size()) {
          variables1=sortedVariables1;
          variables2=sortedVariables2;
        }
      }
 else {
        List<AbstractVariable> sortedVariables1=new ArrayList<AbstractVariable>();
        List<AbstractVariable> sortedVariables2=new ArrayList<AbstractVariable>();
        sortVariables(variables1,variables2,sortedVariables1,sortedVariables2);
        if (sortedVariables1.size() == sortedVariables2.size()) {
          variables1=sortedVariables1;
          variables2=sortedVariables2;
        }
      }
    }
 else {
      List<AbstractVariable> sortedVariables1=new ArrayList<AbstractVariable>();
      List<AbstractVariable> sortedVariables2=new ArrayList<AbstractVariable>();
      sortVariables(variables1,variables2,sortedVariables1,sortedVariables2);
      if (sortedVariables1.size() == sortedVariables2.size()) {
        variables1=sortedVariables1;
        variables2=sortedVariables2;
      }
    }
    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);
}

Fixed version (ground truth):
private void findPassedParameters(){
  Set<AbstractVariable> passedParametersG1=extractPassedParameters(pdg1,mappedNodesG1);
  Set<AbstractVariable> passedParametersG2=extractPassedParameters(pdg2,mappedNodesG2);
  Set<VariableDeclaration> variableDeclarationsInMethod1=pdg1.getVariableDeclarationsInMethod();
  Set<VariableDeclaration> variableDeclarationsInMethod2=pdg2.getVariableDeclarationsInMethod();
  Set<AbstractVariable> parametersToBeRemovedG1=new LinkedHashSet<AbstractVariable>();
  Set<AbstractVariable> parametersToBeRemovedG2=new LinkedHashSet<AbstractVariable>();
  for (  PDGNodeMapping nodeMapping : getMaximumStateWithMinimumDifferences().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();
      for (      VariableDeclaration variableDeclaration : variableDeclarationsInMethod1) {
        IVariableBinding declaredVariableBinding=variableDeclaration.resolveBinding();
        if (declaredVariableBinding.getKey().equals(key1)) {
          if (!declaredVariableBinding.getDeclaringMethod().getDeclaringClass().isAnonymous()) {
            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();
      for (      VariableDeclaration variableDeclaration : variableDeclarationsInMethod2) {
        IVariableBinding declaredVariableBinding=variableDeclaration.resolveBinding();
        if (declaredVariableBinding.getKey().equals(key2)) {
          if (!declaredVariableBinding.getDeclaringMethod().getDeclaringClass().isAnonymous()) {
            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.incomingDataDependencesFromNodesDeclaringOrDefiningVariables();
    Set<AbstractVariable> dataDependences2=nodeG2.incomingDataDependencesFromNodesDeclaringOrDefiningVariables();
    dataDependences1.retainAll(passedParametersG1);
    dataDependences2.retainAll(passedParametersG2);
    List<AbstractVariable> variables1=new ArrayList<AbstractVariable>(dataDependences1);
    List<AbstractVariable> variables2=new ArrayList<AbstractVariable>(dataDependences2);
    if (dataDependences1.size() == dataDependences2.size()) {
      List<String> variableNames1=new ArrayList<String>();
      List<String> variableNames2=new ArrayList<String>();
      for (int i=0; i < variables1.size(); i++) {
        variableNames1.add(variables1.get(i).getVariableName());
        AbstractVariable variable2=variables2.get(i);
        String renamedVariableName=findRenamedVariableName(variable2);
        if (renamedVariableName != null)         variableNames2.add(renamedVariableName);
 else         variableNames2.add(variable2.getVariableName());
      }
      if (variableNames1.containsAll(variableNames2) && variableNames2.containsAll(variableNames1) && variableNames1.size() > 0 && variableNames2.size() > 0) {
        List<AbstractVariable> sortedVariables1=new ArrayList<AbstractVariable>();
        List<AbstractVariable> sortedVariables2=new ArrayList<AbstractVariable>();
        for (int i=0; i < variables1.size(); i++) {
          AbstractVariable variable1=variables1.get(i);
          sortedVariables1.add(variable1);
          for (int j=0; j < variables2.size(); j++) {
            AbstractVariable variable2=variables2.get(j);
            String renamedVariableName=findRenamedVariableName(variable2);
            if ((variable2.getVariableName().equals(variable1.getVariableName()) || variable1.getVariableName().equals(renamedVariableName)) && variable2.getVariableType().equals(variable1.getVariableType())) {
              sortedVariables2.add(variable2);
              break;
            }
          }
        }
        if (sortedVariables1.size() == sortedVariables2.size()) {
          variables1=sortedVariables1;
          variables2=sortedVariables2;
        }
      }
 else {
        List<AbstractVariable> sortedVariables1=new ArrayList<AbstractVariable>();
        List<AbstractVariable> sortedVariables2=new ArrayList<AbstractVariable>();
        sortVariables(variables1,variables2,sortedVariables1,sortedVariables2);
        if (sortedVariables1.size() == sortedVariables2.size()) {
          variables1=sortedVariables1;
          variables2=sortedVariables2;
        }
      }
    }
 else {
      List<AbstractVariable> sortedVariables1=new ArrayList<AbstractVariable>();
      List<AbstractVariable> sortedVariables2=new ArrayList<AbstractVariable>();
      sortVariables(variables1,variables2,sortedVariables1,sortedVariables2);
      if (sortedVariables1.size() == sortedVariables2.size()) {
        variables1=sortedVariables1;
        variables2=sortedVariables2;
      }
    }
    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);
}