int __glob_is_literal(const char *p, int useesc) {
  int bracket = 0;
  for (; *p; p++) {
    switch (*p) {
    case '\\':
      if (!useesc)
        break;
    case '?':
    case '*':
      return 0;
    case '[':
      bracket = 1;
      break;
    case ']':
      if (bracket)
        return 0;
      break;
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<__glob_is_literal>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     11d8 <__glob_is_literal+0xd8>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x1c(%rbp)
sub    $0x2a,%eax
je     118f <__glob_is_literal+0x8f>
jmp    1137 <__glob_is_literal+0x37>
mov    -0x1c(%rbp),%eax
sub    $0x3f,%eax
je     118f <__glob_is_literal+0x8f>
jmp    1148 <__glob_is_literal+0x48>
mov    -0x1c(%rbp),%eax
sub    $0x5b,%eax
je     119b <__glob_is_literal+0x9b>
jmp    1159 <__glob_is_literal+0x59>
mov    -0x1c(%rbp),%eax
sub    $0x5c,%eax
je     117b <__glob_is_literal+0x7b>
jmp    116a <__glob_is_literal+0x6a>
mov    -0x1c(%rbp),%eax
sub    $0x5d,%eax
je     11a7 <__glob_is_literal+0xa7>
jmp    11c2 <__glob_is_literal+0xc2>
cmpl   $0x0,-0x14(%rbp)
jne    118a <__glob_is_literal+0x8a>
jmp    11c2 <__glob_is_literal+0xc2>
jmp    118f <__glob_is_literal+0x8f>
movl   $0x0,-0x4(%rbp)
jmp    11df <__glob_is_literal+0xdf>
movl   $0x1,-0x18(%rbp)
jmp    11c2 <__glob_is_literal+0xc2>
cmpl   $0x0,-0x18(%rbp)
je     11bd <__glob_is_literal+0xbd>
movl   $0x0,-0x4(%rbp)
jmp    11df <__glob_is_literal+0xdf>
jmp    11c2 <__glob_is_literal+0xc2>
jmp    11c7 <__glob_is_literal+0xc7>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1112 <__glob_is_literal+0x12>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<__glob_is_literal>:
mov    (%rdi),%al
test   %al,%al
je     1165 <__glob_is_literal+0x65>
add    $0x1,%rdi
lea    0xeef(%rip),%r8
xor    %edx,%edx
jmp    1130 <__glob_is_literal+0x30>
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0x1,%edx
movzbl (%rdi),%eax
add    $0x1,%rdi
test   %al,%al
je     1165 <__glob_is_literal+0x65>
movsbl %al,%eax
lea    -0x3f(%rax),%ecx
cmp    $0x1e,%ecx
ja     115d <__glob_is_literal+0x5d>
movslq (%r8,%rcx,4),%rcx
add    %r8,%rcx
xor    %eax,%eax
jmp    *%rcx
test   %esi,%esi
je     1125 <__glob_is_literal+0x25>
jmp    1162 <__glob_is_literal+0x62>
nopl   0x0(%rax)
xor    %eax,%eax
test   %edx,%edx
mov    $0x0,%edx
je     1125 <__glob_is_literal+0x25>
jmp    116a <__glob_is_literal+0x6a>
cmp    $0x2a,%eax
jne    1125 <__glob_is_literal+0x25>
xor    %eax,%eax
ret
mov    $0x1,%eax
ret

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

LLVM IR (-O2):
define i32 @__glob_is_literal(i8* nocapture %0, i32 %1) {
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 0
br i1 %4, label %21, label %5
5: ; preds = %2
%6 = icmp eq i32 %1, 0
br label %7
7: ; preds = %5, %16
%8 = phi i8 [ %3, %5 ], [ %19, %16 ]
%9 = phi i32 [ 0, %5 ], [ %17, %16 ]
%10 = phi i8* [ %0, %5 ], [ %18, %16 ]
%11 = sext i8 %8 to i32
switch i32 %11, label %16 [
i32 92, label %12
i32 63, label %21
i32 42, label %21
i32 91, label %13
i32 93, label %14
]
12: ; preds = %7
br i1 %6, label %16, label %21
13: ; preds = %7
br label %16
14: ; preds = %7
%15 = icmp eq i32 %9, 0
br i1 %15, label %16, label %21
16: ; preds = %13, %7, %12, %14
%17 = phi i32 [ %9, %7 ], [ 0, %14 ], [ 1, %13 ], [ %9, %12 ]
%18 = getelementptr inbounds i8, i8* %10, i64 1
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 0
br i1 %20, label %21, label %7
21: ; preds = %12, %7, %7, %14, %16, %2
%22 = phi i32 [ 1, %2 ], [ 1, %16 ], [ 0, %14 ], [ 0, %7 ], [ 0, %7 ], [ 0, %12 ]
ret i32 %22
}