#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 int readNextName(char *, char **, char **, unsigned int *);
unsigned int readNextValue(char *, char **, char **, unsigned char *);
unsigned int validateIdentifier(char *, unsigned char *);
unsigned int validateExpression(char *rule, unsigned char *expressionType) {
  char *first;
  char *last;
  unsigned char type;
  unsigned int hash;
  unsigned int result;
  result = readNextName(rule, &first, &last, &hash);
  if (result != 0) {
    return result;
  }
  if (hash != 4081054038 && hash != 1040718071 && hash != 304370403 &&
      hash != 130502) {
    return validateIdentifier(rule, expressionType);
  } else {
    result = readNextValue(last, &first, &last, &type);
    if (result != 0) {
      return result;
    }
    *expressionType = 0;
    result = readNextName(first, &first, &last, &hash);
    while (result == 0) {
      unsigned char newExpressionType = 0;
      do {
        if (readNextValue(last, &first, &last, &type) != 0) {
          return readNextValue(last, &first, &last, &type);
        }
      } while (0);
      if (type == 0x06) {
        do {
          unsigned int result = validateExpression(first, &newExpressionType);
          if (result != 0) {
            return result;
          }
        } while (0);
      }
      if (newExpressionType == 0x09 || newExpressionType == 0x0C) {
        if (*expressionType == 0x0A) {
          return 102;
        }
        *expressionType = 0x0C;
      }
      if (newExpressionType == 0x0A || newExpressionType == 0x0D) {
        if (*expressionType == 0x09) {
          return 102;
        }
        *expressionType = 0x0C;
      }
      if (hash != 1706836109 && hash != 1203507539) {
        return 105;
      }
      result = readNextName(last, &first, &last, &hash);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<validateExpression>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x28(%rbp),%rdx
lea    -0x30(%rbp),%rcx
call   1060 <readNextName@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
je     117d <validateExpression+0x3d>
mov    -0x34(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    136e <validateExpression+0x22e>
mov    -0x30(%rbp),%eax
mov    $0xf33ff156,%ecx
cmp    %rcx,%rax
je     11ca <validateExpression+0x8a>
cmpl   $0x3e0818f7,-0x30(%rbp)
je     11ca <validateExpression+0x8a>
cmpl   $0x122452e3,-0x30(%rbp)
je     11ca <validateExpression+0x8a>
cmpl   $0x1fdc6,-0x30(%rbp)
je     11ca <validateExpression+0x8a>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <validateIdentifier@plt>
mov    %eax,-0x4(%rbp)
jmp    136e <validateExpression+0x22e>
mov    -0x28(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x28(%rbp),%rdx
lea    -0x29(%rbp),%rcx
call   1040 <readNextValue@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
je     11f7 <validateExpression+0xb7>
mov    -0x34(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    136e <validateExpression+0x22e>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x28(%rbp),%rdx
lea    -0x30(%rbp),%rcx
call   1060 <readNextName@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jne    1362 <validateExpression+0x222>
movb   $0x0,-0x35(%rbp)
mov    -0x28(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x28(%rbp),%rdx
lea    -0x29(%rbp),%rcx
call   1040 <readNextValue@plt>
cmp    $0x0,%eax
je     125f <validateExpression+0x11f>
mov    -0x28(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x28(%rbp),%rdx
lea    -0x29(%rbp),%rcx
call   1040 <readNextValue@plt>
mov    %eax,-0x4(%rbp)
jmp    136e <validateExpression+0x22e>
jmp    1264 <validateExpression+0x124>
movzbl -0x29(%rbp),%eax
cmp    $0x6,%eax
jne    12a5 <validateExpression+0x165>
jmp    1276 <validateExpression+0x136>
mov    -0x20(%rbp),%rdi
lea    -0x35(%rbp),%rsi
call   1030 <validateExpression@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
je     129b <validateExpression+0x15b>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    136e <validateExpression+0x22e>
jmp    12a0 <validateExpression+0x160>
jmp    12a5 <validateExpression+0x165>
movzbl -0x35(%rbp),%eax
cmp    $0x9,%eax
je     12bf <validateExpression+0x17f>
movzbl -0x35(%rbp),%eax
cmp    $0xc,%eax
jne    12e2 <validateExpression+0x1a2>
mov    -0x18(%rbp),%rax
movzbl (%rax),%eax
cmp    $0xa,%eax
jne    12db <validateExpression+0x19b>
movl   $0x66,-0x4(%rbp)
jmp    136e <validateExpression+0x22e>
mov    -0x18(%rbp),%rax
movb   $0xc,(%rax)
movzbl -0x35(%rbp),%eax
cmp    $0xa,%eax
je     12fc <validateExpression+0x1bc>
movzbl -0x35(%rbp),%eax
cmp    $0xd,%eax
jne    131f <validateExpression+0x1df>
mov    -0x18(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x9,%eax
jne    1318 <validateExpression+0x1d8>
movl   $0x66,-0x4(%rbp)
jmp    136e <validateExpression+0x22e>
mov    -0x18(%rbp),%rax
movb   $0xc,(%rax)
cmpl   $0x65bc408d,-0x30(%rbp)
je     1345 <validateExpression+0x205>
cmpl   $0x47bc1153,-0x30(%rbp)
je     1345 <validateExpression+0x205>
movl   $0x69,-0x4(%rbp)
jmp    136e <validateExpression+0x22e>
mov    -0x28(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x28(%rbp),%rdx
lea    -0x30(%rbp),%rcx
call   1060 <readNextName@plt>
mov    %eax,-0x34(%rbp)
jmp    1216 <validateExpression+0xd6>
jmp    1367 <validateExpression+0x227>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<validateExpression>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r13
mov    %rdi,%rbx
lea    0x10(%rsp),%rsi
lea    0x8(%rsp),%rdx
lea    0x4(%rsp),%rcx
call   1060 <readNextName@plt>
mov    %eax,%ebp
test   %eax,%eax
jne    12cc <validateExpression+0x18c>
mov    0x4(%rsp),%eax
cmp    $0x122452e2,%eax
jg     1190 <validateExpression+0x50>
cmp    $0xf33ff156,%eax
je     11a2 <validateExpression+0x62>
cmp    $0x1fdc6,%eax
je     11a2 <validateExpression+0x62>
jmp    12bf <validateExpression+0x17f>
cmp    $0x122452e3,%eax
je     11a2 <validateExpression+0x62>
cmp    $0x3e0818f7,%eax
jne    12bf <validateExpression+0x17f>
mov    0x8(%rsp),%rdi
lea    0x10(%rsp),%rsi
lea    0x8(%rsp),%rdx
lea    0x2(%rsp),%rcx
call   1040 <readNextValue@plt>
mov    %eax,%ebp
test   %eax,%eax
jne    12cc <validateExpression+0x18c>
movb   $0x0,0x0(%r13)
mov    0x10(%rsp),%rdi
lea    0x10(%rsp),%rsi
lea    0x8(%rsp),%rdx
lea    0x4(%rsp),%rcx
call   1060 <readNextName@plt>
xor    %ebp,%ebp
test   %eax,%eax
jne    12cc <validateExpression+0x18c>
lea    0x10(%rsp),%r14
lea    0x8(%rsp),%r15
lea    0x2(%rsp),%r12
lea    0xdfd(%rip),%rbx
jmp    122d <validateExpression+0xed>
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x8(%rsp),%rdi
mov    %r14,%rsi
mov    %r15,%rdx
lea    0x4(%rsp),%rcx
call   1060 <readNextName@plt>
test   %eax,%eax
jne    12cc <validateExpression+0x18c>
movb   $0x0,0x3(%rsp)
mov    0x8(%rsp),%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %r12,%rcx
call   1040 <readNextValue@plt>
test   %eax,%eax
jne    12dd <validateExpression+0x19d>
cmpb   $0x6,0x2(%rsp)
jne    1267 <validateExpression+0x127>
mov    0x10(%rsp),%rdi
lea    0x3(%rsp),%rsi
call   1030 <validateExpression@plt>
test   %eax,%eax
jne    12ca <validateExpression+0x18a>
movzbl 0x3(%rsp),%eax
lea    -0x9(%rax),%ecx
cmp    $0x4,%cl
ja     129e <validateExpression+0x15e>
movzbl %cl,%ecx
movslq (%rbx,%rcx,4),%rcx
add    %rbx,%rcx
jmp    *%rcx
cmpb   $0xa,0x0(%r13)
je     12f8 <validateExpression+0x1b8>
movb   $0xc,0x0(%r13)
cmp    $0xa,%al
je     1299 <validateExpression+0x159>
jmp    129e <validateExpression+0x15e>
cmpb   $0x9,0x0(%r13)
je     12f8 <validateExpression+0x1b8>
movb   $0xc,0x0(%r13)
mov    0x4(%rsp),%eax
cmp    $0x47bc1153,%eax
je     1210 <validateExpression+0xd0>
cmp    $0x65bc408d,%eax
je     1210 <validateExpression+0xd0>
mov    $0x69,%ebp
jmp    12cc <validateExpression+0x18c>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1050 <validateIdentifier@plt>
mov    %eax,%ebp
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x8(%rsp),%rdi
lea    0x10(%rsp),%rsi
lea    0x8(%rsp),%rdx
lea    0x2(%rsp),%rcx
call   1040 <readNextValue@plt>
jmp    12ca <validateExpression+0x18a>
mov    $0x66,%ebp
jmp    12cc <validateExpression+0x18c>

LLVM IR (-O0):
define i32 @validateExpression(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8
%12 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%13 = load i8*, i8** %4
%14 = call i32 @readNextName(i8* %13, i8** %6, i8** %7, i32* %9)
store i32 %14, i32* %10
%15 = load i32, i32* %10
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %2
%18 = load i32, i32* %10
store i32 %18, i32* %3
br label %117
19: ; preds = %2
%20 = load i32, i32* %9
%21 = zext i32 %20 to i64
%22 = icmp ne i64 %21, 4081054038
br i1 %22, label %23, label %36
23: ; preds = %19
%24 = load i32, i32* %9
%25 = icmp ne i32 %24, 1040718071
br i1 %25, label %26, label %36
26: ; preds = %23
%27 = load i32, i32* %9
%28 = icmp ne i32 %27, 304370403
br i1 %28, label %29, label %36
29: ; preds = %26
%30 = load i32, i32* %9
%31 = icmp ne i32 %30, 130502
br i1 %31, label %32, label %36
32: ; preds = %29
%33 = load i8*, i8** %4
%34 = load i8*, i8** %5
%35 = call i32 @validateIdentifier(i8* %33, i8* %34)
store i32 %35, i32* %3
br label %117
36: ; preds = %29, %26, %23, %19
%37 = load i8*, i8** %7
%38 = call i32 @readNextValue(i8* %37, i8** %6, i8** %7, i8* %8)
store i32 %38, i32* %10
%39 = load i32, i32* %10
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %43
41: ; preds = %36
%42 = load i32, i32* %10
store i32 %42, i32* %3
br label %117
43: ; preds = %36
%44 = load i8*, i8** %5
store i8 0, i8* %44
%45 = load i8*, i8** %6
%46 = call i32 @readNextName(i8* %45, i8** %6, i8** %7, i32* %9)
store i32 %46, i32* %10
br label %47
47: ; preds = %112, %43
%48 = load i32, i32* %10
%49 = icmp eq i32 %48, 0
br i1 %49, label %50, label %115
50: ; preds = %47
store i8 0, i8* %11
br label %51
51: ; preds = %50
%52 = load i8*, i8** %7
%53 = call i32 @readNextValue(i8* %52, i8** %6, i8** %7, i8* %8)
%54 = icmp ne i32 %53, 0
br i1 %54, label %55, label %58
55: ; preds = %51
%56 = load i8*, i8** %7
%57 = call i32 @readNextValue(i8* %56, i8** %6, i8** %7, i8* %8)
store i32 %57, i32* %3
br label %117
58: ; preds = %51
br label %59
59: ; preds = %58
%60 = load i8, i8* %8
%61 = zext i8 %60 to i32
%62 = icmp eq i32 %61, 6
br i1 %62, label %63, label %73
63: ; preds = %59
br label %64
64: ; preds = %63
%65 = load i8*, i8** %6
%66 = call i32 @validateExpression(i8* %65, i8* %11)
store i32 %66, i32* %12
%67 = load i32, i32* %12
%68 = icmp ne i32 %67, 0
br i1 %68, label %69, label %71
69: ; preds = %64
%70 = load i32, i32* %12
store i32 %70, i32* %3
br label %117
71: ; preds = %64
br label %72
72: ; preds = %71
br label %73
73: ; preds = %72, %59
%74 = load i8, i8* %11
%75 = zext i8 %74 to i32
%76 = icmp eq i32 %75, 9
br i1 %76, label %81, label %77
77: ; preds = %73
%78 = load i8, i8* %11
%79 = zext i8 %78 to i32
%80 = icmp eq i32 %79, 12
br i1 %80, label %81, label %89
81: ; preds = %77, %73
%82 = load i8*, i8** %5
%83 = load i8, i8* %82
%84 = zext i8 %83 to i32
%85 = icmp eq i32 %84, 10
br i1 %85, label %86, label %87
86: ; preds = %81
store i32 102, i32* %3
br label %117
87: ; preds = %81
%88 = load i8*, i8** %5
store i8 12, i8* %88
br label %89
89: ; preds = %87, %77
%90 = load i8, i8* %11
%91 = zext i8 %90 to i32
%92 = icmp eq i32 %91, 10
br i1 %92, label %97, label %93
93: ; preds = %89
%94 = load i8, i8* %11
%95 = zext i8 %94 to i32
%96 = icmp eq i32 %95, 13
br i1 %96, label %97, label %105
97: ; preds = %93, %89
%98 = load i8*, i8** %5
%99 = load i8, i8* %98
%100 = zext i8 %99 to i32
%101 = icmp eq i32 %100, 9
br i1 %101, label %102, label %103
102: ; preds = %97
store i32 102, i32* %3
br label %117
103: ; preds = %97
%104 = load i8*, i8** %5
store i8 12, i8* %104
br label %105
105: ; preds = %103, %93
%106 = load i32, i32* %9
%107 = icmp ne i32 %106, 1706836109
br i1 %107, label %108, label %112
108: ; preds = %105
%109 = load i32, i32* %9
%110 = icmp ne i32 %109, 1203507539
br i1 %110, label %111, label %112
111: ; preds = %108
store i32 105, i32* %3
br label %117
112: ; preds = %108, %105
%113 = load i8*, i8** %7
%114 = call i32 @readNextName(i8* %113, i8** %6, i8** %7, i32* %9)
store i32 %114, i32* %10
br label %47
115: ; preds = %47
br label %116
116: ; preds = %115
store i32 0, i32* %3
br label %117
117: ; preds = %116, %111, %102, %86, %69, %55, %41, %32, %17
%118 = load i32, i32* %3
ret i32 %118
}

LLVM IR (-O2):
define i32 @validateExpression(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8
%6 = alloca i32
%7 = alloca i8
%8 = bitcast i8** %3 to i8*
%9 = bitcast i8** %4 to i8*
%10 = bitcast i32* %6 to i8*
%11 = call i32 @readNextName(i8* %0, i8** %3, i8** %4, i32* %6)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %58
13: ; preds = %2
%14 = load i32, i32* %6
switch i32 %14, label %15 [
i32 -213913258, label %17
i32 1040718071, label %17
i32 304370403, label %17
i32 130502, label %17
]
15: ; preds = %13
%16 = call i32 @validateIdentifier(i8* %0, i8* %1)
br label %58
17: ; preds = %13, %13, %13, %13
%18 = load i8*, i8** %4
%19 = call i32 @readNextValue(i8* %18, i8** %3, i8** %4, i8* %5)
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %58
21: ; preds = %17
store i8 0, i8* %1
%22 = load i8*, i8** %3
%23 = call i32 @readNextName(i8* %22, i8** %3, i8** %4, i32* %6)
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %58
25: ; preds = %21, %54
store i8 0, i8* %7
%26 = load i8*, i8** %4
%27 = call i32 @readNextValue(i8* %26, i8** %3, i8** %4, i8* %5)
%28 = icmp eq i32 %27, 0
br i1 %28, label %32, label %29
29: ; preds = %25
%30 = load i8*, i8** %4
%31 = call i32 @readNextValue(i8* %30, i8** %3, i8** %4, i8* %5)
br label %52
32: ; preds = %25
%33 = load i8, i8* %5
%34 = icmp eq i8 %33, 6
br i1 %34, label %35, label %39
35: ; preds = %32
%36 = load i8*, i8** %3
%37 = call i32 @validateExpression(i8* %36, i8* %7)
%38 = icmp eq i32 %37, 0
br i1 %38, label %39, label %52
39: ; preds = %35, %32
%40 = load i8, i8* %7
switch i8 %40, label %50 [
i8 12, label %41
i8 9, label %41
i8 13, label %46
i8 10, label %46
]
41: ; preds = %39, %39
%42 = load i8, i8* %1
%43 = icmp eq i8 %42, 10
br i1 %43, label %52, label %44
44: ; preds = %41
store i8 12, i8* %1
%45 = icmp eq i8 %40, 10
br i1 %45, label %49, label %50
46: ; preds = %39, %39
%47 = load i8, i8* %1
%48 = icmp eq i8 %47, 9
br i1 %48, label %52, label %49
49: ; preds = %44, %46
store i8 12, i8* %1
br label %50
50: ; preds = %44, %39, %49
%51 = load i32, i32* %6
switch i32 %51, label %52 [
i32 1706836109, label %54
i32 1203507539, label %54
]
52: ; preds = %35, %41, %46, %50, %29
%53 = phi i32 [ %31, %29 ], [ %37, %35 ], [ 102, %41 ], [ 102, %46 ], [ 105, %50 ]
br label %58
54: ; preds = %50, %50
%55 = load i8*, i8** %4
%56 = call i32 @readNextName(i8* %55, i8** %3, i8** %4, i32* %6)
%57 = icmp eq i32 %56, 0
br i1 %57, label %25, label %58
58: ; preds = %54, %21, %52, %17, %2, %15
%59 = phi i32 [ %16, %15 ], [ %11, %2 ], [ %19, %17 ], [ %53, %52 ], [ 0, %21 ], [ 0, %54 ]
ret i32 %59
}