#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*/);
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;
  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    0x2d8a(%rip),%rax
mov    (%rax),%edi
call   10a0 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    126a <main+0x7a>
jmp    1660 <main+0x470>
mov    0x2d67(%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    1292 <main+0xa2>
jmp    1660 <main+0x470>
cmpl   $0x0,-0x48(%rbp)
jne    12a1 <main+0xb1>
jmp    1247 <main+0x57>
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    12cd <main+0xdd>
jmp    1247 <main+0x57>
lea    -0x50(%rbp),%rdi
xor    %edx,%edx
mov    %edx,%esi
call   10c0 <next_input@plt>
mov    %rax,-0x60(%rbp)
cmpq   $0x0,-0x60(%rbp)
jne    12ee <main+0xfe>
jmp    1247 <main+0x57>
lea    -0x50(%rbp),%rdi
xor    %edx,%edx
mov    %edx,%esi
call   10c0 <next_input@plt>
mov    %rax,-0x68(%rbp)
cmpq   $0x0,-0x68(%rbp)
jne    130f <main+0x11f>
jmp    1247 <main+0x57>
lea    -0x50(%rbp),%rdi
xor    %edx,%edx
mov    %edx,%esi
call   10c0 <next_input@plt>
mov    %rax,-0x70(%rbp)
cmpq   $0x0,-0x70(%rbp)
jne    1330 <main+0x140>
jmp    1247 <main+0x57>
mov    -0x70(%rbp),%rdi
lea    0xcc5(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    1356 <main+0x166>
movl   $0x0,-0x74(%rbp)
jmp    13b8 <main+0x1c8>
mov    -0x70(%rbp),%rdi
lea    0xce0(%rip),%rsi
call   1050 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1381 <main+0x191>
mov    0x2c71(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x74(%rbp)
jmp    13b3 <main+0x1c3>
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     13ae <main+0x1be>
jmp    1247 <main+0x57>
jmp    13b3 <main+0x1c3>
jmp    13b8 <main+0x1c8>
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   10c0 <next_input@plt>
mov    %rax,-0x80(%rbp)
cmpq   $0x0,-0x80(%rbp)
jne    13e2 <main+0x1f2>
lea    0xc86(%rip),%rax
mov    %rax,-0x80(%rbp)
mov    -0x80(%rbp),%rdi
call   1030 <convert_flags@plt>
mov    %eax,-0x84(%rbp)
cmpl   $0xffffffff,-0x84(%rbp)
jne    1403 <main+0x213>
jmp    1247 <main+0x57>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    0x2bbd(%rip),%rax
mov    (%rax),%edi
mov    -0x58(%rbp),%rsi
call   10d0 <setlocale@plt>
cmp    $0x0,%rax
je     1444 <main+0x254>
mov    0x2bb1(%rip),%rax
mov    (%rax),%edi
mov    -0x58(%rbp),%rsi
call   10d0 <setlocale@plt>
cmp    $0x0,%rax
jne    145e <main+0x26e>
lea    0xbb7(%rip),%rdi
call   1060 <puts@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1247 <main+0x57>
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   1110 <escape@plt>
mov    %rax,-0xc0(%rbp)
mov    -0x60(%rbp),%rdi
lea    -0x30(%rbp),%rsi
lea    -0x28(%rbp),%rdx
call   1110 <escape@plt>
mov    %rax,-0xb8(%rbp)
mov    -0x84(%rbp),%edi
call   1100 <flag_output@plt>
mov    %rax,-0xb0(%rbp)
cmpl   $0x0,-0x88(%rbp)
jne    14e8 <main+0x2f8>
lea    0xb24(%rip),%rax
mov    %rax,-0xd0(%rbp)
jmp    1545 <main+0x355>
mov    -0x88(%rbp),%eax
mov    0x2af3(%rip),%rcx
cmp    (%rcx),%eax
jne    1510 <main+0x320>
lea    0xb39(%rip),%rax
mov    %rax,-0xd8(%rbp)
jmp    1537 <main+0x347>
lea    -0xa0(%rbp),%rdi
mov    -0x88(%rbp),%edx
lea    0xb25(%rip),%rsi
call   10f0 <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    0xa7d(%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     165b <main+0x46b>
cmpl   $0x0,-0x74(%rbp)
jne    15e6 <main+0x3f6>
lea    0xa26(%rip),%rax
mov    %rax,-0xe0(%rbp)
jmp    163d <main+0x44d>
mov    -0x74(%rbp),%eax
mov    0x29f8(%rip),%rcx
cmp    (%rcx),%eax
jne    160b <main+0x41b>
lea    0xa3e(%rip),%rax
mov    %rax,-0xe8(%rbp)
jmp    162f <main+0x43f>
lea    -0xa0(%rbp),%rdi
mov    -0x74(%rbp),%edx
lea    0xa2d(%rip),%rsi
call   10f0 <sprintf@plt>
lea    -0xa0(%rbp),%rax
mov    %rax,-0xe8(%rbp)
mov    -0xe8(%rbp),%rax
mov    %rax,-0xe0(%rbp)
mov    -0xe0(%rbp),%rsi
lea    0xa01(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1247 <main+0x57>
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
lea    0x9f8(%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)
mov    0x2d9d(%rip),%rbp
mov    0x0(%rbp),%edi
call   10a0 <feof@plt>
movl   $0x0,0x10(%rsp)
movl   $0x0,0x14(%rsp)
test   %eax,%eax
je     12a3 <main+0xb3>
lea    0xe07(%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    12f0 <main+0x100>
lea    0x20(%rsp),%rbx
mov    %rdi,%r13
mov    0x2cfd(%rip),%rbp
nopl   0x0(%rax,%rax,1)
mov    0x0(%rbp),%edi
call   10a0 <feof@plt>
test   %eax,%eax
jne    1257 <main+0x67>
mov    0x0(%rbp),%edx
mov    %r15,%rdi
mov    %rbx,%rsi
call   10e0 <getline@plt>
test   %eax,%eax
je     12e0 <main+0xf0>
cmp    $0xffffffff,%eax
je     1257 <main+0x67>
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     12e0 <main+0xf0>
mov    %rax,%r14
mov    %r13,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   10c0 <next_input@plt>
test   %rax,%rax
je     12e0 <main+0xf0>
mov    %rax,%r12
mov    %r13,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   10c0 <next_input@plt>
mov    %r13,%rdi
test   %rax,%rax
je     12cc <main+0xdc>
mov    %rax,%r13
xor    %esi,%esi
xor    %edx,%edx
call   10c0 <next_input@plt>
test   %rax,%rax
je     155f <main+0x36f>
mov    %rax,%rbp
mov    %rax,%rdi
lea    0xc86(%rip),%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
je     13b7 <main+0x1c7>
mov    %rbp,%rdi
lea    0xcb3(%rip),%rsi
call   1050 <strcasecmp@plt>
test   %rax,%rax
je     13c1 <main+0x1d1>
mov    %rbp,%rdi
lea    0x48(%rsp),%rsi
xor    %edx,%edx
call   10b0 <strtol@plt>
mov    0x48(%rsp),%rcx
cmpb   $0x0,(%rcx)
jne    155f <main+0x36f>
jmp    13ca <main+0x1da>
movl   $0x0,0x30(%rsp)
jmp    13ce <main+0x1de>
mov    0x2c20(%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    0xc7b(%rip),%rcx
cmove  %rcx,%rax
mov    %rax,%rdi
call   1030 <convert_flags@plt>
cmp    $0xffffffff,%eax
lea    0x28(%rsp),%r15
je     1577 <main+0x387>
mov    %eax,%ebx
mov    0x14(%rsp),%ebp
add    $0x1,%ebp
mov    0x2bbd(%rip),%rax
mov    (%rax),%edi
mov    %r14,%rsi
call   10d0 <setlocale@plt>
test   %rax,%rax
mov    %ebp,0x14(%rsp)
je     1566 <main+0x376>
mov    0x2baf(%rip),%rax
mov    (%rax),%edi
mov    %r14,%rsi
call   10d0 <setlocale@plt>
test   %rax,%rax
je     1566 <main+0x376>
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   1110 <escape@plt>
mov    %rax,%r13
mov    %r12,%rdi
lea    0x58(%rsp),%rsi
lea    0x40(%rsp),%rdx
call   1110 <escape@plt>
mov    %rax,%r12
mov    %ebx,%edi
call   1100 <flag_output@plt>
mov    %rax,%rbx
lea    0xb68(%rip),%r9
test   %r14d,%r14d
je     14ca <main+0x2da>
lea    0xb99(%rip),%r9
mov    0x2b3d(%rip),%rax
cmp    (%rax),%r14d
je     14ca <main+0x2da>
lea    0x60(%rsp),%rbp
mov    %rbp,%rdi
lea    0xb8a(%rip),%rsi
mov    %r14d,%edx
call   10f0 <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    0xb22(%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    155f <main+0x36f>
lea    0xae6(%rip),%rsi
test   %r14d,%r14d
je     154c <main+0x35c>
lea    0xb17(%rip),%rsi
mov    0x2abb(%rip),%rax
cmp    (%rax),%r14d
je     154c <main+0x35c>
lea    0x60(%rsp),%rbx
mov    %rbx,%rdi
lea    0xb08(%rip),%rsi
mov    %r14d,%edx
call   10f0 <sprintf@plt>
mov    %rbx,%rsi
lea    0xaf9(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
addl   $0x1,0x10(%rsp)
lea    0x28(%rsp),%r15
jmp    1577 <main+0x387>
lea    0xa95(%rip),%rdi
call   1060 <puts@plt>
addl   $0x1,0x10(%rsp)
lea    0x20(%rsp),%rbx
lea    0x18(%rsp),%r13
jmp    12d4 <main+0xe4>

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

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