Program: 149987
Project: 149987
Buggy source:
public Address getNextReferenceAddress(){
  int location=-1;
  if (state == CHECK_REFERENCE_STATE) {
    do {
      if (mapId < 0)       mapIndex=maps.getNextJSRRefIndex(mapIndex);
 else       mapIndex=maps.getNextRefIndex(mapIndex,mapId);
      if (mapIndex == VM_QuickReferenceMaps.NOMORE) {
        state+=1;
        break;
      }
 else {
        location=maps.getLocation(mapId,mapIndex);
      }
    }
 while (location == EMPTY_SLOT);
    if (location == INVALID_SLOT) {
      VM.sysWrite("String_Node_Str");
      VM.sysWrite(mapIndex);
      VM.sysWrite("String_Node_Str");
      VM.sysWrite(mapId);
      VM.sysWrite("String_Node_Str");
      return Address.max();
    }
    if (VM.TraceStkMaps) {
      VM.sysWrite("String_Node_Str");
      VM.sysWrite(mapIndex);
      VM.sysWrite("String_Node_Str");
      if (mapId < 0)       VM.sysWrite("String_Node_Str");
    }
  }
  if (state == CHECK_REFERENCE_STATE) {
    if (VM.TraceStkMaps) {
      VM.sysWrite("String_Node_Str");
      VM.sysWrite(location);
    }
    if (location > 0) {
      if (VM.TraceStkMaps) {
        VM.sysWrite("String_Node_Str");
        VM.sysWrite(location);
        VM.sysWrite("String_Node_Str");
      }
      return registerLocations.get(location).toAddress();
    }
 else {
      int offset=maps.locationToOffset(mapIndex);
      if (VM.TraceStkMaps) {
        VM.sysWrite("String_Node_Str");
        VM.sysWriteHex(offset);
        VM.sysWrite("String_Node_Str");
      }
      return (framePtr.add(offset));
    }
  }
 else   if (state == CHECK_THIS_PTR_STATE) {
    state+=1;
    if (checkSavedThisPtr && maps.getSavedThisPtrOffset() >= 0) {
      if (VM.TraceStkMaps) {
        VM.sysWrite("String_Node_Str");
        VM.sysWrite(maps.getSavedThisPtrOffset());
        VM.sysWrite("String_Node_Str");
      }
      checkSavedThisPtr=false;
      return framePtr.add(maps.getSavedThisPtrOffset());
    }
  }
 else   if (state == CHECK_BRIDGE_REFERENCE_STATE && bridgeParameterMappingRequired) {
    if (VM.TraceStkMaps) {
      VM.sysWrite("String_Node_Str");
      VM.sysWrite(bridgeTarget);
      VM.sysWrite("String_Node_Str");
    }
    if (!bridgeRegistersLocationUpdated) {
      Address addr=framePtr.add(VM_Compiler.getFrameSize(currentMethod));
      addr=addr.sub((LAST_NONVOLATILE_FPR - FIRST_VOLATILE_FPR + 1) * BYTES_IN_DOUBLE);
      for (int i=LAST_NONVOLATILE_GPR; i >= FIRST_VOLATILE_GPR; --i) {
        addr=addr.sub(BYTES_IN_ADDRESS);
        registerLocations.set(i,addr);
      }
      bridgeRegistersLocationUpdated=true;
    }
    if (bridgeParameterIndex == -1) {
      bridgeParameterIndex+=1;
      bridgeRegisterIndex+=1;
      bridgeRegisterLocation=bridgeRegisterLocation.add(4);
      return bridgeRegisterLocation.sub(4);
    }
    while (true) {
      if (bridgeParameterIndex == bridgeParameterTypes.length || bridgeRegisterIndex > LAST_VOLATILE_GPR) {
        bridgeParameterMappingRequired=false;
        state+=1;
        break;
      }
      VM_TypeReference bridgeParameterType=bridgeParameterTypes[bridgeParameterIndex++];
      if (bridgeParameterType.isReferenceType()) {
        bridgeRegisterIndex+=1;
        bridgeRegisterLocation=bridgeRegisterLocation.add(4);
        return bridgeRegisterLocation.sub(4);
      }
 else       if (bridgeParameterType.isLongType()) {
        bridgeRegisterIndex+=2;
        bridgeRegisterLocation=bridgeRegisterLocation.add(8);
      }
 else       if (bridgeParameterType.isDoubleType() || bridgeParameterType.isFloatType()) {
      }
 else {
        bridgeRegisterIndex+=1;
        bridgeRegisterLocation=bridgeRegisterLocation.add(4);
      }
    }
  }
  return Address.zero();
}

