#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 ullog2(uint64_t x) {
  static const uint64_t debruijn_magic = 0x022fdd63cc95386dULL;
  static const uint64_t magic_table[] = {
      0,  1,  2,  53, 3,  7,  54, 27, 4,  38, 41, 8,  34, 55, 48, 28,
      62, 5,  39, 46, 44, 42, 22, 9,  24, 35, 59, 56, 49, 18, 29, 11,
      63, 52, 6,  26, 37, 40, 33, 47, 61, 45, 43, 21, 23, 58, 17, 10,
      51, 25, 36, 32, 60, 20, 57, 16, 50, 31, 19, 15, 30, 14, 13, 12,
  };
  x |= (x >> 1);
  x |= (x >> 2);
  x |= (x >> 4);
  x |= (x >> 8);
  x |= (x >> 16);
  x |= (x >> 32);
  return (magic_table[((x & ~(x >> 1)) * debruijn_magic) >> 58]);
}


x86 assembly (clang, -O0):
<ullog2>:
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
mov    $0x20,%ecx
sar    %cl,%eax
or     -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    -0x4(%rbp),%ecx
sar    $0x1,%ecx
xor    $0xffffffff,%ecx
and    %ecx,%eax
imul   $0xcc95386d,%eax,%eax
mov    $0x3a,%ecx
sar    %cl,%eax
movslq %eax,%rcx
lea    0xe98(%rip),%rax
mov    (%rax,%rcx,4),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<ullog2>:
ret

LLVM IR (-O0):
@ullog2.debruijn_magic = internal constant i32 -862635923
@ullog2.magic_table = internal constant [64 x i32] [i32 0, i32 1, i32 2, i32 53, i32 3, i32 7, i32 54, i32 27, i32 4, i32 38, i32 41, i32 8, i32 34, i32 55, i32 48, i32 28, i32 62, i32 5, i32 39, i32 46, i32 44, i32 42, i32 22, i32 9, i32 24, i32 35, i32 59, i32 56, i32 49, i32 18, i32 29, i32 11, i32 63, i32 52, i32 6, i32 26, i32 37, i32 40, i32 33, i32 47, i32 61, i32 45, i32 43, i32 21, i32 23, i32 58, i32 17, i32 10, i32 51, i32 25, i32 36, i32 32, i32 60, i32 20, i32 57, i32 16, i32 50, i32 31, i32 19, i32 15, i32 30, i32 14, i32 13, i32 12]
define i32 @ullog2(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = ashr i32 %3, 1
%5 = load i32, i32* %2
%6 = or i32 %5, %4
store i32 %6, i32* %2
%7 = load i32, i32* %2
%8 = ashr i32 %7, 2
%9 = load i32, i32* %2
%10 = or i32 %9, %8
store i32 %10, i32* %2
%11 = load i32, i32* %2
%12 = ashr i32 %11, 4
%13 = load i32, i32* %2
%14 = or i32 %13, %12
store i32 %14, i32* %2
%15 = load i32, i32* %2
%16 = ashr i32 %15, 8
%17 = load i32, i32* %2
%18 = or i32 %17, %16
store i32 %18, i32* %2
%19 = load i32, i32* %2
%20 = ashr i32 %19, 16
%21 = load i32, i32* %2
%22 = or i32 %21, %20
store i32 %22, i32* %2
%23 = load i32, i32* %2
%24 = ashr i32 %23, 32
%25 = load i32, i32* %2
%26 = or i32 %25, %24
store i32 %26, i32* %2
%27 = load i32, i32* %2
%28 = load i32, i32* %2
%29 = ashr i32 %28, 1
%30 = xor i32 %29, -1
%31 = and i32 %27, %30
%32 = mul nsw i32 %31, -862635923
%33 = ashr i32 %32, 58
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [64 x i32], [64 x i32]* @ullog2.magic_table, i64 0, i64 %34
%36 = load i32, i32* %35
ret i32 %36
}

LLVM IR (-O2):
define i32 @ullog2(i32 %0) {
ret i32 undef
}