Program: 9846
Project: 9846
Buggy source:
public int compare(Description concept1,Description concept2){
  if (concept1 instanceof Nothing) {
    if (concept2 instanceof Nothing)     return 0;
 else     return -1;
  }
 else   if (concept1 instanceof NamedClass) {
    if (concept2 instanceof Nothing)     return 1;
 else     if (concept2 instanceof NamedClass)     return ((NamedClass)concept1).getName().compareTo(((NamedClass)concept2).getName());
 else     return -1;
  }
 else   if (concept1 instanceof BooleanValueRestriction) {
    if (concept2 instanceof Nothing || concept2 instanceof NamedClass) {
      return 1;
    }
 else     if (concept2 instanceof BooleanValueRestriction) {
      int cmp=rc.compare(((BooleanValueRestriction)concept1).getRestrictedPropertyExpresssion(),((BooleanValueRestriction)concept2).getRestrictedPropertyExpresssion());
      if (cmp == 0) {
        boolean val1=((BooleanValueRestriction)concept1).getBooleanValue();
        boolean val2=((BooleanValueRestriction)concept2).getBooleanValue();
        if (val1) {
          if (val2)           return 0;
 else           return 1;
        }
 else {
          if (val2)           return -1;
 else           return 0;
        }
      }
 else       return cmp;
    }
 else     return -1;
  }
 else   if (concept1 instanceof DatatypeSomeRestriction) {
    if (concept2 instanceof Nothing || concept2 instanceof NamedClass || concept2 instanceof BooleanValueRestriction) {
      return 1;
    }
 else     if (concept2 instanceof DatatypeSomeRestriction) {
      DatatypeSomeRestriction dsr=(DatatypeSomeRestriction)concept1;
      DatatypeProperty dp=(DatatypeProperty)dsr.getRestrictedPropertyExpression();
      DatatypeSomeRestriction dsr2=(DatatypeSomeRestriction)concept2;
      DatatypeProperty dp2=(DatatypeProperty)dsr2.getRestrictedPropertyExpression();
      int cmp=rc.compare(dp,dp2);
      if (cmp == 0) {
        SimpleDoubleDataRange dr=(SimpleDoubleDataRange)dsr.getDataRange();
        SimpleDoubleDataRange dr2=(SimpleDoubleDataRange)dsr2.getDataRange();
        if ((dr instanceof DoubleMaxValue && dr2 instanceof DoubleMaxValue) || (dr instanceof DoubleMinValue && dr2 instanceof DoubleMinValue)) {
          double val1=dr.getValue();
          double val2=dr2.getValue();
          if (val1 > val2)           return 1;
 else           if (val1 == val2)           return 0;
 else           return -1;
        }
 else         if (dr instanceof DoubleMaxValue)         return 1;
 else         return -1;
      }
 else       return cmp;
    }
 else     return -1;
  }
 else   if (concept1 instanceof ObjectValueRestriction) {
    if (concept2 instanceof Nothing || concept2 instanceof NamedClass || concept2 instanceof BooleanValueRestriction|| concept2 instanceof DatatypeSomeRestriction) {
      return 1;
    }
 else     if (concept2 instanceof ObjectValueRestriction) {
      int roleCompare=rc.compare(((ObjectValueRestriction)concept1).getRestrictedPropertyExpression(),((ObjectValueRestriction)concept2).getRestrictedPropertyExpression());
      if (roleCompare == 0) {
        Individual value1=((ObjectValueRestriction)concept1).getIndividual();
        Individual value2=((ObjectValueRestriction)concept2).getIndividual();
        return value1.compareTo(value2);
      }
 else {
        return roleCompare;
      }
    }
 else     return -1;
  }
 else   if (concept1 instanceof Thing) {
    if (concept2 instanceof Nothing || concept2 instanceof NamedClass || concept2 instanceof BooleanValueRestriction|| concept2 instanceof DatatypeSomeRestriction|| concept2 instanceof ObjectValueRestriction)     return 1;
 else     if (concept2 instanceof Thing)     return 0;
 else     return -1;
  }
 else   if (concept1 instanceof Negation) {
    if (concept2.getChildren().size() < 1)     return 1;
 else     if (concept2 instanceof Negation)     return compare(concept1.getChild(0),concept2.getChild(0));
 else     return -1;
  }
 else   if (concept1 instanceof ObjectSomeRestriction) {
    if (concept2.getChildren().size() < 1 || concept2 instanceof Negation)     return 1;
 else     if (concept2 instanceof ObjectSomeRestriction) {
      int roleCompare=rc.compare(((ObjectQuantorRestriction)concept1).getRole(),((ObjectQuantorRestriction)concept2).getRole());
      if (roleCompare == 0)       return compare(concept1.getChild(0),concept2.getChild(0));
 else       return roleCompare;
    }
 else     return -1;
  }
 else   if (concept1 instanceof ObjectAllRestriction) {
    if (concept2.getChildren().size() < 1 || concept2 instanceof Negation || concept2 instanceof ObjectSomeRestriction)     return 1;
 else     if (concept2 instanceof ObjectAllRestriction) {
      int roleCompare=rc.compare(((ObjectQuantorRestriction)concept1).getRole(),((ObjectQuantorRestriction)concept2).getRole());
      if (roleCompare == 0)       return compare(concept1.getChild(0),concept2.getChild(0));
 else       return roleCompare;
    }
 else     return -1;
  }
 else   if (concept1 instanceof ObjectMinCardinalityRestriction) {
    if (concept2.getChildren().size() < 1 || concept2 instanceof Negation || concept2 instanceof ObjectQuantorRestriction)     return 1;
 else     if (concept2 instanceof ObjectMinCardinalityRestriction) {
      int roleCompare=rc.compare(((ObjectCardinalityRestriction)concept1).getRole(),((ObjectCardinalityRestriction)concept2).getRole());
      if (roleCompare == 0) {
        Integer number1=((ObjectCardinalityRestriction)concept1).getNumber();
        Integer number2=((ObjectCardinalityRestriction)concept2).getNumber();
        int numberCompare=number1.compareTo(number2);
        if (numberCompare == 0)         return compare(concept1.getChild(0),concept2.getChild(0));
 else         return numberCompare;
      }
 else       return roleCompare;
    }
 else     return -1;
  }
 else   if (concept1 instanceof ObjectMaxCardinalityRestriction) {
    if (concept2.getChildren().size() < 1 || concept2 instanceof Negation || concept2 instanceof ObjectQuantorRestriction || concept2 instanceof ObjectMinCardinalityRestriction)     return 1;
 else     if (concept2 instanceof ObjectMaxCardinalityRestriction) {
      int roleCompare=rc.compare(((ObjectCardinalityRestriction)concept1).getRole(),((ObjectCardinalityRestriction)concept2).getRole());
      if (roleCompare == 0) {
        Integer number1=((ObjectCardinalityRestriction)concept1).getNumber();
        Integer number2=((ObjectCardinalityRestriction)concept2).getNumber();
        int numberCompare=number1.compareTo(number2);
        if (numberCompare == 0)         return compare(concept1.getChild(0),concept2.getChild(0));
 else         return numberCompare;
      }
 else       return roleCompare;
    }
 else     return -1;
  }
 else   if (concept1 instanceof Intersection) {
    if (concept2.getChildren().size() < 2)     return 1;
 else     if (concept2 instanceof Intersection) {
      int nrOfChildrenConcept1=concept1.getChildren().size();
      int nrOfChildrenConcept2=concept2.getChildren().size();
      if (nrOfChildrenConcept1 > nrOfChildrenConcept2)       return 1;
 else       if (nrOfChildrenConcept1 == nrOfChildrenConcept2) {
        for (int i=0; i < nrOfChildrenConcept1; i++) {
          int compareValue=compare(concept1.getChild(i),concept2.getChild(i));
          if (compareValue > 0)           return 1;
 else           if (compareValue < 0)           return -1;
        }
        return 0;
      }
 else       return -1;
    }
 else     return -1;
  }
 else   if (concept1 instanceof Union) {
    if (concept2.getChildren().size() < 2 || concept2 instanceof Intersection)     return 1;
 else     if (concept2 instanceof Union) {
      int nrOfChildrenConcept1=concept1.getChildren().size();
      int nrOfChildrenConcept2=concept2.getChildren().size();
      if (nrOfChildrenConcept1 > nrOfChildrenConcept2)       return 1;
 else       if (nrOfChildrenConcept1 == nrOfChildrenConcept2) {
        for (int i=0; i < nrOfChildrenConcept1; i++) {
          int compareValue=compare(concept1.getChild(i),concept2.getChild(i));
          if (compareValue > 0)           return 1;
 else           if (compareValue < 0)           return -1;
        }
        return 0;
      }
 else       return -1;
    }
 else     return -1;
  }
 else   throw new RuntimeException(concept1.toString());
}

