IOCCC image by Matt Zucker

The International Obfuscated C Code Contest

deobfuscation.html for 2024/ferguson1

The following hints were used for myself but also I offer them for those who wish to more easily follow the code, though that might or might not help that much. If a variable or other kind of symbol is missing or is not what it says here that was by (in some cases) simply missing it or (in other cases) due to having changed things a fair amount; this submission took a lot of work and time to get everything in. One variable, p, is for the encrypted version only.

The following variables are of primary concern (some temporary ones are not documented I think):

When an amount spent (if it happens, not necessarily going to for every variable) spent ends up being < 0 (it’s not allowed to go that low when purchasing) it means that there is an insufficient amount (thus a variable reuse).

The array:

    long *o[]={ &O, &R, &E, &G, &N  } /* animals, food, ammo, clothing, misc. supplies

is used in at least one loop to not have to do checks individually. The variables, btw, are not how many as such (well in some cases it is, although with the number of animals it’s a ‘taken at liberty’ and based on my interpretation of the original 1978 BASIC game) but rather how much was spent on them. As for the ammo: $1 spent on ammo means a belt of 50. That means another variable has to exist (that would be the I one) and every time a purchase is made (at fort or initially) I is set to E * 50.

The functions:

The macro:

If you expect me to try and describe the labels I will direct you straight to line 22!