Declare function at the beginning of the file.
Refactoring: define functions in logical calling order.
Remove useless debug printing.
Refactor: push hl line handling into a separated function.
Move up g++ cmd line at the beginning of the file.
Remove useless code.