Program: 96591
Project: 96591
Buggy source:
public long getNextInvocationTime(Calendar currentTime,Crontab crontab){
  int second=CalendarUtil.getSecond(currentTime);
  int minute=CalendarUtil.getMinute(currentTime);
  if (second > 0) {
    minute++;
  }
  if (crontab.minuteElement.isFixedValue()) {
    minute=getFixedNextInvocationValue(minute,59,crontab.minuteElement);
  }
 else {
    minute=getFixedSameOrNextInvocationValue(minute,crontab.minuteFixedInvocations);
  }
  int hour=CalendarUtil.get24Hour(currentTime);
  if (crontab.hourElement.isFixedValue()) {
    int newHour=crontab.hourElement.toInt();
    if (newHour > hour) {
      if (crontab.minuteElement.isFixedValue()) {
        minute=getFixedNextInvocationValue(minute,59,crontab.minuteElement);
      }
 else {
        minute=getFixedMinimumInvocationValue(crontab.minuteFixedInvocations);
      }
    }
    hour=newHour;
  }
  crontab=replaceWildcardsOfMinuteOrHourValue(crontab);
  int day=CalendarUtil.getDay(currentTime);
  if (crontab.dayElement.isFixedValue()) {
    day=crontab.dayElement.toInt();
  }
  int dayOfWeek=getCrontabDayOfWeekNumber(currentTime);
  if (dayOfWeek >= 7) {
    dayOfWeek=dayOfWeek - 7;
  }
  int month=CalendarUtil.getMonth(currentTime);
  if (crontab.monthElement.isFixedValue()) {
    month=crontab.monthElement.toInt();
  }
  int year=CalendarUtil.getYear(currentTime);
  Calendar nextInvocationTime=CalendarUtil.getCalendar(year,month,day,hour,minute,0);
  boolean isMinuteModified=false;
  boolean isHourModified=false;
  boolean isDayModified=false;
  boolean isMonthModified=false;
  boolean isDayOfWeekPrior=true;
  int loopCounter=0;
  if (crontab.dayOfWeekElement.isNotWildcard()) {
    while (nextInvocationTime.getTimeInMillis() <= currentTime.getTimeInMillis() || (isDayOfWeekPrior && isDayOfWeekNotCameAt(crontab,nextInvocationTime,dayOfWeek))) {
      if (loopCounter >= 100) {
        throw new IllegalStateException("String_Node_Str");
      }
      if (isMinuteModified || crontab.minuteElement.isWildcard()) {
        if (isHourModified || crontab.hourElement.isNotWildcard()) {
          if (isHourModified || crontab.hourElement.isFixedValue()) {
            if (isDayModified) {
              if (isMonthModified || crontab.monthElement.isNotWildcard()) {
                if (isMonthModified || crontab.monthElement.isFixedValue()) {
                  nextInvocationTime.add(Calendar.YEAR,1);
                }
 else {
                  nextInvocationTime.set(Calendar.MONTH,getFixedNextInvocationValue(month,12,crontab.monthElement));
                  isMonthModified=true;
                }
              }
 else {
                nextInvocationTime.add(Calendar.MONTH,1);
                isMonthModified=true;
              }
            }
 else {
              boolean isDayOfWeekNotContainedInCrontab=!isInvocationValueContainedInCrontabValue(dayOfWeek,6,crontab.dayOfWeekElement);
              boolean isNextInvocationNotInThisDate=currentTime.getTimeInMillis() > nextInvocationTime.getTimeInMillis();
              if (isDayOfWeekNotContainedInCrontab || isNextInvocationNotInThisDate) {
                int addDays=0;
                int nextDayOfWeek=getFixedNextInvocationValue(dayOfWeek,6,crontab.dayOfWeekElement);
                if (nextDayOfWeek > dayOfWeek) {
                  addDays=nextDayOfWeek - dayOfWeek;
                }
 else {
                  addDays=nextDayOfWeek - dayOfWeek + 7;
                }
                int addDaysByDayElement=getFixedNextInvocationValue(day,crontab.dayFixedInvocations) - day;
                if (addDaysByDayElement > 0 && addDaysByDayElement < addDays) {
                  addDays=addDaysByDayElement;
                  isDayOfWeekPrior=false;
                }
                nextInvocationTime.add(Calendar.DATE,addDays);
              }
              isDayModified=true;
            }
          }
 else {
            nextInvocationTime.set(Calendar.HOUR_OF_DAY,getFixedNextInvocationValue(hour,23,crontab.hourElement));
            isHourModified=true;
          }
        }
 else {
          nextInvocationTime.add(Calendar.HOUR_OF_DAY,1);
          isHourModified=true;
        }
      }
 else {
        if (!isDayModified && hour >= CalendarUtil.get24Hour(currentTime)) {
          nextInvocationTime.set(Calendar.MINUTE,getFixedSameOrNextInvocationValue(minute,crontab.minuteFixedInvocations));
        }
 else {
          nextInvocationTime.set(Calendar.MINUTE,getFixedMinimumInvocationValue(crontab.minuteFixedInvocations));
        }
        isMinuteModified=true;
      }
      loopCounter++;
    }
  }
 else {
    while ((isMonthModified && (!isDayModified || !isHourModified)) || nextInvocationTime.getTimeInMillis() < currentTime.getTimeInMillis()) {
      if (loopCounter >= 100) {
        throw new IllegalStateException("String_Node_Str");
      }
      if (isHourModified || crontab.hourElement.isNotWildcard()) {
        if (isHourModified || crontab.hourElement.isFixedValue()) {
          if (isDayModified || crontab.dayElement.isNotWildcard()) {
            if (isDayModified || crontab.dayElement.isFixedValue()) {
              if (isMonthModified || crontab.monthElement.isNotWildcard()) {
                if (isMonthModified || crontab.monthElement.isFixedValue()) {
                  nextInvocationTime.add(Calendar.YEAR,1);
                }
 else {
                  nextInvocationTime.set(Calendar.MONTH,getFixedNextInvocationValue(month,12,crontab.monthElement));
                  isHourModified=true;
                  isDayModified=true;
                  isMonthModified=true;
                }
              }
 else {
                nextInvocationTime.add(Calendar.MONTH,1);
                isHourModified=false;
                isDayModified=crontab.dayElement.isFixedValue();
                isMonthModified=true;
                hour=0;
                if (isInvocationValueContainedInCrontabValue(0,23,crontab.hourElement)) {
                  nextInvocationTime.set(Calendar.HOUR_OF_DAY,0);
                  isHourModified=true;
                }
                minute=0;
                int newMinuteValue=0;
                if (crontab.minuteElement.isFixedValue()) {
                  newMinuteValue=getFixedNextInvocationValue(minute,59,crontab.minuteElement);
                }
 else {
                  newMinuteValue=getFixedNextInvocationValue(minute,crontab.minuteFixedInvocations);
                }
                nextInvocationTime.set(Calendar.MINUTE,newMinuteValue);
                nextInvocationTime.set(Calendar.SECOND,0);
              }
            }
 else {
              nextInvocationTime.set(Calendar.DATE,getFixedNextInvocationValue(day,31,crontab.dayElement));
              isHourModified=true;
              isDayModified=true;
            }
          }
 else {
            nextInvocationTime.add(Calendar.DATE,1);
            isHourModified=true;
            isDayModified=true;
          }
        }
 else {
          nextInvocationTime.set(Calendar.HOUR_OF_DAY,getFixedNextInvocationValue(hour,23,crontab.hourElement));
          isHourModified=true;
        }
      }
 else {
        nextInvocationTime.add(Calendar.HOUR_OF_DAY,1);
        isHourModified=true;
      }
      loopCounter++;
    }
  }
  return nextInvocationTime.getTimeInMillis();
}

