#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 big_to_little64(uint64_t big) {
  uint64_t little;
  little = (((big & 0xff00000000000000ULL) >> 48) |
            ((big & 0x00ff000000000000ULL) >> 32) |
            ((big & 0x0000ff0000000000ULL) >> 16) |
            ((big & 0x000000ff00000000ULL) >> 8) |
            ((big & 0x00000000ff000000ULL) << 8) |
            ((big & 0x0000000000ff0000ULL) << 16) |
            ((big & 0x000000000000ff00ULL) << 32) |
            ((big & 0x00000000000000ffULL) << 48));
  return little;
}


x86 assembly (clang, -O0):
<big_to_little64>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
movslq -0x4(%rbp),%rax
movabs $0xff00000000000000,%rcx
and    %rcx,%rax
shr    $0x30,%rax
movslq -0x4(%rbp),%rcx
movabs $0xff000000000000,%rdx
and    %rdx,%rcx
shr    $0x20,%rcx
or     %rcx,%rax
movslq -0x4(%rbp),%rcx
movabs $0xff0000000000,%rdx
and    %rdx,%rcx
shr    $0x10,%rcx
or     %rcx,%rax
movslq -0x4(%rbp),%rcx
movabs $0xff00000000,%rdx
and    %rdx,%rcx
shr    $0x8,%rcx
or     %rcx,%rax
movslq -0x4(%rbp),%rcx
movabs $0xff000000,%rdx
and    %rdx,%rcx
shl    $0x8,%rcx
or     %rcx,%rax
movslq -0x4(%rbp),%rcx
and    $0xff0000,%rcx
shl    $0x10,%rcx
or     %rcx,%rax
movslq -0x4(%rbp),%rcx
and    $0xff00,%rcx
shl    $0x20,%rcx
or     %rcx,%rax
movslq -0x4(%rbp),%rcx
and    $0xff,%rcx
shl    $0x30,%rcx
or     %rcx,%rax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<big_to_little64>:
movslq %edi,%rax
mov    %rax,%rcx
shr    $0x30,%rcx
and    $0xff00,%ecx
mov    %rax,%rdx
shr    $0x20,%rdx
and    $0xff0000,%edx
or     %ecx,%edx
mov    %rax,%rcx
shr    $0x10,%rcx
and    $0xff000000,%ecx
or     %edx,%ecx
shr    $0x8,%rax
and    $0xff000000,%eax
or     %ecx,%eax
ret

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

LLVM IR (-O2):
define i32 @big_to_little64(i32 %0) {
%2 = sext i32 %0 to i64
%3 = lshr i64 %2, 48
%4 = and i64 %3, 65280
%5 = lshr i64 %2, 32
%6 = and i64 %5, 16711680
%7 = or i64 %4, %6
%8 = lshr i64 %2, 16
%9 = and i64 %8, 4278190080
%10 = or i64 %7, %9
%11 = lshr i64 %2, 8
%12 = and i64 %11, 4278190080
%13 = or i64 %10, %12
%14 = trunc i64 %13 to i32
ret i32 %14
}