The Register Home Page

back to article The International Obfuscated C Code Contest is back for 2024

The IOCCC, as it's familiarly known, is back after a four-year gap, giving the entrants more time to come up with some remarkably devious code. This week, the results for the IOCCC 2024 were announced, with a record 23 winners. It's the first IOCCC in four years, but you shouldn't take that to imply it's as regular as the …

  1. DarkwavePunk Silver badge

    Devious

    That "salmon" one hurt my brain.

    1. Liam Proven (Written by Reg staff) Silver badge

      Re: Devious

      Nano makes some of the secret shenanigans more apparent...

      unsigned int *salmon = U"???????????????????????????????????????????????????????????????????????????????????????$

      1. Androgynous Cupboard Silver badge

        Re: Devious

        I went straight to "hexdump -C prog.c". I'm not sure "all becomes clear" exactly, but at least I know I'm not hallucinating. Genuine genius involved there.

      2. DarkwavePunk Silver badge

        Re: Devious

        Nice spot there! Although even if I'd tried that I'd probably just thought it was nano being weird as usual.

      3. alain williams Silver badge

        Re: Devious

        What you have is an array of int containing the values of Unicode characters with values like U+0E0053 (first one), putchar() puts a byte eg 0x53 which is 'S' - the start of 'Season'. The top bits (0x0E00) are ignored as being more than can be stored in a byte.

        It increments in the int array until it outputs U+0E002E (0x2E is '.') followed by U+200A (0x0A is newline) and then NUL which putchar() returns thus stopping the loop.

        This is all output by after 'main {' having U+0E0041 which is the 'grill' macro (somewhat deviously). This is not visible in most text editors as it has a character value U+0E0041.

        Why the squares from 1 .. 10 is not output is because after the U+0E0041 (after 'main {') is another U+0E0041 which expands to ';while(putchar(*salmon++))'. This outputs another NUL byte, which putchar() returns as condition to while(); this being false the body of the while loop never happens.

        I suspect that this will not work on a big endian machine (Intel/AMD are little endian).

        It might need a tweak if sizeof(int) is not 4.

        Phew!

        1. doublelayer Silver badge

          Re: Devious

          It will work on a big endian machine. By the time that the character is sent to putchar, it's already been converted to an integer in the host's preferred byte order by the compiler. The putchar function will cast that to unsigned char, which will take the least significant 8 bits no matter where the CPU chooses to store them. Programmers sometimes learn that to their detriment when trying to use non-Unicode-aware functions like putchar with Unicode strings.

      4. Dan 55 Silver badge

        Re: Devious

        I can tell something is wrong with less and vim, but the computer I'm using at the moment is hardly cutting edge. I guess the older it is, the less compliant it's going to be with UTF-8 shenanigans.

    2. b0llchit Silver badge
      Thumb Up

      Re: Devious

      The preprocessor hack is brilliant obfuscation :-)

    3. elsergiovolador Silver badge

      Re: Devious

      I had coworker once inserting invisible characters into the codebase, complaining it is not compiling and made team pull hair over this for days.

      1. DarkwavePunk Silver badge

        Re: Devious

        I've seen this. Usually it's unintentional and related to editor or or OS, but frustrating nonetheless.

        Speaking of obfuscation, I once had to debug TCL code with embedded external calls to incomprehensible Perl. The sad thing is; I probably wrote it.

        1. elsergiovolador Silver badge

          Re: Devious

          Some people also let their cat walk over the laptop's keyboard.

          1. Marvin the Martian

            Re: Devious

            There is no 'letting' --- the cat walks, or it doesn't. Go ahead, try to cat-proof a keyboard and you will be surprised.

        2. jake Silver badge

          Re: Devious

          About four years ago, I was reading some PDP11 machine code for the first time since I wrote it 45ish years ago, and scratching my head. I couldn't figure out WTF I did what I did ... clearly it worked, but it was also clearly wrong. I'd been going over the (seemingly) simple code for eight or ten hours and was getting increasingly frustrated, which is rare for me. I wrote the shit, why couldn't I figure it out? My wife (ever the wise one) suggested I sleep on it. So I took a nap.

          I woke an hour or so later with two words on my mind: DEC Tape.

          Now, I seriously doubt that even that pile of steam-powered, smoke-belching, carved from solid rock back in the age of Wizards and Grues will ever need anything as weird of DEC Tape again ... So I should excise that block of code (and the others like it, throughout). I should streamline things, make it more efficient, right?

          Should I fuck. It fucking works. Is has worked for over four decades. I ain't touching it. I have been called in far too many times to "fix" projects that started like that, "just one, small tweak", to fall for that one ... I HAVE, however, added comments ("notes to my future self") that I should have added in the first place but didn't, because "it's obvious, innit?".

    4. Jou (Mxyzptlk) Silver badge

      Re: Devious

      Hex-editor needed...

  2. alain williams Silver badge

    moon.c

    I could not get that to compile unless I put "int" on the line above "a,b=44,x,". I admit to not using their Makefile as it included all manner of things that I did not have, I just went "make moon" (on a Debian machine).

    Am I missing something ?

    1. chololennon

      Re: moon.c

      > I could not get that to compile unless I put "int" on the line above "a,b=44,x,".

      Check you compiler (gcc?) flags, mine has "--disable-werror" set (on openSUSE 15.6), so I don't have problem with the default int type:

      $ gcc -v

      Compile your program with:

      $ gcc -Wno-error moon.c

      1. chololennon

        Re: moon.c

        > Compile your program with:

        > $ gcc -Wno-error moon.c

        Maybe this ^^ doesn't solve your problem.

        (My) openSUSE 15.6 uses an old version of gcc (7.5, defaulted to c11) which, I don't why, it doesn't consider an error the lack of a variable type at the point of declaration (since c99 this must an error). The solution is to change the standard (tested with gcc 14):

        $ gcc -std=c90 moon.c

  3. Paul Herber Silver badge

    ' "make moon" (on a Debian machine).

    Am I missing something ?'

    with code obfuscation - the dark side ...

  4. trevorde Silver badge

    Obfuscation for a living

    Worked with a developer who was a real Francophile. His variable names were in French, his comments were in French and his QWERTY keyboard was mapped to AZERTY. His code was cr@p too.

  5. tango_uniform

    Ah, the good old days

    If you want to learn C, try doing end-user support for a C compiler publisher. I did that in the late 80s for a company that wrote C compilers for a bunch of architectures while I went to school. There's no better teacher than looking at someone else's busted(?) code, divining what they were trying to do, whipping up a corrected version and shipping it back to them on the floppy they mailed to us. Yes, support by mail correspondence. At least until I convinced company to allow me to set up a BBS for support.

    I still like looking and these concoctions of unhinged art and teasing out their secrets.

    1. jake Silver badge

      Re: Ah, the good old days

      If you want to really learn C (or any other language), write your own compiler.

      It's not as difficult as it would seem at first blush ...

  6. Soruk
    Facepalm

    El Reg added quirk

    The salmon source has an additional oddity that wasn't there upstream - a spurious "</stdio.h>" at the bottom!

  7. jlturriff

    So, where do the winners have to send their penalty payments?

    1. Jou (Mxyzptlk) Silver badge

      Depends in which country the hacked"worked" for.

  8. Blackjack Silver badge

    In the year 3000 Before Cheers, they will make a Rust version.

  9. GNU Enjoyer
    Angel

    I was hoping the IOCCC had improved from the past

    Considering that previously it was required that submissions were under a proprietary license.

    But of course it's worse now - it seems the submissions now have no license and the primary files are hosted on github.

    Some of them seem trivial enough that it doesn't really matter, but many certainly aren't trivial.

POST COMMENT House rules

Not a member of The Register? Create a new account here.

  • Enter your comment

  • Add an icon

Anonymous cowards cannot choose their icon

Other stories you might like