#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 */
void generic_cpu_swap64p(uint64_t *outp, uint64_t in) {
  *outp = ((in & 0xFF00000000000000ULL) >> 56) |
          ((in & 0x00FF000000000000ULL) >> 40) |
          ((in & 0x0000FF0000000000ULL) >> 24) |
          ((in & 0x000000FF00000000ULL) >> 8) |
          ((in & 0x00000000FF000000ULL) << 8) |
          ((in & 0x0000000000FF0000ULL) << 24) |
          ((in & 0x000000000000FF00ULL) << 40) |
          ((in & 0x00000000000000FFULL) << 56);
}


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

x86 assembly (clang, -O2):
<generic_cpu_swap64p>:
movslq %esi,%rax
bswap  %rax
mov    %eax,(%rdi)
ret

LLVM IR (-O0):
define void @generic_cpu_swap64p(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%5 = load i32, i32* %4
%6 = sext i32 %5 to i64
%7 = and i64 %6, -72057594037927936
%8 = lshr i64 %7, 56
%9 = load i32, i32* %4
%10 = sext i32 %9 to i64
%11 = and i64 %10, 71776119061217280
%12 = lshr i64 %11, 40
%13 = or i64 %8, %12
%14 = load i32, i32* %4
%15 = sext i32 %14 to i64
%16 = and i64 %15, 280375465082880
%17 = lshr i64 %16, 24
%18 = or i64 %13, %17
%19 = load i32, i32* %4
%20 = sext i32 %19 to i64
%21 = and i64 %20, 1095216660480
%22 = lshr i64 %21, 8
%23 = or i64 %18, %22
%24 = load i32, i32* %4
%25 = sext i32 %24 to i64
%26 = and i64 %25, 4278190080
%27 = shl i64 %26, 8
%28 = or i64 %23, %27
%29 = load i32, i32* %4
%30 = sext i32 %29 to i64
%31 = and i64 %30, 16711680
%32 = shl i64 %31, 24
%33 = or i64 %28, %32
%34 = load i32, i32* %4
%35 = sext i32 %34 to i64
%36 = and i64 %35, 65280
%37 = shl i64 %36, 40
%38 = or i64 %33, %37
%39 = load i32, i32* %4
%40 = sext i32 %39 to i64
%41 = and i64 %40, 255
%42 = shl i64 %41, 56
%43 = or i64 %38, %42
%44 = trunc i64 %43 to i32
%45 = load i32*, i32** %3
store i32 %44, i32* %45
ret void
}

LLVM IR (-O2):
define void @generic_cpu_swap64p(i32* nocapture writeonly %0, i32 %1) {
%3 = sext i32 %1 to i64
%4 = tail call i64 @llvm.bswap.i64(i64 %3)
%5 = trunc i64 %4 to i32
store i32 %5, i32* %0
ret void
}