#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 uint32_t;

/* Variables and functions */
uint32_t bit_reverse32(uint32_t x) {
  x = (x >> 16) | (x << 16);
  x = ((x & 0xFF00FF00) >> 8) | ((x & 0x00FF00FF) << 8);
  x = ((x & 0xF0F0F0F0) >> 4) | ((x & 0x0F0F0F0F) << 4);
  x = ((x & 0xCCCCCCCC) >> 2) | ((x & 0x33333333) << 2);
  return ((x & 0xAAAAAAAA) >> 1) | ((x & 0x55555555) << 1);
}


x86 assembly (clang, -O0):
<bit_reverse32>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
sar    $0x10,%eax
mov    -0x4(%rbp),%ecx
shl    $0x10,%ecx
or     %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
and    $0xff00ff00,%eax
shr    $0x8,%eax
mov    -0x4(%rbp),%ecx
and    $0xff00ff,%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
and    $0xf0f0f0f0,%eax
shr    $0x4,%eax
mov    -0x4(%rbp),%ecx
and    $0xf0f0f0f,%ecx
shl    $0x4,%ecx
or     %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
and    $0xcccccccc,%eax
shr    $0x2,%eax
mov    -0x4(%rbp),%ecx
and    $0x33333333,%ecx
shl    $0x2,%ecx
or     %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
and    $0xaaaaaaaa,%eax
shr    $0x1,%eax
mov    -0x4(%rbp),%ecx
and    $0x55555555,%ecx
shl    $0x1,%ecx
or     %ecx,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<bit_reverse32>:
mov    %edi,%eax
sar    $0x10,%eax
shl    $0x10,%edi
or     %eax,%edi
bswap  %edi
ror    $0x10,%edi
mov    %edi,%eax
shr    $0x4,%eax
and    $0xf0f0f0f,%eax
shl    $0x4,%edi
and    $0xf0f0f0f0,%edi
or     %eax,%edi
mov    %edi,%eax
shr    $0x2,%eax
and    $0x33333333,%eax
and    $0xf3333333,%edi
lea    (%rax,%rdi,4),%eax
mov    %eax,%ecx
shr    %ecx
and    $0x55555555,%ecx
and    $0xd5555555,%eax
lea    (%rcx,%rax,2),%eax
ret

LLVM IR (-O0):
define i32 @bit_reverse32(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = ashr i32 %3, 16
%5 = load i32, i32* %2
%6 = shl i32 %5, 16
%7 = or i32 %4, %6
store i32 %7, i32* %2
%8 = load i32, i32* %2
%9 = and i32 %8, -16711936
%10 = lshr i32 %9, 8
%11 = load i32, i32* %2
%12 = and i32 %11, 16711935
%13 = shl i32 %12, 8
%14 = or i32 %10, %13
store i32 %14, i32* %2
%15 = load i32, i32* %2
%16 = and i32 %15, -252645136
%17 = lshr i32 %16, 4
%18 = load i32, i32* %2
%19 = and i32 %18, 252645135
%20 = shl i32 %19, 4
%21 = or i32 %17, %20
store i32 %21, i32* %2
%22 = load i32, i32* %2
%23 = and i32 %22, -858993460
%24 = lshr i32 %23, 2
%25 = load i32, i32* %2
%26 = and i32 %25, 858993459
%27 = shl i32 %26, 2
%28 = or i32 %24, %27
store i32 %28, i32* %2
%29 = load i32, i32* %2
%30 = and i32 %29, -1431655766
%31 = lshr i32 %30, 1
%32 = load i32, i32* %2
%33 = and i32 %32, 1431655765
%34 = shl i32 %33, 1
%35 = or i32 %31, %34
ret i32 %35
}

LLVM IR (-O2):
define i32 @bit_reverse32(i32 %0) {
%2 = ashr i32 %0, 16
%3 = shl i32 %0, 16
%4 = or i32 %2, %3
%5 = lshr i32 %4, 8
%6 = and i32 %5, 16711935
%7 = shl i32 %4, 8
%8 = and i32 %7, -16711936
%9 = or i32 %6, %8
%10 = lshr i32 %9, 4
%11 = and i32 %10, 252645135
%12 = shl i32 %9, 4
%13 = and i32 %12, -252645136
%14 = or i32 %11, %13
%15 = lshr i32 %14, 2
%16 = and i32 %15, 858993459
%17 = shl i32 %14, 2
%18 = and i32 %17, -858993460
%19 = or i32 %16, %18
%20 = lshr i32 %19, 1
%21 = and i32 %20, 1431655765
%22 = shl i32 %19, 1
%23 = and i32 %22, -1431655766
%24 = or i32 %21, %23
ret i32 %24
}