Fixed version (ground truth):
public Address getNextReferenceAddress(){
  int location=-1;
  if (state == CHECK_REFERENCE_STATE) {
    do {
      if (mapId < 0)       mapIndex=maps.getNextJSRRefIndex(mapIndex);
 else       mapIndex=maps.getNextRefIndex(mapIndex,mapId);
      if (mapIndex == VM_QuickReferenceMaps.NOMORE) {
        state+=1;
        break;
      }
 else {
        location=maps.getLocation(mapId,mapIndex);
      }
    }
 while (location == EMPTY_SLOT);
    if (location == INVALID_SLOT) {
      VM.sysWrite("String_Node_Str");
      VM.sysWrite(mapIndex);
      VM.sysWrite("String_Node_Str");
      VM.sysWrite(mapId);
      VM.sysWrite("String_Node_Str");
      return Address.max();
    }
    if (VM.TraceStkMaps) {
      VM.sysWrite("String_Node_Str");
      VM.sysWrite(mapIndex);
      VM.sysWrite("String_Node_Str");
      if (mapId < 0)       VM.sysWrite("String_Node_Str");
    }
  }
  if (state == CHECK_REFERENCE_STATE) {
    if (VM.TraceStkMaps) {
      VM.sysWrite("String_Node_Str");
      VM.sysWrite(location);
    }
    if (location > 0) {
      if (VM.TraceStkMaps) {
        VM.sysWrite("String_Node_Str");
        VM.sysWrite(location);
        VM.sysWrite("String_Node_Str");
      }
      return registerLocations.get(location).toAddress();
    }
 else {
      int offset=maps.locationToOffset(mapIndex);
      if (VM.TraceStkMaps) {
        VM.sysWrite("String_Node_Str");
        VM.sysWriteHex(offset);
        VM.sysWrite("String_Node_Str");
      }
      return (framePtr.plus(offset));
    }
  }
 else   if (state == CHECK_THIS_PTR_STATE) {
    state+=1;
    if (checkSavedThisPtr && maps.getSavedThisPtrOffset() >= 0) {
      if (VM.TraceStkMaps) {
        VM.sysWrite("String_Node_Str");
        VM.sysWrite(maps.getSavedThisPtrOffset());
        VM.sysWrite("String_Node_Str");
      }
      checkSavedThisPtr=false;
      return framePtr.plus(maps.getSavedThisPtrOffset());
    }
  }
 else   if (state == CHECK_BRIDGE_REFERENCE_STATE && bridgeParameterMappingRequired) {
    if (VM.TraceStkMaps) {
      VM.sysWrite("String_Node_Str");
      VM.sysWrite(bridgeTarget);
      VM.sysWrite("String_Node_Str");
    }
    if (!bridgeRegistersLocationUpdated) {
      Address addr=framePtr.plus(VM_Compiler.getFrameSize(currentMethod));
      addr=addr.minus((LAST_NONVOLATILE_FPR - FIRST_VOLATILE_FPR + 1) * BYTES_IN_DOUBLE);
      for (int i=LAST_NONVOLATILE_GPR; i >= FIRST_VOLATILE_GPR; --i) {
        addr=addr.minus(BYTES_IN_ADDRESS);
        registerLocations.set(i,addr);
      }
      bridgeRegistersLocationUpdated=true;
    }
    if (bridgeParameterIndex == -1) {
      bridgeParameterIndex+=1;
      bridgeRegisterIndex+=1;
      bridgeRegisterLocation=bridgeRegisterLocation.plus(4);
      return bridgeRegisterLocation.minus(4);
    }
    while (true) {
      if (bridgeParameterIndex == bridgeParameterTypes.length || bridgeRegisterIndex > LAST_VOLATILE_GPR) {
        bridgeParameterMappingRequired=false;
        state+=1;
        break;
      }
      VM_TypeReference bridgeParameterType=bridgeParameterTypes[bridgeParameterIndex++];
      if (bridgeParameterType.isReferenceType()) {
        bridgeRegisterIndex+=1;
        bridgeRegisterLocation=bridgeRegisterLocation.plus(4);
        return bridgeRegisterLocation.minus(4);
      }
 else       if (bridgeParameterType.isLongType()) {
        bridgeRegisterIndex+=2;
        bridgeRegisterLocation=bridgeRegisterLocation.plus(8);
      }
 else       if (bridgeParameterType.isDoubleType() || bridgeParameterType.isFloatType()) {
      }
 else {
        bridgeRegisterIndex+=1;
        bridgeRegisterLocation=bridgeRegisterLocation.plus(4);
      }
    }
  }
  return Address.zero();
}