int bs_size_ue(unsigned int val) {
  static const int i_size0_254[255] = {
      1,  3,  3,  5,  5,  5,  5,  7,  7,  7,  7,  7,  7,  7,  7,  9,  9,
      9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  11, 11, 11,
      11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
      11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 13, 13, 13, 13, 13,
      13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
      13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
      13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
      13, 13, 13, 13, 13, 13, 13, 13, 15, 15, 15, 15, 15, 15, 15, 15, 15,
      15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
      15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
      15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
      15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
      15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
      15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
      15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15};
  if (val < 255) {
    return i_size0_254[val];
  } else {
    int i_size = 0;
    val++;
    if (val >= 0x10000) {
      i_size += 32;
      val = (val >> 16) - 1;
    }
    if (val >= 0x100) {
      i_size += 16;
      val = (val >> 8) - 1;
    }
    return i_size0_254[val] + i_size;
  }
}


x86 assembly (clang, -O0):
<bs_size_ue>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
cmpl   $0xff,-0x8(%rbp)
jae    112b <bs_size_ue+0x2b>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
lea    0xee0(%rip),%rax
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x4(%rbp)
jmp    1194 <bs_size_ue+0x94>
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x10000,-0x8(%rbp)
jb     115d <bs_size_ue+0x5d>
mov    -0xc(%rbp),%eax
add    $0x20,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
shr    $0x10,%eax
sub    $0x1,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x100,-0x8(%rbp)
jb     117f <bs_size_ue+0x7f>
mov    -0xc(%rbp),%eax
add    $0x10,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
shr    $0x8,%eax
sub    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
lea    0xe75(%rip),%rax
mov    (%rax,%rcx,4),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<bs_size_ue>:
cmp    $0xfe,%edi
ja     1115 <bs_size_ue+0x15>
mov    %edi,%eax
lea    0xeef(%rip),%rcx
mov    (%rcx,%rax,4),%eax
ret
add    $0x1,%edi
mov    %edi,%ecx
shr    $0x10,%ecx
add    $0xffffffff,%ecx
xor    %edx,%edx
cmp    $0x10000,%edi
setae  %dl
cmovb  %edi,%ecx
shl    $0x5,%edx
lea    0x10(%rdx),%eax
mov    %ecx,%esi
shr    $0x8,%esi
add    $0xffffffff,%esi
cmp    $0x100,%ecx
cmovb  %ecx,%esi
cmovb  %edx,%eax
lea    0xeb1(%rip),%rcx
add    (%rcx,%rsi,4),%eax
ret

