#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ findpat(int /*<<< orphan*/ *, char *, char *, int, int);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ *stdin;
int /*<<< orphan*/ strcpy(char *, char *);
int main(int argc, char *argv[]) {
  char pattern[1000];
  int c;
  bool except = false;
  bool number = false;
  FILE *fp;
  while (--argc > 0 && (*++argv)[0] == '-')
    while ((c = *++argv[0]) != '\0')
      switch (c) {
      case 'x':
        except = true;
        break;
      case 'n':
        number = true;
        break;
      default:
        fprintf(stderr, "minfind: illegal option %c\n", c);
        exit(EXIT_FAILURE);
      }
  if (argc < 1) {
    fprintf(stderr, "Usage: minfind [-x] [-n] pattern [file ...]\n");
    exit(EXIT_FAILURE);
  }
  strcpy(pattern, *argv);
  if (argc == 1) {
    findpat(stdin, "", pattern, except, number);
    exit(EXIT_SUCCESS);
  }
  while (--argc > 0) {
    if ((fp = fopen(*++argv, "r")) == NULL) {
      fprintf(stderr, "minfind: cannot open %s\n", *argv);
      exit(EXIT_FAILURE);
    }
    findpat(fp, *argv, pattern, except, number);
    (void)fclose(fp);
  }
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x408(%rbp)
movl   $0x0,-0x40c(%rbp)
mov    -0x8(%rbp),%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x419(%rbp)
jle    11c9 <main+0x69>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    0x8(%rax),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
sete   %al
mov    %al,-0x419(%rbp)
mov    -0x419(%rbp),%al
test   $0x1,%al
jne    11dc <main+0x7c>
jmp    1286 <main+0x126>
jmp    11e1 <main+0x81>
mov    -0x10(%rbp),%rcx
mov    (%rcx),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,(%rcx)
movsbl 0x1(%rax),%eax
mov    %eax,-0x404(%rbp)
cmp    $0x0,%eax
je     1281 <main+0x121>
mov    -0x404(%rbp),%eax
mov    %eax,-0x420(%rbp)
sub    $0x6e,%eax
je     1242 <main+0xe2>
jmp    121f <main+0xbf>
mov    -0x420(%rbp),%eax
sub    $0x78,%eax
jne    1251 <main+0xf1>
jmp    1233 <main+0xd3>
movl   $0x1,-0x408(%rbp)
jmp    127c <main+0x11c>
movl   $0x1,-0x40c(%rbp)
jmp    127c <main+0x11c>
mov    0x2d80(%rip),%rax
mov    (%rax),%edi
mov    -0x404(%rbp),%edx
lea    0xd99(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2d5b(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
jmp    11e1 <main+0x81>
jmp    118d <main+0x2d>
cmpl   $0x1,-0x8(%rbp)
jge    12b5 <main+0x155>
mov    0x2d41(%rip),%rax
mov    (%rax),%edi
lea    0xd7c(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2d22(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
lea    -0x400(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
call   1030 <strcpy@plt>
cmpl   $0x1,-0x8(%rbp)
jne    130a <main+0x1aa>
mov    0x2d0f(%rip),%rax
mov    (%rax),%rdi
lea    -0x400(%rbp),%rdx
mov    -0x408(%rbp),%ecx
mov    -0x40c(%rbp),%r8d
lea    0xd51(%rip),%rsi
call   1050 <findpat@plt>
mov    0x2cc5(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
jmp    130f <main+0x1af>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jle    13b5 <main+0x255>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    0x8(%rax),%rdi
lea    0xd0e(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x418(%rbp)
cmp    $0x0,%rax
jne    137d <main+0x21d>
mov    0x2c80(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xce3(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2c5a(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x418(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    -0x400(%rbp),%rdx
mov    -0x408(%rbp),%ecx
mov    -0x40c(%rbp),%r8d
call   1050 <findpat@plt>
mov    -0x418(%rbp),%rdi
call   1040 <fclose@plt>
jmp    130f <main+0x1af>
mov    0x2c0c(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x3e8,%rsp
cmp    $0x2,%edi
jl     11fb <main+0x9b>
mov    %edi,%r14d
lea    -0x1(%r14),%r15d
lea    0x10(%rsi),%r13
xor    %ebx,%ebx
xor    %ebp,%ebp
jmp    11a1 <main+0x41>
nopl   0x0(%rax,%rax,1)
mov    %ebp,%edi
add    $0xffffffff,%r15d
add    $0x8,%r13
mov    %edi,%ebp
cmp    $0x3,%ecx
jl     11fb <main+0x9b>
mov    %r14d,%ecx
lea    -0x1(%rcx),%r14d
mov    0x8(%rsi),%rax
cmpb   $0x2d,(%rax)
jne    1239 <main+0xd9>
add    $0x8,%rsi
lea    0x1(%rax),%rdx
mov    %rdx,(%rsi)
mov    0x1(%rax),%dl
test   %dl,%dl
je     1190 <main+0x30>
add    $0x2,%rax
jmp    11e0 <main+0x80>
nopl   (%rax)
mov    %rax,(%rsi)
movzbl (%rax),%edx
add    $0x1,%rax
mov    %edi,%ebp
test   %dl,%dl
je     1192 <main+0x32>
movsbl %dl,%edx
mov    $0x1,%edi
cmp    $0x78,%edx
je     11d0 <main+0x70>
cmp    $0x6e,%edx
jne    1214 <main+0xb4>
mov    $0x1,%ebx
mov    %ebp,%edi
jmp    11d0 <main+0x70>
mov    0x2dd6(%rip),%rax
mov    (%rax),%edi
lea    0xe11(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
jmp    122b <main+0xcb>
mov    0x2dbd(%rip),%rax
mov    (%rax),%edi
lea    0xddc(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    0x2d9e(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    %rsp,%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
cmp    $0x1,%r14d
jne    126a <main+0x10a>
mov    0x2d97(%rip),%rax
mov    (%rax),%rdi
lea    0xded(%rip),%rsi
mov    %rsp,%rdx
mov    %ebp,%ecx
mov    %ebx,%r8d
call   1050 <findpat@plt>
jmp    12b2 <main+0x152>
mov    %rsp,%r14
nopl   (%rax)
mov    0x0(%r13),%rdi
lea    0xdce(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     12c0 <main+0x160>
mov    %rax,%r12
mov    0x0(%r13),%rsi
mov    %rax,%rdi
mov    %r14,%rdx
mov    %ebp,%ecx
mov    %ebx,%r8d
call   1050 <findpat@plt>
mov    %r12,%rdi
call   1040 <fclose@plt>
add    $0xffffffff,%r15d
add    $0x8,%r13
cmp    $0x1,%r15d
jg     1270 <main+0x110>
mov    0x2d0f(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    0x2d11(%rip),%rax
mov    (%rax),%edi
mov    0x0(%r13),%rdx
lea    0xd77(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
jmp    122b <main+0xcb>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [28 x i8] c"minfind: illegal option %c\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [45 x i8] c"Usage: minfind [-x] [-n] pattern [file ...]\0A\00"
@stdin = global i32* null
@.str.2 = [1 x i8] zeroinitializer
@EXIT_SUCCESS = global i32 0
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [25 x i8] c"minfind: cannot open %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [1000 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %8
store i32 0, i32* %9
br label %11
11: ; preds = %45, %2
%12 = load i32, i32* %4
%13 = add nsw i32 %12, -1
store i32 %13, i32* %4
%14 = icmp sgt i32 %13, 0
br i1 %14, label %15, label %23
15: ; preds = %11
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i32 1
store i8** %17, i8*** %5
%18 = load i8*, i8** %17
%19 = getelementptr inbounds i8, i8* %18, i64 0
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 45
br label %23
23: ; preds = %15, %11
%24 = phi i1 [ false, %11 ], [ %22, %15 ]
br i1 %24, label %25, label %46
25: ; preds = %23
br label %26
26: ; preds = %44, %25
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 0
%29 = load i8*, i8** %28
%30 = getelementptr inbounds i8, i8* %29, i32 1
store i8* %30, i8** %28
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
store i32 %32, i32* %7
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %45
34: ; preds = %26
%35 = load i32, i32* %7
switch i32 %35, label %38 [
i32 120, label %36
i32 110, label %37
]
36: ; preds = %34
store i32 1, i32* %8
br label %44
37: ; preds = %34
store i32 1, i32* %9
br label %44
38: ; preds = %34
%39 = load i32, i32* @stderr
%40 = load i32, i32* %7
%41 = call i32 (i32, i8*, ...) @fprintf(i32 %39, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %40)
%42 = load i32, i32* @EXIT_FAILURE
%43 = call i32 @exit(i32 %42)
unreachable
44: ; preds = %37, %36
br label %26
45: ; preds = %26
br label %11
46: ; preds = %23
%47 = load i32, i32* %4
%48 = icmp slt i32 %47, 1
br i1 %48, label %49, label %54
49: ; preds = %46
%50 = load i32, i32* @stderr
%51 = call i32 (i32, i8*, ...) @fprintf(i32 %50, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0))
%52 = load i32, i32* @EXIT_FAILURE
%53 = call i32 @exit(i32 %52)
unreachable
54: ; preds = %46
%55 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%56 = load i8**, i8*** %5
%57 = load i8*, i8** %56
%58 = call i32 @strcpy(i8* %55, i8* %57)
%59 = load i32, i32* %4
%60 = icmp eq i32 %59, 1
br i1 %60, label %61, label %69
61: ; preds = %54
%62 = load i32*, i32** @stdin
%63 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%64 = load i32, i32* %8
%65 = load i32, i32* %9
%66 = call i32 @findpat(i32* %62, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* %63, i32 %64, i32 %65)
%67 = load i32, i32* @EXIT_SUCCESS
%68 = call i32 @exit(i32 %67)
unreachable
69: ; preds = %54
br label %70
70: ; preds = %87, %69
%71 = load i32, i32* %4
%72 = add nsw i32 %71, -1
store i32 %72, i32* %4
%73 = icmp sgt i32 %72, 0
br i1 %73, label %74, label %97
74: ; preds = %70
%75 = load i8**, i8*** %5
%76 = getelementptr inbounds i8*, i8** %75, i32 1
store i8** %76, i8*** %5
%77 = load i8*, i8** %76
%78 = call i32* @fopen(i8* %77, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %78, i32** %10
%79 = icmp eq i32* %78, null
br i1 %79, label %80, label %87
80: ; preds = %74
%81 = load i32, i32* @stderr
%82 = load i8**, i8*** %5
%83 = load i8*, i8** %82
%84 = call i32 (i32, i8*, ...) @fprintf(i32 %81, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i8* %83)
%85 = load i32, i32* @EXIT_FAILURE
%86 = call i32 @exit(i32 %85)
unreachable
87: ; preds = %74
%88 = load i32*, i32** %10
%89 = load i8**, i8*** %5
%90 = load i8*, i8** %89
%91 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%92 = load i32, i32* %8
%93 = load i32, i32* %9
%94 = call i32 @findpat(i32* %88, i8* %90, i8* %91, i32 %92, i32 %93)
%95 = load i32*, i32** %10
%96 = call i32 @fclose(i32* %95)
br label %70
97: ; preds = %70
%98 = load i32, i32* @EXIT_SUCCESS
%99 = call i32 @exit(i32 %98)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [28 x i8] c"minfind: illegal option %c\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [45 x i8] c"Usage: minfind [-x] [-n] pattern [file ...]\0A\00"
@stdin = global i32* null
@.str.2 = [1 x i8] zeroinitializer
@EXIT_SUCCESS = global i32 0
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [25 x i8] c"minfind: cannot open %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1000 x i8]
%4 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%5 = icmp sgt i32 %0, 1
br i1 %5, label %10, label %42
6: ; preds = %36, %20
%7 = phi i32 [ %13, %20 ], [ %37, %36 ]
%8 = phi i32 [ %12, %20 ], [ %38, %36 ]
%9 = icmp sgt i32 %11, 2
br i1 %9, label %10, label %42
10: ; preds = %2, %6
%11 = phi i32 [ %15, %6 ], [ %0, %2 ]
%12 = phi i32 [ %8, %6 ], [ 0, %2 ]
%13 = phi i32 [ %7, %6 ], [ 0, %2 ]
%14 = phi i8** [ %16, %6 ], [ %1, %2 ]
%15 = add nsw i32 %11, -1
%16 = getelementptr inbounds i8*, i8** %14, i64 1
%17 = load i8*, i8** %16
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 45
br i1 %19, label %20, label %47
20: ; preds = %10
%21 = getelementptr inbounds i8, i8* %17, i64 1
store i8* %21, i8** %16
%22 = load i8, i8* %21
%23 = icmp eq i8 %22, 0
br i1 %23, label %6, label %24
24: ; preds = %20, %36
%25 = phi i8* [ %39, %36 ], [ %21, %20 ]
%26 = phi i8 [ %40, %36 ], [ %22, %20 ]
%27 = phi i32 [ %38, %36 ], [ %12, %20 ]
%28 = phi i32 [ %37, %36 ], [ %13, %20 ]
%29 = sext i8 %26 to i32
switch i32 %29, label %31 [
i32 120, label %36
i32 110, label %30
]
30: ; preds = %24
br label %36
31: ; preds = %24
%32 = load i32, i32* @stderr
%33 = tail call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %29)
%34 = load i32, i32* @EXIT_FAILURE
%35 = tail call i32 @exit(i32 %34)
unreachable
36: ; preds = %24, %30
%37 = phi i32 [ %28, %30 ], [ 1, %24 ]
%38 = phi i32 [ 1, %30 ], [ %27, %24 ]
%39 = getelementptr inbounds i8, i8* %25, i64 1
store i8* %39, i8** %16
%40 = load i8, i8* %39
%41 = icmp eq i8 %40, 0
br i1 %41, label %6, label %24
42: ; preds = %6, %2
%43 = load i32, i32* @stderr
%44 = tail call i32 (i32, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0))
%45 = load i32, i32* @EXIT_FAILURE
%46 = tail call i32 @exit(i32 %45)
unreachable
47: ; preds = %10
%48 = call i32 @strcpy(i8* %4, i8* %17)
%49 = icmp eq i32 %15, 1
br i1 %49, label %52, label %50
50: ; preds = %47
%51 = add nsw i32 %11, -2
br label %57
52: ; preds = %47
%53 = load i32*, i32** @stdin
%54 = call i32 @findpat(i32* %53, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* %4, i32 %13, i32 %12)
%55 = load i32, i32* @EXIT_SUCCESS
%56 = call i32 @exit(i32 %55)
unreachable
57: ; preds = %50, %70
%58 = phi i32 [ %74, %70 ], [ %51, %50 ]
%59 = phi i8** [ %60, %70 ], [ %16, %50 ]
%60 = getelementptr inbounds i8*, i8** %59, i64 1
%61 = load i8*, i8** %60
%62 = call i32* @fopen(i8* %61, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%63 = icmp eq i32* %62, null
br i1 %63, label %64, label %70
64: ; preds = %57
%65 = load i32, i32* @stderr
%66 = load i8*, i8** %60
%67 = call i32 (i32, i8*, ...) @fprintf(i32 %65, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i8* %66)
%68 = load i32, i32* @EXIT_FAILURE
%69 = call i32 @exit(i32 %68)
unreachable
70: ; preds = %57
%71 = load i8*, i8** %60
%72 = call i32 @findpat(i32* %62, i8* %71, i8* %4, i32 %13, i32 %12)
%73 = call i32 @fclose(i32* %62)
%74 = add nsw i32 %58, -1
%75 = icmp sgt i32 %58, 1
br i1 %75, label %57, label %76
76: ; preds = %70
%77 = load i32, i32* @EXIT_SUCCESS
%78 = call i32 @exit(i32 %77)
unreachable
}