Program: 51078
Project: 51078
Buggy source:
static Axis mergeAxes(Axis axis1,Axis axis2,RolapEvaluator evaluator,boolean ordered){
  if (axis1 == null) {
    return axis2;
  }
  List<Position> pl1=axis1.getPositions();
  List<Position> pl2=axis2.getPositions();
  int arrayLen=-1;
  if (pl1 instanceof RolapAxis.PositionListBase) {
    if (pl1.isEmpty()) {
      return axis2;
    }
    arrayLen=pl1.get(0).size();
  }
  if (axis1 instanceof RolapAxis.SingleEmptyPosition) {
    return axis2;
  }
  if (axis1 instanceof RolapAxis.NoPosition) {
    return axis2;
  }
  if (pl2 instanceof RolapAxis.PositionListBase) {
    if (pl2.isEmpty()) {
      return axis1;
    }
    arrayLen=pl2.get(0).size();
  }
  if (axis2 instanceof RolapAxis.SingleEmptyPosition) {
    return axis1;
  }
  if (axis2 instanceof RolapAxis.NoPosition) {
    return axis1;
  }
  if (arrayLen == -1) {
    arrayLen=0;
    for (    Position p1 : pl1) {
      for (      Member m1 : p1) {
        arrayLen++;
      }
      break;
    }
    pl1=axis1.getPositions();
  }
  if (arrayLen == 1) {
    List<Member> list=new ArrayList<Member>();
    for (    Position p1 : pl1) {
      for (      Member m1 : p1) {
        list.add(m1);
      }
    }
    for (    Position p2 : pl2) {
      for (      Member m2 : p2) {
        if (!list.contains(m2)) {
          list.add(m2);
        }
      }
    }
    return new RolapAxis.MemberList(list);
  }
 else {
    List<Member[]> list=new ArrayList<Member[]>();
    for (    Position p1 : pl1) {
      Member[] members=new Member[arrayLen];
      int i=0;
      for (      Member m1 : p1) {
        members[i++]=m1;
      }
      list.add(members);
    }
    List<Member[]> extras=new ArrayList<Member[]>();
    for (    Position p2 : pl2) {
      int i=0;
      Member[] members=new Member[arrayLen];
      for (      Member m2 : p2) {
        members[i++]=m2;
      }
      Iterator<Member[]> it1=list.iterator();
      boolean found=false;
      while (it1.hasNext()) {
        Member[] m1=it1.next();
        if (java.util.Arrays.equals(members,m1)) {
          found=true;
          break;
        }
      }
      if (!found) {
        extras.add(members);
      }
    }
    list.addAll(extras);
    if (!list.isEmpty() && !extras.isEmpty() && !ordered) {
      Member[] membs=list.get(0);
      int membsSize=membs.length;
      ValueCalc valCalc=new ValueCalc(new DummyExp(new ScalarType()));
      FunUtil.sortTuples(evaluator,list,list,valCalc,false,false,membsSize);
    }
    return new RolapAxis.MemberArrayList(list);
  }
}

Fixed version (ground truth):
static Axis mergeAxes(Axis axis1,Axis axis2,RolapEvaluator evaluator,boolean ordered){
  if (axis1 == null) {
    return axis2;
  }
  List<Position> posList1=axis1.getPositions();
  List<Position> posList2=axis2.getPositions();
  int arrayLen=-1;
  if (posList1 instanceof RolapAxis.PositionListBase) {
    if (posList1.isEmpty()) {
      return axis2;
    }
    arrayLen=posList1.get(0).size();
  }
  if (axis1 instanceof RolapAxis.SingleEmptyPosition) {
    return axis2;
  }
  if (axis1 instanceof RolapAxis.NoPosition) {
    return axis2;
  }
  if (posList2 instanceof RolapAxis.PositionListBase) {
    if (posList2.isEmpty()) {
      return axis1;
    }
    arrayLen=posList2.get(0).size();
  }
  if (axis2 instanceof RolapAxis.SingleEmptyPosition) {
    return axis1;
  }
  if (axis2 instanceof RolapAxis.NoPosition) {
    return axis1;
  }
  if (arrayLen == -1) {
    arrayLen=0;
    for (    Position p1 : posList1) {
      arrayLen+=p1.size();
      break;
    }
    posList1=axis1.getPositions();
  }
  if (arrayLen == 1) {
    LinkedHashSet<Member> orderedSet=new LinkedHashSet<Member>();
    for (    Position p1 : posList1) {
      for (      Member m1 : p1) {
        orderedSet.add(m1);
      }
    }
    for (    Position p2 : posList2) {
      for (      Member m2 : p2) {
        orderedSet.add(m2);
      }
    }
    return new RolapAxis.MemberList(Arrays.asList(orderedSet.toArray(new Member[orderedSet.size()])));
  }
 else {
    Set<List<Member>> set=new HashSet<List<Member>>();
    List<Member[]> list=new ArrayList<Member[]>();
    for (    Position p1 : posList1) {
      if (set.add(p1)) {
        Member[] members=new Member[arrayLen];
        for (int i=0; i < p1.size(); i++) {
          members[i]=p1.get(i);
        }
        list.add(members);
      }
    }
    int halfWay=list.size();
    for (    Position p2 : posList2) {
      if (set.add(p2)) {
        Member[] members=new Member[arrayLen];
        for (int i=0; i < p2.size(); i++) {
          Member m2=p2.get(i);
          members[i]=m2;
        }
        list.add(members);
      }
    }
    if (halfWay > 0 && halfWay < list.size() && !ordered) {
      Member[] membs=list.get(0);
      int membsSize=membs.length;
      ValueCalc valCalc=new ValueCalc(new DummyExp(new ScalarType()));
      FunUtil.sortTuples(evaluator,list,list,valCalc,false,false,membsSize);
    }
    return new RolapAxis.MemberArrayList(list);
  }
}