#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 panic();
int lg(int o) {
  return o == 16  ? 4
         : o == 8 ? 3
         : o == 4 ? 2
         : o == 2 ? 1
         : o == 1 ? 0
                  : panic();
}


x86 assembly (clang, -O0):
<lg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x10,-0x4(%rbp)
jne    1132 <lg+0x22>
mov    $0x4,%eax
mov    %eax,-0x8(%rbp)
jmp    11ad <lg+0x9d>
cmpl   $0x8,-0x4(%rbp)
jne    1149 <lg+0x39>
mov    $0x3,%eax
mov    %eax,-0xc(%rbp)
jmp    11a7 <lg+0x97>
cmpl   $0x4,-0x4(%rbp)
jne    1160 <lg+0x50>
mov    $0x2,%eax
mov    %eax,-0x10(%rbp)
jmp    11a1 <lg+0x91>
cmpl   $0x2,-0x4(%rbp)
jne    1177 <lg+0x67>
mov    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    119b <lg+0x8b>
cmpl   $0x1,-0x4(%rbp)
jne    118b <lg+0x7b>
xor    %eax,%eax
mov    %eax,-0x18(%rbp)
jmp    1195 <lg+0x85>
mov    $0x0,%al
call   1030 <panic@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lg>:
add    $0xffffffff,%edi
cmp    $0xf,%edi
ja     1136 <lg+0x26>
mov    $0x4,%eax
lea    0xedc(%rip),%rcx
movslq (%rcx,%rdi,4),%rdx
add    %rcx,%rdx
jmp    *%rdx
xor    %eax,%eax
ret
mov    $0x1,%eax
ret
xor    %eax,%eax
jmp    1030 <panic@plt>
mov    $0x2,%eax
ret
mov    $0x3,%eax
ret

LLVM IR (-O0):
define i32 @lg(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = icmp eq i32 %3, 16
br i1 %4, label %5, label %6
5: ; preds = %1
br label %32
6: ; preds = %1
%7 = load i32, i32* %2
%8 = icmp eq i32 %7, 8
br i1 %8, label %9, label %10
9: ; preds = %6
br label %30
10: ; preds = %6
%11 = load i32, i32* %2
%12 = icmp eq i32 %11, 4
br i1 %12, label %13, label %14
13: ; preds = %10
br label %28
14: ; preds = %10
%15 = load i32, i32* %2
%16 = icmp eq i32 %15, 2
br i1 %16, label %17, label %18
17: ; preds = %14
br label %26
18: ; preds = %14
%19 = load i32, i32* %2
%20 = icmp eq i32 %19, 1
br i1 %20, label %21, label %22
21: ; preds = %18
br label %24
22: ; preds = %18
%23 = call i32 (...) @panic()
br label %24
24: ; preds = %22, %21
%25 = phi i32 [ 0, %21 ], [ %23, %22 ]
br label %26
26: ; preds = %24, %17
%27 = phi i32 [ 1, %17 ], [ %25, %24 ]
br label %28
28: ; preds = %26, %13
%29 = phi i32 [ 2, %13 ], [ %27, %26 ]
br label %30
30: ; preds = %28, %9
%31 = phi i32 [ 3, %9 ], [ %29, %28 ]
br label %32
32: ; preds = %30, %5
%33 = phi i32 [ 4, %5 ], [ %31, %30 ]
ret i32 %33
}

LLVM IR (-O2):
define i32 @lg(i32 %0) {
switch i32 %0, label %2 [
i32 16, label %8
i32 8, label %4
i32 4, label %5
i32 2, label %6
i32 1, label %7
]
2: ; preds = %1
%3 = tail call i32 (...) @panic()
br label %8
4: ; preds = %1
br label %8
5: ; preds = %1
br label %8
6: ; preds = %1
br label %8
7: ; preds = %1
br label %8
8: ; preds = %1, %7, %6, %5, %4, %2
%9 = phi i32 [ 4, %1 ], [ %3, %2 ], [ 3, %4 ], [ 2, %5 ], [ 1, %6 ], [ 0, %7 ]
ret i32 %9
}