#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 */
int gt_requiredUInt32Bits(uint32_t v) {
  int r;
  static const int MultiplyDeBruijnBitPosition[32] = {
      1,  2,  29, 3,  30, 15, 25, 4, 31, 23, 21, 16, 26, 18, 5,  9,
      32, 28, 14, 24, 22, 20, 17, 8, 27, 13, 19, 7,  12, 6,  11, 10};
  v |= v >> 1;
  v |= v >> 2;
  v |= v >> 4;
  v |= v >> 8;
  v |= v >> 16;
  v = (v >> 1) + 1;
  r = MultiplyDeBruijnBitPosition[(v * (uint32_t)0x077CB531UL) >> 27];
  return r;
}


x86 assembly (clang, -O0):
<gt_requiredUInt32Bits>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
sar    $0x1,%eax
or     -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
sar    $0x2,%eax
or     -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
sar    $0x4,%eax
or     -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
sar    $0x8,%eax
or     -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
sar    $0x10,%eax
or     -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
sar    $0x1,%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
imul   $0x77cb531,-0x4(%rbp),%eax
sar    $0x1b,%eax
movslq %eax,%rcx
lea    0xe9d(%rip),%rax
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<gt_requiredUInt32Bits>:
mov    %edi,%eax
sar    %eax
or     %edi,%eax
mov    %eax,%ecx
sar    $0x2,%ecx
or     %eax,%ecx
mov    %ecx,%eax
sar    $0x4,%eax
or     %ecx,%eax
mov    %eax,%ecx
sar    $0x8,%ecx
or     %eax,%ecx
mov    %ecx,%eax
sar    $0x11,%eax
sar    %ecx
or     %eax,%ecx
imul   $0x77cb531,%ecx,%eax
add    $0x77cb531,%eax
sar    $0x1b,%eax
cltq
lea    0xec5(%rip),%rcx
mov    (%rcx,%rax,4),%eax
ret

LLVM IR (-O0):
@gt_requiredUInt32Bits.MultiplyDeBruijnBitPosition = internal constant [32 x i32] [i32 1, i32 2, i32 29, i32 3, i32 30, i32 15, i32 25, i32 4, i32 31, i32 23, i32 21, i32 16, i32 26, i32 18, i32 5, i32 9, i32 32, i32 28, i32 14, i32 24, i32 22, i32 20, i32 17, i32 8, i32 27, i32 13, i32 19, i32 7, i32 12, i32 6, i32 11, i32 10]
define i32 @gt_requiredUInt32Bits(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = ashr i32 %4, 1
%6 = load i32, i32* %2
%7 = or i32 %6, %5
store i32 %7, i32* %2
%8 = load i32, i32* %2
%9 = ashr i32 %8, 2
%10 = load i32, i32* %2
%11 = or i32 %10, %9
store i32 %11, i32* %2
%12 = load i32, i32* %2
%13 = ashr i32 %12, 4
%14 = load i32, i32* %2
%15 = or i32 %14, %13
store i32 %15, i32* %2
%16 = load i32, i32* %2
%17 = ashr i32 %16, 8
%18 = load i32, i32* %2
%19 = or i32 %18, %17
store i32 %19, i32* %2
%20 = load i32, i32* %2
%21 = ashr i32 %20, 16
%22 = load i32, i32* %2
%23 = or i32 %22, %21
store i32 %23, i32* %2
%24 = load i32, i32* %2
%25 = ashr i32 %24, 1
%26 = add nsw i32 %25, 1
store i32 %26, i32* %2
%27 = load i32, i32* %2
%28 = mul nsw i32 %27, 125613361
%29 = ashr i32 %28, 27
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [32 x i32], [32 x i32]* @gt_requiredUInt32Bits.MultiplyDeBruijnBitPosition, i64 0, i64 %30
%32 = load i32, i32* %31
store i32 %32, i32* %3
%33 = load i32, i32* %3
ret i32 %33
}

LLVM IR (-O2):
@gt_requiredUInt32Bits.MultiplyDeBruijnBitPosition = internal unnamed_addr constant [32 x i32] [i32 1, i32 2, i32 29, i32 3, i32 30, i32 15, i32 25, i32 4, i32 31, i32 23, i32 21, i32 16, i32 26, i32 18, i32 5, i32 9, i32 32, i32 28, i32 14, i32 24, i32 22, i32 20, i32 17, i32 8, i32 27, i32 13, i32 19, i32 7, i32 12, i32 6, i32 11, i32 10]
define i32 @gt_requiredUInt32Bits(i32 %0) {
%2 = ashr i32 %0, 1
%3 = or i32 %2, %0
%4 = ashr i32 %3, 2
%5 = or i32 %4, %3
%6 = ashr i32 %5, 4
%7 = or i32 %6, %5
%8 = ashr i32 %7, 8
%9 = or i32 %8, %7
%10 = ashr i32 %9, 17
%11 = ashr i32 %9, 1
%12 = or i32 %10, %11
%13 = mul i32 %12, 125613361
%14 = add i32 %13, 125613361
%15 = ashr i32 %14, 27
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [32 x i32], [32 x i32]* @gt_requiredUInt32Bits.MultiplyDeBruijnBitPosition, i64 0, i64 %16
%18 = load i32, i32* %17
ret i32 %18
}