

Obfuscated C Code Contest 2006. Please explain sykes2.c - gedrap
http://stackoverflow.com/questions/15393441/obfuscated-c-code-contest-2006-please-explain-sykes2-c

======
MikeTaylor
I was at university with Steve, the author of this program. A couple of years
ago, when I wrote "The hacker, the architect and the superhero: three
completely different ways to be an excellent programmer" [1] he was the one I
wrote about as The Hacker. So it seems more than appropriate that his work is
now on Hacker News.

[1] [http://reprog.wordpress.com/2010/03/21/the-hacker-the-
archit...](http://reprog.wordpress.com/2010/03/21/the-hacker-the-architect-
and-the-superhero-three-completely-different-ways-to-be-an-excellent-
programmer/)

------
maurits
It used to have an evil twin, the Underhanded C Contest [1] where the aim was
to make an innocent program also do something evil in such a way that that it
can be plausibly denied as accidental when the 'bug' is detected in a code
review.

[1] <http://underhanded.xcott.com/>

~~~
JoachimSchipper
"Used to have"? The underhanded C contest is back!

------
sdsykes
This is a really good explanation of my program, recommended.

~~~
aeon10
do you happen to have a blog about this stuff? I'd love to read it

~~~
sdsykes
I have an ancient blog on my ancient website, not much about ioccc though -
but you can at least find links to my previous entries here
<http://stephensykes.com>

------
chrisdotcode
What really irks me is that this question [1], asking word-for-word the same
question for a different year entry, that was posted two days later was closed
as "too localized" and has -10 points, while this one has +452.

Stackoverflow has serious problems.

[1] [http://stackoverflow.com/questions/15429479/obfuscated-c-
cod...](http://stackoverflow.com/questions/15429479/obfuscated-c-code-
contest-2012-please-explain-endoh2-c?rq=1)

~~~
cefstat
It happens more and more often that a Google search for some problem sends me
to a potentially useful Stsckoverflow question that has been closed for a
ridiculous reason. At least, sometimes there are already answers or comments
there that turn out being useful.

~~~
im3w1l
Taking a cue from reddit, it would be cool if someone started
casualstackoverflow, with less strict moderation. Bonus points if closed
questions can be imported.

------
unwind
That reminded me a lot of my old signature from my days on Slashdot:

    
    
        main(O){10<putchar(4^--?77-(15&5128>>4*O):10)&&main(2+O);}
    

I enjoyed the extra mini-confusement from using a capital O as a variable
name. :)

~~~
joshguthrie
I can't even compile it on my mac and my C is too rusty, would you be kind
enough to explain? =)

~~~
unwind
It's perfectly possible to run this on e.g. Ideone (<http://ideone.com>).

Essentially, it's a loop that unpacks my name and prints it, letter by letter,
from the constant 5128. Four bits is being used per letter, and I tried to
compress the number by subtracting an offset from the ASCII codes of each
letter (that's the 77).

It's been ~14 years or something since I first wrote this, and I'm pretty sure
I was inspired by an Obfuscated C contest entry then, too. :)

------
pointyhatuk
I used to avidly reverse engineer the IOCCC entries when announced. It was a
wonderful learning experience that teaches you quite a bit about C that you
don't get from a mainstream book. Time well spent.

~~~
Serow225
I enjoyed 'Expert C Programming: Deep C Secrets' for the same reason. Anyone
know if there are other more modern books along similar lines?

~~~
mtoddh
Neither are recent, but the following are both good:

"Obfuscated C and Other Mysteries" by Don Libes

"C Companion" by Allen Holub

Don Libes' book actually uses Obfuscated C code entries as interesting
instructional examples and Holub's book is a nice intermediate book between
K&R and "Expert C Programming".

I never see Holub mentioned much by other C programmers but I think his books
are awesome. He actually also has a really good compiler book called "Compiler
Design in C" that showed how to build a C compiler from the ground up - with a
lot of practical details I never really see in other books in that area. He
even had a cool curses implementation to go along with it where you could
watch the parsing occur visually, and wrote a curses-like library in assembly
so you could run it all on DOS too. He used to write the C Chest columns for
Dr Dobbs back in the day and the book "C Chest and Other C Treasures" contains
a collection of those articles and other code that C programmers would find
interesting. But that book is harder to find these days.

~~~
Serow225
Thanks! I was thinking it would be great to have a new revision of one of
these books that included material from C99 and newer.

