#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 bswap_64(int);
uint64_t revbit64(uint64_t u) {
  u = ((u >> 1) & 0x5555555555555555ULL) | ((u & 0x5555555555555555ULL) << 1);
  u = ((u >> 2) & 0x3333333333333333ULL) | ((u & 0x3333333333333333ULL) << 2);
  u = ((u >> 4) & 0x0F0F0F0F0F0F0F0FULL) | ((u & 0x0F0F0F0F0F0F0F0FULL) << 4);
  return bswap_64(u);
}


x86 assembly (clang, -O0):
<revbit64>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
sar    $0x1,%eax
cltq
movabs $0x5555555555555555,%rcx
55 55 55
and    %rcx,%rax
movslq -0x4(%rbp),%rcx
movabs $0x5555555555555555,%rdx
55 55 55
and    %rdx,%rcx
shl    $0x1,%rcx
or     %rcx,%rax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
sar    $0x2,%eax
cltq
movabs $0x3333333333333333,%rcx
33 33 33
and    %rcx,%rax
movslq -0x4(%rbp),%rcx
movabs $0x3333333333333333,%rdx
33 33 33
and    %rdx,%rcx
shl    $0x2,%rcx
or     %rcx,%rax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
sar    $0x4,%eax
cltq
movabs $0xf0f0f0f0f0f0f0f,%rcx
0f 0f 0f
and    %rcx,%rax
movslq -0x4(%rbp),%rcx
movabs $0xf0f0f0f0f0f0f0f,%rdx
0f 0f 0f
and    %rdx,%rcx
shl    $0x4,%rcx
or     %rcx,%rax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <bswap_64@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<revbit64>:
mov    %edi,%eax
shr    %eax
and    $0x55555555,%eax
and    $0xd5555555,%edi
lea    (%rax,%rdi,2),%eax
mov    %eax,%ecx
shr    $0x2,%ecx
and    $0x33333333,%ecx
and    $0xf3333333,%eax
lea    (%rcx,%rax,4),%edi
mov    %edi,%eax
shr    $0x4,%eax
and    $0xf0f0f0f,%eax
shl    $0x4,%edi
and    $0xf0f0f0f0,%edi
or     %eax,%edi
jmp    1030 <bswap_64@plt>

LLVM IR (-O0):
define i32 @revbit64(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = ashr i32 %3, 1
%5 = sext i32 %4 to i64
%6 = and i64 %5, 6148914691236517205
%7 = load i32, i32* %2
%8 = sext i32 %7 to i64
%9 = and i64 %8, 6148914691236517205
%10 = shl i64 %9, 1
%11 = or i64 %6, %10
%12 = trunc i64 %11 to i32
store i32 %12, i32* %2
%13 = load i32, i32* %2
%14 = ashr i32 %13, 2
%15 = sext i32 %14 to i64
%16 = and i64 %15, 3689348814741910323
%17 = load i32, i32* %2
%18 = sext i32 %17 to i64
%19 = and i64 %18, 3689348814741910323
%20 = shl i64 %19, 2
%21 = or i64 %16, %20
%22 = trunc i64 %21 to i32
store i32 %22, i32* %2
%23 = load i32, i32* %2
%24 = ashr i32 %23, 4
%25 = sext i32 %24 to i64
%26 = and i64 %25, 1085102592571150095
%27 = load i32, i32* %2
%28 = sext i32 %27 to i64
%29 = and i64 %28, 1085102592571150095
%30 = shl i64 %29, 4
%31 = or i64 %26, %30
%32 = trunc i64 %31 to i32
store i32 %32, i32* %2
%33 = load i32, i32* %2
%34 = call i32 @bswap_64(i32 %33)
ret i32 %34
}

LLVM IR (-O2):
define i32 @revbit64(i32 %0) {
%2 = lshr i32 %0, 1
%3 = and i32 %2, 1431655765
%4 = shl i32 %0, 1
%5 = and i32 %4, -1431655766
%6 = or i32 %3, %5
%7 = lshr i32 %6, 2
%8 = and i32 %7, 858993459
%9 = shl i32 %6, 2
%10 = and i32 %9, -858993460
%11 = or i32 %8, %10
%12 = lshr i32 %11, 4
%13 = and i32 %12, 252645135
%14 = shl i32 %11, 4
%15 = and i32 %14, -252645136
%16 = or i32 %13, %15
%17 = tail call i32 @bswap_64(i32 %16)
ret i32 %17
}