When Landon Curt “Chongo” Noll was trying to fix a bug in an early BSD version of Finger on March 23, 1984, it was a moment of enlightenment. He and cohort Larry Bassel (who had been trying to fix a bug in the Bourne shell) were chewing the fat between bug-squishing sessions at National Semiconductor when the pair compared their woes, surmising that they couldn’t write more confusing and difficult code if they had tried.

And with that, the International Obfuscated C Code Competition was born. The pair put out a call on Usenet asking for C coders to submit their own confounding programs within a preset size limit. The goal of the competition was to write C code that compiled to a functional application, but upon closer inspection of the source code, the connections between the functionality and the code itself should not have been obvious.

As Noll put it, “A program that has value is going to evolve. The open-source community or company behind it is going to take that and reuse it. If you’ve written a bunch of glunk, it’s hard for people to reuse. It’s hard for people to extend the code and fix bugs.” And the IOCCC competition is about writing confusing glunk.

But not inartistic glunk. As Noll put it, the best entries are elegant in their convolution. In one year’s competition, David Korn, author of the Korn Shell, produced a one-line C program so contrived and confusing that even Dennis Ritchie, the father of C, misinterpreted the code’s functionality upon first reading.

“It illustrates, really, what is underlying arrays in C, and also exploits a little-known but widely implemented feature of the C compiler,” he said. He added that, while many older entries no longer compile due to advances in C and in compilers, he’s relatively certain this one-liner still compiles.

The five-year hiatus for the competition was ended because Noll said there was great demand for its return. He said that since this is the 20th competition, it just made sense to go for a round number.

But after 19 previous competitions, things have changed quite a bit. In the first competition in 1984, for example, one of the winning entries was specific to the DEC PDP-11 and VAX platforms. The C code in question generated, via an array of data, VAX assembly code. “It’s an array whose name is ‘Main,’ so when the C startup routine jumps to ‘Main,’ it’s jumping into instructions,” said Noll.

“This worked on VAX and PDP, but on machines where they separate code from instructions, that won’t work.”

The actual functionality of these programs is left entirely to the desires of the developer. One entry manipulated the refresh rate of a computer’s monitor in order to transmit phone-tones over AM frequencies. Using an AM radio, users could listen to these tones, provided they were relatively close to the monitor in question. Another entrant wrote an entire X Windows spreadsheet program in less than 100 lines of code.

And yet, despite the interesting functionality, in the IOCCC, functionality is almost incidental. Certainly, said Noll, maze generators, tic-tac-toe games and ROT13 programs aren’t interesting anymore. The judges, he said, appreciate entries that contain interesting or new functionality, particularly those that seem to be difficult to implement within the constrained size requirements of the competition.

But in the end, it all comes down to the code itself. The idea is to make the code on the screen seem completely unrelated to the functionality of the final compiled program. And while many older tricks don’t work on modern compilers, there’s still plenty of obfuscation to go around, said Noll.

“We see a lot of really interesting algorithmic tricks,” he said. “We see a lot of interesting uses of recursion. There’s also a lot of interesting work being done in interesting data structures that people build that are fairly compact, and when you build that, the program can turn it into a large data set. I also see a number of people trying to take code that isn’t just a tight ball of characters, but appears to be formatted normally, but is misleading. That’s even more to the spirit of the contest.”

The IOCCC kicked off on Nov. 12, and submissions will be accepted at www.ioccc.org until Jan. 12, 2012. The online submission tool will be up on Dec. 1.