#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 /*<<< orphan*/ sqlite3Fts3IsIdChar(char const);
const char *sqlite3Fts3NextToken(const char *zStr, int *pn) {
  const char *z1;
  const char *z2 = 0;
  z1 = zStr;
  while (z2 == 0) {
    char c = *z1;
    switch (c) {
    case '\0':
      return 0;
    case '\'':
    case '"':
    case '`': {
      z2 = z1;
      while (*++z2 && (*z2 != c || *++z2 == c))
        ;
      break;
    }
    case '[':
      z2 = &z1[1];
      while (*z2 && z2[0] != ']')
        z2++;
      if (*z2)
        z2++;
      break;
    default:
      if (sqlite3Fts3IsIdChar(*z1)) {
        z2 = &z1[1];
        while (sqlite3Fts3IsIdChar(*z2))
          z2++;
      } else {
        z1++;
      }
    }
  }
  *pn = (int)(z2 - z1);
  return z1;
}


x86 assembly (clang, -O0):
<sqlite3Fts3NextToken>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    12fb <sqlite3Fts3NextToken+0x1eb>
mov    -0x20(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x29(%rbp)
movsbl -0x29(%rbp),%eax
mov    %eax,-0x30(%rbp)
test   %eax,%eax
je     119c <sqlite3Fts3NextToken+0x8c>
jmp    1158 <sqlite3Fts3NextToken+0x48>
mov    -0x30(%rbp),%eax
sub    $0x22,%eax
je     11a9 <sqlite3Fts3NextToken+0x99>
jmp    1169 <sqlite3Fts3NextToken+0x59>
mov    -0x30(%rbp),%eax
sub    $0x27,%eax
je     11a9 <sqlite3Fts3NextToken+0x99>
jmp    117a <sqlite3Fts3NextToken+0x6a>
mov    -0x30(%rbp),%eax
sub    $0x5b,%eax
je     1229 <sqlite3Fts3NextToken+0x119>
jmp    118b <sqlite3Fts3NextToken+0x7b>
mov    -0x30(%rbp),%eax
sub    $0x60,%eax
je     11a9 <sqlite3Fts3NextToken+0x99>
jmp    1299 <sqlite3Fts3NextToken+0x189>
movq   $0x0,-0x8(%rbp)
jmp    1316 <sqlite3Fts3NextToken+0x206>
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x28(%rbp)
movsbl 0x1(%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x31(%rbp)
je     120f <sqlite3Fts3NextToken+0xff>
mov    -0x28(%rbp),%rax
movsbl (%rax),%ecx
movsbl -0x29(%rbp),%edx
mov    $0x1,%al
cmp    %edx,%ecx
mov    %al,-0x32(%rbp)
jne    1209 <sqlite3Fts3NextToken+0xf9>
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x28(%rbp)
movsbl 0x1(%rax),%eax
movsbl -0x29(%rbp),%ecx
cmp    %ecx,%eax
sete   %al
mov    %al,-0x32(%rbp)
mov    -0x32(%rbp),%al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
test   $0x1,%al
jne    121f <sqlite3Fts3NextToken+0x10f>
jmp    1224 <sqlite3Fts3NextToken+0x114>
jmp    11b1 <sqlite3Fts3NextToken+0xa1>
jmp    12f6 <sqlite3Fts3NextToken+0x1e6>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x33(%rbp)
je     125a <sqlite3Fts3NextToken+0x14a>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5d,%eax
setne  %al
mov    %al,-0x33(%rbp)
mov    -0x33(%rbp),%al
test   $0x1,%al
jne    126a <sqlite3Fts3NextToken+0x15a>
jmp    127b <sqlite3Fts3NextToken+0x16b>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1235 <sqlite3Fts3NextToken+0x125>
mov    -0x28(%rbp),%rax
cmpb   $0x0,(%rax)
je     1294 <sqlite3Fts3NextToken+0x184>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    12f6 <sqlite3Fts3NextToken+0x1e6>
mov    -0x20(%rbp),%rax
movsbl (%rax),%edi
call   1030 <sqlite3Fts3IsIdChar@plt>
cmp    $0x0,%eax
je     12e5 <sqlite3Fts3NextToken+0x1d5>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movsbl (%rax),%edi
call   1030 <sqlite3Fts3IsIdChar@plt>
cmp    $0x0,%eax
je     12e0 <sqlite3Fts3NextToken+0x1d0>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    12ba <sqlite3Fts3NextToken+0x1aa>
jmp    12f1 <sqlite3Fts3NextToken+0x1e1>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    12f6 <sqlite3Fts3NextToken+0x1e6>
jmp    1130 <sqlite3Fts3NextToken+0x20>
mov    -0x28(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sqlite3Fts3NextToken>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
lea    0x1(%rdi),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movzbl -0x1(%r12),%eax
movsbl %al,%edi
cmp    $0x26,%edi
jle    1150 <sqlite3Fts3NextToken+0x40>
cmp    $0x27,%edi
je     1170 <sqlite3Fts3NextToken+0x60>
cmp    $0x60,%edi
je     1170 <sqlite3Fts3NextToken+0x60>
cmp    $0x5b,%edi
jne    115d <sqlite3Fts3NextToken+0x4d>
jmp    11ae <sqlite3Fts3NextToken+0x9e>
nop
test   %edi,%edi
je     11dc <sqlite3Fts3NextToken+0xcc>
cmp    $0x22,%edi
je     1170 <sqlite3Fts3NextToken+0x60>
call   1030 <sqlite3Fts3IsIdChar@plt>
test   %eax,%eax
jne    11e1 <sqlite3Fts3NextToken+0xd1>
add    $0x1,%r12
add    $0x1,%r15d
jmp    1130 <sqlite3Fts3NextToken+0x20>
mov    (%r12),%dl
mov    %r12,%rbx
test   %dl,%dl
je     1201 <sqlite3Fts3NextToken+0xf1>
lea    -0x1(%r12),%rcx
mov    %r12,%rbx
jmp    119f <sqlite3Fts3NextToken+0x8f>
nopl   0x0(%rax)
mov    %rbx,%rcx
add    $0x1,%rbx
movzbl 0x1(%rcx),%edx
test   %dl,%dl
je     1201 <sqlite3Fts3NextToken+0xf1>
cmp    %al,%dl
jne    1190 <sqlite3Fts3NextToken+0x80>
lea    0x2(%rcx),%rbx
cmp    %al,0x2(%rcx)
je     1190 <sqlite3Fts3NextToken+0x80>
jmp    1201 <sqlite3Fts3NextToken+0xf1>
mov    %r12,%rax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movzbl (%rax),%ecx
add    $0x1,%rax
cmp    $0x5d,%cl
je     11d0 <sqlite3Fts3NextToken+0xc0>
test   %cl,%cl
jne    11c0 <sqlite3Fts3NextToken+0xb0>
lea    -0x1(%rax),%rbx
test   %cl,%cl
cmovne %rax,%rbx
jmp    1201 <sqlite3Fts3NextToken+0xf1>
xor    %r12d,%r12d
jmp    120b <sqlite3Fts3NextToken+0xfb>
lea    -0x1(%r12),%rbx
cs nopw 0x0(%rax,%rax,1)
movsbl 0x1(%rbx),%edi
add    $0x1,%rbx
call   1030 <sqlite3Fts3IsIdChar@plt>
test   %eax,%eax
jne    11f0 <sqlite3Fts3NextToken+0xe0>
sub    %r15d,%ebx
mov    %ebx,(%r14)
add    $0xffffffffffffffff,%r12
mov    %r12,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @sqlite3Fts3NextToken(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8
store i8* %0, i8** %4
store i32* %1, i32** %5
store i8* null, i8** %7
%9 = load i8*, i8** %4
store i8* %9, i8** %6
br label %10
10: ; preds = %96, %2
%11 = load i8*, i8** %7
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %97
13: ; preds = %10
%14 = load i8*, i8** %6
%15 = load i8, i8* %14
store i8 %15, i8* %8
%16 = load i8, i8* %8
%17 = sext i8 %16 to i32
switch i32 %17, label %75 [
i32 0, label %18
i32 39, label %19
i32 34, label %19
i32 96, label %19
i32 91, label %48
]
18: ; preds = %13
store i8* null, i8** %3
br label %106
19: ; preds = %13, %13, %13
%20 = load i8*, i8** %6
store i8* %20, i8** %7
br label %21
21: ; preds = %46, %19
%22 = load i8*, i8** %7
%23 = getelementptr inbounds i8, i8* %22, i32 1
store i8* %23, i8** %7
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %44
27: ; preds = %21
%28 = load i8*, i8** %7
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = load i8, i8* %8
%32 = sext i8 %31 to i32
%33 = icmp ne i32 %30, %32
br i1 %33, label %42, label %34
34: ; preds = %27
%35 = load i8*, i8** %7
%36 = getelementptr inbounds i8, i8* %35, i32 1
store i8* %36, i8** %7
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = load i8, i8* %8
%40 = sext i8 %39 to i32
%41 = icmp eq i32 %38, %40
br label %42
42: ; preds = %34, %27
%43 = phi i1 [ true, %27 ], [ %41, %34 ]
br label %44
44: ; preds = %42, %21
%45 = phi i1 [ false, %21 ], [ %43, %42 ]
br i1 %45, label %46, label %47
46: ; preds = %44
br label %21
47: ; preds = %44
br label %96
48: ; preds = %13
%49 = load i8*, i8** %6
%50 = getelementptr inbounds i8, i8* %49, i64 1
store i8* %50, i8** %7
br label %51
51: ; preds = %64, %48
%52 = load i8*, i8** %7
%53 = load i8, i8* %52
%54 = sext i8 %53 to i32
%55 = icmp ne i32 %54, 0
br i1 %55, label %56, label %62
56: ; preds = %51
%57 = load i8*, i8** %7
%58 = getelementptr inbounds i8, i8* %57, i64 0
%59 = load i8, i8* %58
%60 = sext i8 %59 to i32
%61 = icmp ne i32 %60, 93
br label %62
62: ; preds = %56, %51
%63 = phi i1 [ false, %51 ], [ %61, %56 ]
br i1 %63, label %64, label %67
64: ; preds = %62
%65 = load i8*, i8** %7
%66 = getelementptr inbounds i8, i8* %65, i32 1
store i8* %66, i8** %7
br label %51
67: ; preds = %62
%68 = load i8*, i8** %7
%69 = load i8, i8* %68
%70 = icmp ne i8 %69, 0
br i1 %70, label %71, label %74
71: ; preds = %67
%72 = load i8*, i8** %7
%73 = getelementptr inbounds i8, i8* %72, i32 1
store i8* %73, i8** %7
br label %74
74: ; preds = %71, %67
br label %96
75: ; preds = %13
%76 = load i8*, i8** %6
%77 = load i8, i8* %76
%78 = call i32 @sqlite3Fts3IsIdChar(i8 signext %77)
%79 = icmp ne i32 %78, 0
br i1 %79, label %80, label %92
80: ; preds = %75
%81 = load i8*, i8** %6
%82 = getelementptr inbounds i8, i8* %81, i64 1
store i8* %82, i8** %7
br label %83
83: ; preds = %88, %80
%84 = load i8*, i8** %7
%85 = load i8, i8* %84
%86 = call i32 @sqlite3Fts3IsIdChar(i8 signext %85)
%87 = icmp ne i32 %86, 0
br i1 %87, label %88, label %91
88: ; preds = %83
%89 = load i8*, i8** %7
%90 = getelementptr inbounds i8, i8* %89, i32 1
store i8* %90, i8** %7
br label %83
91: ; preds = %83
br label %95
92: ; preds = %75
%93 = load i8*, i8** %6
%94 = getelementptr inbounds i8, i8* %93, i32 1
store i8* %94, i8** %6
br label %95
95: ; preds = %92, %91
br label %96
96: ; preds = %95, %74, %47
br label %10
97: ; preds = %10
%98 = load i8*, i8** %7
%99 = load i8*, i8** %6
%100 = ptrtoint i8* %98 to i64
%101 = ptrtoint i8* %99 to i64
%102 = sub i64 %100, %101
%103 = trunc i64 %102 to i32
%104 = load i32*, i32** %5
store i32 %103, i32* %104
%105 = load i8*, i8** %6
store i8* %105, i8** %3
br label %106
106: ; preds = %97, %18
%107 = load i8*, i8** %3
ret i8* %107
}

LLVM IR (-O2):
define i8* @sqlite3Fts3NextToken(i8* %0, i32* nocapture writeonly %1) {
br label %3
3: ; preds = %42, %2
%4 = phi i8* [ %0, %2 ], [ %43, %42 ]
%5 = load i8, i8* %4
%6 = sext i8 %5 to i32
switch i32 %6, label %33 [
i32 0, label %50
i32 39, label %7
i32 34, label %7
i32 96, label %7
i32 91, label %25
]
7: ; preds = %3, %3, %3
%8 = getelementptr inbounds i8, i8* %4, i64 1
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 0
br i1 %10, label %44, label %11
11: ; preds = %7, %20
%12 = phi i8 [ %23, %20 ], [ %9, %7 ]
%13 = phi i8* [ %22, %20 ], [ %8, %7 ]
%14 = phi i8* [ %21, %20 ], [ %4, %7 ]
%15 = icmp eq i8 %12, %5
br i1 %15, label %16, label %20
16: ; preds = %11
%17 = getelementptr inbounds i8, i8* %14, i64 2
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, %5
br i1 %19, label %20, label %44
20: ; preds = %11, %16
%21 = phi i8* [ %13, %11 ], [ %17, %16 ]
%22 = getelementptr inbounds i8, i8* %21, i64 1
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 0
br i1 %24, label %44, label %11
25: ; preds = %3, %25
%26 = phi i8* [ %27, %25 ], [ %4, %3 ]
%27 = getelementptr inbounds i8, i8* %26, i64 1
%28 = load i8, i8* %27
switch i8 %28, label %25 [
i8 0, label %29
i8 93, label %29
]
29: ; preds = %25, %25
%30 = icmp eq i8 %28, 0
%31 = getelementptr inbounds i8, i8* %26, i64 2
%32 = select i1 %30, i8* %27, i8* %31
br label %44
33: ; preds = %3
%34 = tail call i32 @sqlite3Fts3IsIdChar(i8 signext %5)
%35 = icmp eq i32 %34, 0
br i1 %35, label %42, label %36
36: ; preds = %33, %36
%37 = phi i8* [ %38, %36 ], [ %4, %33 ]
%38 = getelementptr inbounds i8, i8* %37, i64 1
%39 = load i8, i8* %38
%40 = tail call i32 @sqlite3Fts3IsIdChar(i8 signext %39)
%41 = icmp eq i32 %40, 0
br i1 %41, label %44, label %36
42: ; preds = %33
%43 = getelementptr inbounds i8, i8* %4, i64 1
br label %3
44: ; preds = %20, %16, %36, %29, %7
%45 = phi i8* [ %8, %7 ], [ %32, %29 ], [ %38, %36 ], [ %17, %16 ], [ %22, %20 ]
%46 = ptrtoint i8* %45 to i64
%47 = ptrtoint i8* %4 to i64
%48 = sub i64 %46, %47
%49 = trunc i64 %48 to i32
store i32 %49, i32* %1
br label %50
50: ; preds = %3, %44
%51 = phi i8* [ %4, %44 ], [ null, %3 ]
ret i8* %51
}