Program: 149778
Project: 149778
Buggy source:
/** 
 * Get location of next reference. A zero return indicates that no more references exist.
 */
public Address getNextReferenceAddress(){
  if (!finishedWithRegularMap) {
    if (counterArrayBase) {
      counterArrayBase=false;
      return registerLocations.get(EBX.value()).toAddress();
    }
    if (mapId < 0) {
      mapIndex=maps.getNextJSRRefIndex(mapIndex);
    }
 else {
      mapIndex=maps.getNextRefIndex(mapIndex,mapId);
    }
    if (mapIndex != 0) {
      int mapOffset=convertIndexToOffset(mapIndex);
      if (VM.TraceStkMaps || TRACE_ALL) {
        VM.sysWrite("String_Node_Str");
        VM.sysWriteHex(mapOffset);
        VM.sysWrite("String_Node_Str");
        VM.sysWrite("String_Node_Str");
      }
      if (bridgeParameterMappingRequired) {
        if (VM.TraceStkMaps || TRACE_ALL) {
          VM.sysWriteHex(framePtr.plus(mapOffset - BRIDGE_FRAME_EXTRA_SIZE).loadInt());
          VM.sysWrite("String_Node_Str");
          if (mapId < 0) {
            VM.sysWrite("String_Node_Str");
          }
        }
        return (framePtr.plus(mapOffset - BRIDGE_FRAME_EXTRA_SIZE));
      }
 else {
        if (VM.TraceStkMaps || TRACE_ALL) {
          VM.sysWriteHex(framePtr.plus(mapOffset).loadInt());
          VM.sysWrite("String_Node_Str");
          if (mapId < 0) {
            VM.sysWrite("String_Node_Str");
          }
        }
        return (framePtr.plus(mapOffset));
      }
    }
 else {
      finishedWithRegularMap=true;
    }
  }
  if (bridgeParameterMappingRequired) {
    if (VM.TraceStkMaps || TRACE_ALL || TRACE_DL) {
      VM.sysWrite("String_Node_Str");
      VM.sysWrite(bridgeTarget);
      VM.sysWrite("String_Node_Str");
    }
    if (!bridgeRegistersLocationUpdated) {
      registerLocations.set(EDI.value(),framePtr.plus(EDI_SAVE_OFFSET).toWord());
      registerLocations.set(T0.value(),framePtr.plus(T0_SAVE_OFFSET).toWord());
      registerLocations.set(T1.value(),framePtr.plus(T1_SAVE_OFFSET).toWord());
      registerLocations.set(EBX.value(),framePtr.plus(EBX_SAVE_OFFSET).toWord());
      bridgeRegistersLocationUpdated=true;
    }
    if (bridgeParameterIndex == -1) {
      bridgeParameterIndex+=1;
      bridgeRegisterIndex+=1;
      bridgeRegisterLocation=bridgeRegisterLocation.minus(4);
      bridgeSpilledParamLocation=bridgeSpilledParamLocation.minus(4);
      if (VM.TraceStkMaps || TRACE_ALL || TRACE_DL) {
        VM.sysWrite("String_Node_Str");
        VM.sysWrite(bridgeRegisterLocation.plus(WORDSIZE));
        VM.sysWrite("String_Node_Str");
      }
      return bridgeRegisterLocation.plus(WORDSIZE);
    }
    while (bridgeParameterIndex < bridgeParameterTypes.length) {
      TypeReference bridgeParameterType=bridgeParameterTypes[bridgeParameterIndex++];
      if (bridgeParameterType.isReferenceType()) {
        bridgeRegisterIndex+=1;
        bridgeRegisterLocation=bridgeRegisterLocation.minus(WORDSIZE);
        bridgeSpilledParamLocation=bridgeSpilledParamLocation.minus(WORDSIZE);
        if (bridgeRegisterIndex <= NUM_PARAMETER_GPRS) {
          if (VM.TraceStkMaps || TRACE_ALL || TRACE_DL) {
            VM.sysWrite("String_Node_Str");
            VM.sysWrite(bridgeRegisterLocation.plus(WORDSIZE));
            VM.sysWrite("String_Node_Str");
          }
          return bridgeRegisterLocation.plus(WORDSIZE);
        }
 else {
          if (bridgeSpilledParameterMappingRequired) {
            if (VM.TraceStkMaps || TRACE_ALL || TRACE_DL) {
              VM.sysWrite("String_Node_Str");
              VM.sysWrite(bridgeSpilledParamLocation.plus(WORDSIZE));
              VM.sysWrite("String_Node_Str");
            }
            return bridgeSpilledParamLocation.plus(WORDSIZE);
          }
 else {
            break;
          }
        }
      }
 else       if (bridgeParameterType.isLongType()) {
        bridgeRegisterIndex+=VM.BuildFor32Addr ? 2 : 1;
        bridgeRegisterLocation=bridgeRegisterLocation.minus(2 * WORDSIZE);
        bridgeSpilledParamLocation=bridgeSpilledParamLocation.minus(2 * WORDSIZE);
      }
 else       if (bridgeParameterType.isDoubleType()) {
        bridgeSpilledParamLocation=bridgeSpilledParamLocation.minus(2 * WORDSIZE);
      }
 else       if (bridgeParameterType.isFloatType()) {
        bridgeSpilledParamLocation=bridgeSpilledParamLocation.minus(WORDSIZE);
      }
 else {
        bridgeRegisterIndex+=1;
        bridgeRegisterLocation=bridgeRegisterLocation.minus(WORDSIZE);
        bridgeSpilledParamLocation=bridgeSpilledParamLocation.minus(WORDSIZE);
      }
    }
  }
 else {
    registerLocations.set(EDI.value(),framePtr.plus(EDI_SAVE_OFFSET).toWord());
    registerLocations.set(EBX.value(),framePtr.plus(EBX_SAVE_OFFSET).toWord());
  }
  return Address.zero();
}

