#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 */
struct lexer {
  int dummy;
};

/* Variables and functions */
char lexer_next_char(struct lexer *);
int /*<<< orphan*/ lexer_roll_back(struct lexer *, int);
scalar_t__ strchr(char *, char);
int lexer_unquoted_look_ahead_count(struct lexer *lx, char *char_set) {
  char c = -1;
  int count = 0;
  int double_quote = 0;
  int single_quote = 0;
  do {
    c = lexer_next_char(lx);
    count++;
    if (double_quote || single_quote) {
      if (c == '"' && double_quote)
        double_quote = 0;
      else if (c == '\'' && single_quote)
        single_quote = 0;
    } else if (strchr(char_set, c)) {
      break;
    } else if (c == '\\') {
      lexer_next_char(lx);
      count++;
    } else if (c == '"') {
      double_quote = 1;
    } else if (c == '\'') {
      single_quote = 1;
    }
  } while (c != '\n' && c != 26);
  lexer_roll_back(lx, count);
  if (c == 26) {
    if (strchr(char_set, 26))
      return count;
    else
      return -1;
  } else if (c == '\n') {
    if (strchr(char_set, '\n'))
      return count;
    else
      return -1;
  } else
    return count;
}


x86 assembly (clang, -O0):
<lexer_unquoted_look_ahead_count>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movb   $0xff,-0x19(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <lexer_next_char@plt>
mov    %al,-0x19(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x24(%rbp)
jne    1182 <lexer_unquoted_look_ahead_count+0x52>
cmpl   $0x0,-0x28(%rbp)
je     11cd <lexer_unquoted_look_ahead_count+0x9d>
movsbl -0x19(%rbp),%eax
cmp    $0x22,%eax
jne    11a5 <lexer_unquoted_look_ahead_count+0x75>
cmpl   $0x0,-0x24(%rbp)
je     11a5 <lexer_unquoted_look_ahead_count+0x75>
movl   $0x0,-0x24(%rbp)
jmp    11c8 <lexer_unquoted_look_ahead_count+0x98>
movsbl -0x19(%rbp),%eax
cmp    $0x27,%eax
jne    11c3 <lexer_unquoted_look_ahead_count+0x93>
cmpl   $0x0,-0x28(%rbp)
je     11c3 <lexer_unquoted_look_ahead_count+0x93>
movl   $0x0,-0x28(%rbp)
jmp    11c8 <lexer_unquoted_look_ahead_count+0x98>
jmp    124e <lexer_unquoted_look_ahead_count+0x11e>
mov    -0x18(%rbp),%rdi
movsbl -0x19(%rbp),%esi
call   1030 <strchr@plt>
cmp    $0x0,%rax
je     11e9 <lexer_unquoted_look_ahead_count+0xb9>
jmp    127d <lexer_unquoted_look_ahead_count+0x14d>
movsbl -0x19(%rbp),%eax
cmp    $0x5c,%eax
jne    120d <lexer_unquoted_look_ahead_count+0xdd>
mov    -0x10(%rbp),%rdi
call   1040 <lexer_next_char@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1244 <lexer_unquoted_look_ahead_count+0x114>
movsbl -0x19(%rbp),%eax
cmp    $0x22,%eax
jne    1226 <lexer_unquoted_look_ahead_count+0xf6>
movl   $0x1,-0x24(%rbp)
jmp    123f <lexer_unquoted_look_ahead_count+0x10f>
movsbl -0x19(%rbp),%eax
cmp    $0x27,%eax
jne    123a <lexer_unquoted_look_ahead_count+0x10a>
movl   $0x1,-0x28(%rbp)
jmp    123f <lexer_unquoted_look_ahead_count+0x10f>
jmp    1244 <lexer_unquoted_look_ahead_count+0x114>
jmp    1249 <lexer_unquoted_look_ahead_count+0x119>
jmp    124e <lexer_unquoted_look_ahead_count+0x11e>
jmp    1253 <lexer_unquoted_look_ahead_count+0x123>
movsbl -0x19(%rbp),%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x29(%rbp)
je     1272 <lexer_unquoted_look_ahead_count+0x142>
movsbl -0x19(%rbp),%eax
cmp    $0x1a,%eax
setne  %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    1159 <lexer_unquoted_look_ahead_count+0x29>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%esi
call   1050 <lexer_roll_back@plt>
movsbl -0x19(%rbp),%eax
cmp    $0x1a,%eax
jne    12c5 <lexer_unquoted_look_ahead_count+0x195>
mov    -0x18(%rbp),%rdi
mov    $0x1a,%esi
call   1030 <strchr@plt>
cmp    $0x0,%rax
je     12b9 <lexer_unquoted_look_ahead_count+0x189>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1307 <lexer_unquoted_look_ahead_count+0x1d7>
movl   $0xffffffff,-0x4(%rbp)
jmp    1307 <lexer_unquoted_look_ahead_count+0x1d7>
movsbl -0x19(%rbp),%eax
cmp    $0xa,%eax
jne    1301 <lexer_unquoted_look_ahead_count+0x1d1>
mov    -0x18(%rbp),%rdi
mov    $0xa,%esi
call   1030 <strchr@plt>
cmp    $0x0,%rax
je     12f5 <lexer_unquoted_look_ahead_count+0x1c5>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1307 <lexer_unquoted_look_ahead_count+0x1d7>
movl   $0xffffffff,-0x4(%rbp)
jmp    1307 <lexer_unquoted_look_ahead_count+0x1d7>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lexer_unquoted_look_ahead_count>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,(%rsp)
mov    %rdi,%r15
xor    %r14d,%r14d
xor    %ebp,%ebp
xor    %r12d,%r12d
jmp    1174 <lexer_unquoted_look_ahead_count+0x44>
nopl   0x0(%rax)
test   %r12d,%r12d
mov    %r12d,%eax
mov    $0x0,%ecx
cmovne %ecx,%eax
cmp    $0x27,%bl
cmove  %eax,%r12d
mov    %ebx,%eax
and    $0xef,%al
mov    %r13d,%r14d
cmp    $0xa,%al
je     11f4 <lexer_unquoted_look_ahead_count+0xc4>
mov    %r15,%rdi
call   1040 <lexer_next_char@plt>
mov    %eax,%ebx
lea    0x1(%r14),%r13d
mov    %ebp,%eax
or     %r12d,%eax
je     11a0 <lexer_unquoted_look_ahead_count+0x70>
cmp    $0x22,%bl
jne    1150 <lexer_unquoted_look_ahead_count+0x20>
test   %ebp,%ebp
je     1150 <lexer_unquoted_look_ahead_count+0x20>
xor    %ebp,%ebp
jmp    1165 <lexer_unquoted_look_ahead_count+0x35>
cs nopw 0x0(%rax,%rax,1)
movsbl %bl,%esi
mov    (%rsp),%rdi
call   1030 <strchr@plt>
test   %rax,%rax
jne    11f4 <lexer_unquoted_look_ahead_count+0xc4>
cmp    $0x22,%bl
je     11d3 <lexer_unquoted_look_ahead_count+0xa3>
cmp    $0x27,%bl
je     11dd <lexer_unquoted_look_ahead_count+0xad>
cmp    $0x5c,%bl
jne    11ea <lexer_unquoted_look_ahead_count+0xba>
mov    %r15,%rdi
call   1040 <lexer_next_char@plt>
add    $0x2,%r14d
xor    %ebp,%ebp
mov    %r14d,%r13d
jmp    11ec <lexer_unquoted_look_ahead_count+0xbc>
xor    %r12d,%r12d
mov    $0x1,%ebp
jmp    1165 <lexer_unquoted_look_ahead_count+0x35>
mov    $0x1,%r12d
xor    %ebp,%ebp
jmp    1165 <lexer_unquoted_look_ahead_count+0x35>
xor    %ebp,%ebp
xor    %r12d,%r12d
jmp    1165 <lexer_unquoted_look_ahead_count+0x35>
mov    %r15,%rdi
mov    %r13d,%esi
call   1050 <lexer_roll_back@plt>
cmp    $0x1a,%bl
je     120b <lexer_unquoted_look_ahead_count+0xdb>
cmp    $0xa,%bl
jne    1220 <lexer_unquoted_look_ahead_count+0xf0>
mov    $0xa,%bl
movsbl %bl,%esi
mov    (%rsp),%rdi
call   1030 <strchr@plt>
cmp    $0x1,%rax
sbb    %eax,%eax
or     %eax,%r13d
mov    %r13d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
%struct.lexer = type { i32 }
define i32 @lexer_unquoted_look_ahead_count(%struct.lexer* %0, i8* %1) {
br label %3
3: ; preds = %28, %2
%4 = phi i32 [ 0, %2 ], [ %29, %28 ]
%5 = phi i32 [ 0, %2 ], [ %30, %28 ]
%6 = phi i32 [ 0, %2 ], [ %31, %28 ]
%7 = tail call signext i8 @lexer_next_char(%struct.lexer* %0)
%8 = add nsw i32 %4, 1
%9 = icmp ne i32 %5, 0
%10 = icmp ne i32 %6, 0
%11 = select i1 %9, i1 true, i1 %10
br i1 %11, label %12, label %19
12: ; preds = %3
%13 = icmp eq i8 %7, 34
%14 = select i1 %13, i1 %9, i1 false
br i1 %14, label %28, label %15
15: ; preds = %12
%16 = icmp eq i8 %7, 39
%17 = select i1 %16, i1 %10, i1 false
%18 = select i1 %17, i32 0, i32 %6
br label %28
19: ; preds = %3
%20 = tail call i64 @strchr(i8* %1, i8 signext %7)
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %34
22: ; preds = %19
switch i8 %7, label %27 [
i8 92, label %23
i8 34, label %28
i8 39, label %26
]
23: ; preds = %22
%24 = tail call signext i8 @lexer_next_char(%struct.lexer* %0)
%25 = add nsw i32 %4, 2
br label %28
26: ; preds = %22
br label %28
27: ; preds = %22
br label %28
28: ; preds = %22, %27, %12, %15, %23, %26
%29 = phi i32 [ %8, %15 ], [ %25, %23 ], [ %8, %26 ], [ %8, %12 ], [ %8, %22 ], [ %8, %27 ]
%30 = phi i32 [ %5, %15 ], [ 0, %23 ], [ 0, %26 ], [ 0, %12 ], [ 1, %22 ], [ 0, %27 ]
%31 = phi i32 [ %18, %15 ], [ 0, %23 ], [ 1, %26 ], [ %6, %12 ], [ 0, %22 ], [ 0, %27 ]
%32 = and i8 %7, -17
%33 = icmp eq i8 %32, 10
br i1 %33, label %34, label %3
34: ; preds = %19, %28
%35 = phi i32 [ %29, %28 ], [ %8, %19 ]
%36 = tail call i32 @lexer_roll_back(%struct.lexer* %0, i32 %35)
switch i8 %7, label %43 [
i8 26, label %38
i8 10, label %37
]
37: ; preds = %34
br label %38
38: ; preds = %34, %37
%39 = phi i8 [ 10, %37 ], [ %7, %34 ]
%40 = tail call i64 @strchr(i8* %1, i8 signext %39)
%41 = icmp eq i64 %40, 0
%42 = select i1 %41, i32 -1, i32 %35
br label %43
43: ; preds = %38, %34
%44 = phi i32 [ %35, %34 ], [ %42, %38 ]
ret i32 %44
}