double byteswap(double x) {
  char buf[sizeof(double)];
  char t;
  memcpy(buf, &x, sizeof(double));
  if (sizeof(double) > 2 * (0) + 1)
    t = buf[0], buf[0] = buf[sizeof(double) - 1 - (0)],
    buf[sizeof(double) - 1 - (0)] = t;
  if (sizeof(double) > 2 * ((0) + 1) + 1)
    t = buf[(0) + 1], buf[(0) + 1] = buf[sizeof(double) - 1 - ((0) + 1)],
    buf[sizeof(double) - 1 - ((0) + 1)] = t;
  if (sizeof(double) > 2 * ((0) + 2) + 1)
    t = buf[(0) + 2], buf[(0) + 2] = buf[sizeof(double) - 1 - ((0) + 2)],
    buf[sizeof(double) - 1 - ((0) + 2)] = t;
  if (sizeof(double) > 2 * (((0) + 2) + 1) + 1)
    t = buf[((0) + 2) + 1],
    buf[((0) + 2) + 1] = buf[sizeof(double) - 1 - (((0) + 2) + 1)],
    buf[sizeof(double) - 1 - (((0) + 2) + 1)] = t;
  if (sizeof(double) > 2 * ((0) + 4) + 1)
    t = buf[(0) + 4], buf[(0) + 4] = buf[sizeof(double) - 1 - ((0) + 4)],
    buf[sizeof(double) - 1 - ((0) + 4)] = t;
  if (sizeof(double) > 2 * (((0) + 4) + 1) + 1)
    t = buf[((0) + 4) + 1],
    buf[((0) + 4) + 1] = buf[sizeof(double) - 1 - (((0) + 4) + 1)],
    buf[sizeof(double) - 1 - (((0) + 4) + 1)] = t;
  if (sizeof(double) > 2 * (((0) + 4) + 2) + 1)
    t = buf[((0) + 4) + 2],
    buf[((0) + 4) + 2] = buf[sizeof(double) - 1 - (((0) + 4) + 2)],
    buf[sizeof(double) - 1 - (((0) + 4) + 2)] = t;
  if (sizeof(double) > 2 * ((((0) + 4) + 2) + 1) + 1)
    t = buf[(((0) + 4) + 2) + 1],
    buf[(((0) + 4) + 2) + 1] = buf[sizeof(double) - 1 - ((((0) + 4) + 2) + 1)],
    buf[sizeof(double) - 1 - ((((0) + 4) + 2) + 1)] = t;
  if (sizeof(double) > 2 * ((0) + 8) + 1)
    t = buf[(0) + 8], buf[(0) + 8] = buf[sizeof(double) - 1 - ((0) + 8)],
    buf[sizeof(double) - 1 - ((0) + 8)] = t;
  if (sizeof(double) > 2 * (((0) + 8) + 1) + 1)
    t = buf[((0) + 8) + 1],
    buf[((0) + 8) + 1] = buf[sizeof(double) - 1 - (((0) + 8) + 1)],
    buf[sizeof(double) - 1 - (((0) + 8) + 1)] = t;
  if (sizeof(double) > 2 * (((0) + 8) + 2) + 1)
    t = buf[((0) + 8) + 2],
    buf[((0) + 8) + 2] = buf[sizeof(double) - 1 - (((0) + 8) + 2)],
    buf[sizeof(double) - 1 - (((0) + 8) + 2)] = t;
  if (sizeof(double) > 2 * ((((0) + 8) + 2) + 1) + 1)
    t = buf[(((0) + 8) + 2) + 1],
    buf[(((0) + 8) + 2) + 1] = buf[sizeof(double) - 1 - ((((0) + 8) + 2) + 1)],
    buf[sizeof(double) - 1 - ((((0) + 8) + 2) + 1)] = t;
  if (sizeof(double) > 2 * (((0) + 8) + 4) + 1)
    t = buf[((0) + 8) + 4],
    buf[((0) + 8) + 4] = buf[sizeof(double) - 1 - (((0) + 8) + 4)],
    buf[sizeof(double) - 1 - (((0) + 8) + 4)] = t;
  if (sizeof(double) > 2 * ((((0) + 8) + 4) + 1) + 1)
    t = buf[(((0) + 8) + 4) + 1],
    buf[(((0) + 8) + 4) + 1] = buf[sizeof(double) - 1 - ((((0) + 8) + 4) + 1)],
    buf[sizeof(double) - 1 - ((((0) + 8) + 4) + 1)] = t;
  if (sizeof(double) > 2 * ((((0) + 8) + 4) + 2) + 1)
    t = buf[(((0) + 8) + 4) + 2],
    buf[(((0) + 8) + 4) + 2] = buf[sizeof(double) - 1 - ((((0) + 8) + 4) + 2)],
    buf[sizeof(double) - 1 - ((((0) + 8) + 4) + 2)] = t;
  if (sizeof(double) > 2 * (((((0) + 8) + 4) + 2) + 1) + 1)
    t = buf[((((0) + 8) + 4) + 2) + 1],
    buf[((((0) + 8) + 4) + 2) + 1] =
        buf[sizeof(double) - 1 - (((((0) + 8) + 4) + 2) + 1)],
    buf[sizeof(double) - 1 - (((((0) + 8) + 4) + 2) + 1)] = t;
  memcpy(&x, buf, sizeof(double));
  return x;
}