Fixed version (ground truth):
public long getNextInvocationTime(Calendar currentTime,Crontab crontab){
  int millisecond=CalendarUtil.getMillisecond(currentTime);
  if (millisecond > 0) {
    currentTime.set(Calendar.MILLISECOND,0);
    currentTime.add(Calendar.SECOND,1);
  }
  int second=CalendarUtil.getSecond(currentTime);
  int minute=CalendarUtil.getMinute(currentTime);
  if (second > 0) {
    minute++;
  }
  if (crontab.minuteElement.isFixedValue()) {
    minute=getFixedNextInvocationValue(minute,59,crontab.minuteElement);
  }
 else {
    minute=getFixedSameOrNextInvocationValue(minute,crontab.minuteFixedInvocations);
  }
  int hour=CalendarUtil.get24Hour(currentTime);
  if (crontab.hourElement.isFixedValue()) {
    int newHour=crontab.hourElement.toInt();
    if (newHour > hour) {
      if (crontab.minuteElement.isFixedValue()) {
        minute=getFixedNextInvocationValue(minute,59,crontab.minuteElement);
      }
 else {
        minute=getFixedMinimumInvocationValue(crontab.minuteFixedInvocations);
      }
    }
    hour=newHour;
  }
  crontab=replaceWildcardsOfMinuteOrHourValue(crontab);
  int day=CalendarUtil.getDay(currentTime);
  if (crontab.dayElement.isFixedValue()) {
    day=crontab.dayElement.toInt();
  }
  int dayOfWeek=getCrontabDayOfWeekNumber(currentTime);
  if (dayOfWeek >= 7) {
    dayOfWeek=dayOfWeek - 7;
  }
  int month=CalendarUtil.getMonth(currentTime);
  if (crontab.monthElement.isFixedValue()) {
    month=crontab.monthElement.toInt();
  }
  int year=CalendarUtil.getYear(currentTime);
  Calendar nextInvocationTime=CalendarUtil.getCalendar(year,month,day,hour,minute,0);
  boolean isMinuteModified=false;
  boolean isHourModified=false;
  boolean isDayModified=false;
  boolean isMonthModified=false;
  boolean isDayOfWeekPrior=true;
  int loopCounter=0;
  if (crontab.dayOfWeekElement.isNotWildcard()) {
    while (nextInvocationTime.getTimeInMillis() <= currentTime.getTimeInMillis() || (isDayOfWeekPrior && isDayOfWeekNotCameAt(crontab,nextInvocationTime,dayOfWeek))) {
      if (loopCounter >= 100) {
        throw new IllegalStateException("String_Node_Str");
      }
      if (isMinuteModified || crontab.minuteElement.isWildcard()) {
        if (isHourModified || crontab.hourElement.isNotWildcard()) {
          if (isHourModified || crontab.hourElement.isFixedValue()) {
            if (isDayModified) {
              if (isMonthModified || crontab.monthElement.isNotWildcard()) {
                if (isMonthModified || crontab.monthElement.isFixedValue()) {
                  nextInvocationTime.add(Calendar.YEAR,1);
                }
 else {
                  nextInvocationTime.set(Calendar.MONTH,getFixedNextInvocationValue(month,12,crontab.monthElement));
                  isMonthModified=true;
                }
              }
 else {
                nextInvocationTime.add(Calendar.MONTH,1);
                isMonthModified=true;
              }
            }
 else {
              boolean isDayOfWeekNotContainedInCrontab=!isInvocationValueContainedInCrontabValue(dayOfWeek,6,crontab.dayOfWeekElement);
              boolean isNextInvocationNotInThisDate=currentTime.getTimeInMillis() > nextInvocationTime.getTimeInMillis();
              if (isDayOfWeekNotContainedInCrontab || isNextInvocationNotInThisDate) {
                int addDays=0;
                int nextDayOfWeek=getFixedNextInvocationValue(dayOfWeek,6,crontab.dayOfWeekElement);
                if (nextDayOfWeek > dayOfWeek) {
                  addDays=nextDayOfWeek - dayOfWeek;
                }
 else {
                  addDays=nextDayOfWeek - dayOfWeek + 7;
                }
                int addDaysByDayElement=getFixedNextInvocationValue(day,crontab.dayFixedInvocations) - day;
                if (addDaysByDayElement > 0 && addDaysByDayElement < addDays) {
                  addDays=addDaysByDayElement;
                  isDayOfWeekPrior=false;
                }
                nextInvocationTime.add(Calendar.DATE,addDays);
              }
              isDayModified=true;
            }
          }
 else {
            nextInvocationTime.set(Calendar.HOUR_OF_DAY,getFixedNextInvocationValue(hour,23,crontab.hourElement));
            isHourModified=true;
          }
        }
 else {
          nextInvocationTime.add(Calendar.HOUR_OF_DAY,1);
          isHourModified=true;
        }
      }
 else {
        if (!isDayModified && hour >= CalendarUtil.get24Hour(currentTime)) {
          nextInvocationTime.set(Calendar.MINUTE,getFixedSameOrNextInvocationValue(minute,crontab.minuteFixedInvocations));
        }
 else {
          nextInvocationTime.set(Calendar.MINUTE,getFixedMinimumInvocationValue(crontab.minuteFixedInvocations));
        }
        isMinuteModified=true;
      }
      loopCounter++;
    }
  }
 else {
    while ((isMonthModified && (!isDayModified || !isHourModified)) || nextInvocationTime.getTimeInMillis() < currentTime.getTimeInMillis()) {
      if (loopCounter >= 100) {
        throw new IllegalStateException("String_Node_Str");
      }
      if (isHourModified || crontab.hourElement.isNotWildcard()) {
        if (isHourModified || crontab.hourElement.isFixedValue()) {
          if (isDayModified || crontab.dayElement.isNotWildcard()) {
            if (isDayModified || crontab.dayElement.isFixedValue()) {
              if (isMonthModified || crontab.monthElement.isNotWildcard()) {
                if (isMonthModified || crontab.monthElement.isFixedValue()) {
                  nextInvocationTime.add(Calendar.YEAR,1);
                }
 else {
                  nextInvocationTime.set(Calendar.MONTH,getFixedNextInvocationValue(month,12,crontab.monthElement));
                  isHourModified=true;
                  isDayModified=true;
                  isMonthModified=true;
                }
              }
 else {
                nextInvocationTime.add(Calendar.MONTH,1);
                isHourModified=false;
                isDayModified=crontab.dayElement.isFixedValue();
                isMonthModified=true;
                hour=0;
                if (isInvocationValueContainedInCrontabValue(0,23,crontab.hourElement)) {
                  nextInvocationTime.set(Calendar.HOUR_OF_DAY,0);
                  isHourModified=true;
                }
                minute=0;
                int newMinuteValue=0;
                if (crontab.minuteElement.isFixedValue()) {
                  newMinuteValue=getFixedNextInvocationValue(minute,59,crontab.minuteElement);
                }
 else {
                  newMinuteValue=getFixedNextInvocationValue(minute,crontab.minuteFixedInvocations);
                }
                nextInvocationTime.set(Calendar.MINUTE,newMinuteValue);
                nextInvocationTime.set(Calendar.SECOND,0);
              }
            }
 else {
              nextInvocationTime.set(Calendar.DATE,getFixedNextInvocationValue(day,31,crontab.dayElement));
              isHourModified=true;
              isDayModified=true;
            }
          }
 else {
            nextInvocationTime.add(Calendar.DATE,1);
            isHourModified=true;
            isDayModified=true;
          }
        }
 else {
          nextInvocationTime.set(Calendar.HOUR_OF_DAY,getFixedNextInvocationValue(hour,23,crontab.hourElement));
          isHourModified=true;
        }
      }
 else {
        nextInvocationTime.add(Calendar.HOUR_OF_DAY,1);
        isHourModified=true;
      }
      loopCounter++;
    }
  }
  return nextInvocationTime.getTimeInMillis();
}