#include <stdio.h>
#include <stdint.h>
typedef uint64_t u64;
typedef uint32_t u32;
typedef uint16_t u16;
typedef uint8_t u8;
typedef int64_t s64;
typedef int32_t s32;
typedef int16_t s16;
typedef char s8;
static u16
EndianSwap16(u16 var)
{
var = (var >> 8) + (var << 8);
return var;
}
static u32
EndianSwap32(u32 var)
{
var = (var >> 24) +
((var & 0x00ff0000) >> 8) +
((var & 0x0000ff00) << 8) +
(var << 24);
return var;
}
static u64
EndianSwap64(u64 var)
{
var = (var >> 56) +
((var & 0x00ff000000000000) >> 40) +
((var & 0x0000ff0000000000) >> 24) +
((var & 0x000000ff00000000) >> 8) +
((var & 0x00000000ff000000) << 8) +
((var & 0x0000000000ff0000) << 24) +
((var & 0x000000000000ff00) << 40) +
(var << 56);
return var;
}
int main()
{
s64 hhhd = EndianSwap64(0x8877665544332211);
s32 hhhf = EndianSwap32(0x44332211);
s16 hhhg = EndianSwap16(0x2211);
s8 hhhh = 0x11;
printf("%lx, %x, %x, %x\n", hhhd, hhhf, hhhg, hhhh);
return 0;
}