#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 */

/* Variables and functions */
int CHAR_BIT;
unsigned int xdl_hashbits(unsigned int size) {
  unsigned int val = 1, bits = 0;
  for (; val < size && bits < CHAR_BIT * sizeof(unsigned int);
       val <<= 1, bits++)
    ;
  return bits ? bits : 1;
}


x86 assembly (clang, -O0):
<xdl_hashbits>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%ecx
xor    %eax,%eax
cmp    -0x4(%rbp),%ecx
mov    %al,-0xd(%rbp)
jae    1140 <xdl_hashbits+0x40>
mov    -0xc(%rbp),%eax
mov    0x2eb0(%rip),%rcx
movslq (%rcx),%rcx
shl    $0x2,%rcx
cmp    %rcx,%rax
setb   %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    1150 <xdl_hashbits+0x50>
jmp    116c <xdl_hashbits+0x6c>
jmp    1155 <xdl_hashbits+0x55>
mov    -0x8(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1115 <xdl_hashbits+0x15>
cmpl   $0x0,-0xc(%rbp)
je     1181 <xdl_hashbits+0x81>
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    118e <xdl_hashbits+0x8e>
mov    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    118e <xdl_hashbits+0x8e>
mov    -0x14(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<xdl_hashbits>:
cmp    $0x2,%edi
jb     1133 <xdl_hashbits+0x33>
mov    0x2ed4(%rip),%rax
movslq (%rax),%rcx
test   %ecx,%ecx
je     1133 <xdl_hashbits+0x33>
shl    $0x2,%rcx
mov    $0x1,%edx
xor    %eax,%eax
xchg   %ax,%ax
add    %edx,%edx
add    $0x1,%eax
cmp    %edi,%edx
jae    112e <xdl_hashbits+0x2e>
cmp    %rax,%rcx
ja     1120 <xdl_hashbits+0x20>
test   %eax,%eax
je     1133 <xdl_hashbits+0x33>
ret
mov    $0x1,%eax
ret

LLVM IR (-O0):
@CHAR_BIT = global i32 0
define i32 @xdl_hashbits(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
store i32 1, i32* %3
store i32 0, i32* %4
br label %5
5: ; preds = %19, %1
%6 = load i32, i32* %3
%7 = load i32, i32* %2
%8 = icmp ult i32 %6, %7
br i1 %8, label %9, label %16
9: ; preds = %5
%10 = load i32, i32* %4
%11 = zext i32 %10 to i64
%12 = load i32, i32* @CHAR_BIT
%13 = sext i32 %12 to i64
%14 = mul i64 %13, 4
%15 = icmp ult i64 %11, %14
br label %16
16: ; preds = %9, %5
%17 = phi i1 [ false, %5 ], [ %15, %9 ]
br i1 %17, label %18, label %24
18: ; preds = %16
br label %19
19: ; preds = %18
%20 = load i32, i32* %3
%21 = shl i32 %20, 1
store i32 %21, i32* %3
%22 = load i32, i32* %4
%23 = add i32 %22, 1
store i32 %23, i32* %4
br label %5
24: ; preds = %16
%25 = load i32, i32* %4
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %24
%28 = load i32, i32* %4
br label %30
29: ; preds = %24
br label %30
30: ; preds = %29, %27
%31 = phi i32 [ %28, %27 ], [ 1, %29 ]
ret i32 %31
}

LLVM IR (-O2):
@CHAR_BIT = global i32 0
define i32 @xdl_hashbits(i32 %0) {
%2 = load i32, i32* @CHAR_BIT
%3 = sext i32 %2 to i64
%4 = shl nsw i64 %3, 2
%5 = icmp ugt i32 %0, 1
%6 = icmp ne i32 %2, 0
%7 = select i1 %5, i1 %6, i1 false
br i1 %7, label %8, label %19
8: ; preds = %1, %8
%9 = phi i32 [ %12, %8 ], [ 0, %1 ]
%10 = phi i32 [ %11, %8 ], [ 1, %1 ]
%11 = shl i32 %10, 1
%12 = add i32 %9, 1
%13 = icmp ult i32 %11, %0
%14 = zext i32 %12 to i64
%15 = icmp ugt i64 %4, %14
%16 = select i1 %13, i1 %15, i1 false
br i1 %16, label %8, label %17
17: ; preds = %8
%18 = icmp eq i32 %12, 0
br i1 %18, label %19, label %20
19: ; preds = %1, %17
br label %20
20: ; preds = %17, %19
%21 = phi i32 [ 1, %19 ], [ %12, %17 ]
ret i32 %21
}