Reverse morse code

Believe it or not, the following code is completely viable in C. This code can be compiled, via gcc, and can then be executed.

Example of execution
Output of gcc -E of the original program

The transformed code

After all these transformations and after having reformatted a little bit (removing / adding space), the original code is now equivalent to the transformed code below :

Transformed code
  • I A N M are the level-2 nodes, I is “..”, A is “.-”, N is “-.”, M is “ — ”
  • etc…
  • second loop : goes through each letter of w1 and calls the function named function1, which takes the ASCII code of the letter and, via alphabet, translates it into “.” or “-”
  • last loop : converts all lower case letter into uppercase, to be then translated using the alphabet table