Program: 61069
Project: 61069
Buggy source:
void regionMoved(int region,int oldServer,int newServer){
  regionIndexToServerIndex[region]=newServer;
  if (initialRegionIndexToServerIndex[region] == newServer) {
    numMovedRegions--;
  }
 else   if (oldServer >= 0 && initialRegionIndexToServerIndex[region] == oldServer) {
    numMovedRegions++;
  }
  int tableIndex=regionIndexToTableIndex[region];
  if (oldServer >= 0) {
    numRegionsPerServerPerTable[oldServer][tableIndex]--;
  }
  numRegionsPerServerPerTable[newServer][tableIndex]++;
  if (numRegionsPerServerPerTable[newServer][tableIndex] > numMaxRegionsPerTable[tableIndex]) {
    numRegionsPerServerPerTable[newServer][tableIndex]=numMaxRegionsPerTable[tableIndex];
  }
 else   if (oldServer >= 0 && (numRegionsPerServerPerTable[oldServer][tableIndex] + 1) == numMaxRegionsPerTable[tableIndex]) {
    for (int serverIndex=0; serverIndex < numRegionsPerServerPerTable.length; serverIndex++) {
      if (numRegionsPerServerPerTable[serverIndex][tableIndex] > numMaxRegionsPerTable[tableIndex]) {
        numMaxRegionsPerTable[tableIndex]=numRegionsPerServerPerTable[serverIndex][tableIndex];
      }
    }
  }
  int primary=regionIndexToPrimaryIndex[region];
  if (oldServer >= 0) {
    primariesOfRegionsPerServer[oldServer]=removeRegion(primariesOfRegionsPerServer[oldServer],primary);
  }
  primariesOfRegionsPerServer[newServer]=addRegionSorted(primariesOfRegionsPerServer[newServer],primary);
  if (multiServersPerHost) {
    int oldHost=oldServer >= 0 ? serverIndexToHostIndex[oldServer] : -1;
    int newHost=serverIndexToHostIndex[newServer];
    if (newHost != oldHost) {
      regionsPerHost[newHost]=addRegion(regionsPerHost[newHost],region);
      primariesOfRegionsPerHost[newHost]=addRegionSorted(primariesOfRegionsPerHost[newHost],primary);
      if (oldHost >= 0) {
        regionsPerHost[oldHost]=removeRegion(regionsPerHost[oldHost],region);
        primariesOfRegionsPerHost[oldHost]=removeRegion(primariesOfRegionsPerHost[oldHost],primary);
      }
    }
  }
  if (numRacks > 1) {
    int oldRack=oldServer >= 0 ? serverIndexToRackIndex[oldServer] : -1;
    int newRack=serverIndexToRackIndex[newServer];
    if (newRack != oldRack) {
      regionsPerRack[newRack]=addRegion(regionsPerRack[newRack],region);
      primariesOfRegionsPerRack[newRack]=addRegionSorted(primariesOfRegionsPerRack[newRack],primary);
      if (oldRack >= 0) {
        regionsPerRack[oldRack]=removeRegion(regionsPerRack[oldRack],region);
        primariesOfRegionsPerRack[oldRack]=removeRegion(primariesOfRegionsPerRack[oldRack],primary);
      }
    }
  }
}

Fixed version (ground truth):
void regionMoved(int region,int oldServer,int newServer){
  regionIndexToServerIndex[region]=newServer;
  if (initialRegionIndexToServerIndex[region] == newServer) {
    numMovedRegions--;
  }
 else   if (oldServer >= 0 && initialRegionIndexToServerIndex[region] == oldServer) {
    numMovedRegions++;
  }
  int tableIndex=regionIndexToTableIndex[region];
  if (oldServer >= 0) {
    numRegionsPerServerPerTable[oldServer][tableIndex]--;
  }
  numRegionsPerServerPerTable[newServer][tableIndex]++;
  if (numRegionsPerServerPerTable[newServer][tableIndex] > numMaxRegionsPerTable[tableIndex]) {
    numMaxRegionsPerTable[tableIndex]=numRegionsPerServerPerTable[newServer][tableIndex];
  }
 else   if (oldServer >= 0 && (numRegionsPerServerPerTable[oldServer][tableIndex] + 1) == numMaxRegionsPerTable[tableIndex]) {
    for (int serverIndex=0; serverIndex < numRegionsPerServerPerTable.length; serverIndex++) {
      if (numRegionsPerServerPerTable[serverIndex][tableIndex] > numMaxRegionsPerTable[tableIndex]) {
        numMaxRegionsPerTable[tableIndex]=numRegionsPerServerPerTable[serverIndex][tableIndex];
      }
    }
  }
  int primary=regionIndexToPrimaryIndex[region];
  if (oldServer >= 0) {
    primariesOfRegionsPerServer[oldServer]=removeRegion(primariesOfRegionsPerServer[oldServer],primary);
  }
  primariesOfRegionsPerServer[newServer]=addRegionSorted(primariesOfRegionsPerServer[newServer],primary);
  if (multiServersPerHost) {
    int oldHost=oldServer >= 0 ? serverIndexToHostIndex[oldServer] : -1;
    int newHost=serverIndexToHostIndex[newServer];
    if (newHost != oldHost) {
      regionsPerHost[newHost]=addRegion(regionsPerHost[newHost],region);
      primariesOfRegionsPerHost[newHost]=addRegionSorted(primariesOfRegionsPerHost[newHost],primary);
      if (oldHost >= 0) {
        regionsPerHost[oldHost]=removeRegion(regionsPerHost[oldHost],region);
        primariesOfRegionsPerHost[oldHost]=removeRegion(primariesOfRegionsPerHost[oldHost],primary);
      }
    }
  }
  if (numRacks > 1) {
    int oldRack=oldServer >= 0 ? serverIndexToRackIndex[oldServer] : -1;
    int newRack=serverIndexToRackIndex[newServer];
    if (newRack != oldRack) {
      regionsPerRack[newRack]=addRegion(regionsPerRack[newRack],region);
      primariesOfRegionsPerRack[newRack]=addRegionSorted(primariesOfRegionsPerRack[newRack],primary);
      if (oldRack >= 0) {
        regionsPerRack[oldRack]=removeRegion(regionsPerRack[oldRack],region);
        primariesOfRegionsPerRack[oldRack]=removeRegion(primariesOfRegionsPerRack[oldRack],primary);
      }
    }
  }
}