Girish Mahajan (Editor)

International Obfuscated C Code Contest

Updated on
Edit
Like
Comment
Share on FacebookTweet on TwitterShare on LinkedInShare on Reddit

The International Obfuscated C Code Contest (abbreviated IOCCC) is a computer programming contest for the most creatively obfuscated C code. Held annually in the years 1984-1996, 1998, 2000, 2001, 2004-2006, and then since 2011, it is described as "celebrating [C's] syntactical opaqueness". The winning code for the 22nd contest, held in 2013, was released in January 2014.

Contents

Prior to 2004, entries were submitted by email. In 2004, for the 17th IOCCC, the competition switched to using a web-based submission process.

Entries are evaluated anonymously by a panel of judges. The judging process is documented in the competition guidelines and consists of elimination rounds. By tradition, no information is given about the total number of entries for each competition. Winning entries are awarded with a category, such as "Worst Abuse of the C preprocessor" or "Most Erratic Behavior", and then announced on the official IOCCC website. Entries that do not make it are deleted and forgotten; the contest states that being announced on the IOCCC website is the award for winning.

History

The IOCCC was started by Landon Curt Noll and Larry Bassel in 1984 while employed at National Semiconductor's Genix porting group. The idea for the contest came after they compared notes with each other about some poorly written code that they had to fix, notably the Bourne shell, which used macros to emulate ALGOL 68 syntax, and buggy version of finger for BSD. The contest itself was the topic of a quiz question in the 1993 Computer Bowl. After a hiatus of five years starting in 2006, the contest returned in 2011.

Compared with other programming contests, the IOCCC is described as "not all that serious" by Michael Swaine, editor of Dr. Dobbs.

Rules

Each year, the rules of the contest are published on the IOCCC website. Rules vary from year to year and are posted with a set of guidelines that attempt to convey the spirit of the rules.

The rules are often deliberately written with subtle loopholes that contestants are somewhat encouraged to find and abuse. This is the result of the contest being a "parody of the software development process". Entries that take advantage of some loophole in the rules (whether or not they pass a final round of judging) can cause the rules for the following year's contest to be adjusted accordingly (although often other subtle loopholes are deliberately introduced in the process).

Obfuscations employed

Due to the nature of the contest, entries often employ strange or unusual tricks, such as using the C preprocessor to do things it was not designed to do, or avoiding commonly used constructs in the C programming language in favor of much more obscure ways of achieving the same thing. Two contest winners generated a list of prime numbers using the C preprocessor "spectacularly", according to Dr. Dobbs. Some quotes from 2004 winners include:

To keep things simple, I have avoided the C preprocessor and tricky statements such as "if", "for", "do", "while", "switch", and "goto".

We still aren't sure whether or not this is a useful program, but it's the first atomic fission we've seen in the IOCCC.

Why not use the program to hide another program in the program? It must have seemed reasonable at the time.

The program implements an 11-bit ALU in the C preprocessor.

I found that calculating prime numbers up to 1024 makes the program include itself over 6.8 million times.

Some ways in which contributions are notable include:

  • The appearance of the source code, formatted to resemble images, text, etc., after the manner of ASCII art.
  • Preprocessor redefinitions to make code harder to read.
  • Self-modifying code.
  • Worst abuse of the rules. In several years, an entry was submitted that was so patently absurd that it required a new definition of some of the rules for the next year. This is regarded as a high honor. An example is the world's shortest self-reproducing program. The entry was a program designed to output its own source code, and which had zero bytes of source code. When the program ran, it printed all zero bytes of the entire program's source code (meaning it prints nothing).
  • In the effort to take obfuscation to its extremes, contestants have produced programs which skirt around the edges of C standards, or result in constructs which trigger rarely used code path combinations in compilers. As a result, several of the past entries may not compile directly in a modern compiler, and some may even cause crashes.

    Examples

    Within the code size limit of only a few kilobytes, contestants have managed to do impressively complicated things – a 2004 winner turned out an operating system.

    Below is a 1988 entry which calculates pi by looking at its own area:

    (This entry was written in K&R C; it does not work correctly in ANSI C without some change.)

    Another example is the following flight simulator, the winner of the 1998 IOCCC, as listed and described in Calculated Bets: Computers, Gambling, and Mathematical Modeling to Win (2001) and shown below:

    This program needs the following command line on a Linux system to be compiled:

    cc banks.c -o banks -DIT=XK_Page_Up -DDT=XK_Page_Down -DUP=XK_Up -DDN=XK_Down -DLT=XK_Left -DRT=XK_Right -DCS=XK_Return -Ddt=0.02 -lm -lX11 -L/usr/X11R6/lib

    References

    International Obfuscated C Code Contest Wikipedia


    Similar Topics