#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 */
const char *g_utf8_next_char(const char *s) {
  unsigned char ch = *s;
  if (ch == '\0')
    return NULL;
  if (ch < 0x80)
    return s + 1;
  if (ch < 0xE0)
    return s + 2;
  if (ch < 0xF0)
    return s + 3;
  if (ch < 0xF5)
    return s + 4;
  return NULL;
}


x86 assembly (clang, -O0):
<g_utf8_next_char>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x11(%rbp)
movzbl -0x11(%rbp),%eax
cmp    $0x0,%eax
jne    112b <g_utf8_next_char+0x2b>
movq   $0x0,-0x8(%rbp)
jmp    11b3 <g_utf8_next_char+0xb3>
movzbl -0x11(%rbp),%eax
cmp    $0x80,%eax
jge    114b <g_utf8_next_char+0x4b>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    11b3 <g_utf8_next_char+0xb3>
movzbl -0x11(%rbp),%eax
cmp    $0xe0,%eax
jge    116b <g_utf8_next_char+0x6b>
mov    -0x10(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x8(%rbp)
jmp    11b3 <g_utf8_next_char+0xb3>
movzbl -0x11(%rbp),%eax
cmp    $0xf0,%eax
jge    118b <g_utf8_next_char+0x8b>
mov    -0x10(%rbp),%rax
add    $0x3,%rax
mov    %rax,-0x8(%rbp)
jmp    11b3 <g_utf8_next_char+0xb3>
movzbl -0x11(%rbp),%eax
cmp    $0xf5,%eax
jge    11ab <g_utf8_next_char+0xab>
mov    -0x10(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x8(%rbp)
jmp    11b3 <g_utf8_next_char+0xb3>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<g_utf8_next_char>:
mov    (%rdi),%cl
test   %cl,%cl
je     1110 <g_utf8_next_char+0x10>
mov    %rdi,%rax
js     1113 <g_utf8_next_char+0x13>
add    $0x1,%rax
ret
xor    %eax,%eax
ret
cmp    $0xdf,%cl
ja     111d <g_utf8_next_char+0x1d>
add    $0x2,%rax
ret
cmp    $0xef,%cl
ja     1127 <g_utf8_next_char+0x27>
add    $0x3,%rax
ret
add    $0x4,%rax
xor    %edx,%edx
cmp    $0xf5,%cl
cmovae %rdx,%rax
ret

LLVM IR (-O0):
define i8* @g_utf8_next_char(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = load i8, i8* %5
store i8 %6, i8* %4
%7 = load i8, i8* %4
%8 = zext i8 %7 to i32
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %1
store i8* null, i8** %2
br label %40
11: ; preds = %1
%12 = load i8, i8* %4
%13 = zext i8 %12 to i32
%14 = icmp slt i32 %13, 128
br i1 %14, label %15, label %18
15: ; preds = %11
%16 = load i8*, i8** %3
%17 = getelementptr inbounds i8, i8* %16, i64 1
store i8* %17, i8** %2
br label %40
18: ; preds = %11
%19 = load i8, i8* %4
%20 = zext i8 %19 to i32
%21 = icmp slt i32 %20, 224
br i1 %21, label %22, label %25
22: ; preds = %18
%23 = load i8*, i8** %3
%24 = getelementptr inbounds i8, i8* %23, i64 2
store i8* %24, i8** %2
br label %40
25: ; preds = %18
%26 = load i8, i8* %4
%27 = zext i8 %26 to i32
%28 = icmp slt i32 %27, 240
br i1 %28, label %29, label %32
29: ; preds = %25
%30 = load i8*, i8** %3
%31 = getelementptr inbounds i8, i8* %30, i64 3
store i8* %31, i8** %2
br label %40
32: ; preds = %25
%33 = load i8, i8* %4
%34 = zext i8 %33 to i32
%35 = icmp slt i32 %34, 245
br i1 %35, label %36, label %39
36: ; preds = %32
%37 = load i8*, i8** %3
%38 = getelementptr inbounds i8, i8* %37, i64 4
store i8* %38, i8** %2
br label %40
39: ; preds = %32
store i8* null, i8** %2
br label %40
40: ; preds = %39, %36, %29, %22, %15, %10
%41 = load i8*, i8** %2
ret i8* %41
}

LLVM IR (-O2):
define i8* @g_utf8_next_char(i8* %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %20, label %4
4: ; preds = %1
%5 = icmp sgt i8 %2, -1
br i1 %5, label %6, label %8
6: ; preds = %4
%7 = getelementptr inbounds i8, i8* %0, i64 1
br label %20
8: ; preds = %4
%9 = icmp ult i8 %2, -32
br i1 %9, label %10, label %12
10: ; preds = %8
%11 = getelementptr inbounds i8, i8* %0, i64 2
br label %20
12: ; preds = %8
%13 = icmp ult i8 %2, -16
br i1 %13, label %14, label %16
14: ; preds = %12
%15 = getelementptr inbounds i8, i8* %0, i64 3
br label %20
16: ; preds = %12
%17 = icmp ult i8 %2, -11
%18 = getelementptr inbounds i8, i8* %0, i64 4
%19 = select i1 %17, i8* %18, i8* null
br label %20
20: ; preds = %16, %1, %14, %10, %6
%21 = phi i8* [ %7, %6 ], [ %11, %10 ], [ %15, %14 ], [ null, %1 ], [ %19, %16 ]
ret i8* %21
}