Best choice of optimization

Don Yang

Judges' comments:

To build:

make sinon

To run:

cp sinon.c run.c

Then keep running ./ or ./ within a minute with slight pauses between invocations.


cp sinon.c run.c; ./; ./; sleep 3; ./; sleep 1; ./

Selected Judges Remarks:

Try to figure out how this entry determines the optimization level with which it had been compiled. Is this an example of undefined behavior or unspecified behavior?

Author’s comments:


Sinon is a game of timing, the goal is to eliminate all enemies in under one minute.

To start, compile and run the program. To resume, compile and run the output repeatedly until you have won/lost the game. For example:

cp sinon.c run.c
gcc -O0 run.c -o run && ./run | tee run.c
gcc -O2 run.c -o run && ./run | tee run.c


Sinon is played by compiling and running the output repeatedly. Two factors determine what actions are taken:

If you fire too quickly, the weapon will jam. If you fire too slowly, you will not be able to eliminate all the enemies in time. Thus the primary objective of the game is to time your compilations just right.

Sinon has two weapons that are selected based on compiler optimization level:

Because the weapons cool off independently, the best strategy is to alternate between the two weapons. It is fairly easy to win the game with this strategy even with occasional jams.

If your compiler does not have the right optimizations, only Glock 18C would be available. It is still possible to win, but your timing will need to be more precise. This is effectively playing the game on “hard” mode. It is worth trying this mode even if you have the right compilers.


Sinon has been tested and verified to work on these platforms:

Sinon is intended to be played in a 80x25 terminal.

Miscellaneous features

Sinon might be the first game that uses compiler optimization level as a primary input.

Sinon has a demo mode that plays the game automatically. Make sure that there are no files named “run” and “run.c” in current directory (they will be overwritten) and run:

perl sinon.c | bash

File size and CRC32 of sinon.c are embedded in line 7.

Process for making Sinon is included in spoiler.html.

Layout of this code is based on Asada Shino, also known as “Sinon”, from Sword Art Online.

Creative Commons License

© Copyright 1984-2015, Leo Broukhis, Simon Cooper, Landon Curt Noll - All rights reserved
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.