#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 */
size_t guac_utf8_charsize(unsigned char c) {
  if ((c | 0x7F) == 0x7F)
    return 1;
  if ((c | 0x1F) == 0xDF)
    return 2;
  if ((c | 0x0F) == 0xEF)
    return 3;
  if ((c | 0x07) == 0xF7)
    return 4;
  return 1;
}


x86 assembly (clang, -O0):
<guac_utf8_charsize>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x9(%rbp)
movzbl -0x9(%rbp),%eax
or     $0x7f,%eax
cmp    $0x7f,%eax
jne    1127 <guac_utf8_charsize+0x27>
movq   $0x1,-0x8(%rbp)
jmp    118c <guac_utf8_charsize+0x8c>
movzbl -0x9(%rbp),%eax
or     $0x1f,%eax
cmp    $0xdf,%eax
jne    1146 <guac_utf8_charsize+0x46>
movq   $0x2,-0x8(%rbp)
jmp    118c <guac_utf8_charsize+0x8c>
movzbl -0x9(%rbp),%eax
or     $0xf,%eax
cmp    $0xef,%eax
jne    1165 <guac_utf8_charsize+0x65>
movq   $0x3,-0x8(%rbp)
jmp    118c <guac_utf8_charsize+0x8c>
movzbl -0x9(%rbp),%eax
or     $0x7,%eax
cmp    $0xf7,%eax
jne    1184 <guac_utf8_charsize+0x84>
movq   $0x4,-0x8(%rbp)
jmp    118c <guac_utf8_charsize+0x8c>
movq   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<guac_utf8_charsize>:
mov    $0x1,%eax
test   %dil,%dil
js     110b <guac_utf8_charsize+0xb>
ret
mov    %edi,%ecx
and    $0xffffffe0,%ecx
mov    $0x2,%eax
cmp    $0xc0,%ecx
je     110a <guac_utf8_charsize+0xa>
mov    %edi,%ecx
and    $0xfffffff0,%ecx
mov    $0x3,%eax
cmp    $0xe0,%ecx
je     110a <guac_utf8_charsize+0xa>
and    $0xfffffff8,%edi
xor    %eax,%eax
cmp    $0xf0,%edi
sete   %al
lea    (%rax,%rax,2),%rax
add    $0x1,%rax
ret

LLVM IR (-O0):
define i64 @guac_utf8_charsize(i8 zeroext %0) {
%2 = alloca i64
%3 = alloca i8
store i8 %0, i8* %3
%4 = load i8, i8* %3
%5 = zext i8 %4 to i32
%6 = or i32 %5, 127
%7 = icmp eq i32 %6, 127
br i1 %7, label %8, label %9
8: ; preds = %1
store i64 1, i64* %2
br label %28
9: ; preds = %1
%10 = load i8, i8* %3
%11 = zext i8 %10 to i32
%12 = or i32 %11, 31
%13 = icmp eq i32 %12, 223
br i1 %13, label %14, label %15
14: ; preds = %9
store i64 2, i64* %2
br label %28
15: ; preds = %9
%16 = load i8, i8* %3
%17 = zext i8 %16 to i32
%18 = or i32 %17, 15
%19 = icmp eq i32 %18, 239
br i1 %19, label %20, label %21
20: ; preds = %15
store i64 3, i64* %2
br label %28
21: ; preds = %15
%22 = load i8, i8* %3
%23 = zext i8 %22 to i32
%24 = or i32 %23, 7
%25 = icmp eq i32 %24, 247
br i1 %25, label %26, label %27
26: ; preds = %21
store i64 4, i64* %2
br label %28
27: ; preds = %21
store i64 1, i64* %2
br label %28
28: ; preds = %27, %26, %20, %14, %8
%29 = load i64, i64* %2
ret i64 %29
}

LLVM IR (-O2):
define i64 @guac_utf8_charsize(i8 zeroext %0) {
%2 = zext i8 %0 to i32
%3 = icmp sgt i8 %0, -1
br i1 %3, label %14, label %4
4: ; preds = %1
%5 = and i32 %2, 224
%6 = icmp eq i32 %5, 192
br i1 %6, label %14, label %7
7: ; preds = %4
%8 = and i32 %2, 240
%9 = icmp eq i32 %8, 224
br i1 %9, label %14, label %10
10: ; preds = %7
%11 = and i32 %2, 248
%12 = icmp eq i32 %11, 240
%13 = select i1 %12, i64 4, i64 1
br label %14
14: ; preds = %10, %7, %4, %1
%15 = phi i64 [ 1, %1 ], [ 2, %4 ], [ 3, %7 ], [ %13, %10 ]
ret i64 %15
}