#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 ssize_t;

/* Variables and functions */
int FNM_NOMATCH;
int /*<<< orphan*/ LC_COLLATE;
int /*<<< orphan*/ LC_CTYPE;
int convert_flags(char const *);
char *escape(char const *, size_t *, char **);
int /*<<< orphan*/ feof(int /*<<< orphan*/);
char *flag_output(int);
int fnmatch(char const *, char const *, int);
int /*<<< orphan*/ free(char *);
int getline(char **, size_t *, int /*<<< orphan*/);
int /*<<< orphan*/ mtrace();
char *next_input(char **, int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ *setlocale(int /*<<< orphan*/, char const *);
char *sprintf(char *, char *, int);
int /*<<< orphan*/ stdin;
scalar_t__ strcasecmp(char const *, char *);
scalar_t__ strcmp(char const *, char *);
int strtol(char const *, char **, int /*<<< orphan*/);
int main(void) {
  char *linebuf = NULL;
  size_t linebuflen = 0;
  int ntests = 0;
  int nfailed = 0;
  char *escinput = NULL;
  size_t escinputlen = 0;
  char *escpattern = NULL;
  size_t escpatternlen = 0;
  int nr = 0;
  mtrace();
  while (!feof(stdin)) {
    ssize_t n = getline(&linebuf, &linebuflen, stdin);
    char *cp;
    const char *locale;
    const char *input;
    const char *pattern;
    const char *result_str;
    int result;
    const char *flags;
    int flags_val;
    int fnmres;
    char numbuf[24];
    if (n == -1)
      break;
    if (n == 0)
      continue;
    cp = linebuf;
    locale = next_input(&cp, 1, 0);
    if (locale == NULL)
      continue;
    input = next_input(&cp, 0, 0);
    if (input == NULL)
      continue;
    pattern = next_input(&cp, 0, 0);
    if (pattern == NULL)
      continue;
    result_str = next_input(&cp, 0, 0);
    if (result_str == NULL)
      continue;
    if (strcmp(result_str, "0") == 0)
      result = 0;
    else if (strcasecmp(result_str, "NOMATCH") == 0)
      result = FNM_NOMATCH;
    else {
      char *endp;
      result = strtol(result_str, &endp, 0);
      if (*endp != '\0')
        continue;
    }
    flags = next_input(&cp, 0, 1);
    if (flags == NULL)
      flags = "";
    flags_val = convert_flags(flags);
    if (flags_val == -1)
      continue;
    ++ntests;
    if (setlocale(LC_COLLATE, locale) == NULL ||
        setlocale(LC_CTYPE, locale) == NULL) {
      puts("*** Cannot set locale");
      ++nfailed;
      continue;
    }
    fnmres = fnmatch(pattern, input, flags_val);
    printf("%3d: fnmatch (\"%s\", \"%s\", %s) = %s%c", ++nr,
           escape(pattern, &escpatternlen, &escpattern),
           escape(input, &escinputlen, &escinput), flag_output(flags_val),
           (fnmres == 0 ? "0"
                        : (fnmres == FNM_NOMATCH
                               ? "FNM_NOMATCH"
                               : (sprintf(numbuf, "%d", fnmres), numbuf))),
           (fnmres != 0) != (result != 0) ? ' ' : '\n');
    if ((fnmres != 0) != (result != 0)) {
      printf("(FAIL, expected %s) ***\n",
             result == 0 ? "0"
                         : (result == FNM_NOMATCH
                                ? "FNM_NOMATCH"
                                : (sprintf(numbuf, "%d", result), numbuf)));
      ++nfailed;
    }
  }
  printf("=====================\n%3d tests, %3d failed\n", ntests, nfailed);
  free(escpattern);
  free(escinput);
  free(linebuf);
  return nfailed != 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
movl   $0x0,-0x44(%rbp)
mov    $0x0,%al
call   10f0 <mtrace@plt>
mov    0x2d73(%rip),%rax
mov    (%rax),%edi
call   10a0 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1281 <main+0x81>
jmp    1677 <main+0x477>
mov    0x2d50(%rip),%rax
mov    (%rax),%edx
lea    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   10e0 <getline@plt>
mov    %eax,-0x48(%rbp)
cmpl   $0xffffffff,-0x48(%rbp)
jne    12a9 <main+0xa9>
jmp    1677 <main+0x477>
cmpl   $0x0,-0x48(%rbp)
jne    12b8 <main+0xb8>
jmp    125e <main+0x5e>
mov    -0x10(%rbp),%rax
mov    %rax,-0x50(%rbp)
lea    -0x50(%rbp),%rdi
mov    $0x1,%esi
xor    %edx,%edx
call   10c0 <next_input@plt>
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x58(%rbp)
jne    12e4 <main+0xe4>
jmp    125e <main+0x5e>
lea    -0x50(%rbp),%rdi
xor    %edx,%edx
mov    %edx,%esi
call   10c0 <next_input@plt>
mov    %rax,-0x60(%rbp)
cmpq   $0x0,-0x60(%rbp)
jne    1305 <main+0x105>
jmp    125e <main+0x5e>
lea    -0x50(%rbp),%rdi
xor    %edx,%edx
mov    %edx,%esi
call   10c0 <next_input@plt>
mov    %rax,-0x68(%rbp)
cmpq   $0x0,-0x68(%rbp)
jne    1326 <main+0x126>
jmp    125e <main+0x5e>
lea    -0x50(%rbp),%rdi
xor    %edx,%edx
mov    %edx,%esi
call   10c0 <next_input@plt>
mov    %rax,-0x70(%rbp)
cmpq   $0x0,-0x70(%rbp)
jne    1347 <main+0x147>
jmp    125e <main+0x5e>
mov    -0x70(%rbp),%rdi
lea    0xcae(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    136d <main+0x16d>
movl   $0x0,-0x74(%rbp)
jmp    13cf <main+0x1cf>
mov    -0x70(%rbp),%rdi
lea    0xcc9(%rip),%rsi
call   1050 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1398 <main+0x198>
mov    0x2c5a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x74(%rbp)
jmp    13ca <main+0x1ca>
mov    -0x70(%rbp),%rdi
lea    -0xa8(%rbp),%rsi
xor    %edx,%edx
call   10b0 <strtol@plt>
mov    %eax,-0x74(%rbp)
mov    -0xa8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     13c5 <main+0x1c5>
jmp    125e <main+0x5e>
jmp    13ca <main+0x1ca>
jmp    13cf <main+0x1cf>
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   10c0 <next_input@plt>
mov    %rax,-0x80(%rbp)
cmpq   $0x0,-0x80(%rbp)
jne    13f9 <main+0x1f9>
lea    0xc6f(%rip),%rax
mov    %rax,-0x80(%rbp)
mov    -0x80(%rbp),%rdi
call   1030 <convert_flags@plt>
mov    %eax,-0x84(%rbp)
cmpl   $0xffffffff,-0x84(%rbp)
jne    141a <main+0x21a>
jmp    125e <main+0x5e>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    0x2ba6(%rip),%rax
mov    (%rax),%edi
mov    -0x58(%rbp),%rsi
call   10d0 <setlocale@plt>
cmp    $0x0,%rax
je     145b <main+0x25b>
mov    0x2b9a(%rip),%rax
mov    (%rax),%edi
mov    -0x58(%rbp),%rsi
call   10d0 <setlocale@plt>
cmp    $0x0,%rax
jne    1475 <main+0x275>
lea    0xba0(%rip),%rdi
call   1060 <puts@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    125e <main+0x5e>
mov    -0x68(%rbp),%rdi
mov    -0x60(%rbp),%rsi
mov    -0x84(%rbp),%edx
call   1080 <fnmatch@plt>
mov    %eax,-0x88(%rbp)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc4(%rbp)
mov    %eax,-0x44(%rbp)
mov    -0x68(%rbp),%rdi
lea    -0x40(%rbp),%rsi
lea    -0x38(%rbp),%rdx
call   1120 <escape@plt>
mov    %rax,-0xc0(%rbp)
mov    -0x60(%rbp),%rdi
lea    -0x30(%rbp),%rsi
lea    -0x28(%rbp),%rdx
call   1120 <escape@plt>
mov    %rax,-0xb8(%rbp)
mov    -0x84(%rbp),%edi
call   1110 <flag_output@plt>
mov    %rax,-0xb0(%rbp)
cmpl   $0x0,-0x88(%rbp)
jne    14ff <main+0x2ff>
lea    0xb0d(%rip),%rax
mov    %rax,-0xd0(%rbp)
jmp    155c <main+0x35c>
mov    -0x88(%rbp),%eax
mov    0x2adc(%rip),%rcx
cmp    (%rcx),%eax
jne    1527 <main+0x327>
lea    0xb22(%rip),%rax
mov    %rax,-0xd8(%rbp)
jmp    154e <main+0x34e>
lea    -0xa0(%rbp),%rdi
mov    -0x88(%rbp),%edx
lea    0xb0e(%rip),%rsi
call   1100 <sprintf@plt>
lea    -0xa0(%rbp),%rax
mov    %rax,-0xd8(%rbp)
mov    -0xd8(%rbp),%rax
mov    %rax,-0xd0(%rbp)
mov    -0xb0(%rbp),%r8
mov    -0xb8(%rbp),%rcx
mov    -0xc0(%rbp),%rdx
mov    -0xc4(%rbp),%esi
mov    -0xd0(%rbp),%r9
cmpl   $0x0,-0x88(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%r10d
cmpl   $0x0,-0x74(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%r11d
mov    $0xa,%eax
mov    $0x20,%edi
cmp    %r11d,%r10d
cmovne %edi,%eax
lea    0xa66(%rip),%rdi
mov    %eax,(%rsp)
mov    $0x0,%al
call   1070 <printf@plt>
cmpl   $0x0,-0x88(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%eax
cmpl   $0x0,-0x74(%rbp)
setne  %cl
and    $0x1,%cl
movzbl %cl,%ecx
cmp    %ecx,%eax
je     1672 <main+0x472>
cmpl   $0x0,-0x74(%rbp)
jne    15fd <main+0x3fd>
lea    0xa0f(%rip),%rax
mov    %rax,-0xe0(%rbp)
jmp    1654 <main+0x454>
mov    -0x74(%rbp),%eax
mov    0x29e1(%rip),%rcx
cmp    (%rcx),%eax
jne    1622 <main+0x422>
lea    0xa27(%rip),%rax
mov    %rax,-0xe8(%rbp)
jmp    1646 <main+0x446>
lea    -0xa0(%rbp),%rdi
mov    -0x74(%rbp),%edx
lea    0xa16(%rip),%rsi
call   1100 <sprintf@plt>
lea    -0xa0(%rbp),%rax
mov    %rax,-0xe8(%rbp)
mov    -0xe8(%rbp),%rax
mov    %rax,-0xe0(%rbp)
mov    -0xe0(%rbp),%rsi
lea    0x9ea(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    125e <main+0x5e>
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
lea    0x9e1(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x38(%rbp),%rdi
call   1040 <free@plt>
mov    -0x28(%rbp),%rdi
call   1040 <free@plt>
mov    -0x10(%rbp),%rdi
call   1040 <free@plt>
cmpl   $0x0,-0x20(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
movq   $0x0,0x28(%rsp)
movq   $0x0,0x20(%rsp)
movq   $0x0,0x40(%rsp)
movq   $0x0,0x58(%rsp)
movq   $0x0,0x38(%rsp)
movq   $0x0,0x50(%rsp)
movl   $0x0,0x10(%rsp)
xor    %eax,%eax
call   10f0 <mtrace@plt>
mov    0x2d7e(%rip),%rbp
mov    0x0(%rbp),%edi
call   10a0 <feof@plt>
movl   $0x0,0x14(%rsp)
test   %eax,%eax
je     12ba <main+0xba>
lea    0xdf0(%rip),%rdi
mov    0x14(%rsp),%esi
mov    0x10(%rsp),%ebx
mov    %ebx,%edx
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x38(%rsp),%rdi
call   1040 <free@plt>
mov    0x40(%rsp),%rdi
call   1040 <free@plt>
mov    0x28(%rsp),%rdi
call   1040 <free@plt>
xor    %eax,%eax
test   %ebx,%ebx
setne  %al
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x28(%rsp),%r15
lea    0x20(%rsp),%rbx
lea    0x18(%rsp),%r13
movl   $0x0,0x14(%rsp)
movl   $0x0,0x10(%rsp)
movl   $0x0,0x34(%rsp)
jmp    1310 <main+0x110>
lea    0x20(%rsp),%rbx
mov    %rdi,%r13
mov    0x2ce6(%rip),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x0(%rbp),%edi
call   10a0 <feof@plt>
test   %eax,%eax
jne    126e <main+0x6e>
mov    0x0(%rbp),%edx
mov    %r15,%rdi
mov    %rbx,%rsi
call   10e0 <getline@plt>
test   %eax,%eax
je     1300 <main+0x100>
cmp    $0xffffffff,%eax
je     126e <main+0x6e>
mov    0x28(%rsp),%rax
mov    %rax,0x18(%rsp)
mov    %r13,%rdi
mov    $0x1,%esi
xor    %edx,%edx
call   10c0 <next_input@plt>
test   %rax,%rax
je     1300 <main+0x100>
mov    %rax,%r14
mov    %r13,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   10c0 <next_input@plt>
test   %rax,%rax
je     1300 <main+0x100>
mov    %rax,%r12
mov    %r13,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   10c0 <next_input@plt>
mov    %r13,%rdi
test   %rax,%rax
je     12e3 <main+0xe3>
mov    %rax,%r13
xor    %esi,%esi
xor    %edx,%edx
call   10c0 <next_input@plt>
test   %rax,%rax
je     157f <main+0x37f>
mov    %rax,%rbp
mov    %rax,%rdi
lea    0xc66(%rip),%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
je     13d7 <main+0x1d7>
mov    %rbp,%rdi
lea    0xc93(%rip),%rsi
call   1050 <strcasecmp@plt>
test   %rax,%rax
je     13e1 <main+0x1e1>
mov    %rbp,%rdi
lea    0x48(%rsp),%rsi
xor    %edx,%edx
call   10b0 <strtol@plt>
mov    0x48(%rsp),%rcx
cmpb   $0x0,(%rcx)
jne    157f <main+0x37f>
jmp    13ea <main+0x1ea>
movl   $0x0,0x30(%rsp)
jmp    13ee <main+0x1ee>
mov    0x2c00(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x30(%rsp)
lea    0x18(%rsp),%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   10c0 <next_input@plt>
test   %rax,%rax
lea    0xc5b(%rip),%rcx
cmove  %rcx,%rax
mov    %rax,%rdi
call   1030 <convert_flags@plt>
cmp    $0xffffffff,%eax
lea    0x28(%rsp),%r15
je     1597 <main+0x397>
mov    %eax,%ebx
mov    0x14(%rsp),%ebp
add    $0x1,%ebp
mov    0x2b9d(%rip),%rax
mov    (%rax),%edi
mov    %r14,%rsi
call   10d0 <setlocale@plt>
test   %rax,%rax
mov    %ebp,0x14(%rsp)
je     1586 <main+0x386>
mov    0x2b8f(%rip),%rax
mov    (%rax),%edi
mov    %r14,%rsi
call   10d0 <setlocale@plt>
test   %rax,%rax
je     1586 <main+0x386>
mov    %r13,%rdi
mov    %r12,%rsi
mov    %ebx,%edx
call   1080 <fnmatch@plt>
mov    %eax,%r14d
mov    0x34(%rsp),%r15d
add    $0x1,%r15d
mov    %r13,%rdi
lea    0x50(%rsp),%rsi
lea    0x38(%rsp),%rdx
call   1120 <escape@plt>
mov    %rax,%r13
mov    %r12,%rdi
lea    0x58(%rsp),%rsi
lea    0x40(%rsp),%rdx
call   1120 <escape@plt>
mov    %rax,%r12
mov    %ebx,%edi
call   1110 <flag_output@plt>
mov    %rax,%rbx
lea    0xb48(%rip),%r9
test   %r14d,%r14d
je     14ea <main+0x2ea>
lea    0xb79(%rip),%r9
mov    0x2b1d(%rip),%rax
cmp    (%rax),%r14d
je     14ea <main+0x2ea>
lea    0x60(%rsp),%rbp
mov    %rbp,%rdi
lea    0xb6a(%rip),%rsi
mov    %r14d,%edx
call   1100 <sprintf@plt>
mov    %rbp,%r9
test   %r14d,%r14d
sete   %al
mov    0x30(%rsp),%r14d
test   %r14d,%r14d
setne  %bpl
xor    %al,%bpl
mov    $0x20,%eax
mov    $0xa,%ecx
cmovne %ecx,%eax
mov    %eax,(%rsp)
lea    0xb02(%rip),%rdi
mov    %r15d,%esi
mov    %r13,%rdx
mov    %r12,%rcx
mov    %rbx,%r8
xor    %eax,%eax
call   1070 <printf@plt>
test   %bpl,%bpl
mov    %r15d,0x34(%rsp)
jne    157f <main+0x37f>
lea    0xac6(%rip),%rsi
test   %r14d,%r14d
je     156c <main+0x36c>
lea    0xaf7(%rip),%rsi
mov    0x2a9b(%rip),%rax
cmp    (%rax),%r14d
je     156c <main+0x36c>
lea    0x60(%rsp),%rbx
mov    %rbx,%rdi
lea    0xae8(%rip),%rsi
mov    %r14d,%edx
call   1100 <sprintf@plt>
mov    %rbx,%rsi
lea    0xad9(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
addl   $0x1,0x10(%rsp)
lea    0x28(%rsp),%r15
jmp    1597 <main+0x397>
lea    0xa75(%rip),%rdi
call   1060 <puts@plt>
addl   $0x1,0x10(%rsp)
lea    0x20(%rsp),%rbx
lea    0x18(%rsp),%r13
jmp    12eb <main+0xeb>

LLVM IR (-O0):
@stdin = global i32 0
@.str = [2 x i8] c"0\00"
@.str.1 = [8 x i8] c"NOMATCH\00"
@FNM_NOMATCH = global i32 0
@.str.2 = [1 x i8] zeroinitializer
@LC_COLLATE = global i32 0
@LC_CTYPE = global i32 0
@.str.3 = [22 x i8] c"*** Cannot set locale\00"
@.str.4 = [37 x i8] c"%3d: fnmatch (\22%s\22, \22%s\22, %s) = %s%c\00"
@.str.5 = [12 x i8] c"FNM_NOMATCH\00"
@.str.6 = [3 x i8] c"%d\00"
@.str.7 = [25 x i8] c"(FAIL, expected %s) ***\0A\00"
@.str.8 = [45 x i8] c"=====================\0A%3d tests, %3d failed\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i8*
%16 = alloca i8*
%17 = alloca i32
%18 = alloca i8*
%19 = alloca i32
%20 = alloca i32
%21 = alloca [24 x i8]
%22 = alloca i8*
store i32 0, i32* %1
store i8* null, i8** %2
store i64 0, i64* %3
store i32 0, i32* %4
store i32 0, i32* %5
store i8* null, i8** %6
store i64 0, i64* %7
store i8* null, i8** %8
store i64 0, i64* %9
store i32 0, i32* %10
%23 = call i32 (...) @mtrace()
br label %24
24: ; preds = %176, %104, %91, %78, %59, %54, %49, %44, %38, %0
%25 = load i32, i32* @stdin
%26 = call i32 @feof(i32 %25)
%27 = icmp ne i32 %26, 0
%28 = xor i1 %27, true
br i1 %28, label %29, label %177
29: ; preds = %24
%30 = load i32, i32* @stdin
%31 = call i32 @getline(i8** %2, i64* %3, i32 %30)
store i32 %31, i32* %11
%32 = load i32, i32* %11
%33 = icmp eq i32 %32, -1
br i1 %33, label %34, label %35
34: ; preds = %29
br label %177
35: ; preds = %29
%36 = load i32, i32* %11
%37 = icmp eq i32 %36, 0
br i1 %37, label %38, label %39
38: ; preds = %35
br label %24
39: ; preds = %35
%40 = load i8*, i8** %2
store i8* %40, i8** %12
%41 = call i8* @next_input(i8** %12, i32 1, i32 0)
store i8* %41, i8** %13
%42 = load i8*, i8** %13
%43 = icmp eq i8* %42, null
br i1 %43, label %44, label %45
44: ; preds = %39
br label %24
45: ; preds = %39
%46 = call i8* @next_input(i8** %12, i32 0, i32 0)
store i8* %46, i8** %14
%47 = load i8*, i8** %14
%48 = icmp eq i8* %47, null
br i1 %48, label %49, label %50
49: ; preds = %45
br label %24
50: ; preds = %45
%51 = call i8* @next_input(i8** %12, i32 0, i32 0)
store i8* %51, i8** %15
%52 = load i8*, i8** %15
%53 = icmp eq i8* %52, null
br i1 %53, label %54, label %55
54: ; preds = %50
br label %24
55: ; preds = %50
%56 = call i8* @next_input(i8** %12, i32 0, i32 0)
store i8* %56, i8** %16
%57 = load i8*, i8** %16
%58 = icmp eq i8* %57, null
br i1 %58, label %59, label %60
59: ; preds = %55
br label %24
60: ; preds = %55
%61 = load i8*, i8** %16
%62 = call i64 @strcmp(i8* %61, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%63 = icmp eq i64 %62, 0
br i1 %63, label %64, label %65
64: ; preds = %60
store i32 0, i32* %17
br label %81
65: ; preds = %60
%66 = load i8*, i8** %16
%67 = call i64 @strcasecmp(i8* %66, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%68 = icmp eq i64 %67, 0
br i1 %68, label %69, label %71
69: ; preds = %65
%70 = load i32, i32* @FNM_NOMATCH
store i32 %70, i32* %17
br label %80
71: ; preds = %65
%72 = load i8*, i8** %16
%73 = call i32 @strtol(i8* %72, i8** %22, i32 0)
store i32 %73, i32* %17
%74 = load i8*, i8** %22
%75 = load i8, i8* %74
%76 = sext i8 %75 to i32
%77 = icmp ne i32 %76, 0
br i1 %77, label %78, label %79
78: ; preds = %71
br label %24
79: ; preds = %71
br label %80
80: ; preds = %79, %69
br label %81
81: ; preds = %80, %64
%82 = call i8* @next_input(i8** %12, i32 0, i32 1)
store i8* %82, i8** %18
%83 = load i8*, i8** %18
%84 = icmp eq i8* %83, null
br i1 %84, label %85, label %86
85: ; preds = %81
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8** %18
br label %86
86: ; preds = %85, %81
%87 = load i8*, i8** %18
%88 = call i32 @convert_flags(i8* %87)
store i32 %88, i32* %19
%89 = load i32, i32* %19
%90 = icmp eq i32 %89, -1
br i1 %90, label %91, label %92
91: ; preds = %86
br label %24
92: ; preds = %86
%93 = load i32, i32* %4
%94 = add nsw i32 %93, 1
store i32 %94, i32* %4
%95 = load i32, i32* @LC_COLLATE
%96 = load i8*, i8** %13
%97 = call i32* @setlocale(i32 %95, i8* %96)
%98 = icmp eq i32* %97, null
br i1 %98, label %104, label %99
99: ; preds = %92
%100 = load i32, i32* @LC_CTYPE
%101 = load i8*, i8** %13
%102 = call i32* @setlocale(i32 %100, i8* %101)
%103 = icmp eq i32* %102, null
br i1 %103, label %104, label %108
104: ; preds = %99, %92
%105 = call i32 @puts(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%106 = load i32, i32* %5
%107 = add nsw i32 %106, 1
store i32 %107, i32* %5
br label %24
108: ; preds = %99
%109 = load i8*, i8** %15
%110 = load i8*, i8** %14
%111 = load i32, i32* %19
%112 = call i32 @fnmatch(i8* %109, i8* %110, i32 %111)
store i32 %112, i32* %20
%113 = load i32, i32* %10
%114 = add nsw i32 %113, 1
store i32 %114, i32* %10
%115 = load i8*, i8** %15
%116 = call i8* @escape(i8* %115, i64* %9, i8** %8)
%117 = load i8*, i8** %14
%118 = call i8* @escape(i8* %117, i64* %7, i8** %6)
%119 = load i32, i32* %19
%120 = call i8* @flag_output(i32 %119)
%121 = load i32, i32* %20
%122 = icmp eq i32 %121, 0
br i1 %122, label %123, label %124
123: ; preds = %108
br label %136
124: ; preds = %108
%125 = load i32, i32* %20
%126 = load i32, i32* @FNM_NOMATCH
%127 = icmp eq i32 %125, %126
br i1 %127, label %128, label %129
128: ; preds = %124
br label %134
129: ; preds = %124
%130 = getelementptr inbounds [24 x i8], [24 x i8]* %21, i64 0, i64 0
%131 = load i32, i32* %20
%132 = call i8* @sprintf(i8* %130, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 %131)
%133 = getelementptr inbounds [24 x i8], [24 x i8]* %21, i64 0, i64 0
br label %134
134: ; preds = %129, %128
%135 = phi i8* [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), %128 ], [ %133, %129 ]
br label %136
136: ; preds = %134, %123
%137 = phi i8* [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), %123 ], [ %135, %134 ]
%138 = load i32, i32* %20
%139 = icmp ne i32 %138, 0
%140 = zext i1 %139 to i32
%141 = load i32, i32* %17
%142 = icmp ne i32 %141, 0
%143 = zext i1 %142 to i32
%144 = icmp ne i32 %140, %143
%145 = zext i1 %144 to i64
%146 = select i1 %144, i32 32, i32 10
%147 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i32 %114, i8* %116, i8* %118, i8* %120, i8* %137, i32 %146)
%148 = load i32, i32* %20
%149 = icmp ne i32 %148, 0
%150 = zext i1 %149 to i32
%151 = load i32, i32* %17
%152 = icmp ne i32 %151, 0
%153 = zext i1 %152 to i32
%154 = icmp ne i32 %150, %153
br i1 %154, label %155, label %176
155: ; preds = %136
%156 = load i32, i32* %17
%157 = icmp eq i32 %156, 0
br i1 %157, label %158, label %159
158: ; preds = %155
br label %171
159: ; preds = %155
%160 = load i32, i32* %17
%161 = load i32, i32* @FNM_NOMATCH
%162 = icmp eq i32 %160, %161
br i1 %162, label %163, label %164
163: ; preds = %159
br label %169
164: ; preds = %159
%165 = getelementptr inbounds [24 x i8], [24 x i8]* %21, i64 0, i64 0
%166 = load i32, i32* %17
%167 = call i8* @sprintf(i8* %165, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 %166)
%168 = getelementptr inbounds [24 x i8], [24 x i8]* %21, i64 0, i64 0
br label %169
169: ; preds = %164, %163
%170 = phi i8* [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), %163 ], [ %168, %164 ]
br label %171
171: ; preds = %169, %158
%172 = phi i8* [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), %158 ], [ %170, %169 ]
%173 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0), i8* %172)
%174 = load i32, i32* %5
%175 = add nsw i32 %174, 1
store i32 %175, i32* %5
br label %176
176: ; preds = %171, %136
br label %24
177: ; preds = %34, %24
%178 = load i32, i32* %4
%179 = load i32, i32* %5
%180 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.8, i64 0, i64 0), i32 %178, i32 %179)
%181 = load i8*, i8** %8
%182 = call i32 @free(i8* %181)
%183 = load i8*, i8** %6
%184 = call i32 @free(i8* %183)
%185 = load i8*, i8** %2
%186 = call i32 @free(i8* %185)
%187 = load i32, i32* %5
%188 = icmp ne i32 %187, 0
%189 = zext i1 %188 to i32
ret i32 %189
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [2 x i8] c"0\00"
@.str.1 = [8 x i8] c"NOMATCH\00"
@FNM_NOMATCH = global i32 0
@.str.2 = [1 x i8] zeroinitializer
@LC_COLLATE = global i32 0
@LC_CTYPE = global i32 0
@.str.3 = [22 x i8] c"*** Cannot set locale\00"
@.str.4 = [37 x i8] c"%3d: fnmatch (\22%s\22, \22%s\22, %s) = %s%c\00"
@.str.5 = [12 x i8] c"FNM_NOMATCH\00"
@.str.6 = [3 x i8] c"%d\00"
@.str.7 = [25 x i8] c"(FAIL, expected %s) ***\0A\00"
@.str.8 = [45 x i8] c"=====================\0A%3d tests, %3d failed\0A\00"
define i32 @main() {
%1 = alloca i8*
%2 = alloca i64
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i8*
%8 = alloca [24 x i8]
%9 = alloca i8*
%10 = bitcast i8** %1 to i8*
store i8* null, i8** %1
%11 = bitcast i64* %2 to i8*
store i64 0, i64* %2
%12 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%13 = bitcast i64* %4 to i8*
store i64 0, i64* %4
%14 = bitcast i8** %5 to i8*
store i8* null, i8** %5
%15 = bitcast i64* %6 to i8*
store i64 0, i64* %6
%16 = tail call i32 (...) @mtrace()
%17 = load i32, i32* @stdin
%18 = call i32 @feof(i32 %17)
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %112
20: ; preds = %0
%21 = bitcast i8** %7 to i8*
%22 = getelementptr inbounds [24 x i8], [24 x i8]* %8, i64 0, i64 0
%23 = bitcast i8** %9 to i8*
br label %24
24: ; preds = %20, %105
%25 = phi i32 [ 0, %20 ], [ %108, %105 ]
%26 = phi i32 [ 0, %20 ], [ %107, %105 ]
%27 = phi i32 [ 0, %20 ], [ %106, %105 ]
%28 = load i32, i32* @stdin
%29 = call i32 @getline(i8** %1, i64* %2, i32 %28)
switch i32 %29, label %31 [
i32 -1, label %30
i32 0, label %105
]
30: ; preds = %24
br label %112
31: ; preds = %24
%32 = load i8*, i8** %1
store i8* %32, i8** %7
%33 = call i8* @next_input(i8** %7, i32 1, i32 0)
%34 = icmp eq i8* %33, null
br i1 %34, label %105, label %35
35: ; preds = %31
%36 = call i8* @next_input(i8** %7, i32 0, i32 0)
%37 = icmp eq i8* %36, null
br i1 %37, label %105, label %38
38: ; preds = %35
%39 = call i8* @next_input(i8** %7, i32 0, i32 0)
%40 = icmp eq i8* %39, null
br i1 %40, label %105, label %41
41: ; preds = %38
%42 = call i8* @next_input(i8** %7, i32 0, i32 0)
%43 = icmp eq i8* %42, null
br i1 %43, label %105, label %44
44: ; preds = %41
%45 = call i64 @strcmp(i8* %42, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%46 = icmp eq i64 %45, 0
br i1 %46, label %57, label %47
47: ; preds = %44
%48 = call i64 @strcasecmp(i8* %42, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%49 = icmp eq i64 %48, 0
br i1 %49, label %50, label %52
50: ; preds = %47
%51 = load i32, i32* @FNM_NOMATCH
br label %57
52: ; preds = %47
%53 = call i32 @strtol(i8* %42, i8** %9, i32 0)
%54 = load i8*, i8** %9
%55 = load i8, i8* %54
%56 = icmp eq i8 %55, 0
br i1 %56, label %57, label %105
57: ; preds = %44, %50, %52
%58 = phi i32 [ %51, %50 ], [ %53, %52 ], [ 0, %44 ]
%59 = call i8* @next_input(i8** %7, i32 0, i32 1)
%60 = icmp eq i8* %59, null
%61 = select i1 %60, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* %59
%62 = call i32 @convert_flags(i8* %61)
%63 = icmp eq i32 %62, -1
br i1 %63, label %105, label %64
64: ; preds = %57
%65 = add nsw i32 %25, 1
%66 = load i32, i32* @LC_COLLATE
%67 = call i32* @setlocale(i32 %66, i8* %33)
%68 = icmp eq i32* %67, null
br i1 %68, label %73, label %69
69: ; preds = %64
%70 = load i32, i32* @LC_CTYPE
%71 = call i32* @setlocale(i32 %70, i8* %33)
%72 = icmp eq i32* %71, null
br i1 %72, label %73, label %76
73: ; preds = %69, %64
%74 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%75 = add nsw i32 %26, 1
br label %105
76: ; preds = %69
%77 = call i32 @fnmatch(i8* %39, i8* %36, i32 %62)
%78 = add nsw i32 %27, 1
%79 = call i8* @escape(i8* %39, i64* %6, i8** %5)
%80 = call i8* @escape(i8* %36, i64* %4, i8** %3)
%81 = call i8* @flag_output(i32 %62)
%82 = icmp eq i32 %77, 0
br i1 %82, label %88, label %83
83: ; preds = %76
%84 = load i32, i32* @FNM_NOMATCH
%85 = icmp eq i32 %77, %84
br i1 %85, label %88, label %86
86: ; preds = %83
%87 = call i8* @sprintf(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 %77)
br label %88
88: ; preds = %86, %83, %76
%89 = phi i8* [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), %76 ], [ %22, %86 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), %83 ]
%90 = icmp ne i32 %58, 0
%91 = xor i1 %90, %82
%92 = select i1 %91, i32 10, i32 32
%93 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i32 %78, i8* %79, i8* %80, i8* %81, i8* %89, i32 %92)
br i1 %91, label %105, label %94
94: ; preds = %88
%95 = icmp eq i32 %58, 0
br i1 %95, label %101, label %96
96: ; preds = %94
%97 = load i32, i32* @FNM_NOMATCH
%98 = icmp eq i32 %58, %97
br i1 %98, label %101, label %99
99: ; preds = %96
%100 = call i8* @sprintf(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 %58)
br label %101
101: ; preds = %99, %96, %94
%102 = phi i8* [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), %94 ], [ %22, %99 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), %96 ]
%103 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0), i8* %102)
%104 = add nsw i32 %26, 1
br label %105
105: ; preds = %24, %88, %101, %57, %41, %38, %35, %31, %52, %73
%106 = phi i32 [ %27, %73 ], [ %27, %52 ], [ %27, %31 ], [ %27, %35 ], [ %27, %38 ], [ %27, %41 ], [ %27, %57 ], [ %78, %101 ], [ %78, %88 ], [ %27, %24 ]
%107 = phi i32 [ %75, %73 ], [ %26, %52 ], [ %26, %31 ], [ %26, %35 ], [ %26, %38 ], [ %26, %41 ], [ %26, %57 ], [ %104, %101 ], [ %26, %88 ], [ %26, %24 ]
%108 = phi i32 [ %65, %73 ], [ %25, %52 ], [ %25, %31 ], [ %25, %35 ], [ %25, %38 ], [ %25, %41 ], [ %25, %57 ], [ %65, %101 ], [ %65, %88 ], [ %25, %24 ]
%109 = load i32, i32* @stdin
%110 = call i32 @feof(i32 %109)
%111 = icmp eq i32 %110, 0
br i1 %111, label %24, label %112
112: ; preds = %105, %0, %30
%113 = phi i32 [ %26, %30 ], [ 0, %0 ], [ %107, %105 ]
%114 = phi i32 [ %25, %30 ], [ 0, %0 ], [ %108, %105 ]
%115 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.8, i64 0, i64 0), i32 %114, i32 %113)
%116 = load i8*, i8** %5
%117 = call i32 @free(i8* %116)
%118 = load i8*, i8** %3
%119 = call i32 @free(i8* %118)
%120 = load i8*, i8** %1
%121 = call i32 @free(i8* %120)
%122 = icmp ne i32 %113, 0
%123 = zext i1 %122 to i32
ret i32 %123
}