#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 */
typedef int uint8_t;

/* Variables and functions */
int get_len(uint8_t b) {
  int top = b & 0xF0;
  switch (top) {
  case 0x80:
    return 2;
  case 0x90:
    return 2;
  case 0xA0:
    return 2;
  case 0xB0:
    return 2;
  case 0xC0:
    return 1;
  case 0xD0:
    return 1;
  case 0xE0:
    return 2;
  case 0xF0:
    return 0;
  default:
    break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<get_len>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
and    $0xf0,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
sub    $0x80,%eax
je     11ad <get_len+0xad>
jmp    1128 <get_len+0x28>
mov    -0x10(%rbp),%eax
sub    $0x90,%eax
je     11b9 <get_len+0xb9>
jmp    113b <get_len+0x3b>
mov    -0x10(%rbp),%eax
sub    $0xa0,%eax
je     11c5 <get_len+0xc5>
jmp    114e <get_len+0x4e>
mov    -0x10(%rbp),%eax
sub    $0xb0,%eax
je     11d1 <get_len+0xd1>
jmp    1161 <get_len+0x61>
mov    -0x10(%rbp),%eax
sub    $0xc0,%eax
je     11dd <get_len+0xdd>
jmp    1174 <get_len+0x74>
mov    -0x10(%rbp),%eax
sub    $0xd0,%eax
je     11e9 <get_len+0xe9>
jmp    1187 <get_len+0x87>
mov    -0x10(%rbp),%eax
sub    $0xe0,%eax
je     11f5 <get_len+0xf5>
jmp    119a <get_len+0x9a>
mov    -0x10(%rbp),%eax
sub    $0xf0,%eax
je     1201 <get_len+0x101>
jmp    120d <get_len+0x10d>
movl   $0x2,-0x4(%rbp)
jmp    1219 <get_len+0x119>
movl   $0x2,-0x4(%rbp)
jmp    1219 <get_len+0x119>
movl   $0x2,-0x4(%rbp)
jmp    1219 <get_len+0x119>
movl   $0x2,-0x4(%rbp)
jmp    1219 <get_len+0x119>
movl   $0x1,-0x4(%rbp)
jmp    1219 <get_len+0x119>
movl   $0x1,-0x4(%rbp)
jmp    1219 <get_len+0x119>
movl   $0x2,-0x4(%rbp)
jmp    1219 <get_len+0x119>
movl   $0x0,-0x4(%rbp)
jmp    1219 <get_len+0x119>
jmp    1212 <get_len+0x112>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_len>:
and    $0xf0,%edi
add    $0xffffff80,%edi
xor    %eax,%eax
cmp    $0x7f,%edi
ja     111d <get_len+0x1d>
shr    $0x4,%edi
lea    0xee6(%rip),%rax
mov    (%rax,%rdi,4),%eax
ret

LLVM IR (-O0):
define i32 @get_len(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
%5 = load i32, i32* %3
%6 = and i32 %5, 240
store i32 %6, i32* %4
%7 = load i32, i32* %4
switch i32 %7, label %16 [
i32 128, label %8
i32 144, label %9
i32 160, label %10
i32 176, label %11
i32 192, label %12
i32 208, label %13
i32 224, label %14
i32 240, label %15
]
8: ; preds = %1
store i32 2, i32* %2
br label %18
9: ; preds = %1
store i32 2, i32* %2
br label %18
10: ; preds = %1
store i32 2, i32* %2
br label %18
11: ; preds = %1
store i32 2, i32* %2
br label %18
12: ; preds = %1
store i32 1, i32* %2
br label %18
13: ; preds = %1
store i32 1, i32* %2
br label %18
14: ; preds = %1
store i32 2, i32* %2
br label %18
15: ; preds = %1
store i32 0, i32* %2
br label %18
16: ; preds = %1
br label %17
17: ; preds = %16
store i32 0, i32* %2
br label %18
18: ; preds = %17, %15, %14, %13, %12, %11, %10, %9, %8
%19 = load i32, i32* %2
ret i32 %19
}

LLVM IR (-O2):
@switch.table.get_len = [8 x i32] [i32 2, i32 2, i32 2, i32 2, i32 1, i32 1, i32 2, i32 0]
define i32 @get_len(i32 %0) {
%2 = and i32 %0, 240
%3 = add nsw i32 %2, -128
%4 = icmp ult i32 %3, 128
br i1 %4, label %5, label %10
5: ; preds = %1
%6 = lshr exact i32 %3, 4
%7 = zext i32 %6 to i64
%8 = getelementptr inbounds [8 x i32], [8 x i32]* @switch.table.get_len, i64 0, i64 %7
%9 = load i32, i32* %8
br label %10
10: ; preds = %1, %5
%11 = phi i32 [ %9, %5 ], [ 0, %1 ]
ret i32 %11
}