Make it more possible to override cflags/cxxflags

Unfortunately the user has to tell cmake the custom flag
'-DCFLAGS=...', because I did not find a way to get
CMAKE_C(XX)_FLAGS in the desired order without breaking
something else.  Now `./dev-build -DCFLAGS='-O0 -ggdb'`,
for example, works to change the opt/debug levels.
add -DCFLAGS to link flags as well because e.g. -fsanitize=undefined needs it

(If anyone needs to control compile and link flags separately,
do say so and it can be made so.)
remove some undefined behavior (fixes #61)

Left-shifting (by a positive amount) signed negative numbers
is undefined behavior.  Found via -fsanitize=undefined.
Now --run-self-tests and basic playing around don't emit any
-fsanitize=undefined errors.

If there's more undefined behavior, let's open new tickets for
it when we find it.