#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*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ puts(char *);
int scanf(char *, char *);
scalar_t__ strstr(char *, char *);
int main(int argc, char *argv[]) {
  char line[80];
  if (argc < 2) {
    puts("Too few arguments");
    return 1;
  }
  FILE *files[argc - 1];
  int i, j;
  int use = 0;
  if (strstr(argv[1], "-a"))
    use = 1;
  for (i = 1; i < argc; i++) {
    if (!strstr(argv[i], "-a")) {
      if (use) {
        files[i - 1] = fopen(argv[i], "a");
      } else {
        files[i - 1] = fopen(argv[i], "w");
      }
    }
  }
  while (scanf("%79[^\n]\n", line) == 1) {
    printf("%s\n", line);
    for (j = 1; j < argc; j++) {
      if (!strstr(argv[j], "-a"))
        fprintf(files[j - 1], "%s\n", line);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    119b <main+0x3b>
lea    0xe76(%rip),%rdi
call   1030 <puts@plt>
movl   $0x1,-0x4(%rbp)
jmp    135b <main+0x1fb>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %rsp,%rcx
mov    %rcx,-0x68(%rbp)
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x88(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x70(%rbp)
movl   $0x0,-0x7c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe34(%rip),%rsi
call   1080 <strstr@plt>
cmp    $0x0,%rax
je     11f4 <main+0x94>
movl   $0x1,-0x7c(%rbp)
movl   $0x1,-0x74(%rbp)
mov    -0x74(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12ae <main+0x14e>
mov    -0x10(%rbp),%rax
movslq -0x74(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xdf8(%rip),%rsi
call   1080 <strstr@plt>
cmp    $0x0,%rax
jne    129b <main+0x13b>
cmpl   $0x0,-0x7c(%rbp)
je     1267 <main+0x107>
mov    -0x10(%rbp),%rax
movslq -0x74(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xdcd(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rdx
mov    -0x88(%rbp),%rax
mov    -0x74(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
jmp    1296 <main+0x136>
mov    -0x10(%rbp),%rax
movslq -0x74(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xd9b(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rdx
mov    -0x88(%rbp),%rax
mov    -0x74(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
jmp    129b <main+0x13b>
jmp    12a0 <main+0x140>
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    11fb <main+0x9b>
jmp    12b3 <main+0x153>
lea    -0x60(%rbp),%rsi
lea    0xd59(%rip),%rdi
call   1060 <scanf@plt>
cmp    $0x1,%eax
jne    134d <main+0x1ed>
lea    -0x60(%rbp),%rsi
lea    0xd49(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x78(%rbp)
mov    -0x78(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1348 <main+0x1e8>
mov    -0x10(%rbp),%rax
movslq -0x78(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xd10(%rip),%rsi
call   1080 <strstr@plt>
cmp    $0x0,%rax
jne    1335 <main+0x1d5>
mov    -0x88(%rbp),%rax
mov    -0x78(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x60(%rbp),%rdx
lea    0xcf0(%rip),%rsi
call   1050 <fprintf@plt>
jmp    133a <main+0x1da>
mov    -0x78(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x78(%rbp)
jmp    12e3 <main+0x183>
jmp    12b3 <main+0x153>
movl   $0x0,-0x4(%rbp)
mov    -0x68(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
cmp    $0x1,%edi
jg     118c <main+0x2c>
lea    0xe83(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
jmp    12da <main+0x17a>
mov    %rsi,%rbx
mov    %edi,%r14d
mov    %rsp,-0x38(%rbp)
lea    -0x1(%r14),%eax
mov    %rsp,%rcx
lea    0xf(,%rax,8),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    0x8(%rsi),%rdi
lea    0xe54(%rip),%rsi
call   1080 <strstr@plt>
test   %rax,%rax
mov    %r14d,%r15d
lea    0xe45(%rip),%rax
lea    0xe3c(%rip),%rcx
cmove  %rax,%rcx
mov    %rcx,-0x40(%rbp)
lea    -0x1(%r15),%r13
xor    %r12d,%r12d
jmp    11f9 <main+0x99>
nopl   0x0(%rax,%rax,1)
add    $0x1,%r12
cmp    %r12,%r13
je     1227 <main+0xc7>
mov    0x8(%rbx,%r12,8),%rdi
lea    0xe0d(%rip),%rsi
call   1080 <strstr@plt>
test   %rax,%rax
jne    11f0 <main+0x90>
mov    0x8(%rbx,%r12,8),%rdi
mov    -0x40(%rbp),%rsi
call   1070 <fopen@plt>
mov    -0x30(%rbp),%rcx
mov    %rax,(%rcx,%r12,8)
jmp    11f0 <main+0x90>
lea    0xde9(%rip),%rdi
lea    -0xa0(%rbp),%rsi
call   1060 <scanf@plt>
cmp    $0x1,%eax
jne    12d4 <main+0x174>
add    $0xffffffffffffffff,%r15
lea    -0xa0(%rbp),%r12
lea    0xdbd(%rip),%r13
mov    %r14,-0x48(%rbp)
jmp    1278 <main+0x118>
nopl   0x0(%rax,%rax,1)
lea    0xdb0(%rip),%rdi
mov    %r12,%rsi
call   1060 <scanf@plt>
cmp    $0x1,%eax
mov    -0x48(%rbp),%r14
jne    12d4 <main+0x174>
lea    0xda1(%rip),%rdi
mov    %r12,%rsi
call   1040 <printf@plt>
cmp    $0x2,%r14d
jl     1260 <main+0x100>
xor    %r14d,%r14d
jmp    12a9 <main+0x149>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%r14
cmp    %r14,%r15
je     1260 <main+0x100>
mov    0x8(%rbx,%r14,8),%rdi
mov    %r13,%rsi
call   1080 <strstr@plt>
test   %rax,%rax
jne    12a0 <main+0x140>
mov    -0x30(%rbp),%rax
mov    (%rax,%r14,8),%rdi
lea    0xd56(%rip),%rsi
mov    %r12,%rdx
call   1050 <fprintf@plt>
jmp    12a0 <main+0x140>
mov    -0x38(%rbp),%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"Too few arguments\00"
@.str.1 = [3 x i8] c"-a\00"
@.str.2 = [2 x i8] c"a\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [9 x i8] c"%79[^\0A]\0A\00"
@.str.5 = [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 [80 x i8]
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 2
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = call i32 @puts(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %106
16: ; preds = %2
%17 = load i32, i32* %4
%18 = sub nsw i32 %17, 1
%19 = zext i32 %18 to i64
%20 = call i8* @llvm.stacksave()
store i8* %20, i8** %7
%21 = alloca i32*, i64 %19
store i64 %19, i64* %8
store i32 0, i32* %11
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i64 @strstr(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %16
store i32 1, i32* %11
br label %28
28: ; preds = %27, %16
store i32 1, i32* %9
br label %29
29: ; preds = %68, %28
%30 = load i32, i32* %9
%31 = load i32, i32* %4
%32 = icmp slt i32 %30, %31
br i1 %32, label %33, label %71
33: ; preds = %29
%34 = load i8**, i8*** %5
%35 = load i32, i32* %9
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8*, i8** %34, i64 %36
%38 = load i8*, i8** %37
%39 = call i64 @strstr(i8* %38, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%40 = icmp ne i64 %39, 0
br i1 %40, label %67, label %41
41: ; preds = %33
%42 = load i32, i32* %11
%43 = icmp ne i32 %42, 0
br i1 %43, label %44, label %55
44: ; preds = %41
%45 = load i8**, i8*** %5
%46 = load i32, i32* %9
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8*, i8** %45, i64 %47
%49 = load i8*, i8** %48
%50 = call i32* @fopen(i8* %49, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%51 = load i32, i32* %9
%52 = sub nsw i32 %51, 1
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i32*, i32** %21, i64 %53
store i32* %50, i32** %54
br label %66
55: ; preds = %41
%56 = load i8**, i8*** %5
%57 = load i32, i32* %9
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i8*, i8** %56, i64 %58
%60 = load i8*, i8** %59
%61 = call i32* @fopen(i8* %60, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%62 = load i32, i32* %9
%63 = sub nsw i32 %62, 1
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds i32*, i32** %21, i64 %64
store i32* %61, i32** %65
br label %66
66: ; preds = %55, %44
br label %67
67: ; preds = %66, %33
br label %68
68: ; preds = %67
%69 = load i32, i32* %9
%70 = add nsw i32 %69, 1
store i32 %70, i32* %9
br label %29
71: ; preds = %29
br label %72
72: ; preds = %103, %71
%73 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%74 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* %73)
%75 = icmp eq i32 %74, 1
br i1 %75, label %76, label %104
76: ; preds = %72
%77 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%78 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %77)
store i32 1, i32* %10
br label %79
79: ; preds = %100, %76
%80 = load i32, i32* %10
%81 = load i32, i32* %4
%82 = icmp slt i32 %80, %81
br i1 %82, label %83, label %103
83: ; preds = %79
%84 = load i8**, i8*** %5
%85 = load i32, i32* %10
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds i8*, i8** %84, i64 %86
%88 = load i8*, i8** %87
%89 = call i64 @strstr(i8* %88, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%90 = icmp ne i64 %89, 0
br i1 %90, label %99, label %91
91: ; preds = %83
%92 = load i32, i32* %10
%93 = sub nsw i32 %92, 1
%94 = sext i32 %93 to i64
%95 = getelementptr inbounds i32*, i32** %21, i64 %94
%96 = load i32*, i32** %95
%97 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%98 = call i32 @fprintf(i32* %96, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %97)
br label %99
99: ; preds = %91, %83
br label %100
100: ; preds = %99
%101 = load i32, i32* %10
%102 = add nsw i32 %101, 1
store i32 %102, i32* %10
br label %79
103: ; preds = %79
br label %72
104: ; preds = %72
store i32 0, i32* %3
%105 = load i8*, i8** %7
br label %106
106: ; preds = %104, %14
%107 = load i32, i32* %3
ret i32 %107
}

LLVM IR (-O2):
@.str = [18 x i8] c"Too few arguments\00"
@.str.1 = [3 x i8] c"-a\00"
@.str.2 = [2 x i8] c"a\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [9 x i8] c"%79[^\0A]\0A\00"
@.str.5 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [80 x i8]
%4 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%5 = icmp slt i32 %0, 2
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %59
8: ; preds = %2
%9 = add nsw i32 %0, -1
%10 = zext i32 %9 to i64
%11 = tail call i8* @llvm.stacksave()
%12 = alloca i32*, i64 %10
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = tail call i64 @strstr(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
%17 = zext i32 %0 to i64
%18 = select i1 %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0)
br label %25
19: ; preds = %36
%20 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* %4)
%21 = icmp eq i32 %20, 1
br i1 %21, label %22, label %58
22: ; preds = %19
%23 = icmp sgt i32 %0, 1
%24 = zext i32 %0 to i64
br label %42
25: ; preds = %8, %36
%26 = phi i64 [ 1, %8 ], [ %37, %36 ]
%27 = getelementptr inbounds i8*, i8** %1, i64 %26
%28 = load i8*, i8** %27
%29 = tail call i64 @strstr(i8* %28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %36
31: ; preds = %25
%32 = load i8*, i8** %27
%33 = tail call i32* @fopen(i8* %32, i8* %18)
%34 = add nsw i64 %26, -1
%35 = getelementptr inbounds i32*, i32** %12, i64 %34
store i32* %33, i32** %35
br label %36
36: ; preds = %31, %25
%37 = add nuw nsw i64 %26, 1
%38 = icmp eq i64 %37, %17
br i1 %38, label %19, label %25
39: ; preds = %55, %42
%40 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* %4)
%41 = icmp eq i32 %40, 1
br i1 %41, label %42, label %58
42: ; preds = %22, %39
%43 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %4)
br i1 %23, label %44, label %39
44: ; preds = %42, %55
%45 = phi i64 [ %56, %55 ], [ 1, %42 ]
%46 = getelementptr inbounds i8*, i8** %1, i64 %45
%47 = load i8*, i8** %46
%48 = call i64 @strstr(i8* %47, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%49 = icmp eq i64 %48, 0
br i1 %49, label %50, label %55
50: ; preds = %44
%51 = add nsw i64 %45, -1
%52 = getelementptr inbounds i32*, i32** %12, i64 %51
%53 = load i32*, i32** %52
%54 = call i32 @fprintf(i32* %53, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %4)
br label %55
55: ; preds = %44, %50
%56 = add nuw nsw i64 %45, 1
%57 = icmp eq i64 %56, %24
br i1 %57, label %39, label %44
58: ; preds = %39, %19
br label %59
59: ; preds = %58, %6
%60 = phi i32 [ 1, %6 ], [ 0, %58 ]
ret i32 %60
}