#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(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int getopt(int, char **, char *);
scalar_t__ optind;
int /*<<< orphan*/ printf(char *, char const *);
scalar_t__ search(int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *stdin;
int /*<<< orphan*/ usage();
int /*<<< orphan*/ warn(char *, char const *);
int main(int argc, char *argv[]) {
  const char *file;
  FILE *in;
  bool found, qflag, sflag;
  int c;
  qflag = sflag = false;
  while ((c = getopt(argc, argv, "qs")) != -1) {
    switch (c) {
    case 'q':
      qflag = true;
      break;
    case 's':
      sflag = true;
      break;
    default:
      usage();
    }
  }
  argc -= optind;
  argv += optind;
  found = false;
  if (argc == 0) {
    if (search(sflag, qflag, stdin))
      found = true;
  } else {
    while (argc--) {
      file = *argv++;
      in = fopen(file, "r");
      if (in == NULL) {
        if (!qflag)
          warn("%s", file);
        continue;
      }
      if (!qflag)
        printf("%s:\n", file);
      if (search(sflag, qflag, in))
        found = true;
      fclose(in);
    }
  }
  exit(found ? 0 : 1);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe4e(%rip),%rdx
call   1090 <getopt@plt>
mov    %eax,-0x30(%rbp)
cmp    $0xffffffff,%eax
je     120c <main+0x8c>
mov    -0x30(%rbp),%eax
mov    %eax,-0x34(%rbp)
sub    $0x71,%eax
je     11e8 <main+0x68>
jmp    11d7 <main+0x57>
mov    -0x34(%rbp),%eax
sub    $0x73,%eax
je     11f4 <main+0x74>
jmp    1200 <main+0x80>
movl   $0x1,-0x28(%rbp)
jmp    1207 <main+0x87>
movl   $0x1,-0x2c(%rbp)
jmp    1207 <main+0x87>
mov    $0x0,%al
call   1070 <usage@plt>
jmp    11a4 <main+0x24>
mov    0x2dcd(%rip),%rax
mov    (%rax),%rcx
movslq -0x8(%rbp),%rax
sub    %rcx,%rax
mov    %eax,-0x8(%rbp)
mov    0x2db9(%rip),%rax
mov    (%rax),%rax
shl    $0x3,%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1272 <main+0xf2>
mov    -0x2c(%rbp),%edi
mov    -0x28(%rbp),%esi
mov    0x2d94(%rip),%rax
mov    (%rax),%rdx
call   1060 <search@plt>
cmp    $0x0,%rax
je     126d <main+0xed>
movl   $0x1,-0x24(%rbp)
jmp    132c <main+0x1ac>
jmp    1277 <main+0xf7>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x0,%eax
je     1327 <main+0x1a7>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xd57(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    12df <main+0x15f>
cmpl   $0x0,-0x28(%rbp)
jne    12da <main+0x15a>
mov    -0x18(%rbp),%rsi
lea    0xd30(%rip),%rdi
call   1030 <warn@plt>
jmp    1277 <main+0xf7>
cmpl   $0x0,-0x28(%rbp)
jne    12f9 <main+0x179>
mov    -0x18(%rbp),%rsi
lea    0xd14(%rip),%rdi
call   1050 <printf@plt>
mov    -0x2c(%rbp),%edi
mov    -0x28(%rbp),%esi
mov    -0x20(%rbp),%rdx
call   1060 <search@plt>
cmp    $0x0,%rax
je     1319 <main+0x199>
movl   $0x1,-0x24(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
jmp    1277 <main+0xf7>
jmp    132c <main+0x1ac>
mov    -0x24(%rbp),%ecx
mov    $0x1,%edi
xor    %eax,%eax
cmp    $0x0,%ecx
cmovne %eax,%edi
call   10a0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbp
mov    %edi,%ebx
mov    $0x1,%r14b
lea    0xe63(%rip),%r12
xor    %r15d,%r15d
xor    %r13d,%r13d
jmp    11b0 <main+0x30>
mov    $0x1,%r13d
nopl   0x0(%rax,%rax,1)
mov    %ebx,%edi
mov    %rbp,%rsi
mov    %r12,%rdx
call   1090 <getopt@plt>
cmp    $0x71,%eax
je     11d5 <main+0x55>
cmp    $0x73,%eax
je     11a5 <main+0x25>
cmp    $0xffffffff,%eax
je     11e0 <main+0x60>
xor    %eax,%eax
call   1070 <usage@plt>
jmp    11b0 <main+0x30>
mov    $0x1,%r15d
xor    %r14d,%r14d
jmp    11b0 <main+0x30>
mov    0x2df9(%rip),%rax
mov    (%rax),%rax
sub    %eax,%ebx
jne    121f <main+0x9f>
mov    0x2df3(%rip),%rax
mov    (%rax),%rdx
mov    %r13d,%edi
mov    %r15d,%esi
call   1060 <search@plt>
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
mov    %ecx,0xc(%rsp)
xor    %edi,%edi
cmpl   $0x0,0xc(%rsp)
sete   %dil
call   10a0 <exit@plt>
mov    %r13d,0x10(%rsp)
mov    %r15d,0x14(%rsp)
lea    0x0(,%rax,8),%r15
add    %rbp,%r15
movl   $0x0,0xc(%rsp)
lea    0xdc0(%rip),%rbp
jmp    1285 <main+0x105>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r12d,%ebx
neg    %ebx
mov    0x10(%rsp),%edi
mov    0x14(%rsp),%esi
mov    %r13,%rdx
call   1060 <search@plt>
test   %rax,%rax
mov    0xc(%rsp),%eax
mov    $0x1,%ecx
cmovne %ecx,%eax
mov    %eax,0xc(%rsp)
mov    %r13,%rdi
call   1040 <fclose@plt>
test   %r12d,%r12d
je     120f <main+0x8f>
mov    $0x1,%r12d
sub    %ebx,%r12d
add    $0x8,%r15
jmp    12b2 <main+0x132>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%r12d
add    $0x8,%r15
cmp    $0x1,%r12d
je     120f <main+0x8f>
mov    -0x8(%r15),%rbx
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1080 <fopen@plt>
test   %rax,%rax
jne    12e0 <main+0x160>
test   $0x1,%r14b
je     12a0 <main+0x120>
lea    0xd32(%rip),%rdi
mov    %rbx,%rsi
call   1030 <warn@plt>
jmp    12a0 <main+0x120>
nopl   (%rax)
mov    %rax,%r13
test   $0x1,%r14b
je     1250 <main+0xd0>
lea    0xd14(%rip),%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
jmp    1250 <main+0xd0>

LLVM IR (-O0):
@.str = [3 x i8] c"qs\00"
@optind = global i64 0
@stdin = global i32* null
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [5 x i8] c"%s:\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32*
%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 i32 0, i32* %10
store i32 0, i32* %9
br label %12
12: ; preds = %23, %2
%13 = load i32, i32* %4
%14 = load i8**, i8*** %5
%15 = call i32 @getopt(i32 %13, i8** %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 %15, i32* %11
%16 = icmp ne i32 %15, -1
br i1 %16, label %17, label %24
17: ; preds = %12
%18 = load i32, i32* %11
switch i32 %18, label %21 [
i32 113, label %19
i32 115, label %20
]
19: ; preds = %17
store i32 1, i32* %9
br label %23
20: ; preds = %17
store i32 1, i32* %10
br label %23
21: ; preds = %17
%22 = call i32 (...) @usage()
br label %23
23: ; preds = %21, %20, %19
br label %12
24: ; preds = %12
%25 = load i64, i64* @optind
%26 = load i32, i32* %4
%27 = sext i32 %26 to i64
%28 = sub nsw i64 %27, %25
%29 = trunc i64 %28 to i32
store i32 %29, i32* %4
%30 = load i64, i64* @optind
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 %30
store i8** %32, i8*** %5
store i32 0, i32* %8
%33 = load i32, i32* %4
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %43
35: ; preds = %24
%36 = load i32, i32* %10
%37 = load i32, i32* %9
%38 = load i32*, i32** @stdin
%39 = call i64 @search(i32 %36, i32 %37, i32* %38)
%40 = icmp ne i64 %39, 0
br i1 %40, label %41, label %42
41: ; preds = %35
store i32 1, i32* %8
br label %42
42: ; preds = %41, %35
br label %80
43: ; preds = %24
br label %44
44: ; preds = %76, %62, %43
%45 = load i32, i32* %4
%46 = add nsw i32 %45, -1
store i32 %46, i32* %4
%47 = icmp ne i32 %45, 0
br i1 %47, label %48, label %79
48: ; preds = %44
%49 = load i8**, i8*** %5
%50 = getelementptr inbounds i8*, i8** %49, i32 1
store i8** %50, i8*** %5
%51 = load i8*, i8** %49
store i8* %51, i8** %6
%52 = load i8*, i8** %6
%53 = call i32* @fopen(i8* %52, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %53, i32** %7
%54 = load i32*, i32** %7
%55 = icmp eq i32* %54, null
br i1 %55, label %56, label %63
56: ; preds = %48
%57 = load i32, i32* %9
%58 = icmp ne i32 %57, 0
br i1 %58, label %62, label %59
59: ; preds = %56
%60 = load i8*, i8** %6
%61 = call i32 @warn(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %60)
br label %62
62: ; preds = %59, %56
br label %44
63: ; preds = %48
%64 = load i32, i32* %9
%65 = icmp ne i32 %64, 0
br i1 %65, label %69, label %66
66: ; preds = %63
%67 = load i8*, i8** %6
%68 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %67)
br label %69
69: ; preds = %66, %63
%70 = load i32, i32* %10
%71 = load i32, i32* %9
%72 = load i32*, i32** %7
%73 = call i64 @search(i32 %70, i32 %71, i32* %72)
%74 = icmp ne i64 %73, 0
br i1 %74, label %75, label %76
75: ; preds = %69
store i32 1, i32* %8
br label %76
76: ; preds = %75, %69
%77 = load i32*, i32** %7
%78 = call i32 @fclose(i32* %77)
br label %44
79: ; preds = %44
br label %80
80: ; preds = %79, %42
%81 = load i32, i32* %8
%82 = icmp ne i32 %81, 0
%83 = zext i1 %82 to i64
%84 = select i1 %82, i32 0, i32 1
%85 = call i32 @exit(i32 %84)
unreachable
}

LLVM IR (-O2):
@.str = [3 x i8] c"qs\00"
@optind = global i64 0
@stdin = global i32* null
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [5 x i8] c"%s:\0A\00"
define i32 @main(i32 %0, i8** %1) {
br label %3
3: ; preds = %9, %2
%4 = phi i1 [ true, %2 ], [ false, %9 ]
%5 = phi i32 [ 0, %2 ], [ 1, %9 ]
%6 = phi i32 [ 0, %2 ], [ %8, %9 ]
br label %7
7: ; preds = %9, %3
%8 = phi i32 [ %6, %3 ], [ 1, %9 ]
br label %9
9: ; preds = %7, %11
%10 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
switch i32 %10, label %11 [
i32 -1, label %13
i32 113, label %3
i32 115, label %7
]
11: ; preds = %9
%12 = tail call i32 (...) @usage()
br label %9
13: ; preds = %9
%14 = load i64, i64* @optind
%15 = trunc i64 %14 to i32
%16 = sub i32 %0, %15
%17 = icmp eq i32 %16, 0
br i1 %17, label %20, label %18
18: ; preds = %13
%19 = getelementptr inbounds i8*, i8** %1, i64 %14
br label %47
20: ; preds = %13
%21 = load i32*, i32** @stdin
%22 = tail call i64 @search(i32 %8, i32 %5, i32* %21)
%23 = icmp ne i64 %22, 0
%24 = zext i1 %23 to i32
br label %51
25: ; preds = %47, %36
%26 = phi i32 [ %48, %47 ], [ %28, %36 ]
%27 = phi i8** [ %50, %47 ], [ %29, %36 ]
%28 = add nsw i32 %26, -1
%29 = getelementptr inbounds i8*, i8** %27, i64 1
%30 = load i8*, i8** %27
%31 = tail call i32* @fopen(i8* %30, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%32 = icmp eq i32* %31, null
br i1 %32, label %33, label %38
33: ; preds = %25
br i1 %4, label %34, label %36
34: ; preds = %33
%35 = tail call i32 @warn(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %30)
br label %36
36: ; preds = %34, %33
%37 = icmp eq i32 %28, 0
br i1 %37, label %51, label %25
38: ; preds = %25
br i1 %4, label %39, label %41
39: ; preds = %38
%40 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %30)
br label %41
41: ; preds = %39, %38
%42 = tail call i64 @search(i32 %8, i32 %5, i32* %31)
%43 = icmp eq i64 %42, 0
%44 = select i1 %43, i32 %49, i32 1
%45 = tail call i32 @fclose(i32* %31)
%46 = icmp eq i32 %28, 0
br i1 %46, label %51, label %47
47: ; preds = %18, %41
%48 = phi i32 [ %16, %18 ], [ %28, %41 ]
%49 = phi i32 [ 0, %18 ], [ %44, %41 ]
%50 = phi i8** [ %19, %18 ], [ %29, %41 ]
br label %25
51: ; preds = %41, %36, %20
%52 = phi i32 [ %24, %20 ], [ %49, %36 ], [ %44, %41 ]
%53 = icmp eq i32 %52, 0
%54 = zext i1 %53 to i32
%55 = tail call i32 @exit(i32 %54)
unreachable
}