unsigned int leadingZero(const unsigned int input) {
  unsigned int l;
  const static unsigned int leadingZero8bit[256] = {
      8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3,
      3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
      2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1,
      1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
      1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
      1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
  if (input & 0xFFFF0000) {
    if (input & 0xFF000000) {
      l = leadingZero8bit[input >> 24];
    } else {
      l = 8 + leadingZero8bit[input >> 16];
    }
  } else {
    if (input & 0x0000FF00) {
      l = 16 + leadingZero8bit[input >> 8];
    } else {
      l = 24 + leadingZero8bit[input];
    }
  }
  return l;
}


x86 assembly (clang, -O0):
<leadingZero>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
and    $0xffff0000,%eax
cmp    $0x0,%eax
je     1164 <leadingZero+0x64>
mov    -0x4(%rbp),%eax
and    $0xff000000,%eax
cmp    $0x0,%eax
je     1145 <leadingZero+0x45>
mov    -0x4(%rbp),%eax
shr    $0x18,%eax
mov    %eax,%eax
mov    %eax,%ecx
lea    0xec6(%rip),%rax
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x8(%rbp)
jmp    115f <leadingZero+0x5f>
mov    -0x4(%rbp),%eax
shr    $0x10,%eax
mov    %eax,%eax
mov    %eax,%ecx
lea    0xeaa(%rip),%rax
mov    (%rax,%rcx,4),%eax
add    $0x8,%eax
mov    %eax,-0x8(%rbp)
jmp    11ae <leadingZero+0xae>
mov    -0x4(%rbp),%eax
and    $0xff00,%eax
cmp    $0x0,%eax
je     1194 <leadingZero+0x94>
mov    -0x4(%rbp),%eax
shr    $0x8,%eax
mov    %eax,%eax
mov    %eax,%ecx
lea    0xe7a(%rip),%rax
mov    (%rax,%rcx,4),%eax
add    $0x10,%eax
mov    %eax,-0x8(%rbp)
jmp    11a9 <leadingZero+0xa9>
mov    -0x4(%rbp),%eax
mov    %eax,%ecx
lea    0xe60(%rip),%rax
mov    (%rax,%rcx,4),%eax
add    $0x18,%eax
mov    %eax,-0x8(%rbp)
jmp    11ae <leadingZero+0xae>
mov    -0x8(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<leadingZero>:
cmp    $0x10000,%edi
jae    1121 <leadingZero+0x21>
test   $0xff00,%edi
je     1148 <leadingZero+0x48>
shr    $0x8,%edi
lea    0xee6(%rip),%rax
mov    (%rax,%rdi,4),%eax
add    $0x10,%eax
ret
cmp    $0x1000000,%edi
jae    113a <leadingZero+0x3a>
shr    $0x10,%edi
lea    0xecd(%rip),%rax
mov    (%rax,%rdi,4),%eax
add    $0x8,%eax
ret
shr    $0x18,%edi
lea    0xebc(%rip),%rax
mov    (%rax,%rdi,4),%eax
ret
mov    %edi,%eax
lea    0xeaf(%rip),%rcx
mov    (%rcx,%rax,4),%eax
add    $0x18,%eax
ret

LLVM IR (-O0):
@leadingZero.leadingZero8bit = internal constant <{ [128 x i32], [128 x i32] }> <{ [128 x i32] [i32 8, i32 7, i32 6, i32 6, i32 5, i32 5, i32 5, i32 5, i32 4, i32 4, i32 4, i32 4, i32 4, i32 4, i32 4, i32 4, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1], [128 x i32] zeroinitializer }>
define i32 @leadingZero(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = and i32 %4, -65536
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %25
7: ; preds = %1
%8 = load i32, i32* %2
%9 = and i32 %8, -16777216
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %17
11: ; preds = %7
%12 = load i32, i32* %2
%13 = lshr i32 %12, 24
%14 = zext i32 %13 to i64
%15 = getelementptr inbounds [256 x i32], [256 x i32]* bitcast (<{ [128 x i32], [128 x i32] }>* @leadingZero.leadingZero8bit to [256 x i32]*), i64 0, i64 %14
%16 = load i32, i32* %15
store i32 %16, i32* %3
br label %24
17: ; preds = %7
%18 = load i32, i32* %2
%19 = lshr i32 %18, 16
%20 = zext i32 %19 to i64
%21 = getelementptr inbounds [256 x i32], [256 x i32]* bitcast (<{ [128 x i32], [128 x i32] }>* @leadingZero.leadingZero8bit to [256 x i32]*), i64 0, i64 %20
%22 = load i32, i32* %21
%23 = add i32 8, %22
store i32 %23, i32* %3
br label %24
24: ; preds = %17, %11
br label %43
25: ; preds = %1
%26 = load i32, i32* %2
%27 = and i32 %26, 65280
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %36
29: ; preds = %25
%30 = load i32, i32* %2
%31 = lshr i32 %30, 8
%32 = zext i32 %31 to i64
%33 = getelementptr inbounds [256 x i32], [256 x i32]* bitcast (<{ [128 x i32], [128 x i32] }>* @leadingZero.leadingZero8bit to [256 x i32]*), i64 0, i64 %32
%34 = load i32, i32* %33
%35 = add i32 16, %34
store i32 %35, i32* %3
br label %42
36: ; preds = %25
%37 = load i32, i32* %2
%38 = zext i32 %37 to i64
%39 = getelementptr inbounds [256 x i32], [256 x i32]* bitcast (<{ [128 x i32], [128 x i32] }>* @leadingZero.leadingZero8bit to [256 x i32]*), i64 0, i64 %38
%40 = load i32, i32* %39
%41 = add i32 24, %40
store i32 %41, i32* %3
br label %42
42: ; preds = %36, %29
br label %43
43: ; preds = %42, %24
%44 = load i32, i32* %3
ret i32 %44
}

LLVM IR (-O2):
@leadingZero.leadingZero8bit = internal unnamed_addr constant <{ [128 x i32], [128 x i32] }> <{ [128 x i32] [i32 8, i32 7, i32 6, i32 6, i32 5, i32 5, i32 5, i32 5, i32 4, i32 4, i32 4, i32 4, i32 4, i32 4, i32 4, i32 4, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1], [128 x i32] zeroinitializer }>
define i32 @leadingZero(i32 %0) {
%2 = icmp ult i32 %0, 65536
br i1 %2, label %16, label %3
3: ; preds = %1
%4 = icmp ult i32 %0, 16777216
br i1 %4, label %10, label %5
5: ; preds = %3
%6 = lshr i32 %0, 24
%7 = zext i32 %6 to i64
%8 = getelementptr inbounds [256 x i32], [256 x i32]* bitcast (<{ [128 x i32], [128 x i32] }>* @leadingZero.leadingZero8bit to [256 x i32]*), i64 0, i64 %7
%9 = load i32, i32* %8
br label %30
10: ; preds = %3
%11 = lshr i32 %0, 16
%12 = zext i32 %11 to i64
%13 = getelementptr inbounds [256 x i32], [256 x i32]* bitcast (<{ [128 x i32], [128 x i32] }>* @leadingZero.leadingZero8bit to [256 x i32]*), i64 0, i64 %12
%14 = load i32, i32* %13
%15 = add i32 %14, 8
br label %30
16: ; preds = %1
%17 = and i32 %0, 65280
%18 = icmp eq i32 %17, 0
br i1 %18, label %25, label %19
19: ; preds = %16
%20 = lshr i32 %0, 8
%21 = zext i32 %20 to i64
%22 = getelementptr inbounds [256 x i32], [256 x i32]* bitcast (<{ [128 x i32], [128 x i32] }>* @leadingZero.leadingZero8bit to [256 x i32]*), i64 0, i64 %21
%23 = load i32, i32* %22
%24 = add i32 %23, 16
br label %30
25: ; preds = %16
%26 = zext i32 %0 to i64
%27 = getelementptr inbounds [256 x i32], [256 x i32]* bitcast (<{ [128 x i32], [128 x i32] }>* @leadingZero.leadingZero8bit to [256 x i32]*), i64 0, i64 %26
%28 = load i32, i32* %27
%29 = add i32 %28, 24
br label %30
30: ; preds = %19, %25, %5, %10
%31 = phi i32 [ %9, %5 ], [ %15, %10 ], [ %24, %19 ], [ %29, %25 ]
ret i32 %31
}