Fix out-of-bound array access.
Use early return.
Use # as register prefix.

Format string for emit() contained too many % characters
because in order to print out %rax, for example, you had to
write it as "%%rax". If variable r has a register name,
you had to write as emit("%%%s", r). This is hard to read.

This patch allows you to write # to emit character %.