#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 */
typedef int /*<<< orphan*/ text;
typedef int /*<<< orphan*/ p;

/* Variables and functions */
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strlen(char *);
scalar_t__ wildmat(char *, char *, int /*<<< orphan*/);
int main() {
  char p[80];
  char text[80];
  printf("Wildmat tester.  Enter pattern, then strings to test.\n");
  printf("A blank line gets prompts for a new pattern; a blank pattern\n");
  printf("exits the program.\n");
  for (;;) {
    printf("\nEnter pattern:  ");
    (void)fflush(stdout);
    if (fgets(p, sizeof(p) - 1, stdin) == NULL || p[0] == '\0')
      break;
    for (;;) {
      printf("Enter text:  ");
      (void)fflush(stdout);
      if (fgets(text, sizeof(text) - 1, stdin) == NULL)
        exit(0);
      if (text[0] == '\0')
        break;
      printf("      %s\n", wildmat(text, p, strlen(p)) ? "YES" : "NO");
    }
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xee0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xee6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2e27(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
lea    -0x60(%rbp),%rdi
mov    0x2e25(%rip),%rax
mov    (%rax),%edx
mov    $0x4f,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     11e6 <main+0x86>
movsbl -0x60(%rbp),%eax
cmp    $0x0,%eax
jne    11eb <main+0x8b>
jmp    12b4 <main+0x154>
jmp    11f0 <main+0x90>
lea    0xea4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2dd3(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
lea    -0xb0(%rbp),%rdi
mov    0x2dce(%rip),%rax
mov    (%rax),%edx
mov    $0x4f,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
jne    1237 <main+0xd7>
xor    %edi,%edi
call   1080 <exit@plt>
movsbl -0xb0(%rbp),%eax
cmp    $0x0,%eax
jne    124c <main+0xec>
jmp    12af <main+0x14f>
lea    -0xb0(%rbp),%rax
mov    %rax,-0xc0(%rbp)
lea    -0x60(%rbp),%rax
mov    %rax,-0xb8(%rbp)
lea    -0x60(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0xc0(%rbp),%rdi
mov    -0xb8(%rbp),%rsi
mov    %eax,%edx
call   1050 <wildmat@plt>
mov    %rax,%rcx
lea    0xe2a(%rip),%rsi
lea    0xe1f(%rip),%rax
cmp    $0x0,%rcx
cmovne %rax,%rsi
lea    0xe06(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11f0 <main+0x90>
jmp    119c <main+0x3c>
xor    %edi,%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xa8,%rsp
lea    0xea9(%rip),%rdi
call   1030 <puts@plt>
lea    0xed3(%rip),%rdi
call   1030 <puts@plt>
lea    0xf04(%rip),%rdi
call   1030 <puts@plt>
lea    0xe54(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2e1e(%rip),%rax
mov    (%rax),%edi
call   1080 <fflush@plt>
mov    0x2e20(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rdi
mov    $0x4f,%esi
call   1070 <fgets@plt>
test   %rax,%rax
je     12b0 <main+0x140>
cmpb   $0x0,(%rsp)
je     12b0 <main+0x140>
lea    0xe21(%rip),%r14
lea    0x50(%rsp),%r12
mov    %rsp,%rbx
lea    0xe2e(%rip),%rbp
lea    0xe23(%rip),%r15
lea    0xe12(%rip),%r13
jmp    1239 <main+0xc9>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1060 <wildmat@plt>
test   %rax,%rax
mov    %r15,%rsi
cmove  %rbp,%rsi
mov    %r13,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2d8e(%rip),%rax
mov    (%rax),%edi
call   1080 <fflush@plt>
mov    0x2d90(%rip),%rax
mov    (%rax),%edx
mov    %r12,%rdi
mov    $0x4f,%esi
call   1070 <fgets@plt>
test   %rax,%rax
je     12b0 <main+0x140>
cmpb   $0x0,0x50(%rsp)
jne    1210 <main+0xa0>
lea    0xd86(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2d50(%rip),%rax
mov    (%rax),%edi
call   1080 <fflush@plt>
mov    0x2d52(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    $0x4f,%esi
call   1070 <fgets@plt>
test   %rax,%rax
je     12b0 <main+0x140>
cmpb   $0x0,(%rsp)
jne    1239 <main+0xc9>
xor    %edi,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [55 x i8] c"Wildmat tester. Enter pattern, then strings to test.\0A\00"
@.str.1 = [62 x i8] c"A blank line gets prompts for a new pattern; a blank pattern\0A\00"
@.str.2 = [20 x i8] c"exits the program.\0A\00"
@.str.3 = [18 x i8] c"\0AEnter pattern: \00"
@stdout = global i32 0
@stdin = global i32 0
@.str.4 = [14 x i8] c"Enter text: \00"
@.str.5 = [10 x i8] c" %s\0A\00"
@.str.6 = [4 x i8] c"YES\00"
@.str.7 = [3 x i8] c"NO\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [80 x i8]
%3 = alloca [80 x i8]
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0))
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
br label %7
7: ; preds = %48, %0
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%9 = load i32, i32* @stdout
%10 = call i32 @fflush(i32 %9)
%11 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%12 = load i32, i32* @stdin
%13 = call i32* @fgets(i8* %11, i32 79, i32 %12)
%14 = icmp eq i32* %13, null
br i1 %14, label %20, label %15
15: ; preds = %7
%16 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %15, %7
br label %49
21: ; preds = %15
br label %22
22: ; preds = %38, %21
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
%24 = load i32, i32* @stdout
%25 = call i32 @fflush(i32 %24)
%26 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%27 = load i32, i32* @stdin
%28 = call i32* @fgets(i8* %26, i32 79, i32 %27)
%29 = icmp eq i32* %28, null
br i1 %29, label %30, label %32
30: ; preds = %22
%31 = call i32 @exit(i32 0)
unreachable
32: ; preds = %22
%33 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp eq i32 %35, 0
br i1 %36, label %37, label %38
37: ; preds = %32
br label %48
38: ; preds = %32
%39 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%40 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%41 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%42 = call i32 @strlen(i8* %41)
%43 = call i64 @wildmat(i8* %39, i8* %40, i32 %42)
%44 = icmp ne i64 %43, 0
%45 = zext i1 %44 to i64
%46 = select i1 %44, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0)
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8* %46)
br label %22
48: ; preds = %37
br label %7
49: ; preds = %20
%50 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str.3 = [18 x i8] c"\0AEnter pattern: \00"
@stdout = global i32 0
@stdin = global i32 0
@.str.4 = [14 x i8] c"Enter text: \00"
@.str.5 = [10 x i8] c" %s\0A\00"
@.str.6 = [4 x i8] c"YES\00"
@.str.7 = [3 x i8] c"NO\00"
@str = [54 x i8] c"Wildmat tester. Enter pattern, then strings to test.\00"
@str.8 = [61 x i8] c"A blank line gets prompts for a new pattern; a blank pattern\00"
@str.9 = [19 x i8] c"exits the program.\00"
define i32 @main() {
%1 = alloca [80 x i8]
%2 = alloca [80 x i8]
%3 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @str.8, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.9, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%9 = load i32, i32* @stdout
%10 = call i32 @fflush(i32 %9)
%11 = load i32, i32* @stdin
%12 = call i32* @fgets(i8* %3, i32 79, i32 %11)
%13 = icmp eq i32* %12, null
%14 = load i8, i8* %3
%15 = icmp eq i8 %14, 0
%16 = select i1 %13, i1 true, i1 %15
br i1 %16, label %51, label %27
17: ; preds = %36
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%19 = load i32, i32* @stdout
%20 = call i32 @fflush(i32 %19)
%21 = load i32, i32* @stdin
%22 = call i32* @fgets(i8* %3, i32 79, i32 %21)
%23 = icmp eq i32* %22, null
%24 = load i8, i8* %3
%25 = icmp eq i8 %24, 0
%26 = select i1 %23, i1 true, i1 %25
br i1 %26, label %51, label %27
27: ; preds = %0, %17
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
%29 = load i32, i32* @stdout
%30 = call i32 @fflush(i32 %29)
%31 = load i32, i32* @stdin
%32 = call i32* @fgets(i8* %4, i32 79, i32 %31)
%33 = icmp eq i32* %32, null
br i1 %33, label %34, label %36
34: ; preds = %27, %39
%35 = call i32 @exit(i32 0)
unreachable
36: ; preds = %27, %39
%37 = load i8, i8* %4
%38 = icmp eq i8 %37, 0
br i1 %38, label %17, label %39
39: ; preds = %36
%40 = call i32 @strlen(i8* %3)
%41 = call i64 @wildmat(i8* %4, i8* %3, i32 %40)
%42 = icmp eq i64 %41, 0
%43 = select i1 %42, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0)
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8* %43)
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
%46 = load i32, i32* @stdout
%47 = call i32 @fflush(i32 %46)
%48 = load i32, i32* @stdin
%49 = call i32* @fgets(i8* %4, i32 79, i32 %48)
%50 = icmp eq i32* %49, null
br i1 %50, label %34, label %36
51: ; preds = %17, %0
%52 = call i32 @exit(i32 0)
unreachable
}