#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__ getline_x(char *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ *strstr(char *, char *);
int main(int argc, char *argv[]) {
  char line[1000];
  long lineno = 0;
  int c, except = 0, number = 0, found = 0;
  while (--argc > 0 && (*++argv)[0] == '-')
    switch ((*argv)[1]) {
    case 'x':
      except = 1;
      break;
    case 'n':
      number = 1;
      break;
    default:
      printf("find: illegal option %c\n", c);
      argc = 0;
      found = -1;
      break;
    }
  if (argc != 1)
    printf("Usage: find -x -n pattern\n");
  else
    while (getline_x(line, 1000) > 0) {
      lineno++;
      if ((strstr(line, *argv) != NULL) != except) {
        if (number)
          printf("%ld: ", lineno);
        printf("%s\n", line);
        found++;
      }
    }
  return found;
}


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)
movq   $0x0,-0x408(%rbp)
movl   $0x0,-0x410(%rbp)
movl   $0x0,-0x414(%rbp)
movl   $0x0,-0x418(%rbp)
mov    -0x8(%rbp),%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x419(%rbp)
jle    11ae <main+0x7e>
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    11c1 <main+0x91>
jmp    123c <main+0x10c>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl 0x1(%rax),%eax
mov    %eax,-0x420(%rbp)
sub    $0x6e,%eax
je     1203 <main+0xd3>
jmp    11e0 <main+0xb0>
mov    -0x420(%rbp),%eax
sub    $0x78,%eax
jne    1212 <main+0xe2>
jmp    11f4 <main+0xc4>
movl   $0x1,-0x410(%rbp)
jmp    1237 <main+0x107>
movl   $0x1,-0x414(%rbp)
jmp    1237 <main+0x107>
mov    -0x40c(%rbp),%esi
lea    0xde1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x8(%rbp)
movl   $0xffffffff,-0x418(%rbp)
ff ff ff
jmp    1172 <main+0x42>
cmpl   $0x1,-0x8(%rbp)
je     1259 <main+0x129>
lea    0xdcc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1306 <main+0x1d6>
jmp    125e <main+0x12e>
lea    -0x400(%rbp),%rdi
mov    $0x3e8,%esi
call   1030 <getline_x@plt>
cmp    $0x0,%rax
jle    1301 <main+0x1d1>
mov    -0x408(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x408(%rbp)
lea    -0x400(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
call   1050 <strstr@plt>
cmp    $0x0,%rax
setne  %al
and    $0x1,%al
movzbl %al,%eax
cmp    -0x410(%rbp),%eax
je     12fc <main+0x1cc>
cmpl   $0x0,-0x414(%rbp)
je     12d8 <main+0x1a8>
mov    -0x408(%rbp),%rsi
lea    0xd63(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x400(%rbp),%rsi
lea    0xd54(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x418(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x418(%rbp)
jmp    125e <main+0x12e>
jmp    1306 <main+0x1d6>
mov    -0x418(%rbp),%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x3e8,%rsp
xor    %r14d,%r14d
cmp    $0x2,%edi
jl     124b <main+0x10b>
mov    %rsi,%rbx
add    $0x8,%rbx
xor    %r13d,%r13d
xor    %r12d,%r12d
jmp    1183 <main+0x43>
nopl   0x0(%rax)
add    $0xffffffff,%edi
add    $0x8,%rbx
mov    %eax,%r12d
cmp    $0x1,%edi
jbe    1232 <main+0xf2>
mov    (%rbx),%rax
cmpb   $0x2d,(%rax)
jne    11ad <main+0x6d>
movsbl 0x1(%rax),%ecx
mov    $0x1,%eax
cmp    $0x78,%ecx
je     1170 <main+0x30>
cmp    $0x6e,%ecx
jne    1237 <main+0xf7>
mov    $0x1,%r13d
mov    %r12d,%eax
jmp    1170 <main+0x30>
xor    %r14d,%r14d
cmp    $0x2,%edi
jne    124b <main+0x10b>
mov    %rsp,%rdi
mov    $0x3e8,%esi
call   1040 <getline_x@plt>
test   %rax,%rax
jle    126c <main+0x12c>
mov    $0x1,%ebp
mov    %rsp,%r15
xor    %r14d,%r14d
jmp    1202 <main+0xc2>
nopl   0x0(%rax)
mov    %r15,%rdi
call   1030 <puts@plt>
add    $0x1,%r14d
mov    %r15,%rdi
mov    $0x3e8,%esi
call   1040 <getline_x@plt>
add    $0x1,%rbp
test   %rax,%rax
jle    1257 <main+0x117>
mov    (%rbx),%rsi
mov    %r15,%rdi
call   1060 <strstr@plt>
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
cmp    %ecx,%r12d
je     11ec <main+0xac>
test   %r13d,%r13d
je     11e0 <main+0xa0>
lea    0xdf3(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11e0 <main+0xa0>
xor    %r14d,%r14d
jmp    124b <main+0x10b>
lea    0xdc2(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xffffffff,%r14d
lea    0xdcd(%rip),%rdi
call   1030 <puts@plt>
mov    %r14d,%eax
add    $0x3e8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %r14d,%r14d
jmp    1257 <main+0x117>

LLVM IR (-O0):
@.str = [25 x i8] c"find: illegal option %c\0A\00"
@.str.1 = [27 x i8] c"Usage: find -x -n pattern\0A\00"
@.str.2 = [6 x i8] c"%ld: \00"
@.str.3 = [4 x i8] c"%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 i64
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 0, i64* %7
store i32 0, i32* %9
store i32 0, i32* %10
store i32 0, i32* %11
br label %12
12: ; preds = %37, %2
%13 = load i32, i32* %4
%14 = add nsw i32 %13, -1
store i32 %14, i32* %4
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %24
16: ; preds = %12
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i32 1
store i8** %18, i8*** %5
%19 = load i8*, i8** %18
%20 = getelementptr inbounds i8, i8* %19, i64 0
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 45
br label %24
24: ; preds = %16, %12
%25 = phi i1 [ false, %12 ], [ %23, %16 ]
br i1 %25, label %26, label %38
26: ; preds = %24
%27 = load i8**, i8*** %5
%28 = load i8*, i8** %27
%29 = getelementptr inbounds i8, i8* %28, i64 1
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
switch i32 %31, label %34 [
i32 120, label %32
i32 110, label %33
]
32: ; preds = %26
store i32 1, i32* %9
br label %37
33: ; preds = %26
store i32 1, i32* %10
br label %37
34: ; preds = %26
%35 = load i32, i32* %8
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %35)
store i32 0, i32* %4
store i32 -1, i32* %11
br label %37
37: ; preds = %34, %33, %32
br label %12
38: ; preds = %24
%39 = load i32, i32* %4
%40 = icmp ne i32 %39, 1
br i1 %40, label %41, label %43
41: ; preds = %38
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
br label %72
43: ; preds = %38
br label %44
44: ; preds = %70, %43
%45 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%46 = call i64 @getline_x(i8* %45, i32 1000)
%47 = icmp sgt i64 %46, 0
br i1 %47, label %48, label %71
48: ; preds = %44
%49 = load i64, i64* %7
%50 = add nsw i64 %49, 1
store i64 %50, i64* %7
%51 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%52 = load i8**, i8*** %5
%53 = load i8*, i8** %52
%54 = call i32* @strstr(i8* %51, i8* %53)
%55 = icmp ne i32* %54, null
%56 = zext i1 %55 to i32
%57 = load i32, i32* %9
%58 = icmp ne i32 %56, %57
br i1 %58, label %59, label %70
59: ; preds = %48
%60 = load i32, i32* %10
%61 = icmp ne i32 %60, 0
br i1 %61, label %62, label %65
62: ; preds = %59
%63 = load i64, i64* %7
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i64 %63)
br label %65
65: ; preds = %62, %59
%66 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %66)
%68 = load i32, i32* %11
%69 = add nsw i32 %68, 1
store i32 %69, i32* %11
br label %70
70: ; preds = %65, %48
br label %44
71: ; preds = %44
br label %72
72: ; preds = %71, %41
%73 = load i32, i32* %11
ret i32 %73
}

LLVM IR (-O2):
@.str = [25 x i8] c"find: illegal option %c\0A\00"
@.str.2 = [6 x i8] c"%ld: \00"
@str = [26 x i8] c"Usage: find -x -n pattern\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 %6, label %34
6: ; preds = %2, %23
%7 = phi i32 [ %11, %23 ], [ %0, %2 ]
%8 = phi i32 [ %25, %23 ], [ 0, %2 ]
%9 = phi i32 [ %24, %23 ], [ 0, %2 ]
%10 = phi i8** [ %12, %23 ], [ %1, %2 ]
%11 = add nsw i32 %7, -1
%12 = getelementptr inbounds i8*, i8** %10, i64 1
%13 = load i8*, i8** %12
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 45
br i1 %15, label %16, label %27
16: ; preds = %6
%17 = getelementptr inbounds i8, i8* %13, i64 1
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
switch i32 %19, label %21 [
i32 120, label %23
i32 110, label %20
]
20: ; preds = %16
br label %23
21: ; preds = %16
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 undef)
br label %34
23: ; preds = %16, %20
%24 = phi i32 [ %9, %20 ], [ 1, %16 ]
%25 = phi i32 [ 1, %20 ], [ %8, %16 ]
%26 = icmp ugt i32 %11, 1
br i1 %26, label %6, label %34
27: ; preds = %6
%28 = icmp eq i32 %11, 1
br i1 %28, label %29, label %34
29: ; preds = %27
%30 = call i64 @getline_x(i8* %4, i32 1000)
%31 = icmp sgt i64 %30, 0
br i1 %31, label %32, label %56
32: ; preds = %29
%33 = icmp eq i32 %8, 0
br label %37
34: ; preds = %23, %21, %2, %27
%35 = phi i32 [ 0, %27 ], [ 0, %2 ], [ -1, %21 ], [ 0, %23 ]
%36 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
br label %56
37: ; preds = %32, %52
%38 = phi i32 [ 0, %32 ], [ %53, %52 ]
%39 = phi i64 [ 0, %32 ], [ %40, %52 ]
%40 = add nuw nsw i64 %39, 1
%41 = load i8*, i8** %12
%42 = call i32* @strstr(i8* %4, i8* dereferenceable(1) %41)
%43 = icmp ne i32* %42, null
%44 = zext i1 %43 to i32
%45 = icmp eq i32 %9, %44
br i1 %45, label %52, label %46
46: ; preds = %37
br i1 %33, label %49, label %47
47: ; preds = %46
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i64 %40)
br label %49
49: ; preds = %47, %46
%50 = call i32 @puts(i8* %4)
%51 = add nsw i32 %38, 1
br label %52
52: ; preds = %49, %37
%53 = phi i32 [ %51, %49 ], [ %38, %37 ]
%54 = call i64 @getline_x(i8* %4, i32 1000)
%55 = icmp sgt i64 %54, 0
br i1 %55, label %37, label %56
56: ; preds = %52, %29, %34
%57 = phi i32 [ %35, %34 ], [ 0, %29 ], [ %53, %52 ]
ret i32 %57
}