int smatch_check(pat) const char *pat;
{
  int inword = 0;
  while (*pat) {
    switch (*pat) {
    case '\\':
      if (*++pat)
        pat++;
      break;
    case '[':
      if (!(pat = estrchr(pat, ']', '\\'))) {
        eprintf("glob error: unmatched '['");
        return 0;
      }
      pat++;
      break;
    case '{':
      if (inword) {
        eprintf("glob error: nested '{'");
        return 0;
      }
      inword = 1;
      pat++;
      break;
    case '}':
      inword = 0;
      pat++;
      break;
    case '?':
    case '*':
    default:
      pat++;
      break;
    }
  }
  if (inword)
    eprintf("glob error: unmatched '{'");
  return !inword;
}


x86 assembly (clang, -O0):
<smatch_check>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     1291 <smatch_check+0x171>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x18(%rbp)
sub    $0x2a,%eax
je     127b <smatch_check+0x15b>
jmp    1158 <smatch_check+0x38>
mov    -0x18(%rbp),%eax
sub    $0x3f,%eax
je     127b <smatch_check+0x15b>
jmp    1169 <smatch_check+0x49>
mov    -0x18(%rbp),%eax
sub    $0x5b,%eax
je     11d7 <smatch_check+0xb7>
jmp    117a <smatch_check+0x5a>
mov    -0x18(%rbp),%eax
sub    $0x5c,%eax
je     11ad <smatch_check+0x8d>
jmp    118b <smatch_check+0x6b>
mov    -0x18(%rbp),%eax
sub    $0x7b,%eax
je     1227 <smatch_check+0x107>
jmp    119c <smatch_check+0x7c>
mov    -0x18(%rbp),%eax
sub    $0x7d,%eax
je     1263 <smatch_check+0x143>
jmp    1280 <smatch_check+0x160>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
cmpb   $0x0,0x1(%rax)
je     11d2 <smatch_check+0xb2>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    128c <smatch_check+0x16c>
mov    -0x10(%rbp),%rdi
mov    $0x5d,%esi
mov    $0x5c,%edx
mov    $0x0,%al
call   1030 <estrchr@plt>
cltq
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    1216 <smatch_check+0xf6>
lea    0xdfd(%rip),%rdi
mov    $0x0,%al
call   1040 <eprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12ba <smatch_check+0x19a>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    128c <smatch_check+0x16c>
cmpl   $0x0,-0x14(%rbp)
je     124b <smatch_check+0x12b>
lea    0xde2(%rip),%rdi
mov    $0x0,%al
call   1040 <eprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12ba <smatch_check+0x19a>
movl   $0x1,-0x14(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    128c <smatch_check+0x16c>
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    128c <smatch_check+0x16c>
jmp    1280 <smatch_check+0x160>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1133 <smatch_check+0x13>
cmpl   $0x0,-0x14(%rbp)
je     12a9 <smatch_check+0x189>
lea    0xd8f(%rip),%rdi
mov    $0x0,%al
call   1040 <eprintf@plt>
cmpl   $0x0,-0x14(%rbp)
setne  %al
xor    $0xff,%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):
<smatch_check>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    (%rdi),%al
mov    $0x1,%r12d
test   %al,%al
je     11f5 <smatch_check+0xd5>
lea    0xec1(%rip),%rbx
lea    0xf46(%rip),%r15
lea    0xf59(%rip),%r14
xor    %ebp,%ebp
jmp    116b <smatch_check+0x4b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%rdi
movzbl (%rdi),%eax
test   %al,%al
je     11d8 <smatch_check+0xb8>
movsbl %al,%eax
add    $0xffffffa5,%eax
cmp    $0x22,%eax
ja     1160 <smatch_check+0x40>
movslq (%rbx,%rax,4),%rax
add    %rbx,%rax
jmp    *%rax
mov    $0x5d,%esi
mov    $0x5c,%edx
xor    %eax,%eax
call   1030 <estrchr@plt>
test   %eax,%eax
je     11e5 <smatch_check+0xc5>
movslq %eax,%rdi
jmp    1160 <smatch_check+0x40>
nopl   0x0(%rax)
cmpb   $0x0,0x1(%rdi)
lea    0x1(%rdi),%rax
lea    0x2(%rdi),%rdi
cmove  %rax,%rdi
jmp    1164 <smatch_check+0x44>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
test   %ebp,%ebp
jne    11e8 <smatch_check+0xc8>
add    $0x1,%rdi
mov    $0x1,%ebp
jmp    1164 <smatch_check+0x44>
nop
add    $0x1,%rdi
xor    %ebp,%ebp
jmp    1164 <smatch_check+0x44>
test   %ebp,%ebp
je     11f5 <smatch_check+0xd5>
lea    0xeda(%rip),%r14
jmp    11e8 <smatch_check+0xc8>
mov    %r15,%r14
xor    %r12d,%r12d
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <eprintf@plt>
mov    %r12d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [26 x i8] c"glob error: unmatched '['\00"
@.str.1 = [23 x i8] c"glob error: nested '{'\00"
@.str.2 = [26 x i8] c"glob error: unmatched '{'\00"
define i32 @smatch_check(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %4
br label %5
5: ; preds = %48, %1
%6 = load i8*, i8** %3
%7 = load i8, i8* %6
%8 = icmp ne i8 %7, 0
br i1 %8, label %9, label %49
9: ; preds = %5
%10 = load i8*, i8** %3
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
switch i32 %12, label %45 [
i32 92, label %13
i32 91, label %22
i32 123, label %33
i32 125, label %41
i32 63, label %44
i32 42, label %44
]
13: ; preds = %9
%14 = load i8*, i8** %3
%15 = getelementptr inbounds i8, i8* %14, i32 1
store i8* %15, i8** %3
%16 = load i8, i8* %15
%17 = icmp ne i8 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %13
%19 = load i8*, i8** %3
%20 = getelementptr inbounds i8, i8* %19, i32 1
store i8* %20, i8** %3
br label %21
21: ; preds = %18, %13
br label %48
22: ; preds = %9
%23 = load i8*, i8** %3
%24 = call i32 (i8*, i32, i32, ...) bitcast (i32 (...)* @estrchr to i32 (i8*, i32, i32, ...)*)(i8* %23, i32 93, i32 92)
%25 = sext i32 %24 to i64
%26 = inttoptr i64 %25 to i8*
store i8* %26, i8** %3
%27 = icmp ne i8* %26, null
br i1 %27, label %30, label %28
28: ; preds = %22
%29 = call i32 (i8*, ...) bitcast (i32 (...)* @eprintf to i32 (i8*, ...)*)(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %2
br label %59
30: ; preds = %22
%31 = load i8*, i8** %3
%32 = getelementptr inbounds i8, i8* %31, i32 1
store i8* %32, i8** %3
br label %48
33: ; preds = %9
%34 = load i32, i32* %4
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %38
36: ; preds = %33
%37 = call i32 (i8*, ...) bitcast (i32 (...)* @eprintf to i32 (i8*, ...)*)(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %2
br label %59
38: ; preds = %33
store i32 1, i32* %4
%39 = load i8*, i8** %3
%40 = getelementptr inbounds i8, i8* %39, i32 1
store i8* %40, i8** %3
br label %48
41: ; preds = %9
store i32 0, i32* %4
%42 = load i8*, i8** %3
%43 = getelementptr inbounds i8, i8* %42, i32 1
store i8* %43, i8** %3
br label %48
44: ; preds = %9, %9
br label %45
45: ; preds = %9, %44
%46 = load i8*, i8** %3
%47 = getelementptr inbounds i8, i8* %46, i32 1
store i8* %47, i8** %3
br label %48
48: ; preds = %45, %41, %38, %30, %21
br label %5
49: ; preds = %5
%50 = load i32, i32* %4
%51 = icmp ne i32 %50, 0
br i1 %51, label %52, label %54
52: ; preds = %49
%53 = call i32 (i8*, ...) bitcast (i32 (...)* @eprintf to i32 (i8*, ...)*)(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
br label %54
54: ; preds = %52, %49
%55 = load i32, i32* %4
%56 = icmp ne i32 %55, 0
%57 = xor i1 %56, true
%58 = zext i1 %57 to i32
store i32 %58, i32* %2
br label %59
59: ; preds = %54, %36, %28
%60 = load i32, i32* %2
ret i32 %60
}

LLVM IR (-O2):
@.str = [26 x i8] c"glob error: unmatched '['\00"
@.str.1 = [23 x i8] c"glob error: nested '{'\00"
@.str.2 = [26 x i8] c"glob error: unmatched '{'\00"
define i32 @smatch_check(i8* %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %40, label %4
4: ; preds = %1, %30
%5 = phi i8 [ %33, %30 ], [ %2, %1 ]
%6 = phi i32 [ %32, %30 ], [ 0, %1 ]
%7 = phi i8* [ %31, %30 ], [ %0, %1 ]
%8 = sext i8 %5 to i32
switch i32 %8, label %28 [
i32 92, label %9
i32 91, label %15
i32 123, label %22
i32 125, label %26
]
9: ; preds = %4
%10 = getelementptr inbounds i8, i8* %7, i64 1
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 0
%13 = getelementptr inbounds i8, i8* %7, i64 2
%14 = select i1 %12, i8* %10, i8* %13
br label %30
15: ; preds = %4
%16 = tail call i32 (i8*, i32, i32, ...) bitcast (i32 (...)* @estrchr to i32 (i8*, i32, i32, ...)*)(i8* %7, i32 93, i32 92)
%17 = icmp eq i32 %16, 0
br i1 %17, label %37, label %18
18: ; preds = %15
%19 = sext i32 %16 to i64
%20 = inttoptr i64 %19 to i8*
%21 = getelementptr inbounds i8, i8* %20, i64 1
br label %30
22: ; preds = %4
%23 = icmp eq i32 %6, 0
br i1 %23, label %24, label %37
24: ; preds = %22
%25 = getelementptr inbounds i8, i8* %7, i64 1
br label %30
26: ; preds = %4
%27 = getelementptr inbounds i8, i8* %7, i64 1
br label %30
28: ; preds = %4
%29 = getelementptr inbounds i8, i8* %7, i64 1
br label %30
30: ; preds = %9, %28, %26, %24, %18
%31 = phi i8* [ %29, %28 ], [ %27, %26 ], [ %25, %24 ], [ %21, %18 ], [ %14, %9 ]
%32 = phi i32 [ %6, %28 ], [ 0, %26 ], [ 1, %24 ], [ %6, %18 ], [ %6, %9 ]
%33 = load i8, i8* %31
%34 = icmp eq i8 %33, 0
br i1 %34, label %35, label %4
35: ; preds = %30
%36 = icmp eq i32 %32, 0
br i1 %36, label %40, label %37
37: ; preds = %22, %15, %35
%38 = phi i8* [ getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), %35 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), %22 ], [ getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), %15 ]
%39 = tail call i32 (i8*, ...) bitcast (i32 (...)* @eprintf to i32 (i8*, ...)*)(i8* %38)
br label %40
40: ; preds = %37, %35, %1
%41 = phi i32 [ 1, %35 ], [ 1, %1 ], [ 0, %37 ]
ret i32 %41
}