#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 func32(uint32_t x) {
  uint32_t n = x;
  n = ((n & 0xffff0000) >> 16) | ((n & 0x0000ffff) << 16);
  n = ((n & 0xff00ff00) >> 8) | ((n & 0x00ff00ff) << 8);
  n = ((n & 0xf0f0f0f0) >> 4) | ((n & 0x0f0f0f0f) << 4);
  n = ((n & 0xcccccccc) >> 2) | ((n & 0x33333333) << 2);
  n = ((n & 0xaaaaaaaa) >> 1) | ((n & 0x55555555) << 1);
  return n;
}


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

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

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

LLVM IR (-O2):
define i32 @func32(i32 %0) {
%2 = tail call i32 @llvm.bitreverse.i32(i32 %0)
ret i32 %2
}