Daniel felipe Escobar chavez
4 min readMar 10, 2021

WHAT (IOCCC winner, 1986) DOES?

Hello, how are you, programmer friends, today I have prepared a blog to explain how the program works (IOCCC winner, 1986).

Before starting with the explanation I want to clarify some concepts such as morse code.
This is a code created based on symbols such as dots and dashes which was used to transmit secret messages at first only numbers and then letters as well. for more information: https://es.wikipedia.org/wiki/C%C3%B3digo_morse

Now with this clear we can explain the code which starts like this:

And when it comes to executing errors like these come out:

So anyone would think that the program could not work but all this is false since if we execute the program we can do this

So now I will begin to explain the program and the processes it goes through.
The main function of the program is to print a message in Morse code through macros called DIH and DAH in the function.
at the beginning what the function does is reserve enough memory in malloc for the elements to be entered.
then the program makes several comparisons for cases in which the program has just been printed and you have to print a line and things like that.
at the end this function examines the characters sent by the user and converts them to morse code.

now we are going to see an interesting topic which is obfuscation. obfuscation is about the concealment of a code making it more complicated to read and understand and this can be done for the security of the program, for protection or just for fun.
Examples like this can be seen in the code since it is somewhat messy and confusing due to the use of macros with similar names and also if you execute it it has some errors.

but we can see how to de-fuzz the code using the gcc -E command since this will show us the prerpocessor and since the macros are in this part we will be able to see the process in a clearer way

here I have done a deofuscation so that it is seen clearly where we can see that there are some DAH and DIH pointer there to confuse whoever reads the command

now explain the process that the program does to get to print in morse
First, what it does is create several pointers with similar names to start working. It also has an array with several characters to value and also there is a variable malloc and a gets, These are declared in a strange way but still manage to work as we can see in the compilation.

then a kind of loop begins to be created in which a lot of space is stored in the malloc and prints a new line at the end.

then we can see that there is another loop where it begins to check the sent characters and in case one of them is not in _DAH_ it prints a ‘?’ then those that are, the conversion will be applied since as we can see inside the array there are several characters, there are parts like _DAH <= ‘a’ and & 223 where we can see how this conversion gives a value to the characters based on Specific conditions.

then it checks if the character is 1, if so it prints a dash ‘-’.
otherwise it prints a period ‘.’

finally it prints the values that the user sent changed with the help of a write for the standard output.

so we have a simpler code with a more understandable and clear process!.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

No responses yet

Write a response