#include <stdint.h>

#define UINT16_T_SWAP_LE_BE_CONSTANT(val)	((uint16_t) ( \
    (uint16_t) ((uint16_t) (val) >> 8) |	\
    (uint16_t) ((uint16_t) (val) << 8)))

static inline uint16_t
my_bswap_16(uint16_t val)
{
  register uint16_t __v;
  if (__builtin_constant_p (val))
    __v = UINT16_T_SWAP_LE_BE_CONSTANT (val);
  else
    __asm__ ("rorw $8, %w0"
	     : "=r" (__v)
	     : "0" (val)
	     : "cc");
  
  return __v;
}

uint16_t my_bswap_test(uint16_t val) {
  return my_bswap_16(val);
}

uint16_t my_bswap_test_constant() {
  return my_bswap_16(123);
}
