#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 */
int u8_rune_length(char const *);
int u8_rune_length_xml(const char *p) {
  int length = u8_rune_length(p);
  if (length == 1) {
    if (*p != '\x09' && *p != '\x0a' && *p != '\x0d' && *p < '\x20')
      return -1;
  }
  if (length == 3) {
    if (*p == '\xef' && *(p + 1) == '\xbf' &&
        ((*(p + 2) == '\xbe') || (*(p + 2) == '\xbf')))
      return -1;
  }
  return length;
}


x86 assembly (clang, -O0):
<u8_rune_length_xml>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <u8_rune_length@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
jne    1183 <u8_rune_length_xml+0x73>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x9,%eax
je     117e <u8_rune_length_xml+0x6e>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
je     117e <u8_rune_length_xml+0x6e>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xd,%eax
je     117e <u8_rune_length_xml+0x6e>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jge    117e <u8_rune_length_xml+0x6e>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e7 <u8_rune_length_xml+0xd7>
jmp    1183 <u8_rune_length_xml+0x73>
cmpl   $0x3,-0x14(%rbp)
jne    11e1 <u8_rune_length_xml+0xd1>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xffffffef,%eax
jne    11dc <u8_rune_length_xml+0xcc>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0xffffffbf,%eax
jne    11dc <u8_rune_length_xml+0xcc>
mov    -0x10(%rbp),%rax
movsbl 0x2(%rax),%eax
cmp    $0xffffffbe,%eax
je     11d0 <u8_rune_length_xml+0xc0>
mov    -0x10(%rbp),%rax
movsbl 0x2(%rax),%eax
cmp    $0xffffffbf,%eax
jne    11dc <u8_rune_length_xml+0xcc>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e7 <u8_rune_length_xml+0xd7>
jmp    11e1 <u8_rune_length_xml+0xd1>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<u8_rune_length_xml>:
push   %rbx
mov    %rdi,%rbx
call   1030 <u8_rune_length@plt>
cmp    $0x3,%eax
je     1143 <u8_rune_length_xml+0x33>
cmp    $0x1,%eax
jne    115e <u8_rune_length_xml+0x4e>
movzbl (%rbx),%edx
cmp    $0xd,%rdx
ja     1137 <u8_rune_length_xml+0x27>
mov    $0x2600,%ecx
bt     %rdx,%rcx
jb     115e <u8_rune_length_xml+0x4e>
mov    $0xffffffff,%ecx
cmp    $0x20,%dl
jge    115e <u8_rune_length_xml+0x4e>
jmp    1160 <u8_rune_length_xml+0x50>
cmpb   $0xef,(%rbx)
jne    115e <u8_rune_length_xml+0x4e>
cmpb   $0xbf,0x1(%rbx)
jne    115e <u8_rune_length_xml+0x4e>
mov    0x2(%rbx),%dl
and    $0xfe,%dl
mov    $0xffffffff,%ecx
cmp    $0xbe,%dl
je     1160 <u8_rune_length_xml+0x50>
mov    %eax,%ecx
mov    %ecx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @u8_rune_length_xml(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i32 @u8_rune_length(i8* %5)
store i32 %6, i32* %4
%7 = load i32, i32* %4
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %31
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 9
br i1 %13, label %14, label %30
14: ; preds = %9
%15 = load i8*, i8** %3
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %17, 10
br i1 %18, label %19, label %30
19: ; preds = %14
%20 = load i8*, i8** %3
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %22, 13
br i1 %23, label %24, label %30
24: ; preds = %19
%25 = load i8*, i8** %3
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp slt i32 %27, 32
br i1 %28, label %29, label %30
29: ; preds = %24
store i32 -1, i32* %2
br label %61
30: ; preds = %24, %19, %14, %9
br label %31
31: ; preds = %30, %1
%32 = load i32, i32* %4
%33 = icmp eq i32 %32, 3
br i1 %33, label %34, label %59
34: ; preds = %31
%35 = load i8*, i8** %3
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp eq i32 %37, -17
br i1 %38, label %39, label %58
39: ; preds = %34
%40 = load i8*, i8** %3
%41 = getelementptr inbounds i8, i8* %40, i64 1
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %43, -65
br i1 %44, label %45, label %58
45: ; preds = %39
%46 = load i8*, i8** %3
%47 = getelementptr inbounds i8, i8* %46, i64 2
%48 = load i8, i8* %47
%49 = sext i8 %48 to i32
%50 = icmp eq i32 %49, -66
br i1 %50, label %57, label %51
51: ; preds = %45
%52 = load i8*, i8** %3
%53 = getelementptr inbounds i8, i8* %52, i64 2
%54 = load i8, i8* %53
%55 = sext i8 %54 to i32
%56 = icmp eq i32 %55, -65
br i1 %56, label %57, label %58
57: ; preds = %51, %45
store i32 -1, i32* %2
br label %61
58: ; preds = %51, %39, %34
br label %59
59: ; preds = %58, %31
%60 = load i32, i32* %4
store i32 %60, i32* %2
br label %61
61: ; preds = %59, %57, %29
%62 = load i32, i32* %2
ret i32 %62
}

LLVM IR (-O2):
define i32 @u8_rune_length_xml(i8* %0) {
%2 = tail call i32 @u8_rune_length(i8* %0)
switch i32 %2, label %19 [
i32 1, label %3
i32 3, label %7
]
3: ; preds = %1
%4 = load i8, i8* %0
switch i8 %4, label %5 [
i8 9, label %19
i8 10, label %19
i8 13, label %19
]
5: ; preds = %3
%6 = icmp slt i8 %4, 32
br i1 %6, label %20, label %19
7: ; preds = %1
%8 = load i8, i8* %0
%9 = icmp eq i8 %8, -17
br i1 %9, label %10, label %19
10: ; preds = %7
%11 = getelementptr inbounds i8, i8* %0, i64 1
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, -65
br i1 %13, label %14, label %19
14: ; preds = %10
%15 = getelementptr inbounds i8, i8* %0, i64 2
%16 = load i8, i8* %15
%17 = and i8 %16, -2
%18 = icmp eq i8 %17, -66
br i1 %18, label %20, label %19
19: ; preds = %5, %3, %3, %3, %14, %1, %7, %10
br label %20
20: ; preds = %14, %5, %19
%21 = phi i32 [ %2, %19 ], [ -1, %5 ], [ -1, %14 ]
ret i32 %21
}