#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*/ abort();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
int log2_ceil(int n) {
  int e;
  do {
    if (!(n >= 1)) {
      fprintf(stderr, "Assertion failure\n");
      abort();
    }
  } while (0);
  for (e = 0;; e++)
    if ((1 << e) >= n)
      break;
  return e;
}


x86 assembly (clang, -O0):
<log2_ceil>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x1,-0x4(%rbp)
jge    1151 <log2_ceil+0x31>
mov    0x2ea4(%rip),%rax
mov    (%rax),%edi
lea    0xebb(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x0,%al
call   1030 <abort@plt>
jmp    1156 <log2_ceil+0x36>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
cmp    -0x4(%rbp),%eax
jl     1175 <log2_ceil+0x55>
jmp    1188 <log2_ceil+0x68>
jmp    117a <log2_ceil+0x5a>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    115d <log2_ceil+0x3d>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<log2_ceil>:
test   %edi,%edi
jle    1141 <log2_ceil+0x21>
mov    $0xffffffff,%ecx
nopl   0x0(%rax)
add    $0x1,%ecx
mov    $0x1,%eax
shl    %cl,%eax
cmp    %edi,%eax
jl     1130 <log2_ceil+0x10>
mov    %ecx,%eax
ret
push   %rax
mov    0x2e97(%rip),%rax
mov    (%rax),%edi
lea    0xeae(%rip),%rsi
call   1040 <fprintf@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [19 x i8] c"Assertion failure\0A\00"
define i32 @log2_ceil(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
br label %4
4: ; preds = %1
%5 = load i32, i32* %2
%6 = icmp sge i32 %5, 1
br i1 %6, label %11, label %7
7: ; preds = %4
%8 = load i32, i32* @stderr
%9 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (...) @abort()
unreachable
11: ; preds = %4
br label %12
12: ; preds = %11
store i32 0, i32* %3
br label %13
13: ; preds = %20, %12
%14 = load i32, i32* %3
%15 = shl i32 1, %14
%16 = load i32, i32* %2
%17 = icmp sge i32 %15, %16
br i1 %17, label %18, label %19
18: ; preds = %13
br label %23
19: ; preds = %13
br label %20
20: ; preds = %19
%21 = load i32, i32* %3
%22 = add nsw i32 %21, 1
store i32 %22, i32* %3
br label %13
23: ; preds = %18
%24 = load i32, i32* %3
ret i32 %24
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [19 x i8] c"Assertion failure\0A\00"
define i32 @log2_ceil(i32 %0) {
%2 = icmp sgt i32 %0, 0
br i1 %2, label %7, label %3
3: ; preds = %1
%4 = load i32, i32* @stderr
%5 = tail call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 (...) @abort()
unreachable
7: ; preds = %1, %7
%8 = phi i32 [ %11, %7 ], [ 0, %1 ]
%9 = shl nuw i32 1, %8
%10 = icmp slt i32 %9, %0
%11 = add nuw nsw i32 %8, 1
br i1 %10, label %7, label %12
12: ; preds = %7
ret i32 %8
}