#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 */
scalar_t__ match_class(int, int);
int uchar(char const);
int matchbracketclass(int c, const char *p, const char *ec) {
  int sig = 1;
  if (*(p + 1) == '^') {
    sig = 0;
    p++;
  }
  while (++p < ec) {
    if (*p == '%') {
      p++;
      if (match_class(c, uchar(*p)))
        return sig;
    } else if ((*(p + 1) == '-') && (p + 2 < ec)) {
      p += 2;
      if (uchar(*(p - 2)) <= c && c <= uchar(*p))
        return sig;
    } else if (uchar(*p) == c)
      return sig;
  }
  return !sig;
}


x86 assembly (clang, -O0):
<matchbracketclass>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x5e,%eax
jne    115e <matchbracketclass+0x3e>
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1163 <matchbracketclass+0x43>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
cmp    -0x18(%rbp),%rax
jae    126e <matchbracketclass+0x14e>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x25,%eax
jne    11cb <matchbracketclass+0xab>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <uchar@plt>
mov    -0x20(%rbp),%edi
mov    %eax,%esi
call   1040 <match_class@plt>
cmp    $0x0,%rax
je     11c6 <matchbracketclass+0xa6>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    127f <matchbracketclass+0x15f>
jmp    1269 <matchbracketclass+0x149>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x2d,%eax
jne    123f <matchbracketclass+0x11f>
mov    -0x10(%rbp),%rax
add    $0x2,%rax
cmp    -0x18(%rbp),%rax
jae    123f <matchbracketclass+0x11f>
mov    -0x10(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl -0x2(%rax),%edi
call   1030 <uchar@plt>
cmp    -0x8(%rbp),%eax
jg     123a <matchbracketclass+0x11a>
mov    -0x8(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <uchar@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
cmp    %ecx,%eax
jg     123a <matchbracketclass+0x11a>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    127f <matchbracketclass+0x15f>
jmp    1264 <matchbracketclass+0x144>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <uchar@plt>
cmp    -0x8(%rbp),%eax
jne    125f <matchbracketclass+0x13f>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    127f <matchbracketclass+0x15f>
jmp    1264 <matchbracketclass+0x144>
jmp    1269 <matchbracketclass+0x149>
jmp    1163 <matchbracketclass+0x43>
cmpl   $0x0,-0x1c(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<matchbracketclass>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0x1(%rsi),%rbp
cmpb   $0x5e,0x1(%rsi)
sete   %r14b
setne  %r15b
cmovne %rsi,%rbp
lea    0x1(%rbp),%rbx
cmp    %rdx,%rbx
jae    11df <matchbracketclass+0xbf>
mov    %rdx,%r13
mov    %edi,%r12d
jmp    1179 <matchbracketclass+0x59>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl %al,%edi
call   1030 <uchar@plt>
cmp    %r12d,%eax
je     11dc <matchbracketclass+0xbc>
mov    %rbx,%rbp
add    $0x1,%rbx
cmp    %r13,%rbx
jae    11df <matchbracketclass+0xbf>
movzbl 0x1(%rbp),%eax
movzbl 0x2(%rbp),%ecx
cmp    $0x25,%al
jne    11b0 <matchbracketclass+0x90>
movsbl %cl,%edi
call   1030 <uchar@plt>
mov    %r12d,%edi
mov    %eax,%esi
call   1040 <match_class@plt>
test   %rax,%rax
jne    11dc <matchbracketclass+0xbc>
add    $0x2,%rbp
mov    %rbp,%rbx
jmp    116d <matchbracketclass+0x4d>
cs nopw 0x0(%rax,%rax,1)
nop
cmp    $0x2d,%cl
jne    1160 <matchbracketclass+0x40>
add    $0x3,%rbp
cmp    %r13,%rbp
jae    1160 <matchbracketclass+0x40>
movsbl %al,%edi
call   1030 <uchar@plt>
cmp    %r12d,%eax
jg     11a0 <matchbracketclass+0x80>
movsbl 0x0(%rbp),%edi
call   1030 <uchar@plt>
mov    %rbp,%rbx
cmp    %r12d,%eax
jl     116d <matchbracketclass+0x4d>
mov    %r15d,%r14d
movzbl %r14b,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @matchbracketclass(i32 %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
store i32 %0, i32* %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i32 1, i32* %8
%9 = load i8*, i8** %6
%10 = getelementptr inbounds i8, i8* %9, i64 1
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %12, 94
br i1 %13, label %14, label %17
14: ; preds = %3
store i32 0, i32* %8
%15 = load i8*, i8** %6
%16 = getelementptr inbounds i8, i8* %15, i32 1
store i8* %16, i8** %6
br label %17
17: ; preds = %14, %3
br label %18
18: ; preds = %79, %17
%19 = load i8*, i8** %6
%20 = getelementptr inbounds i8, i8* %19, i32 1
store i8* %20, i8** %6
%21 = load i8*, i8** %7
%22 = icmp ult i8* %20, %21
br i1 %22, label %23, label %80
23: ; preds = %18
%24 = load i8*, i8** %6
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 37
br i1 %27, label %28, label %40
28: ; preds = %23
%29 = load i8*, i8** %6
%30 = getelementptr inbounds i8, i8* %29, i32 1
store i8* %30, i8** %6
%31 = load i32, i32* %5
%32 = load i8*, i8** %6
%33 = load i8, i8* %32
%34 = call i32 @uchar(i8 signext %33)
%35 = call i64 @match_class(i32 %31, i32 %34)
%36 = icmp ne i64 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %28
%38 = load i32, i32* %8
store i32 %38, i32* %4
br label %85
39: ; preds = %28
br label %79
40: ; preds = %23
%41 = load i8*, i8** %6
%42 = getelementptr inbounds i8, i8* %41, i64 1
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = icmp eq i32 %44, 45
br i1 %45, label %46, label %69
46: ; preds = %40
%47 = load i8*, i8** %6
%48 = getelementptr inbounds i8, i8* %47, i64 2
%49 = load i8*, i8** %7
%50 = icmp ult i8* %48, %49
br i1 %50, label %51, label %69
51: ; preds = %46
%52 = load i8*, i8** %6
%53 = getelementptr inbounds i8, i8* %52, i64 2
store i8* %53, i8** %6
%54 = load i8*, i8** %6
%55 = getelementptr inbounds i8, i8* %54, i64 -2
%56 = load i8, i8* %55
%57 = call i32 @uchar(i8 signext %56)
%58 = load i32, i32* %5
%59 = icmp sle i32 %57, %58
br i1 %59, label %60, label %68
60: ; preds = %51
%61 = load i32, i32* %5
%62 = load i8*, i8** %6
%63 = load i8, i8* %62
%64 = call i32 @uchar(i8 signext %63)
%65 = icmp sle i32 %61, %64
br i1 %65, label %66, label %68
66: ; preds = %60
%67 = load i32, i32* %8
store i32 %67, i32* %4
br label %85
68: ; preds = %60, %51
br label %78
69: ; preds = %46, %40
%70 = load i8*, i8** %6
%71 = load i8, i8* %70
%72 = call i32 @uchar(i8 signext %71)
%73 = load i32, i32* %5
%74 = icmp eq i32 %72, %73
br i1 %74, label %75, label %77
75: ; preds = %69
%76 = load i32, i32* %8
store i32 %76, i32* %4
br label %85
77: ; preds = %69
br label %78
78: ; preds = %77, %68
br label %79
79: ; preds = %78, %39
br label %18
80: ; preds = %18
%81 = load i32, i32* %8
%82 = icmp ne i32 %81, 0
%83 = xor i1 %82, true
%84 = zext i1 %83 to i32
store i32 %84, i32* %4
br label %85
85: ; preds = %80, %75, %66, %37
%86 = load i32, i32* %4
ret i32 %86
}

LLVM IR (-O2):
define i32 @matchbracketclass(i32 %0, i8* %1, i8* readnone %2) {
%4 = getelementptr inbounds i8, i8* %1, i64 1
%5 = load i8, i8* %4
%6 = icmp eq i8 %5, 94
%7 = select i1 %6, i8* %4, i8* %1
%8 = xor i1 %6, true
%9 = getelementptr inbounds i8, i8* %7, i64 1
%10 = icmp ult i8* %9, %2
br i1 %10, label %11, label %41
11: ; preds = %3, %37
%12 = phi i8* [ %39, %37 ], [ %9, %3 ]
%13 = phi i8* [ %38, %37 ], [ %7, %3 ]
%14 = load i8, i8* %12
%15 = icmp eq i8 %14, 37
%16 = getelementptr inbounds i8, i8* %13, i64 2
%17 = load i8, i8* %16
br i1 %15, label %18, label %22
18: ; preds = %11
%19 = tail call i32 @uchar(i8 signext %17)
%20 = tail call i64 @match_class(i32 %0, i32 %19)
%21 = icmp eq i64 %20, 0
br i1 %21, label %37, label %41
22: ; preds = %11
%23 = icmp eq i8 %17, 45
br i1 %23, label %24, label %34
24: ; preds = %22
%25 = getelementptr inbounds i8, i8* %13, i64 3
%26 = icmp ult i8* %25, %2
br i1 %26, label %27, label %34
27: ; preds = %24
%28 = tail call i32 @uchar(i8 signext %14)
%29 = icmp sgt i32 %28, %0
br i1 %29, label %37, label %30
30: ; preds = %27
%31 = load i8, i8* %25
%32 = tail call i32 @uchar(i8 signext %31)
%33 = icmp slt i32 %32, %0
br i1 %33, label %37, label %41
34: ; preds = %24, %22
%35 = tail call i32 @uchar(i8 signext %14)
%36 = icmp eq i32 %35, %0
br i1 %36, label %41, label %37
37: ; preds = %30, %27, %34, %18
%38 = phi i8* [ %16, %18 ], [ %25, %30 ], [ %25, %27 ], [ %12, %34 ]
%39 = getelementptr inbounds i8, i8* %38, i64 1
%40 = icmp ult i8* %39, %2
br i1 %40, label %11, label %41
41: ; preds = %18, %30, %34, %37, %3
%42 = phi i1 [ %6, %3 ], [ %6, %37 ], [ %8, %34 ], [ %8, %30 ], [ %8, %18 ]
%43 = zext i1 %42 to i32
ret i32 %43
}