int BN_num_bits_word(unsigned int l) {
  static const char bits[256] = {
      0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5,
      5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
      6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7,
      7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
      7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
      7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
      8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
      8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
      8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
      8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
      8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
  };
  {
    if (l & 0xffff0000L) {
      if (l & 0xff000000L)
        return bits[(int)(l >> 24L)] + 24;
      else
        return bits[(int)(l >> 16L)] + 16;
    } else {
      if (l & 0xff00L)
        return bits[(int)(l >> 8)] + 8;
      else
        return bits[(int)(l)];
    }
  }
}


x86 assembly (clang, -O0):
<BN_num_bits_word>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
movabs $0xffff0000,%rcx
and    %rcx,%rax
cmp    $0x0,%rax
je     1179 <BN_num_bits_word+0x79>
mov    -0x8(%rbp),%eax
movabs $0xff000000,%rcx
and    %rcx,%rax
cmp    $0x0,%rax
je     115a <BN_num_bits_word+0x5a>
mov    -0x8(%rbp),%eax
shr    $0x18,%eax
movslq %eax,%rcx
lea    0xeb5(%rip),%rax
movsbl (%rax,%rcx,1),%eax
add    $0x18,%eax
mov    %eax,-0x4(%rbp)
jmp    11bd <BN_num_bits_word+0xbd>
mov    -0x8(%rbp),%eax
shr    $0x10,%eax
movslq %eax,%rcx
lea    0xe96(%rip),%rax
movsbl (%rax,%rcx,1),%eax
add    $0x10,%eax
mov    %eax,-0x4(%rbp)
jmp    11bd <BN_num_bits_word+0xbd>
mov    -0x8(%rbp),%eax
and    $0xff00,%rax
cmp    $0x0,%rax
je     11ab <BN_num_bits_word+0xab>
mov    -0x8(%rbp),%eax
shr    $0x8,%eax
movslq %eax,%rcx
lea    0xe64(%rip),%rax
movsbl (%rax,%rcx,1),%eax
add    $0x8,%eax
mov    %eax,-0x4(%rbp)
jmp    11bd <BN_num_bits_word+0xbd>
movslq -0x8(%rbp),%rcx
lea    0xe4a(%rip),%rax
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<BN_num_bits_word>:
mov    %edi,%eax
test   $0xffff0000,%eax
je     1123 <BN_num_bits_word+0x23>
test   $0xff000000,%eax
je     113d <BN_num_bits_word+0x3d>
shr    $0x18,%rax
lea    0xee5(%rip),%rcx
movsbl (%rax,%rcx,1),%eax
add    $0x18,%eax
ret
test   $0xff00,%eax
je     1150 <BN_num_bits_word+0x50>
shr    $0x8,%rax
lea    0xecb(%rip),%rcx
movsbl (%rax,%rcx,1),%eax
add    $0x8,%eax
ret
shr    $0x10,%rax
lea    0xeb8(%rip),%rcx
movsbl (%rax,%rcx,1),%eax
add    $0x10,%eax
ret
movslq %edi,%rax
lea    0xea6(%rip),%rcx
movsbl (%rax,%rcx,1),%eax
ret

LLVM IR (-O0):
@BN_num_bits_word.bits = internal constant [256 x i8] c"\00\01\02\02\03\03\03\03\04\04\04\04\04\04\04\04\05\05\05\05\05\05\05\05\05\05\05\05\05\05\05\05\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08"
define i32 @BN_num_bits_word(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = zext i32 %4 to i64
%6 = and i64 %5, 4294901760
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %29
8: ; preds = %1
%9 = load i32, i32* %3
%10 = zext i32 %9 to i64
%11 = and i64 %10, 4278190080
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %21
13: ; preds = %8
%14 = load i32, i32* %3
%15 = lshr i32 %14, 24
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [256 x i8], [256 x i8]* @BN_num_bits_word.bits, i64 0, i64 %16
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = add nsw i32 %19, 24
store i32 %20, i32* %2
br label %48
21: ; preds = %8
%22 = load i32, i32* %3
%23 = lshr i32 %22, 16
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [256 x i8], [256 x i8]* @BN_num_bits_word.bits, i64 0, i64 %24
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = add nsw i32 %27, 16
store i32 %28, i32* %2
br label %48
29: ; preds = %1
%30 = load i32, i32* %3
%31 = zext i32 %30 to i64
%32 = and i64 %31, 65280
%33 = icmp ne i64 %32, 0
br i1 %33, label %34, label %42
34: ; preds = %29
%35 = load i32, i32* %3
%36 = lshr i32 %35, 8
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [256 x i8], [256 x i8]* @BN_num_bits_word.bits, i64 0, i64 %37
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = add nsw i32 %40, 8
store i32 %41, i32* %2
br label %48
42: ; preds = %29
%43 = load i32, i32* %3
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [256 x i8], [256 x i8]* @BN_num_bits_word.bits, i64 0, i64 %44
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
store i32 %47, i32* %2
br label %48
48: ; preds = %42, %34, %21, %13
%49 = load i32, i32* %2
ret i32 %49
}

LLVM IR (-O2):
@BN_num_bits_word.bits = internal unnamed_addr constant [256 x i8] c"\00\01\02\02\03\03\03\03\04\04\04\04\04\04\04\04\05\05\05\05\05\05\05\05\05\05\05\05\05\05\05\05\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08"
define i32 @BN_num_bits_word(i32 %0) {
%2 = zext i32 %0 to i64
%3 = and i64 %2, 4294901760
%4 = icmp eq i64 %3, 0
br i1 %4, label %22, label %5
5: ; preds = %1
%6 = and i64 %2, 4278190080
%7 = icmp eq i64 %6, 0
br i1 %7, label %15, label %8
8: ; preds = %5
%9 = lshr i32 %0, 24
%10 = zext i32 %9 to i64
%11 = getelementptr inbounds [256 x i8], [256 x i8]* @BN_num_bits_word.bits, i64 0, i64 %10
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = add nsw i32 %13, 24
br label %37
15: ; preds = %5
%16 = lshr i32 %0, 16
%17 = zext i32 %16 to i64
%18 = getelementptr inbounds [256 x i8], [256 x i8]* @BN_num_bits_word.bits, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = add nsw i32 %20, 16
br label %37
22: ; preds = %1
%23 = and i64 %2, 65280
%24 = icmp eq i64 %23, 0
br i1 %24, label %32, label %25
25: ; preds = %22
%26 = lshr i32 %0, 8
%27 = zext i32 %26 to i64
%28 = getelementptr inbounds [256 x i8], [256 x i8]* @BN_num_bits_word.bits, i64 0, i64 %27
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = add nsw i32 %30, 8
br label %37
32: ; preds = %22
%33 = sext i32 %0 to i64
%34 = getelementptr inbounds [256 x i8], [256 x i8]* @BN_num_bits_word.bits, i64 0, i64 %33
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
br label %37
37: ; preds = %32, %25, %15, %8
%38 = phi i32 [ %14, %8 ], [ %21, %15 ], [ %31, %25 ], [ %36, %32 ]
ret i32 %38
}