#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 */
unsigned _utf8_encoding_width(unsigned long codepoint) {
  size_t steps[] = {0x7f, 0x07ff, 0xffff, 0x1fffff, 0x3ffffff, 0x7fffffff};
  unsigned n = 0;
  if (codepoint > 0x7fffffff)
    return 0;
  for (n = 1; codepoint > steps[n - 1]; ++n)
    ;
  ;
  return n;
}


x86 assembly (clang, -O0):
<_utf8_encoding_width>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1030 <memset@plt>
movq   $0x7f,-0x40(%rbp)
movq   $0x7ff,-0x38(%rbp)
movq   $0xffff,-0x30(%rbp)
movq   $0x1fffff,-0x28(%rbp)
movq   $0x3ffffff,-0x20(%rbp)
03
movq   $0x7fffffff,-0x18(%rbp)
7f
movl   $0x0,-0x44(%rbp)
cmpq   $0x7fffffff,-0x10(%rbp)
7f
jbe    117d <_utf8_encoding_width+0x6d>
movl   $0x0,-0x4(%rbp)
jmp    11b4 <_utf8_encoding_width+0xa4>
movl   $0x1,-0x44(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x44(%rbp),%ecx
sub    $0x1,%ecx
mov    %ecx,%ecx
cmp    -0x40(%rbp,%rcx,8),%rax
jbe    11ae <_utf8_encoding_width+0x9e>
jmp    11a0 <_utf8_encoding_width+0x90>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1184 <_utf8_encoding_width+0x74>
mov    -0x44(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_utf8_encoding_width>:
movaps 0xef9(%rip),%xmm0
movaps %xmm0,-0x38(%rsp)
movaps 0xefd(%rip),%xmm0
movaps %xmm0,-0x28(%rsp)
movaps 0xf01(%rip),%xmm0
movaps %xmm0,-0x18(%rsp)
xor    %eax,%eax
cmp    $0x7fffffff,%rdi
ja     115c <_utf8_encoding_width+0x5c>
mov    $0x1,%eax
cmp    $0x80,%rdi
jb     115c <_utf8_encoding_width+0x5c>
mov    $0x1,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %eax,%ecx
add    $0x1,%eax
cmp    %rdi,-0x38(%rsp,%rcx,8)
jb     1150 <_utf8_encoding_width+0x50>
ret

LLVM IR (-O0):
define i32 @_utf8_encoding_width(i64 %0) {
%2 = alloca i32
%3 = alloca i64
%4 = alloca [6 x i64]
%5 = alloca i32
store i64 %0, i64* %3
%6 = bitcast [6 x i64]* %4 to i8*
%7 = bitcast i8* %6 to [6 x i64]*
%8 = getelementptr inbounds [6 x i64], [6 x i64]* %7, i32 0, i32 0
store i64 127, i64* %8
%9 = getelementptr inbounds [6 x i64], [6 x i64]* %7, i32 0, i32 1
store i64 2047, i64* %9
%10 = getelementptr inbounds [6 x i64], [6 x i64]* %7, i32 0, i32 2
store i64 65535, i64* %10
%11 = getelementptr inbounds [6 x i64], [6 x i64]* %7, i32 0, i32 3
store i64 2097151, i64* %11
%12 = getelementptr inbounds [6 x i64], [6 x i64]* %7, i32 0, i32 4
store i64 67108863, i64* %12
%13 = getelementptr inbounds [6 x i64], [6 x i64]* %7, i32 0, i32 5
store i64 2147483647, i64* %13
store i32 0, i32* %5
%14 = load i64, i64* %3
%15 = icmp ugt i64 %14, 2147483647
br i1 %15, label %16, label %17
16: ; preds = %1
store i32 0, i32* %2
br label %32
17: ; preds = %1
store i32 1, i32* %5
br label %18
18: ; preds = %27, %17
%19 = load i64, i64* %3
%20 = load i32, i32* %5
%21 = sub i32 %20, 1
%22 = zext i32 %21 to i64
%23 = getelementptr inbounds [6 x i64], [6 x i64]* %4, i64 0, i64 %22
%24 = load i64, i64* %23
%25 = icmp ugt i64 %19, %24
br i1 %25, label %26, label %30
26: ; preds = %18
br label %27
27: ; preds = %26
%28 = load i32, i32* %5
%29 = add i32 %28, 1
store i32 %29, i32* %5
br label %18
30: ; preds = %18
%31 = load i32, i32* %5
store i32 %31, i32* %2
br label %32
32: ; preds = %30, %16
%33 = load i32, i32* %2
ret i32 %33
}

LLVM IR (-O2):
define i32 @_utf8_encoding_width(i64 %0) {
%2 = alloca [6 x i64]
%3 = bitcast [6 x i64]* %2 to i8*
%4 = bitcast [6 x i64]* %2 to <2 x i64>*
store <2 x i64> <i64 127, i64 2047>, <2 x i64>* %4
%5 = getelementptr inbounds [6 x i64], [6 x i64]* %2, i64 0, i64 2
%6 = bitcast i64* %5 to <2 x i64>*
store <2 x i64> <i64 65535, i64 2097151>, <2 x i64>* %6
%7 = getelementptr inbounds [6 x i64], [6 x i64]* %2, i64 0, i64 4
%8 = bitcast i64* %7 to <2 x i64>*
store <2 x i64> <i64 67108863, i64 2147483647>, <2 x i64>* %8
%9 = icmp ugt i64 %0, 2147483647
br i1 %9, label %19, label %10
10: ; preds = %1
%11 = icmp ugt i64 %0, 127
br i1 %11, label %12, label %19
12: ; preds = %10, %12
%13 = phi i32 [ %14, %12 ], [ 1, %10 ]
%14 = add i32 %13, 1
%15 = zext i32 %13 to i64
%16 = getelementptr inbounds [6 x i64], [6 x i64]* %2, i64 0, i64 %15
%17 = load i64, i64* %16
%18 = icmp ult i64 %17, %0
br i1 %18, label %12, label %19
19: ; preds = %12, %10, %1
%20 = phi i32 [ 0, %1 ], [ 1, %10 ], [ %14, %12 ]
ret i32 %20
}