Source:
<code>public static int hashMemory(final Memory memory, final long position, final int length) { switch (length) { case 4: <START> return 31 + memory.getInt(position); <END> case 8: return 31 * (31 + memory.getInt(position)) + memory.getInt(position + Integer.BYTES); case 9: return 31 * (31 * (31 + memory.getInt(position)) + memory.getInt(position + Integer.BYTES)) + memory.getByte(position + 2 * Integer.BYTES); case 12: return 31 * (31 * (31 + memory.getInt(position)) + memory.getInt(position + Integer.BYTES)) + memory.getInt(position + 2 * Integer.BYTES); case 13: return 31 * (31 * (31 * (31 + memory.getInt(position)) + memory.getInt(position + Integer.BYTES)) + memory.getInt(position + 2 * Integer.BYTES)) + memory.getByte(position + 3 * Integer.BYTES); case 16: return 31 * (31 * (31 * (31 + memory.getInt(position)) + memory.getInt(position + Integer.BYTES)) + memory.getInt(position + 2 * Integer.BYTES)) + memory.getInt(position + 3 * Integer.BYTES); default: int hashCode = 1; int remainingBytes = length; long pos = position; while (remainingBytes >= Integer.BYTES) { hashCode = 31 * hashCode + memory.getInt(pos); remainingBytes -= Integer.BYTES; pos += Integer.BYTES; } if (remainingBytes == 1) { hashCode = 31 * hashCode + memory.getByte(pos); } else if (remainingBytes == 2) { hashCode = 31 * hashCode + memory.getByte(pos); hashCode = 31 * hashCode + memory.getByte(pos + 1); } else if (remainingBytes == 3) { hashCode = 31 * hashCode + memory.getByte(pos); hashCode = 31 * hashCode + memory.getByte(pos + 1); hashCode = 31 * hashCode + memory.getByte(pos + 2); } return hashCode; } }</code><technical_language>+ 31 necessary</technical_language>

Target:
public static int hashMemory(final Memory memory, final long position, final int length) { switch (length) { case 4: return memory.getInt(position); case 8: return 31 * (31 + memory.getInt(position)) + memory.getInt(position + Integer.BYTES); case 9: return 31 * (31 * (31 + memory.getInt(position)) + memory.getInt(position + Integer.BYTES)) + memory.getByte(position + 2 * Integer.BYTES); case 12: return 31 * (31 * (31 + memory.getInt(position)) + memory.getInt(position + Integer.BYTES)) + memory.getInt(position + 2 * Integer.BYTES); case 13: return 31 * (31 * (31 * (31 + memory.getInt(position)) + memory.getInt(position + Integer.BYTES)) + memory.getInt(position + 2 * Integer.BYTES)) + memory.getByte(position + 3 * Integer.BYTES); case 16: return 31 * (31 * (31 * (31 + memory.getInt(position)) + memory.getInt(position + Integer.BYTES)) + memory.getInt(position + 2 * Integer.BYTES)) + memory.getInt(position + 3 * Integer.BYTES); default: int hashCode = 1; int remainingBytes = length; long pos = position; while (remainingBytes >= Integer.BYTES) { hashCode = 31 * hashCode + memory.getInt(pos); remainingBytes -= Integer.BYTES; pos += Integer.BYTES; } if (remainingBytes == 1) { hashCode = 31 * hashCode + memory.getByte(pos); } else if (remainingBytes == 2) { hashCode = 31 * hashCode + memory.getByte(pos); hashCode = 31 * hashCode + memory.getByte(pos + 1); } else if (remainingBytes == 3) { hashCode = 31 * hashCode + memory.getByte(pos); hashCode = 31 * hashCode + memory.getByte(pos + 1); hashCode = 31 * hashCode + memory.getByte(pos + 2); } return hashCode; } }