#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 matchbracketclass(int, char *, char *);
int matchclass(int, unsigned char);
int luaI_singlematch(int c, char *p, char *ep) {
  switch (*p) {
  case '.':
    return 1;
  case '%':
    return matchclass(c, (unsigned char)*(p + 1));
  case '[':
    return matchbracketclass(c, p, ep - 1);
  default:
    return ((unsigned char)*p == c);
  }
}


x86 assembly (clang, -O0):
<luaI_singlematch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x1c(%rbp)
sub    $0x25,%eax
je     1179 <luaI_singlematch+0x59>
jmp    114b <luaI_singlematch+0x2b>
mov    -0x1c(%rbp),%eax
sub    $0x2e,%eax
je     116d <luaI_singlematch+0x4d>
jmp    115c <luaI_singlematch+0x3c>
mov    -0x1c(%rbp),%eax
sub    $0x5b,%eax
je     1191 <luaI_singlematch+0x71>
jmp    11ad <luaI_singlematch+0x8d>
movl   $0x1,-0x4(%rbp)
jmp    11c2 <luaI_singlematch+0xa2>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rax
movzbl 0x1(%rax),%esi
call   1040 <matchclass@plt>
mov    %eax,-0x4(%rbp)
jmp    11c2 <luaI_singlematch+0xa2>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
add    $0xffffffffffffffff,%rdx
call   1030 <matchbracketclass@plt>
mov    %eax,-0x4(%rbp)
jmp    11c2 <luaI_singlematch+0xa2>
mov    -0x10(%rbp),%rax
movzbl (%rax),%eax
cmp    -0x8(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<luaI_singlematch>:
movsbl (%rsi),%eax
cmp    $0x5b,%eax
je     113b <luaI_singlematch+0x1b>
cmp    $0x2e,%eax
je     1144 <luaI_singlematch+0x24>
cmp    $0x25,%eax
jne    114a <luaI_singlematch+0x2a>
movzbl 0x1(%rsi),%esi
jmp    1040 <matchclass@plt>
add    $0xffffffffffffffff,%rdx
jmp    1030 <matchbracketclass@plt>
mov    $0x1,%eax
ret
movzbl %al,%ecx
xor    %eax,%eax
cmp    %edi,%ecx
sete   %al
ret

LLVM IR (-O0):
define i32 @luaI_singlematch(i32 %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
store i32 %0, i32* %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%8 = load i8*, i8** %6
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
switch i32 %10, label %24 [
i32 46, label %11
i32 37, label %12
i32 91, label %18
]
11: ; preds = %3
store i32 1, i32* %4
br label %31
12: ; preds = %3
%13 = load i32, i32* %5
%14 = load i8*, i8** %6
%15 = getelementptr inbounds i8, i8* %14, i64 1
%16 = load i8, i8* %15
%17 = call i32 @matchclass(i32 %13, i8 zeroext %16)
store i32 %17, i32* %4
br label %31
18: ; preds = %3
%19 = load i32, i32* %5
%20 = load i8*, i8** %6
%21 = load i8*, i8** %7
%22 = getelementptr inbounds i8, i8* %21, i64 -1
%23 = call i32 @matchbracketclass(i32 %19, i8* %20, i8* %22)
store i32 %23, i32* %4
br label %31
24: ; preds = %3
%25 = load i8*, i8** %6
%26 = load i8, i8* %25
%27 = zext i8 %26 to i32
%28 = load i32, i32* %5
%29 = icmp eq i32 %27, %28
%30 = zext i1 %29 to i32
store i32 %30, i32* %4
br label %31
31: ; preds = %24, %18, %12, %11
%32 = load i32, i32* %4
ret i32 %32
}

LLVM IR (-O2):
define i32 @luaI_singlematch(i32 %0, i8* %1, i8* %2) {
%4 = load i8, i8* %1
%5 = sext i8 %4 to i32
switch i32 %5, label %13 [
i32 46, label %17
i32 37, label %6
i32 91, label %10
]
6: ; preds = %3
%7 = getelementptr inbounds i8, i8* %1, i64 1
%8 = load i8, i8* %7
%9 = tail call i32 @matchclass(i32 %0, i8 zeroext %8)
br label %17
10: ; preds = %3
%11 = getelementptr inbounds i8, i8* %2, i64 -1
%12 = tail call i32 @matchbracketclass(i32 %0, i8* %1, i8* %11)
br label %17
13: ; preds = %3
%14 = zext i8 %4 to i32
%15 = icmp eq i32 %14, %0
%16 = zext i1 %15 to i32
br label %17
17: ; preds = %3, %13, %10, %6
%18 = phi i32 [ %16, %13 ], [ %12, %10 ], [ %9, %6 ], [ 1, %3 ]
ret i32 %18
}