#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__ re_comp(char *);
int re_exec(char *);
int wcmatch(char *s, char *template) {
  char temp[200];
  char *p = temp;
  if (!template)
    return (1);
  *p++ = '^';
  while (*template) {
    if (*template == '*') {
      *(p++) = '.';
      *(p++) = *(template ++);
    } else if (*template == '?') {
      *(p++) = '.';
      template ++;
    } else if (*template == '.') {
      *(p++) = '\\';
      *(p++) = '.';
      template ++;
    } else if (*template == '[') {
      *(p++) = '\\';
      *(p++) = '[';
      template ++;
    } else if (*template == '$') {
      *(p++) = '\\';
      *(p++) = '$';
      template ++;
    } else if (*template == '^') {
      *(p++) = '\\';
      *(p++) = '^';
      template ++;
    } else if (*template == '\\') {
      *(p++) = '\\';
      *(p++) = '\\';
      template ++;
    } else
      *(p++) = *(template ++);
  }
  *p++ = '$';
  *p++ = '\0';
  if (re_comp(temp))
    return (0);
  return (re_exec(s));
}


x86 assembly (clang, -O0):
<wcmatch>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    -0xe0(%rbp),%rax
mov    %rax,-0xe8(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1158 <wcmatch+0x38>
movl   $0x1,-0x4(%rbp)
jmp    1449 <wcmatch+0x329>
mov    -0xe8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0xe8(%rbp)
movb   $0x5e,(%rax)
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     13eb <wcmatch+0x2cb>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2a,%eax
jne    11d2 <wcmatch+0xb2>
mov    -0xe8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0xe8(%rbp)
movb   $0x2e,(%rax)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
mov    (%rax),%cl
mov    -0xe8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0xe8(%rbp)
mov    %cl,(%rax)
jmp    13e6 <wcmatch+0x2c6>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3f,%eax
jne    120b <wcmatch+0xeb>
mov    -0xe8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0xe8(%rbp)
movb   $0x2e,(%rax)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    13e1 <wcmatch+0x2c1>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    125c <wcmatch+0x13c>
mov    -0xe8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0xe8(%rbp)
movb   $0x5c,(%rax)
mov    -0xe8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0xe8(%rbp)
movb   $0x2e,(%rax)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    13dc <wcmatch+0x2bc>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5b,%eax
jne    12ad <wcmatch+0x18d>
mov    -0xe8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0xe8(%rbp)
movb   $0x5c,(%rax)
mov    -0xe8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0xe8(%rbp)
movb   $0x5b,(%rax)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    13d7 <wcmatch+0x2b7>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x24,%eax
jne    12fe <wcmatch+0x1de>
mov    -0xe8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0xe8(%rbp)
movb   $0x5c,(%rax)
mov    -0xe8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0xe8(%rbp)
movb   $0x24,(%rax)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    13d2 <wcmatch+0x2b2>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5e,%eax
jne    134f <wcmatch+0x22f>
mov    -0xe8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0xe8(%rbp)
movb   $0x5c,(%rax)
mov    -0xe8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0xe8(%rbp)
movb   $0x5e,(%rax)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    13cd <wcmatch+0x2ad>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
jne    13a0 <wcmatch+0x280>
mov    -0xe8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0xe8(%rbp)
movb   $0x5c,(%rax)
mov    -0xe8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0xe8(%rbp)
movb   $0x5c,(%rax)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    13c8 <wcmatch+0x2a8>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
mov    (%rax),%cl
mov    -0xe8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0xe8(%rbp)
mov    %cl,(%rax)
jmp    13cd <wcmatch+0x2ad>
jmp    13d2 <wcmatch+0x2b2>
jmp    13d7 <wcmatch+0x2b7>
jmp    13dc <wcmatch+0x2bc>
jmp    13e1 <wcmatch+0x2c1>
jmp    13e6 <wcmatch+0x2c6>
jmp    1170 <wcmatch+0x50>
mov    -0xe8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0xe8(%rbp)
movb   $0x24,(%rax)
mov    -0xe8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0xe8(%rbp)
movb   $0x0,(%rax)
lea    -0xe0(%rbp),%rdi
call   1040 <re_comp@plt>
cmp    $0x0,%rax
je     143d <wcmatch+0x31d>
movl   $0x0,-0x4(%rbp)
jmp    1449 <wcmatch+0x329>
mov    -0x10(%rbp),%rdi
call   1030 <re_exec@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wcmatch>:
push   %rbx
sub    $0xd0,%rsp
test   %rsi,%rsi
je     11ca <wcmatch+0xaa>
mov    %rdi,%rbx
lea    0x1(%rsp),%rax
movb   $0x5e,(%rsp)
lea    0xebc(%rip),%rcx
jmp    1158 <wcmatch+0x38>
movw   $0x2a2e,(%rax)
nopl   0x0(%rax,%rax,1)
add    $0x2,%rax
add    $0x1,%rsi
movzbl (%rsi),%edx
lea    -0x24(%rdx),%edi
cmp    $0x3a,%dil
ja     1199 <wcmatch+0x79>
movzbl %dil,%edi
movslq (%rcx,%rdi,4),%rdi
add    %rcx,%rdi
jmp    *%rdi
movw   $0x245c,(%rax)
jmp    1150 <wcmatch+0x30>
movw   $0x2e5c,(%rax)
jmp    1150 <wcmatch+0x30>
movb   $0x2e,(%rax)
jmp    119f <wcmatch+0x7f>
movw   $0x5b5c,(%rax)
jmp    1150 <wcmatch+0x30>
movw   $0x5c5c,(%rax)
jmp    1150 <wcmatch+0x30>
movw   $0x5e5c,(%rax)
jmp    1150 <wcmatch+0x30>
test   %dl,%dl
je     11a9 <wcmatch+0x89>
mov    %dl,(%rax)
add    $0x1,%rax
add    $0x1,%rsi
jmp    1158 <wcmatch+0x38>
movw   $0x24,(%rax)
mov    %rsp,%rdi
call   1040 <re_comp@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
jne    11cf <wcmatch+0xaf>
mov    %rbx,%rdi
call   1030 <re_exec@plt>
jmp    11cf <wcmatch+0xaf>
mov    $0x1,%eax
add    $0xd0,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @wcmatch(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca [200 x i8]
%7 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%8 = getelementptr inbounds [200 x i8], [200 x i8]* %6, i64 0, i64 0
store i8* %8, i8** %7
%9 = load i8*, i8** %5
%10 = icmp ne i8* %9, null
br i1 %10, label %12, label %11
11: ; preds = %2
store i32 1, i32* %3
br label %127
12: ; preds = %2
%13 = load i8*, i8** %7
%14 = getelementptr inbounds i8, i8* %13, i32 1
store i8* %14, i8** %7
store i8 94, i8* %13
br label %15
15: ; preds = %114, %12
%16 = load i8*, i8** %5
%17 = load i8, i8* %16
%18 = icmp ne i8 %17, 0
br i1 %18, label %19, label %115
19: ; preds = %15
%20 = load i8*, i8** %5
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 42
br i1 %23, label %24, label %32
24: ; preds = %19
%25 = load i8*, i8** %7
%26 = getelementptr inbounds i8, i8* %25, i32 1
store i8* %26, i8** %7
store i8 46, i8* %25
%27 = load i8*, i8** %5
%28 = getelementptr inbounds i8, i8* %27, i32 1
store i8* %28, i8** %5
%29 = load i8, i8* %27
%30 = load i8*, i8** %7
%31 = getelementptr inbounds i8, i8* %30, i32 1
store i8* %31, i8** %7
store i8 %29, i8* %30
br label %114
32: ; preds = %19
%33 = load i8*, i8** %5
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp eq i32 %35, 63
br i1 %36, label %37, label %42
37: ; preds = %32
%38 = load i8*, i8** %7
%39 = getelementptr inbounds i8, i8* %38, i32 1
store i8* %39, i8** %7
store i8 46, i8* %38
%40 = load i8*, i8** %5
%41 = getelementptr inbounds i8, i8* %40, i32 1
store i8* %41, i8** %5
br label %113
42: ; preds = %32
%43 = load i8*, i8** %5
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = icmp eq i32 %45, 46
br i1 %46, label %47, label %54
47: ; preds = %42
%48 = load i8*, i8** %7
%49 = getelementptr inbounds i8, i8* %48, i32 1
store i8* %49, i8** %7
store i8 92, i8* %48
%50 = load i8*, i8** %7
%51 = getelementptr inbounds i8, i8* %50, i32 1
store i8* %51, i8** %7
store i8 46, i8* %50
%52 = load i8*, i8** %5
%53 = getelementptr inbounds i8, i8* %52, i32 1
store i8* %53, i8** %5
br label %112
54: ; preds = %42
%55 = load i8*, i8** %5
%56 = load i8, i8* %55
%57 = sext i8 %56 to i32
%58 = icmp eq i32 %57, 91
br i1 %58, label %59, label %66
59: ; preds = %54
%60 = load i8*, i8** %7
%61 = getelementptr inbounds i8, i8* %60, i32 1
store i8* %61, i8** %7
store i8 92, i8* %60
%62 = load i8*, i8** %7
%63 = getelementptr inbounds i8, i8* %62, i32 1
store i8* %63, i8** %7
store i8 91, i8* %62
%64 = load i8*, i8** %5
%65 = getelementptr inbounds i8, i8* %64, i32 1
store i8* %65, i8** %5
br label %111
66: ; preds = %54
%67 = load i8*, i8** %5
%68 = load i8, i8* %67
%69 = sext i8 %68 to i32
%70 = icmp eq i32 %69, 36
br i1 %70, label %71, label %78
71: ; preds = %66
%72 = load i8*, i8** %7
%73 = getelementptr inbounds i8, i8* %72, i32 1
store i8* %73, i8** %7
store i8 92, i8* %72
%74 = load i8*, i8** %7
%75 = getelementptr inbounds i8, i8* %74, i32 1
store i8* %75, i8** %7
store i8 36, i8* %74
%76 = load i8*, i8** %5
%77 = getelementptr inbounds i8, i8* %76, i32 1
store i8* %77, i8** %5
br label %110
78: ; preds = %66
%79 = load i8*, i8** %5
%80 = load i8, i8* %79
%81 = sext i8 %80 to i32
%82 = icmp eq i32 %81, 94
br i1 %82, label %83, label %90
83: ; preds = %78
%84 = load i8*, i8** %7
%85 = getelementptr inbounds i8, i8* %84, i32 1
store i8* %85, i8** %7
store i8 92, i8* %84
%86 = load i8*, i8** %7
%87 = getelementptr inbounds i8, i8* %86, i32 1
store i8* %87, i8** %7
store i8 94, i8* %86
%88 = load i8*, i8** %5
%89 = getelementptr inbounds i8, i8* %88, i32 1
store i8* %89, i8** %5
br label %109
90: ; preds = %78
%91 = load i8*, i8** %5
%92 = load i8, i8* %91
%93 = sext i8 %92 to i32
%94 = icmp eq i32 %93, 92
br i1 %94, label %95, label %102
95: ; preds = %90
%96 = load i8*, i8** %7
%97 = getelementptr inbounds i8, i8* %96, i32 1
store i8* %97, i8** %7
store i8 92, i8* %96
%98 = load i8*, i8** %7
%99 = getelementptr inbounds i8, i8* %98, i32 1
store i8* %99, i8** %7
store i8 92, i8* %98
%100 = load i8*, i8** %5
%101 = getelementptr inbounds i8, i8* %100, i32 1
store i8* %101, i8** %5
br label %108
102: ; preds = %90
%103 = load i8*, i8** %5
%104 = getelementptr inbounds i8, i8* %103, i32 1
store i8* %104, i8** %5
%105 = load i8, i8* %103
%106 = load i8*, i8** %7
%107 = getelementptr inbounds i8, i8* %106, i32 1
store i8* %107, i8** %7
store i8 %105, i8* %106
br label %108
108: ; preds = %102, %95
br label %109
109: ; preds = %108, %83
br label %110
110: ; preds = %109, %71
br label %111
111: ; preds = %110, %59
br label %112
112: ; preds = %111, %47
br label %113
113: ; preds = %112, %37
br label %114
114: ; preds = %113, %24
br label %15
115: ; preds = %15
%116 = load i8*, i8** %7
%117 = getelementptr inbounds i8, i8* %116, i32 1
store i8* %117, i8** %7
store i8 36, i8* %116
%118 = load i8*, i8** %7
%119 = getelementptr inbounds i8, i8* %118, i32 1
store i8* %119, i8** %7
store i8 0, i8* %118
%120 = getelementptr inbounds [200 x i8], [200 x i8]* %6, i64 0, i64 0
%121 = call i64 @re_comp(i8* %120)
%122 = icmp ne i64 %121, 0
br i1 %122, label %123, label %124
123: ; preds = %115
store i32 0, i32* %3
br label %127
124: ; preds = %115
%125 = load i8*, i8** %4
%126 = call i32 @re_exec(i8* %125)
store i32 %126, i32* %3
br label %127
127: ; preds = %124, %123, %11
%128 = load i32, i32* %3
ret i32 %128
}

LLVM IR (-O2):
define i32 @wcmatch(i8* %0, i8* %1) {
%3 = alloca [200 x i8]
%4 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 0
%5 = icmp eq i8* %1, null
br i1 %5, label %43, label %6
6: ; preds = %2
%7 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 1
store i8 94, i8* %4
br label %8
8: ; preds = %34, %6
%9 = phi i8* [ %1, %6 ], [ %36, %34 ]
%10 = phi i8* [ %7, %6 ], [ %35, %34 ]
%11 = load i8, i8* %9
switch i8 %11, label %32 [
i8 0, label %37
i8 42, label %12
i8 63, label %15
i8 46, label %17
i8 91, label %20
i8 36, label %23
i8 94, label %26
i8 92, label %29
]
12: ; preds = %8
%13 = getelementptr inbounds i8, i8* %10, i64 1
store i8 46, i8* %10
%14 = getelementptr inbounds i8, i8* %10, i64 2
store i8 42, i8* %13
br label %34
15: ; preds = %8
%16 = getelementptr inbounds i8, i8* %10, i64 1
store i8 46, i8* %10
br label %34
17: ; preds = %8
%18 = getelementptr inbounds i8, i8* %10, i64 1
store i8 92, i8* %10
%19 = getelementptr inbounds i8, i8* %10, i64 2
store i8 46, i8* %18
br label %34
20: ; preds = %8
%21 = getelementptr inbounds i8, i8* %10, i64 1
store i8 92, i8* %10
%22 = getelementptr inbounds i8, i8* %10, i64 2
store i8 91, i8* %21
br label %34
23: ; preds = %8
%24 = getelementptr inbounds i8, i8* %10, i64 1
store i8 92, i8* %10
%25 = getelementptr inbounds i8, i8* %10, i64 2
store i8 36, i8* %24
br label %34
26: ; preds = %8
%27 = getelementptr inbounds i8, i8* %10, i64 1
store i8 92, i8* %10
%28 = getelementptr inbounds i8, i8* %10, i64 2
store i8 94, i8* %27
br label %34
29: ; preds = %8
%30 = getelementptr inbounds i8, i8* %10, i64 1
store i8 92, i8* %10
%31 = getelementptr inbounds i8, i8* %10, i64 2
store i8 92, i8* %30
br label %34
32: ; preds = %8
%33 = getelementptr inbounds i8, i8* %10, i64 1
store i8 %11, i8* %10
br label %34
34: ; preds = %15, %20, %26, %32, %29, %23, %17, %12
%35 = phi i8* [ %14, %12 ], [ %16, %15 ], [ %19, %17 ], [ %22, %20 ], [ %25, %23 ], [ %28, %26 ], [ %31, %29 ], [ %33, %32 ]
%36 = getelementptr inbounds i8, i8* %9, i64 1
br label %8
37: ; preds = %8
%38 = getelementptr inbounds i8, i8* %10, i64 1
store i8 36, i8* %10
store i8 0, i8* %38
%39 = call i64 @re_comp(i8* %4)
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %43
41: ; preds = %37
%42 = call i32 @re_exec(i8* %0)
br label %43
43: ; preds = %37, %2, %41
%44 = phi i32 [ %42, %41 ], [ 1, %2 ], [ 0, %37 ]
ret i32 %44
}