fix compilation with Clang/LLVM, and compilation on FreeBSD (and other BSDs, supposedly) and big-endian platforms

    (these got broken some time ago)
silence a compiler warning
fix some undefinedish behavior