unsigned long long ___swab64(unsigned long long x) {
  unsigned long long __x = (x);
  return (
      unsigned long long)((unsigned long long)(((unsigned long long)(__x) &
                                                (unsigned long long)0x00000000000000ffULL)
                                               << 56) |
                          (unsigned long long)(((unsigned long long)(__x) &
                                                (unsigned long long)0x000000000000ff00ULL)
                                               << 40) |
                          (unsigned long long)(((unsigned long long)(__x) &
                                                (unsigned long long)0x0000000000ff0000ULL)
                                               << 24) |
                          (unsigned long long)(((unsigned long long)(__x) &
                                                (unsigned long long)0x00000000ff000000ULL)
                                               << 8) |
                          (unsigned long long)(((unsigned long long)(__x) &
                                                (unsigned long long)0x000000ff00000000ULL) >>
                                               8) |
                          (unsigned long long)(((unsigned long long)(__x) &
                                                (unsigned long long)0x0000ff0000000000ULL) >>
                                               24) |
                          (unsigned long long)(((unsigned long long)(__x) &
                                                (unsigned long long)0x00ff000000000000ULL) >>
                                               40) |
                          (unsigned long long)(((unsigned long long)(__x) &
                                                (unsigned long long)0xff00000000000000ULL) >>
                                               56));
}


x86 assembly (clang, -O0):
<___swab64>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
and    $0xff,%rax
shl    $0x38,%rax
mov    -0x10(%rbp),%rcx
and    $0xff00,%rcx
shl    $0x28,%rcx
or     %rcx,%rax
mov    -0x10(%rbp),%rcx
and    $0xff0000,%rcx
shl    $0x18,%rcx
or     %rcx,%rax
movabs $0xff000000,%rcx
and    -0x10(%rbp),%rcx
shl    $0x8,%rcx
or     %rcx,%rax
movabs $0xff00000000,%rcx
and    -0x10(%rbp),%rcx
shr    $0x8,%rcx
or     %rcx,%rax
movabs $0xff0000000000,%rcx
and    -0x10(%rbp),%rcx
shr    $0x18,%rcx
or     %rcx,%rax
movabs $0xff000000000000,%rcx
and    -0x10(%rbp),%rcx
shr    $0x28,%rcx
or     %rcx,%rax
movabs $0xff00000000000000,%rcx
and    -0x10(%rbp),%rcx
shr    $0x38,%rcx
or     %rcx,%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<___swab64>:
mov    %rdi,%rax
bswap  %rax
ret

LLVM IR (-O0):
define i64 @___swab64(i64 %0) {
%2 = alloca i64
%3 = alloca i64
store i64 %0, i64* %2
%4 = load i64, i64* %2
store i64 %4, i64* %3
%5 = load i64, i64* %3
%6 = and i64 %5, 255
%7 = shl i64 %6, 56
%8 = load i64, i64* %3
%9 = and i64 %8, 65280
%10 = shl i64 %9, 40
%11 = or i64 %7, %10
%12 = load i64, i64* %3
%13 = and i64 %12, 16711680
%14 = shl i64 %13, 24
%15 = or i64 %11, %14
%16 = load i64, i64* %3
%17 = and i64 %16, 4278190080
%18 = shl i64 %17, 8
%19 = or i64 %15, %18
%20 = load i64, i64* %3
%21 = and i64 %20, 1095216660480
%22 = lshr i64 %21, 8
%23 = or i64 %19, %22
%24 = load i64, i64* %3
%25 = and i64 %24, 280375465082880
%26 = lshr i64 %25, 24
%27 = or i64 %23, %26
%28 = load i64, i64* %3
%29 = and i64 %28, 71776119061217280
%30 = lshr i64 %29, 40
%31 = or i64 %27, %30
%32 = load i64, i64* %3
%33 = and i64 %32, -72057594037927936
%34 = lshr i64 %33, 56
%35 = or i64 %31, %34
ret i64 %35
}

LLVM IR (-O2):
define i64 @___swab64(i64 %0) {
%2 = tail call i64 @llvm.bswap.i64(i64 %0)
ret i64 %2
}