x86 assembly (clang, -O0):
<byteswap>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%al
mov    %al,-0x11(%rbp)
mov    -0x9(%rbp),%al
mov    %al,-0x10(%rbp)
mov    -0x11(%rbp),%al
mov    %al,-0x9(%rbp)
mov    -0xf(%rbp),%al
mov    %al,-0x11(%rbp)
mov    -0xa(%rbp),%al
mov    %al,-0xf(%rbp)
mov    -0x11(%rbp),%al
mov    %al,-0xa(%rbp)
mov    -0xe(%rbp),%al
mov    %al,-0x11(%rbp)
mov    -0xb(%rbp),%al
mov    %al,-0xe(%rbp)
mov    -0x11(%rbp),%al
mov    %al,-0xb(%rbp)
mov    -0xd(%rbp),%al
mov    %al,-0x11(%rbp)
mov    -0xc(%rbp),%al
mov    %al,-0xd(%rbp)
mov    -0x11(%rbp),%al
mov    %al,-0xc(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<byteswap>:
movq   %xmm0,%rax
bswap  %rax
movq   %rax,%xmm0
ret

LLVM IR (-O0):
define double @byteswap(double %0) {
%2 = alloca double
%3 = alloca [8 x i8]
%4 = alloca i8
store double %0, double* %2
%5 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%6 = bitcast double* %2 to i8*
%7 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%8 = load i8, i8* %7
store i8 %8, i8* %4
%9 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 7
%10 = load i8, i8* %9
%11 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
store i8 %10, i8* %11
%12 = load i8, i8* %4
%13 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 7
store i8 %12, i8* %13
%14 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 1
%15 = load i8, i8* %14
store i8 %15, i8* %4
%16 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 6
%17 = load i8, i8* %16
%18 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 1
store i8 %17, i8* %18
%19 = load i8, i8* %4
%20 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 6
store i8 %19, i8* %20
%21 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 2
%22 = load i8, i8* %21
store i8 %22, i8* %4
%23 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 5
%24 = load i8, i8* %23
%25 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 2
store i8 %24, i8* %25
%26 = load i8, i8* %4
%27 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 5
store i8 %26, i8* %27
%28 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 3
%29 = load i8, i8* %28
store i8 %29, i8* %4
%30 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 4
%31 = load i8, i8* %30
%32 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 3
store i8 %31, i8* %32
%33 = load i8, i8* %4
%34 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 4
store i8 %33, i8* %34
%35 = bitcast double* %2 to i8*
%36 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%37 = load double, double* %2
ret double %37
}

LLVM IR (-O2):
define double @byteswap(double %0) {
%2 = bitcast double %0 to i64
%3 = tail call i64 @llvm.bswap.i64(i64 %2)
%4 = bitcast i64 %3 to double
ret double %4
}