Fixed version (ground truth):
/** 
 * Get location of next reference. A zero return indicates that no more references exist.
 */
public Address getNextReferenceAddress(){
  if (!finishedWithRegularMap) {
    if (counterArrayBase) {
      counterArrayBase=false;
      return registerLocations.get(EBX.value()).toAddress();
    }
    if (mapId < 0) {
      mapIndex=maps.getNextJSRRefIndex(mapIndex);
    }
 else {
      mapIndex=maps.getNextRefIndex(mapIndex,mapId);
    }
    if (mapIndex != 0) {
      int mapOffset=convertIndexToOffset(mapIndex);
      if (VM.TraceStkMaps || TRACE_ALL) {
        VM.sysWrite("String_Node_Str");
        VM.sysWriteHex(mapOffset);
        VM.sysWrite("String_Node_Str");
        VM.sysWrite("String_Node_Str");
      }
      if (bridgeParameterMappingRequired) {
        if (VM.TraceStkMaps || TRACE_ALL) {
          VM.sysWriteHex(framePtr.plus(mapOffset - BRIDGE_FRAME_EXTRA_SIZE).loadAddress());
          VM.sysWrite("String_Node_Str");
          if (mapId < 0) {
            VM.sysWrite("String_Node_Str");
          }
        }
        return (framePtr.plus(mapOffset - BRIDGE_FRAME_EXTRA_SIZE));
      }
 else {
        if (VM.TraceStkMaps || TRACE_ALL) {
          VM.sysWriteHex(framePtr.plus(mapOffset).loadAddress());
          VM.sysWrite("String_Node_Str");
          if (mapId < 0) {
            VM.sysWrite("String_Node_Str");
          }
        }
        return (framePtr.plus(mapOffset));
      }
    }
 else {
      finishedWithRegularMap=true;
    }
  }
  if (bridgeParameterMappingRequired) {
    if (VM.TraceStkMaps || TRACE_ALL || TRACE_DL) {
      VM.sysWrite("String_Node_Str");
      VM.sysWrite(bridgeTarget);
      VM.sysWrite("String_Node_Str");
    }
    if (!bridgeRegistersLocationUpdated) {
      registerLocations.set(EDI.value(),framePtr.plus(EDI_SAVE_OFFSET).toWord());
      registerLocations.set(T0.value(),framePtr.plus(T0_SAVE_OFFSET).toWord());
      registerLocations.set(T1.value(),framePtr.plus(T1_SAVE_OFFSET).toWord());
      registerLocations.set(EBX.value(),framePtr.plus(EBX_SAVE_OFFSET).toWord());
      bridgeRegistersLocationUpdated=true;
    }
    if (bridgeParameterIndex == -1) {
      bridgeParameterIndex+=1;
      bridgeRegisterIndex+=1;
      bridgeRegisterLocation=bridgeRegisterLocation.minus(4);
      bridgeSpilledParamLocation=bridgeSpilledParamLocation.minus(4);
      if (VM.TraceStkMaps || TRACE_ALL || TRACE_DL) {
        VM.sysWrite("String_Node_Str");
        VM.sysWrite(bridgeRegisterLocation.plus(WORDSIZE));
        VM.sysWrite("String_Node_Str");
      }
      return bridgeRegisterLocation.plus(WORDSIZE);
    }
    while (bridgeParameterIndex < bridgeParameterTypes.length) {
      TypeReference bridgeParameterType=bridgeParameterTypes[bridgeParameterIndex++];
      if (bridgeParameterType.isReferenceType()) {
        bridgeRegisterIndex+=1;
        bridgeRegisterLocation=bridgeRegisterLocation.minus(WORDSIZE);
        bridgeSpilledParamLocation=bridgeSpilledParamLocation.minus(WORDSIZE);
        if (bridgeRegisterIndex <= NUM_PARAMETER_GPRS) {
          if (VM.TraceStkMaps || TRACE_ALL || TRACE_DL) {
            VM.sysWrite("String_Node_Str");
            VM.sysWrite(bridgeRegisterLocation.plus(WORDSIZE));
            VM.sysWrite("String_Node_Str");
          }
          return bridgeRegisterLocation.plus(WORDSIZE);
        }
 else {
          if (bridgeSpilledParameterMappingRequired) {
            if (VM.TraceStkMaps || TRACE_ALL || TRACE_DL) {
              VM.sysWrite("String_Node_Str");
              VM.sysWrite(bridgeSpilledParamLocation.plus(WORDSIZE));
              VM.sysWrite("String_Node_Str");
            }
            return bridgeSpilledParamLocation.plus(WORDSIZE);
          }
 else {
            break;
          }
        }
      }
 else       if (bridgeParameterType.isLongType()) {
        bridgeRegisterIndex+=VM.BuildFor32Addr ? 2 : 1;
        bridgeRegisterLocation=bridgeRegisterLocation.minus(2 * WORDSIZE);
        bridgeSpilledParamLocation=bridgeSpilledParamLocation.minus(2 * WORDSIZE);
      }
 else       if (bridgeParameterType.isDoubleType()) {
        bridgeSpilledParamLocation=bridgeSpilledParamLocation.minus(2 * WORDSIZE);
      }
 else       if (bridgeParameterType.isFloatType()) {
        bridgeSpilledParamLocation=bridgeSpilledParamLocation.minus(WORDSIZE);
      }
 else {
        bridgeRegisterIndex+=1;
        bridgeRegisterLocation=bridgeRegisterLocation.minus(WORDSIZE);
        bridgeSpilledParamLocation=bridgeSpilledParamLocation.minus(WORDSIZE);
      }
    }
  }
 else {
    registerLocations.set(EDI.value(),framePtr.plus(EDI_SAVE_OFFSET).toWord());
    registerLocations.set(EBX.value(),framePtr.plus(EBX_SAVE_OFFSET).toWord());
  }
  return Address.zero();
}