double convert_double(double i) {
  double d;
  unsigned char *iptr = (unsigned char *)&i;
  unsigned char *optr = (unsigned char *)&d;
  *(optr + 7) = *iptr;
  *(optr + 6) = *(iptr + 1);
  *(optr + 5) = *(iptr + 2);
  *(optr + 4) = *(iptr + 3);
  *(optr + 3) = *(iptr + 4);
  *(optr + 2) = *(iptr + 5);
  *(optr + 1) = *(iptr + 6);
  *optr = *(iptr + 7);
  return d;
}


x86 assembly (clang, -O0):
<convert_double>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
lea    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
lea    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%cl
mov    -0x20(%rbp),%rax
mov    %cl,0x7(%rax)
mov    -0x18(%rbp),%rax
mov    0x1(%rax),%cl
mov    -0x20(%rbp),%rax
mov    %cl,0x6(%rax)
mov    -0x18(%rbp),%rax
mov    0x2(%rax),%cl
mov    -0x20(%rbp),%rax
mov    %cl,0x5(%rax)
mov    -0x18(%rbp),%rax
mov    0x3(%rax),%cl
mov    -0x20(%rbp),%rax
mov    %cl,0x4(%rax)
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%cl
mov    -0x20(%rbp),%rax
mov    %cl,0x3(%rax)
mov    -0x18(%rbp),%rax
mov    0x5(%rax),%cl
mov    -0x20(%rbp),%rax
mov    %cl,0x2(%rax)
mov    -0x18(%rbp),%rax
mov    0x6(%rax),%cl
mov    -0x20(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0x18(%rbp),%rax
mov    0x7(%rax),%cl
mov    -0x20(%rbp),%rax
mov    %cl,(%rax)
movsd  -0x10(%rbp),%xmm0
pop    %rbp
ret

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

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

LLVM IR (-O2):
define double @convert_double(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
}