#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int uint64_t;

/* Variables and functions */
uint64_t __swap64(uint64_t x) {
  return (
      ((((((x & 0x00000000ffffffffULL & 0x0000ffffU & 0x00ffU) << 8) |
          (((x & 0x00000000ffffffffULL & 0x0000ffffU & 0xff00U) >> 8)))
         << 16) |
        (((((x & 0x00000000ffffffffULL & 0xffff0000U) >> 16 & 0x00ffU) << 8) |
          ((((x & 0x00000000ffffffffULL & 0xffff0000U) >> 16 & 0xff00U) >>
            8)))))
       << 32) |
      (((((((x & 0xffffffff00000000ULL) >> 32 & 0x0000ffffU & 0x00ffU) << 8) |
          ((((x & 0xffffffff00000000ULL) >> 32 & 0x0000ffffU & 0xff00U) >> 8)))
         << 16) |
        ((((((x & 0xffffffff00000000ULL) >> 32 & 0xffff0000U) >> 16 & 0x00ffU)
           << 8) |
          (((((x & 0xffffffff00000000ULL) >> 32 & 0xffff0000U) >> 16 &
             0xff00U) >>
            8)))))));
}


x86 assembly (clang, -O0):
<__swap64>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
movslq -0x4(%rbp),%rax
movabs $0xffffffff,%rcx
and    %rcx,%rax
and    $0xffff,%rax
and    $0xff,%rax
shl    $0x8,%rax
movslq -0x4(%rbp),%rcx
movabs $0xffffffff,%rdx
and    %rdx,%rcx
and    $0xffff,%rcx
and    $0xff00,%rcx
shr    $0x8,%rcx
or     %rcx,%rax
shl    $0x10,%rax
movslq -0x4(%rbp),%rcx
movabs $0xffffffff,%rdx
and    %rdx,%rcx
movabs $0xffff0000,%rdx
and    %rdx,%rcx
shr    $0x10,%rcx
and    $0xff,%rcx
shl    $0x8,%rcx
movslq -0x4(%rbp),%rdx
movabs $0xffffffff,%rsi
and    %rsi,%rdx
movabs $0xffff0000,%rsi
and    %rsi,%rdx
shr    $0x10,%rdx
and    $0xff00,%rdx
shr    $0x8,%rdx
or     %rdx,%rcx
or     %rcx,%rax
shl    $0x20,%rax
movslq -0x4(%rbp),%rcx
movabs $0xffffffff00000000,%rdx
ff ff ff
and    %rdx,%rcx
shr    $0x20,%rcx
and    $0xffff,%rcx
and    $0xff,%rcx
shl    $0x8,%rcx
movslq -0x4(%rbp),%rdx
movabs $0xffffffff00000000,%rsi
ff ff ff
and    %rsi,%rdx
shr    $0x20,%rdx
and    $0xffff,%rdx
and    $0xff00,%rdx
shr    $0x8,%rdx
or     %rdx,%rcx
shl    $0x10,%rcx
movslq -0x4(%rbp),%rdx
movabs $0xffffffff00000000,%rsi
ff ff ff
and    %rsi,%rdx
shr    $0x20,%rdx
movabs $0xffff0000,%rsi
and    %rsi,%rdx
shr    $0x10,%rdx
and    $0xff,%rdx
shl    $0x8,%rdx
movslq -0x4(%rbp),%rsi
movabs $0xffffffff00000000,%rdi
ff ff ff
and    %rdi,%rsi
shr    $0x20,%rsi
movabs $0xffff0000,%rdi
and    %rdi,%rsi
shr    $0x10,%rsi
and    $0xff00,%rsi
shr    $0x8,%rsi
or     %rsi,%rdx
or     %rdx,%rcx
or     %rcx,%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<__swap64>:
movslq %edi,%rax
mov    %rax,%rcx
shr    $0x18,%rcx
and    $0xff00,%ecx
mov    %rax,%rdx
shr    $0x28,%rdx
movzbl %dl,%esi
or     %ecx,%esi
shl    $0x10,%esi
and    $0xff00,%edx
shr    $0x38,%rax
or     %edx,%eax
or     %esi,%eax
ret

LLVM IR (-O0):
define i32 @__swap64(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = sext i32 %3 to i64
%5 = and i64 %4, 4294967295
%6 = and i64 %5, 65535
%7 = and i64 %6, 255
%8 = shl i64 %7, 8
%9 = load i32, i32* %2
%10 = sext i32 %9 to i64
%11 = and i64 %10, 4294967295
%12 = and i64 %11, 65535
%13 = and i64 %12, 65280
%14 = lshr i64 %13, 8
%15 = or i64 %8, %14
%16 = shl i64 %15, 16
%17 = load i32, i32* %2
%18 = sext i32 %17 to i64
%19 = and i64 %18, 4294967295
%20 = and i64 %19, 4294901760
%21 = lshr i64 %20, 16
%22 = and i64 %21, 255
%23 = shl i64 %22, 8
%24 = load i32, i32* %2
%25 = sext i32 %24 to i64
%26 = and i64 %25, 4294967295
%27 = and i64 %26, 4294901760
%28 = lshr i64 %27, 16
%29 = and i64 %28, 65280
%30 = lshr i64 %29, 8
%31 = or i64 %23, %30
%32 = or i64 %16, %31
%33 = shl i64 %32, 32
%34 = load i32, i32* %2
%35 = sext i32 %34 to i64
%36 = and i64 %35, -4294967296
%37 = lshr i64 %36, 32
%38 = and i64 %37, 65535
%39 = and i64 %38, 255
%40 = shl i64 %39, 8
%41 = load i32, i32* %2
%42 = sext i32 %41 to i64
%43 = and i64 %42, -4294967296
%44 = lshr i64 %43, 32
%45 = and i64 %44, 65535
%46 = and i64 %45, 65280
%47 = lshr i64 %46, 8
%48 = or i64 %40, %47
%49 = shl i64 %48, 16
%50 = load i32, i32* %2
%51 = sext i32 %50 to i64
%52 = and i64 %51, -4294967296
%53 = lshr i64 %52, 32
%54 = and i64 %53, 4294901760
%55 = lshr i64 %54, 16
%56 = and i64 %55, 255
%57 = shl i64 %56, 8
%58 = load i32, i32* %2
%59 = sext i32 %58 to i64
%60 = and i64 %59, -4294967296
%61 = lshr i64 %60, 32
%62 = and i64 %61, 4294901760
%63 = lshr i64 %62, 16
%64 = and i64 %63, 65280
%65 = lshr i64 %64, 8
%66 = or i64 %57, %65
%67 = or i64 %49, %66
%68 = or i64 %33, %67
%69 = trunc i64 %68 to i32
ret i32 %69
}

LLVM IR (-O2):
define i32 @__swap64(i32 %0) {
%2 = sext i32 %0 to i64
%3 = lshr i64 %2, 24
%4 = and i64 %3, 65280
%5 = lshr i64 %2, 40
%6 = and i64 %5, 255
%7 = or i64 %4, %6
%8 = shl nuw nsw i64 %7, 16
%9 = and i64 %5, 65280
%10 = lshr i64 %2, 56
%11 = or i64 %10, %9
%12 = or i64 %8, %11
%13 = trunc i64 %12 to i32
ret i32 %13
}