#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 /*<<< orphan*/ assert(int);
__attribute__((const)) unsigned ceil_po2(unsigned x) {
  if (x == 0)
    return 0;
  assert(x < (1U << 31));
  x = x - 1;
  x |= x >> 1;
  x |= x >> 2;
  x |= x >> 4;
  x |= x >> 8;
  x |= x >> 16;
  return x + 1;
}


x86 assembly (clang, -O0):
<ceil_po2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1131 <ceil_po2+0x21>
movl   $0x0,-0x4(%rbp)
jmp    1193 <ceil_po2+0x83>
cmpl   $0x80000000,-0x8(%rbp)
setb   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
shr    $0x1,%eax
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
shr    $0x2,%eax
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
shr    $0x4,%eax
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
shr    $0x8,%eax
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
shr    $0x10,%eax
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ceil_po2>:
test   %edi,%edi
je     114b <ceil_po2+0x3b>
push   %rbx
mov    %edi,%ebx
not    %edi
shr    $0x1f,%edi
call   1030 <assert@plt>
add    $0xffffffff,%ebx
mov    %ebx,%eax
shr    %eax
or     %ebx,%eax
mov    %eax,%ecx
shr    $0x2,%ecx
or     %eax,%ecx
mov    %ecx,%eax
shr    $0x4,%eax
or     %ecx,%eax
mov    %eax,%ecx
shr    $0x8,%ecx
or     %eax,%ecx
mov    %ecx,%eax
shr    $0x10,%eax
or     %ecx,%eax
add    $0x1,%eax
pop    %rbx
ret
xor    %eax,%eax
ret

LLVM IR (-O0):
define i32 @ceil_po2(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %7
6: ; preds = %1
store i32 0, i32* %2
br label %36
7: ; preds = %1
%8 = load i32, i32* %3
%9 = icmp ult i32 %8, -2147483648
%10 = zext i1 %9 to i32
%11 = call i32 @assert(i32 %10)
%12 = load i32, i32* %3
%13 = sub i32 %12, 1
store i32 %13, i32* %3
%14 = load i32, i32* %3
%15 = lshr i32 %14, 1
%16 = load i32, i32* %3
%17 = or i32 %16, %15
store i32 %17, i32* %3
%18 = load i32, i32* %3
%19 = lshr i32 %18, 2
%20 = load i32, i32* %3
%21 = or i32 %20, %19
store i32 %21, i32* %3
%22 = load i32, i32* %3
%23 = lshr i32 %22, 4
%24 = load i32, i32* %3
%25 = or i32 %24, %23
store i32 %25, i32* %3
%26 = load i32, i32* %3
%27 = lshr i32 %26, 8
%28 = load i32, i32* %3
%29 = or i32 %28, %27
store i32 %29, i32* %3
%30 = load i32, i32* %3
%31 = lshr i32 %30, 16
%32 = load i32, i32* %3
%33 = or i32 %32, %31
store i32 %33, i32* %3
%34 = load i32, i32* %3
%35 = add i32 %34, 1
store i32 %35, i32* %2
br label %36
36: ; preds = %7, %6
%37 = load i32, i32* %2
ret i32 %37
}

LLVM IR (-O2):
define i32 @ceil_po2(i32 %0) {
%2 = icmp eq i32 %0, 0
br i1 %2, label %19, label %3
3: ; preds = %1
%4 = xor i32 %0, -1
%5 = lshr i32 %4, 31
%6 = tail call i32 @assert(i32 %5)
%7 = add i32 %0, -1
%8 = lshr i32 %7, 1
%9 = or i32 %8, %7
%10 = lshr i32 %9, 2
%11 = or i32 %10, %9
%12 = lshr i32 %11, 4
%13 = or i32 %12, %11
%14 = lshr i32 %13, 8
%15 = or i32 %14, %13
%16 = lshr i32 %15, 16
%17 = or i32 %16, %15
%18 = add i32 %17, 1
br label %19
19: ; preds = %1, %3
%20 = phi i32 [ %18, %3 ], [ 0, %1 ]
ret i32 %20
}