#include #include #define NBITS (sizeof(uint64_t) * CHAR_BIT) #define MSBMASK (1ULL << (NBITS - 1)) typedef struct { uint64_t hi; uint64_t lo; } uint128_t; void bitr128(uint128_t *); void bitr128(uint128_t *n) { uint64_t hiword, loword, lsbit, msbit; hiword = n->hi; loword = n->lo; msbit = hiword & MSBMASK; hiword <<= 1; for (unsigned i = 0; i < NBITS; i++) { lsbit = loword & 1; loword >>= 1; loword |= msbit; msbit = hiword & MSBMASK; hiword <<= 1; hiword |= lsbit; } n->hi = hiword; n->lo = loword; }