crc32 quine
As a side feature, the file size and crc32 of sugar.c is embedded in
itself (at line 8, col 72, offset 718). This is actually a pretty
difficult trick to do, since the crc depends on the file content, and
the file content depends on the crc value.
We could, of course, search through 2^32 possible crc32 values, and we
may or may not find one that works. Changing some of the comments
would help -- there are about 6 characters, each can take on about 93
different values (if we want to be 8 bit clean and free of control
codes).
... this comes out to be about 2.78e+21 different values to try,
multiplying by the file size and it's about 1.7e+25 crc32 operations.
Too big a search space.
The final search algorithm is a bit more clever: we can compute a
partial crc32 starting from middle of the program, then adjust the
comments up to that point so that the intermediate crc32 is zero.
This reduces the search space by 2^32 (6.5+e11 values left).
Also, for each of the 6 characters, we can compute a partial crc32 up
to that point to save some calculations.
The comment offsets are: 545, 2273, 2274, 2318, 2319, 4805
First, the final crc32 were computed: 6110-4805 = 1305 operations
Then each step uses a partial sum from before:
2273*93 * (
(2274-2273)*93 * (
(2318-2274)*93 * (
(2319-2318)*93 * (
(4805-2319)*93 * 93 ))))
... 1.6e+20 crc32 operations, much better than 1.7e+25. But this can
still take a long time, of course ^_^;
To my luck, a solution was found very early (in 7 minutes, about
2.0e+14 operations). Source that did this search is crc.c, included.
Because a match was found early on, other matches are probably
possible. You can check this by changing the value of crc_mid to
something other than zero.