#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 endianSwapU64(uint64_t u) {
  uint64_t tmp = 0;
  tmp |= ((u >> 56) & (0xffull << 0));
  tmp |= ((u >> 40) & (0xffull << 8));
  tmp |= ((u >> 24) & (0xffull << 16));
  tmp |= ((u >> 8) & (0xffull << 24));
  tmp |= ((u << 8) & (0xffull << 32));
  tmp |= ((u << 24) & (0xffull << 40));
  tmp |= ((u << 40) & (0xffull << 48));
  tmp |= ((u << 56) & (0xffull << 56));
  return tmp;
}


x86 assembly (clang, -O0):
<endianSwapU64>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x38,%ecx
sar    %cl,%eax
movslq %eax,%rcx
and    $0xff,%rcx
movslq -0x8(%rbp),%rax
or     %rcx,%rax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x28,%ecx
sar    %cl,%eax
movslq %eax,%rcx
and    $0xff00,%rcx
movslq -0x8(%rbp),%rax
or     %rcx,%rax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
sar    $0x18,%eax
movslq %eax,%rcx
and    $0xff0000,%rcx
movslq -0x8(%rbp),%rax
or     %rcx,%rax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
sar    $0x8,%eax
movslq %eax,%rcx
movabs $0xff000000,%rax
and    %rax,%rcx
movslq -0x8(%rbp),%rax
or     %rcx,%rax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
shl    $0x8,%eax
movslq %eax,%rcx
movabs $0xff00000000,%rax
and    %rax,%rcx
movslq -0x8(%rbp),%rax
or     %rcx,%rax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
shl    $0x18,%eax
movslq %eax,%rcx
movabs $0xff0000000000,%rax
and    %rax,%rcx
movslq -0x8(%rbp),%rax
or     %rcx,%rax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x28,%ecx
shl    %cl,%eax
movslq %eax,%rcx
movabs $0xff000000000000,%rax
and    %rax,%rcx
movslq -0x8(%rbp),%rax
or     %rcx,%rax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x38,%ecx
shl    %cl,%eax
movslq %eax,%rcx
movabs $0xff00000000000000,%rax
and    %rax,%rcx
movslq -0x8(%rbp),%rax
or     %rcx,%rax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<endianSwapU64>:
ret

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

LLVM IR (-O2):
define i32 @endianSwapU64(i32 %0) {
ret i32 poison
}