#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 */
int UINT64_C(int);
uint64_t swap64(uint64_t x) {
  return ((x & UINT64_C(0x00000000000000ff)) << 56) |
         ((x & UINT64_C(0x000000000000ff00)) << 40) |
         ((x & UINT64_C(0x0000000000ff0000)) << 24) |
         ((x & UINT64_C(0x00000000ff000000)) << 8) |
         ((x & UINT64_C(0x000000ff00000000)) >> 8) |
         ((x & UINT64_C(0x0000ff0000000000)) >> 24) |
         ((x & UINT64_C(0x00ff000000000000)) >> 40) |
         ((x & UINT64_C(0xff00000000000000)) >> 56);
}


x86 assembly (clang, -O0):
<swap64>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    $0xff,%edi
call   1030 <UINT64_C@plt>
mov    %eax,%ecx
mov    -0x40(%rbp),%eax
and    %ecx,%eax
mov    $0x38,%ecx
shl    %cl,%eax
mov    %eax,-0x38(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    $0xff00,%edi
call   1030 <UINT64_C@plt>
mov    -0x3c(%rbp),%edx
mov    %eax,%ecx
mov    -0x38(%rbp),%eax
and    %ecx,%edx
mov    $0x28,%ecx
shl    %cl,%edx
mov    %edx,%ecx
or     %ecx,%eax
mov    %eax,-0x30(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    $0xff0000,%edi
call   1030 <UINT64_C@plt>
mov    -0x34(%rbp),%ecx
mov    %eax,%edx
mov    -0x30(%rbp),%eax
and    %edx,%ecx
shl    $0x18,%ecx
or     %ecx,%eax
mov    %eax,-0x28(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    $0xff000000,%edi
call   1030 <UINT64_C@plt>
mov    -0x2c(%rbp),%ecx
mov    %eax,%edx
mov    -0x28(%rbp),%eax
and    %edx,%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    %eax,-0x20(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x24(%rbp)
xor    %edi,%edi
call   1030 <UINT64_C@plt>
mov    -0x24(%rbp),%ecx
mov    %eax,%edx
mov    -0x20(%rbp),%eax
and    %edx,%ecx
sar    $0x8,%ecx
or     %ecx,%eax
mov    %eax,-0x18(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x1c(%rbp)
xor    %edi,%edi
call   1030 <UINT64_C@plt>
mov    -0x1c(%rbp),%ecx
mov    %eax,%edx
mov    -0x18(%rbp),%eax
and    %edx,%ecx
sar    $0x18,%ecx
or     %ecx,%eax
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
xor    %edi,%edi
call   1030 <UINT64_C@plt>
mov    -0x14(%rbp),%edx
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
and    %ecx,%edx
mov    $0x28,%ecx
sar    %cl,%edx
mov    %edx,%ecx
or     %ecx,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
xor    %edi,%edi
call   1030 <UINT64_C@plt>
mov    -0xc(%rbp),%edx
mov    %eax,%ecx
mov    -0x8(%rbp),%eax
and    %ecx,%edx
mov    $0x38,%ecx
sar    %cl,%edx
mov    %edx,%ecx
or     %ecx,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<swap64>:
push   %rax
mov    $0xff,%edi
call   1030 <UINT64_C@plt>
mov    $0xff00,%edi
call   1030 <UINT64_C@plt>
mov    $0xff0000,%edi
call   1030 <UINT64_C@plt>
mov    $0xff000000,%edi
call   1030 <UINT64_C@plt>
xor    %edi,%edi
call   1030 <UINT64_C@plt>
xor    %edi,%edi
call   1030 <UINT64_C@plt>
xor    %edi,%edi
call   1030 <UINT64_C@plt>
xor    %edi,%edi
pop    %rax
jmp    1030 <UINT64_C@plt>

LLVM IR (-O0):
define i32 @swap64(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = call i32 @UINT64_C(i32 255)
%5 = and i32 %3, %4
%6 = shl i32 %5, 56
%7 = load i32, i32* %2
%8 = call i32 @UINT64_C(i32 65280)
%9 = and i32 %7, %8
%10 = shl i32 %9, 40
%11 = or i32 %6, %10
%12 = load i32, i32* %2
%13 = call i32 @UINT64_C(i32 16711680)
%14 = and i32 %12, %13
%15 = shl i32 %14, 24
%16 = or i32 %11, %15
%17 = load i32, i32* %2
%18 = call i32 @UINT64_C(i32 -16777216)
%19 = and i32 %17, %18
%20 = shl i32 %19, 8
%21 = or i32 %16, %20
%22 = load i32, i32* %2
%23 = call i32 @UINT64_C(i32 0)
%24 = and i32 %22, %23
%25 = ashr i32 %24, 8
%26 = or i32 %21, %25
%27 = load i32, i32* %2
%28 = call i32 @UINT64_C(i32 0)
%29 = and i32 %27, %28
%30 = ashr i32 %29, 24
%31 = or i32 %26, %30
%32 = load i32, i32* %2
%33 = call i32 @UINT64_C(i32 0)
%34 = and i32 %32, %33
%35 = ashr i32 %34, 40
%36 = or i32 %31, %35
%37 = load i32, i32* %2
%38 = call i32 @UINT64_C(i32 0)
%39 = and i32 %37, %38
%40 = ashr i32 %39, 56
%41 = or i32 %36, %40
ret i32 %41
}

LLVM IR (-O2):
define i32 @swap64(i32 %0) {
%2 = tail call i32 @UINT64_C(i32 255)
%3 = tail call i32 @UINT64_C(i32 65280)
%4 = tail call i32 @UINT64_C(i32 16711680)
%5 = tail call i32 @UINT64_C(i32 -16777216)
%6 = tail call i32 @UINT64_C(i32 0)
%7 = tail call i32 @UINT64_C(i32 0)
%8 = tail call i32 @UINT64_C(i32 0)
%9 = tail call i32 @UINT64_C(i32 0)
ret i32 poison
}