Program: 12045
Project: 12045
Buggy source:
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<VariableDeclaration> variableDeclarationsAndFieldAccessedInMethod1=pdg1.getVariableDeclarationsAndAccessedFieldsInMethod();
  Set<VariableDeclaration> variableDeclarationsAndFieldAccessedInMethod2=pdg2.getVariableDeclarationsAndAccessedFieldsInMethod();
  for (  PDGNodeMapping nodeMapping : getMaximumStateWithMinimumDifferences().getSortedNodeMappings()) {
    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=findRenamedVariableName2(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);
          IVariableBinding variableBinding1=getVariableBinding(variable1,variableDeclarationsAndFieldAccessedInMethod1);
          sortedVariables1.add(variable1);
          for (int j=0; j < variables2.size(); j++) {
            AbstractVariable variable2=variables2.get(j);
            IVariableBinding variableBinding2=getVariableBinding(variable2,variableDeclarationsAndFieldAccessedInMethod2);
            String renamedVariableName=findRenamedVariableName2(variable2);
            if ((variable2.getVariableName().equals(variable1.getVariableName()) || variable1.getVariableName().equals(renamedVariableName)) && (variable2.getVariableType().equals(variable1.getVariableType()) || ASTNodeMatcher.commonSuperType(variableBinding1.getType(),variableBinding2.getType()) != null)) {
              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());
        if (!declaredLocalVariablesInMappedNodes.containsKey(keyPair) && !commonPassedParametersAlreadyContainOneOfTheKeys(keyPair)) {
          commonPassedParameters.put(keyPair,variableDeclarations);
        }
      }
    }
  }
}

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<VariableDeclaration> variableDeclarationsAndFieldAccessedInMethod1=pdg1.getVariableDeclarationsAndAccessedFieldsInMethod();
  Set<VariableDeclaration> variableDeclarationsAndFieldAccessedInMethod2=pdg2.getVariableDeclarationsAndAccessedFieldsInMethod();
  for (  PDGNodeMapping nodeMapping : getMaximumStateWithMinimumDifferences().getSortedNodeMappings()) {
    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=findRenamedVariableName2(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);
          IVariableBinding variableBinding1=getVariableBinding(variable1,variableDeclarationsAndFieldAccessedInMethod1);
          sortedVariables1.add(variable1);
          for (int j=0; j < variables2.size(); j++) {
            AbstractVariable variable2=variables2.get(j);
            IVariableBinding variableBinding2=getVariableBinding(variable2,variableDeclarationsAndFieldAccessedInMethod2);
            String renamedVariableName=findRenamedVariableName2(variable2);
            if ((variable2.getVariableName().equals(variable1.getVariableName()) || variable1.getVariableName().equals(renamedVariableName)) && (variable2.getVariableType().equals(variable1.getVariableType()) || ASTNodeMatcher.commonSuperType(variableBinding1.getType(),variableBinding2.getType()) != null)) {
              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());
        if (!declaredLocalVariablesInMappedNodes.containsKey(keyPair) && commonPassedParametersAlreadyContainOneOfTheKeys(keyPair) == null) {
          commonPassedParameters.put(keyPair,variableDeclarations);
        }
      }
    }
  }
}