Fixed version (ground truth):
public int compare(Description concept1,Description concept2){
  if (concept1 instanceof Nothing) {
    if (concept2 instanceof Nothing)     return 0;
 else     return -1;
  }
 else   if (concept1 instanceof NamedClass) {
    if (concept2 instanceof Nothing)     return 1;
 else     if (concept2 instanceof NamedClass)     return ((NamedClass)concept1).getName().compareTo(((NamedClass)concept2).getName());
 else     return -1;
  }
 else   if (concept1 instanceof BooleanValueRestriction) {
    if (concept2 instanceof Nothing || concept2 instanceof NamedClass) {
      return 1;
    }
 else     if (concept2 instanceof BooleanValueRestriction) {
      int cmp=rc.compare(((BooleanValueRestriction)concept1).getRestrictedPropertyExpresssion(),((BooleanValueRestriction)concept2).getRestrictedPropertyExpresssion());
      if (cmp == 0) {
        boolean val1=((BooleanValueRestriction)concept1).getBooleanValue();
        boolean val2=((BooleanValueRestriction)concept2).getBooleanValue();
        if (val1) {
          if (val2)           return 0;
 else           return 1;
        }
 else {
          if (val2)           return -1;
 else           return 0;
        }
      }
 else       return cmp;
    }
 else     return -1;
  }
 else   if (concept1 instanceof DatatypeSomeRestriction) {
    if (concept2 instanceof Nothing || concept2 instanceof NamedClass || concept2 instanceof BooleanValueRestriction) {
      return 1;
    }
 else     if (concept2 instanceof DatatypeSomeRestriction) {
      DatatypeSomeRestriction dsr=(DatatypeSomeRestriction)concept1;
      DatatypeProperty dp=(DatatypeProperty)dsr.getRestrictedPropertyExpression();
      DatatypeSomeRestriction dsr2=(DatatypeSomeRestriction)concept2;
      DatatypeProperty dp2=(DatatypeProperty)dsr2.getRestrictedPropertyExpression();
      int cmp=rc.compare(dp,dp2);
      if (cmp == 0) {
        SimpleDoubleDataRange dr=(SimpleDoubleDataRange)dsr.getDataRange();
        SimpleDoubleDataRange dr2=(SimpleDoubleDataRange)dsr2.getDataRange();
        if ((dr instanceof DoubleMaxValue && dr2 instanceof DoubleMaxValue) || (dr instanceof DoubleMinValue && dr2 instanceof DoubleMinValue)) {
          double val1=dr.getValue();
          double val2=dr2.getValue();
          if (val1 > val2)           return 1;
 else           if (val1 == val2)           return 0;
 else           return -1;
        }
 else         if (dr instanceof DoubleMaxValue)         return 1;
 else         return -1;
      }
 else       return cmp;
    }
 else     return -1;
  }
 else   if (concept1 instanceof ObjectValueRestriction) {
    if (concept2 instanceof Nothing || concept2 instanceof NamedClass || concept2 instanceof BooleanValueRestriction|| concept2 instanceof DatatypeSomeRestriction) {
      return 1;
    }
 else     if (concept2 instanceof ObjectValueRestriction) {
      int roleCompare=rc.compare(((ObjectValueRestriction)concept1).getRestrictedPropertyExpression(),((ObjectValueRestriction)concept2).getRestrictedPropertyExpression());
      if (roleCompare == 0) {
        Individual value1=((ObjectValueRestriction)concept1).getIndividual();
        Individual value2=((ObjectValueRestriction)concept2).getIndividual();
        return value1.compareTo(value2);
      }
 else {
        return roleCompare;
      }
    }
 else     return -1;
  }
 else   if (concept1 instanceof DatatypeValueRestriction) {
    if (concept2 instanceof Nothing || concept2 instanceof NamedClass || concept2 instanceof BooleanValueRestriction|| concept2 instanceof DatatypeSomeRestriction|| concept2 instanceof ObjectValueRestriction) {
      return 1;
    }
 else     if (concept2 instanceof DatatypeValueRestriction) {
      int roleCompare=rc.compare(((DatatypeValueRestriction)concept1).getRestrictedPropertyExpression(),((DatatypeValueRestriction)concept2).getRestrictedPropertyExpression());
      if (roleCompare == 0) {
        Constant value1=((DatatypeValueRestriction)concept1).getValue();
        Constant value2=((DatatypeValueRestriction)concept2).getValue();
        return value1.compareTo(value2);
      }
 else {
        return roleCompare;
      }
    }
 else     return -1;
  }
 else   if (concept1 instanceof Thing) {
    if (concept2 instanceof Nothing || concept2 instanceof NamedClass || concept2 instanceof BooleanValueRestriction|| concept2 instanceof DatatypeSomeRestriction|| concept2 instanceof ObjectValueRestriction|| concept2 instanceof DatatypeValueRestriction)     return 1;
 else     if (concept2 instanceof Thing)     return 0;
 else     return -1;
  }
 else   if (concept1 instanceof Negation) {
    if (concept2.getChildren().size() < 1)     return 1;
 else     if (concept2 instanceof Negation)     return compare(concept1.getChild(0),concept2.getChild(0));
 else     return -1;
  }
 else   if (concept1 instanceof ObjectSomeRestriction) {
    if (concept2.getChildren().size() < 1 || concept2 instanceof Negation)     return 1;
 else     if (concept2 instanceof ObjectSomeRestriction) {
      int roleCompare=rc.compare(((ObjectQuantorRestriction)concept1).getRole(),((ObjectQuantorRestriction)concept2).getRole());
      if (roleCompare == 0)       return compare(concept1.getChild(0),concept2.getChild(0));
 else       return roleCompare;
    }
 else     return -1;
  }
 else   if (concept1 instanceof ObjectAllRestriction) {
    if (concept2.getChildren().size() < 1 || concept2 instanceof Negation || concept2 instanceof ObjectSomeRestriction)     return 1;
 else     if (concept2 instanceof ObjectAllRestriction) {
      int roleCompare=rc.compare(((ObjectQuantorRestriction)concept1).getRole(),((ObjectQuantorRestriction)concept2).getRole());
      if (roleCompare == 0)       return compare(concept1.getChild(0),concept2.getChild(0));
 else       return roleCompare;
    }
 else     return -1;
  }
 else   if (concept1 instanceof ObjectMinCardinalityRestriction) {
    if (concept2.getChildren().size() < 1 || concept2 instanceof Negation || concept2 instanceof ObjectQuantorRestriction)     return 1;
 else     if (concept2 instanceof ObjectMinCardinalityRestriction) {
      int roleCompare=rc.compare(((ObjectCardinalityRestriction)concept1).getRole(),((ObjectCardinalityRestriction)concept2).getRole());
      if (roleCompare == 0) {
        Integer number1=((ObjectCardinalityRestriction)concept1).getNumber();
        Integer number2=((ObjectCardinalityRestriction)concept2).getNumber();
        int numberCompare=number1.compareTo(number2);
        if (numberCompare == 0)         return compare(concept1.getChild(0),concept2.getChild(0));
 else         return numberCompare;
      }
 else       return roleCompare;
    }
 else     return -1;
  }
 else   if (concept1 instanceof ObjectMaxCardinalityRestriction) {
    if (concept2.getChildren().size() < 1 || concept2 instanceof Negation || concept2 instanceof ObjectQuantorRestriction || concept2 instanceof ObjectMinCardinalityRestriction)     return 1;
 else     if (concept2 instanceof ObjectMaxCardinalityRestriction) {
      int roleCompare=rc.compare(((ObjectCardinalityRestriction)concept1).getRole(),((ObjectCardinalityRestriction)concept2).getRole());
      if (roleCompare == 0) {
        Integer number1=((ObjectCardinalityRestriction)concept1).getNumber();
        Integer number2=((ObjectCardinalityRestriction)concept2).getNumber();
        int numberCompare=number1.compareTo(number2);
        if (numberCompare == 0)         return compare(concept1.getChild(0),concept2.getChild(0));
 else         return numberCompare;
      }
 else       return roleCompare;
    }
 else     return -1;
  }
 else   if (concept1 instanceof Intersection) {
    if (concept2.getChildren().size() < 2)     return 1;
 else     if (concept2 instanceof Intersection) {
      int nrOfChildrenConcept1=concept1.getChildren().size();
      int nrOfChildrenConcept2=concept2.getChildren().size();
      if (nrOfChildrenConcept1 > nrOfChildrenConcept2)       return 1;
 else       if (nrOfChildrenConcept1 == nrOfChildrenConcept2) {
        for (int i=0; i < nrOfChildrenConcept1; i++) {
          int compareValue=compare(concept1.getChild(i),concept2.getChild(i));
          if (compareValue > 0)           return 1;
 else           if (compareValue < 0)           return -1;
        }
        return 0;
      }
 else       return -1;
    }
 else     return -1;
  }
 else   if (concept1 instanceof Union) {
    if (concept2.getChildren().size() < 2 || concept2 instanceof Intersection)     return 1;
 else     if (concept2 instanceof Union) {
      int nrOfChildrenConcept1=concept1.getChildren().size();
      int nrOfChildrenConcept2=concept2.getChildren().size();
      if (nrOfChildrenConcept1 > nrOfChildrenConcept2)       return 1;
 else       if (nrOfChildrenConcept1 == nrOfChildrenConcept2) {
        for (int i=0; i < nrOfChildrenConcept1; i++) {
          int compareValue=compare(concept1.getChild(i),concept2.getChild(i));
          if (compareValue > 0)           return 1;
 else           if (compareValue < 0)           return -1;
        }
        return 0;
      }
 else       return -1;
    }
 else     return -1;
  }
 else   throw new RuntimeException(concept1.toString());
}