LLVM IR (-O0):
@bs_size_ue.i_size0_254 = internal constant [255 x i32] [i32 1, i32 3, i32 3, i32 5, i32 5, i32 5, i32 5, i32 7, i32 7, i32 7, i32 7, i32 7, i32 7, i32 7, i32 7, i32 9, i32 9, i32 9, i32 9, i32 9, i32 9, i32 9, i32 9, i32 9, i32 9, i32 9, i32 9, i32 9, i32 9, i32 9, i32 9, i32 11, i32 11, i32 11, i32 11, i32 11, i32 11, i32 11, i32 11, i32 11, i32 11, i32 11, i32 11, i32 11, i32 11, i32 11, i32 11, i32 11, i32 11, i32 11, i32 11, i32 11, i32 11, i32 11, i32 11, i32 11, i32 11, i32 11, i32 11, i32 11, i32 11, i32 11, i32 11, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15]
define i32 @bs_size_ue(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
%5 = load i32, i32* %3
%6 = icmp ult i32 %5, 255
br i1 %6, label %7, label %12
7: ; preds = %1
%8 = load i32, i32* %3
%9 = zext i32 %8 to i64
%10 = getelementptr inbounds [255 x i32], [255 x i32]* @bs_size_ue.i_size0_254, i64 0, i64 %9
%11 = load i32, i32* %10
store i32 %11, i32* %2
br label %39
12: ; preds = %1
store i32 0, i32* %4
%13 = load i32, i32* %3
%14 = add i32 %13, 1
store i32 %14, i32* %3
%15 = load i32, i32* %3
%16 = icmp uge i32 %15, 65536
br i1 %16, label %17, label %23
17: ; preds = %12
%18 = load i32, i32* %4
%19 = add nsw i32 %18, 32
store i32 %19, i32* %4
%20 = load i32, i32* %3
%21 = lshr i32 %20, 16
%22 = sub i32 %21, 1
store i32 %22, i32* %3
br label %23
23: ; preds = %17, %12
%24 = load i32, i32* %3
%25 = icmp uge i32 %24, 256
br i1 %25, label %26, label %32
26: ; preds = %23
%27 = load i32, i32* %4
%28 = add nsw i32 %27, 16
store i32 %28, i32* %4
%29 = load i32, i32* %3
%30 = lshr i32 %29, 8
%31 = sub i32 %30, 1
store i32 %31, i32* %3
br label %32
32: ; preds = %26, %23
%33 = load i32, i32* %3
%34 = zext i32 %33 to i64
%35 = getelementptr inbounds [255 x i32], [255 x i32]* @bs_size_ue.i_size0_254, i64 0, i64 %34
%36 = load i32, i32* %35
%37 = load i32, i32* %4
%38 = add nsw i32 %36, %37
store i32 %38, i32* %2
br label %39
39: ; preds = %32, %7
%40 = load i32, i32* %2
ret i32 %40
}

LLVM IR (-O2):
@bs_size_ue.i_size0_254 = internal unnamed_addr constant [255 x i32] [i32 1, i32 3, i32 3, i32 5, i32 5, i32 5, i32 5, i32 7, i32 7, i32 7, i32 7, i32 7, i32 7, i32 7, i32 7, i32 9, i32 9, i32 9, i32 9, i32 9, i32 9, i32 9, i32 9, i32 9, i32 9, i32 9, i32 9, i32 9, i32 9, i32 9, i32 9, i32 11, i32 11, i32 11, i32 11, i32 11, i32 11, i32 11, i32 11, i32 11, i32 11, i32 11, i32 11, i32 11, i32 11, i32 11, i32 11, i32 11, i32 11, i32 11, i32 11, i32 11, i32 11, i32 11, i32 11, i32 11, i32 11, i32 11, i32 11, i32 11, i32 11, i32 11, i32 11, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 13, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15]
define i32 @bs_size_ue(i32 %0) {
%2 = icmp ult i32 %0, 255
br i1 %2, label %3, label %7
3: ; preds = %1
%4 = zext i32 %0 to i64
%5 = getelementptr inbounds [255 x i32], [255 x i32]* @bs_size_ue.i_size0_254, i64 0, i64 %4
%6 = load i32, i32* %5
br label %24
7: ; preds = %1
%8 = add i32 %0, 1
%9 = icmp ugt i32 %8, 65535
%10 = lshr i32 %8, 16
%11 = add nsw i32 %10, -1
%12 = select i1 %9, i32 %11, i32 %8
%13 = select i1 %9, i32 32, i32 0
%14 = icmp ugt i32 %12, 255
%15 = or i32 %13, 16
%16 = lshr i32 %12, 8
%17 = add nsw i32 %16, -1
%18 = select i1 %14, i32 %17, i32 %12
%19 = select i1 %14, i32 %15, i32 %13
%20 = zext i32 %18 to i64
%21 = getelementptr inbounds [255 x i32], [255 x i32]* @bs_size_ue.i_size0_254, i64 0, i64 %20
%22 = load i32, i32* %21
%23 = add nsw i32 %22, %19
br label %24
24: ; preds = %7, %3
%25 = phi i32 [ %6, %3 ], [ %23, %7 ]
ret i32 %25
}