- This is a "single error correction, double error detection" (SECDED) extended Hamming code scrubber.
- Each gigabyte of non-ECC DRAM flips a bit every few hours on average. We want to protect against such flips.
- This function returns -1, 0, or 1. Triple-bit (or worse) errors are neither corrected nor reliably detected.
- If all data bits and all checksum bits are correct, 0 is returned.
- If exactly one bit is flipped (anywhere in the data or checksum), the flip is corrected and 1 is returned.
- If exactly two bits are flipped (anywhere in the data or checksum), nothing is modified and -1 is returned.
- All data bits and all checksum bits are XOR'ed together to yield the blanket parity bit.
- The data bits are numbered 3+(2*i): 3, 5, 7, 9, ... so that each data bit gets an index having two or more 1-bits.
- The index numbers for all 1-bits in the data are XOR'ed out of the checksum's index sum to yield the remainder.
- If all data bits and all checksum bits are correct, the blanket parity bit is 0 and the remainder is 0.
- If exactly two bits are flipped, the blanket parity bit is 0 and the remainder is not 0.
- Otherwise, exactly one bit is flipped (in the data or checksum) and the blanket parity bit is 1.
- If a data bit is flipped, the remainder is the index number of the flipped bit (and so has two or more 1-bits).
- If a bit is flipped in the checksum's index sum, the remainder has a 1-bit only at the corresponding position.
- Finally, if the checksum's overall parity bit is flipped, the remainder is 0.

To receive a hint, submit unfixed code.