Why can't I use a variable in an if statement?
@NickAlexeev seem to have hit upon the problem- this compiler is non-compliant. See this.

If you get rid of the global declarations (outside of main), I bet it works.

I've seen compiler problems with global variables in Hitech C for the baseline PICs as well.