int glob_execute(pattern, s)
char *pattern;
char *s;
{
  char *current;
  int result;
  for (;;)
    switch (*pattern++) {
    case '?':
      if (*s++)
        continue;
      return (0);
    case 'X':
      if (*pattern++ == *s++)
        continue;
      return (0);
    case '$':
      return (*s == 0);
    case '[':
      if ((result = in_set(pattern, *s++)) == 1) {
        pattern += *pattern + 1;
        continue;
      }
      return (result);
    case '*':
      current = s;
      while (*s++)
        continue;
      do {
        s--;
        if (result = glob_execute(pattern, s))
          return (result);
      } while (s > current);
      return (0);
    default:
      return (-6);
    }
}


x86 assembly (clang, -O0):
<glob_execute>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl (%rax),%eax
mov    %eax,-0x28(%rbp)
sub    $0x24,%eax
je     11fd <glob_execute+0xdd>
jmp    1153 <glob_execute+0x33>
mov    -0x28(%rbp),%eax
sub    $0x2a,%eax
je     1268 <glob_execute+0x148>
jmp    1164 <glob_execute+0x44>
mov    -0x28(%rbp),%eax
sub    $0x3f,%eax
je     1197 <glob_execute+0x77>
jmp    1175 <glob_execute+0x55>
mov    -0x28(%rbp),%eax
sub    $0x58,%eax
je     11c0 <glob_execute+0xa0>
jmp    1186 <glob_execute+0x66>
mov    -0x28(%rbp),%eax
sub    $0x5b,%eax
je     1217 <glob_execute+0xf7>
jmp    12e1 <glob_execute+0x1c1>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
cmpb   $0x0,(%rax)
je     11b4 <glob_execute+0x94>
jmp    1130 <glob_execute+0x10>
movl   $0x0,-0x4(%rbp)
jmp    12e8 <glob_execute+0x1c8>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl (%rax),%eax
mov    -0x18(%rbp),%rcx
mov    %rcx,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jne    11f1 <glob_execute+0xd1>
jmp    1130 <glob_execute+0x10>
movl   $0x0,-0x4(%rbp)
jmp    12e8 <glob_execute+0x1c8>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    12e8 <glob_execute+0x1c8>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movsbl (%rax),%esi
mov    $0x0,%al
call   1040 <in_set@plt>
mov    %eax,-0x24(%rbp)
cmp    $0x1,%eax
jne    125d <glob_execute+0x13d>
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
add    $0x1,%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
jmp    1130 <glob_execute+0x10>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    12e8 <glob_execute+0x1c8>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
cmpb   $0x0,(%rax)
je     128d <glob_execute+0x16d>
jmp    1270 <glob_execute+0x150>
jmp    1292 <glob_execute+0x172>
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <glob_execute@plt>
mov    %eax,-0x24(%rbp)
cmp    $0x0,%eax
je     12c2 <glob_execute+0x1a2>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    12e8 <glob_execute+0x1c8>
jmp    12c7 <glob_execute+0x1a7>
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
ja     1292 <glob_execute+0x172>
movl   $0x0,-0x4(%rbp)
jmp    12e8 <glob_execute+0x1c8>
movl   $0xfffffffa,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<glob_execute>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
jmp    1137 <glob_execute+0x17>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r14
mov    %r15,%rdi
lea    0x1(%rdi),%r15
movsbl (%rdi),%ecx
mov    $0xfffffffa,%eax
cmp    $0x57,%ecx
jle    1180 <glob_execute+0x60>
cmp    $0x58,%ecx
je     1190 <glob_execute+0x70>
cmp    $0x5b,%ecx
jne    11e7 <glob_execute+0xc7>
movsbl (%r14),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <in_set@plt>
cmp    $0x1,%eax
jne    11e7 <glob_execute+0xc7>
movsbq (%r15),%rax
add    %rax,%r15
add    $0x1,%r15
jmp    1130 <glob_execute+0x10>
nopw   0x0(%rax,%rax,1)
cmp    $0x3f,%ecx
jne    11a2 <glob_execute+0x82>
cmpb   $0x0,(%r14)
jne    1130 <glob_execute+0x10>
jmp    11da <glob_execute+0xba>
nopl   (%rax)
movzbl 0x1(%rdi),%eax
cmp    (%r14),%al
jne    11da <glob_execute+0xba>
add    $0x2,%rdi
mov    %rdi,%r15
jmp    1130 <glob_execute+0x10>
cmp    $0x24,%ecx
je     11de <glob_execute+0xbe>
cmp    $0x2a,%ecx
jne    11e7 <glob_execute+0xc7>
mov    %r14,%rbx
nop
cmpb   $0x0,(%rbx)
lea    0x1(%rbx),%rbx
jne    11b0 <glob_execute+0x90>
jmp    11c5 <glob_execute+0xa5>
nopl   0x0(%rax,%rax,1)
cmp    %r14,%rbx
jbe    11da <glob_execute+0xba>
add    $0xffffffffffffffff,%rbx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <glob_execute@plt>
test   %eax,%eax
je     11c0 <glob_execute+0xa0>
jmp    11e7 <glob_execute+0xc7>
xor    %eax,%eax
jmp    11e7 <glob_execute+0xc7>
xor    %eax,%eax
cmpb   $0x0,(%r14)
sete   %al
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i32 @glob_execute(i8* %0, i8* %1) {
br label %3
3: ; preds = %31, %2
%4 = phi i8* [ %0, %2 ], [ %32, %31 ]
%5 = phi i8* [ %1, %2 ], [ %33, %31 ]
%6 = getelementptr inbounds i8, i8* %4, i64 1
%7 = load i8, i8* %4
%8 = sext i8 %7 to i32
switch i32 %8, label %46 [
i32 63, label %9
i32 88, label %12
i32 36, label %17
i32 91, label %21
i32 42, label %34
]
9: ; preds = %3
%10 = load i8, i8* %5
%11 = icmp eq i8 %10, 0
br i1 %11, label %46, label %31
12: ; preds = %3
%13 = getelementptr inbounds i8, i8* %4, i64 2
%14 = load i8, i8* %6
%15 = load i8, i8* %5
%16 = icmp eq i8 %14, %15
br i1 %16, label %31, label %46
17: ; preds = %3
%18 = load i8, i8* %5
%19 = icmp eq i8 %18, 0
%20 = zext i1 %19 to i32
br label %46
21: ; preds = %3
%22 = load i8, i8* %5
%23 = sext i8 %22 to i32
%24 = tail call i32 (i8*, i32, ...) bitcast (i32 (...)* @in_set to i32 (i8*, i32, ...)*)(i8* %6, i32 %23)
%25 = icmp eq i32 %24, 1
br i1 %25, label %26, label %46
26: ; preds = %21
%27 = load i8, i8* %6
%28 = sext i8 %27 to i64
%29 = add nsw i64 %28, 1
%30 = getelementptr inbounds i8, i8* %6, i64 %29
br label %31
31: ; preds = %26, %9, %12
%32 = phi i8* [ %30, %26 ], [ %13, %12 ], [ %6, %9 ]
%33 = getelementptr inbounds i8, i8* %5, i64 1
br label %3
34: ; preds = %3, %34
%35 = phi i8* [ %36, %34 ], [ %5, %3 ]
%36 = getelementptr inbounds i8, i8* %35, i64 1
%37 = load i8, i8* %35
%38 = icmp eq i8 %37, 0
br i1 %38, label %39, label %34
39: ; preds = %34, %44
%40 = phi i8* [ %41, %44 ], [ %36, %34 ]
%41 = getelementptr inbounds i8, i8* %40, i64 -1
%42 = tail call i32 @glob_execute(i8* %6, i8* %41)
%43 = icmp eq i32 %42, 0
br i1 %43, label %44, label %46
44: ; preds = %39
%45 = icmp ugt i8* %41, %5
br i1 %45, label %39, label %46
46: ; preds = %3, %21, %12, %9, %44, %39, %17
%47 = phi i32 [ %20, %17 ], [ 0, %44 ], [ %42, %39 ], [ -6, %3 ], [ %24, %21 ], [ 0, %12 ], [ 0, %9 ]
ret i32 %47
}