#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 */
char EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int fscanf(int /*<<< orphan*/, char *, char *);
char getopt(int, char **, char *);
scalar_t__ optind;
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ *stdout;
int main(int argc, char *argv[]) {
  char buffer[100];
  char ch;
  int append = 0;
  while ((ch = getopt(argc, argv, "a")) != EOF) {
    switch (ch) {
    case 'a':
      append = 1;
      break;
    default:
      fprintf(stderr, "Unknown option");
      return 1;
    }
  }
  argv += optind;
  argc -= optind;
  FILE *outputFiles[argc - 1];
  int i;
  for (i = 0; i < argc; i++) {
    if (append == 0) {
      outputFiles[i] = fopen(argv[i], "w");
    } else if (append == 1) {
      outputFiles[i] = fopen(argv[i], "a");
    }
  }
  while (fscanf(stdin, "%99s", buffer) == 1) {
    for (int i = 0; i < argc; i++) {
      fprintf(stdout, "%s\n", buffer);
      fprintf(outputFiles[i], "%s\n", buffer);
    }
  }
  for (int i = 0; i < argc; i++) {
    fclose(outputFiles[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x88(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe7f(%rip),%rdx
call   1070 <getopt@plt>
mov    %al,-0x81(%rbp)
movsbl %al,%eax
mov    0x2e4a(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11ec <main+0x9c>
mov    -0x81(%rbp),%al
sub    $0x61,%al
jne    11c3 <main+0x73>
jmp    11b4 <main+0x64>
movl   $0x1,-0x88(%rbp)
jmp    11e7 <main+0x97>
mov    0x2dfe(%rip),%rax
movslq (%rax),%rdi
lea    0xe2e(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    13e3 <main+0x293>
jmp    1173 <main+0x23>
mov    0x2de5(%rip),%rax
mov    (%rax),%rdx
mov    -0x10(%rbp),%rcx
lea    (%rcx,%rdx,8),%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%ecx
mov    -0x8(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %rsp,%rcx
mov    %rcx,-0x90(%rbp)
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0xb0(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x98(%rbp)
movl   $0x0,-0x9c(%rbp)
mov    -0x9c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12f5 <main+0x1a5>
cmpl   $0x0,-0x88(%rbp)
jne    129a <main+0x14a>
mov    -0x10(%rbp),%rax
movslq -0x9c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xd96(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%rdx
mov    -0xb0(%rbp),%rax
movslq -0x9c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
jmp    12dc <main+0x18c>
cmpl   $0x1,-0x88(%rbp)
jne    12d7 <main+0x187>
mov    -0x10(%rbp),%rax
movslq -0x9c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xd43(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%rdx
mov    -0xb0(%rbp),%rax
movslq -0x9c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
jmp    12dc <main+0x18c>
jmp    12e1 <main+0x191>
mov    -0x9c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x9c(%rbp)
jmp    1249 <main+0xf9>
jmp    12fa <main+0x1aa>
mov    0x2ce7(%rip),%rax
mov    (%rax),%edi
lea    -0x80(%rbp),%rdx
lea    0xd05(%rip),%rsi
call   1040 <fscanf@plt>
cmp    $0x1,%eax
jne    138e <main+0x23e>
movl   $0x0,-0xa0(%rbp)
mov    -0xa0(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1389 <main+0x239>
mov    0x2c84(%rip),%rax
mov    (%rax),%rdi
lea    -0x80(%rbp),%rdx
lea    0xcce(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0xb0(%rbp),%rax
movslq -0xa0(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x80(%rbp),%rdx
lea    0xcaa(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0xa0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa0(%rbp)
jmp    1326 <main+0x1d6>
jmp    12fa <main+0x1aa>
movl   $0x0,-0xa4(%rbp)
mov    -0xa4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    13d2 <main+0x282>
mov    -0xb0(%rbp),%rax
movslq -0xa4(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <fclose@plt>
mov    -0xa4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa4(%rbp)
jmp    1398 <main+0x248>
movl   $0x0,-0x4(%rbp)
mov    -0x90(%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    $0x88,%rsp
mov    %rsi,%r15
lea    0xe82(%rip),%r14
mov    %rdi,%rbx
mov    %r14,%rdx
call   1070 <getopt@plt>
mov    0x2e50(%rip),%r12
mov    (%r12),%cl
mov    %al,-0x30(%rbp)
mov    %cl,-0x38(%rbp)
cmp    %cl,%al
je     11cb <main+0x6b>
lea    0xe5b(%rip),%r13
mov    -0x30(%rbp),%al
nopl   0x0(%rax,%rax,1)
cmp    $0x61,%al
jne    130a <main+0x1aa>
mov    %ebx,%edi
mov    %r15,%rsi
mov    %r13,%rdx
call   1070 <getopt@plt>
cmp    (%r12),%al
jne    11b0 <main+0x50>
mov    %rsp,-0x48(%rbp)
mov    0x2e02(%rip),%rax
mov    (%rax),%rax
sub    %eax,%ebx
lea    -0x1(%rbx),%ecx
lea    0xf(,%rcx,8),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%r13
sub    %rcx,%r13
mov    %r13,%rsp
mov    %ebx,%r12d
mov    %rbx,-0x40(%rbp)
test   %ebx,%ebx
jle    123a <main+0xda>
lea    (%r15,%rax,8),%r15
mov    -0x38(%rbp),%al
cmp    %al,-0x30(%rbp)
lea    0xe02(%rip),%rax
cmove  %rax,%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%r15,%rbx,8),%rdi
mov    %r14,%rsi
call   1060 <fopen@plt>
mov    %rax,0x0(%r13,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1220 <main+0xc0>
mov    %r12,-0x38(%rbp)
mov    %r13,-0x30(%rbp)
mov    0x2d9f(%rip),%rax
mov    (%rax),%edi
lea    0xdc1(%rip),%rsi
lea    -0xb0(%rbp),%rdx
call   1040 <fscanf@plt>
cmp    $0x1,%eax
jne    12e0 <main+0x180>
lea    0xdae(%rip),%rbx
lea    -0xb0(%rbp),%r12
mov    -0x38(%rbp),%r13
jmp    129d <main+0x13d>
nopw   0x0(%rax,%rax,1)
mov    0x2d61(%rip),%rax
mov    (%rax),%edi
lea    0xd83(%rip),%rsi
mov    %r12,%rdx
call   1040 <fscanf@plt>
cmp    $0x1,%eax
jne    12e0 <main+0x180>
cmpl   $0x0,-0x40(%rbp)
mov    0x2d18(%rip),%r15
jle    1280 <main+0x120>
xor    %r14d,%r14d
nopl   (%rax)
mov    (%r15),%rdi
mov    %rbx,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    -0x30(%rbp),%rax
mov    (%rax,%r14,8),%rdi
mov    %rbx,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
add    $0x1,%r14
cmp    %r14,%r13
jne    12b0 <main+0x150>
jmp    1280 <main+0x120>
cmpl   $0x0,-0x40(%rbp)
mov    -0x30(%rbp),%r14
mov    -0x38(%rbp),%r15
jle    1302 <main+0x1a2>
xor    %ebx,%ebx
mov    (%r14,%rbx,8),%rdi
call   1030 <fclose@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    12f0 <main+0x190>
mov    -0x48(%rbp),%rsp
xor    %eax,%eax
jmp    132f <main+0x1cf>
mov    0x2cb7(%rip),%rax
movslq (%rax),%rcx
lea    0xce7(%rip),%rdi
mov    $0xe,%esi
mov    $0x1,%edx
call   1080 <fwrite@plt>
mov    $0x1,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"a\00"
@EOF = global i8 0
@stderr = global i32 0
@.str.1 = [15 x i8] c"Unknown option\00"
@optind = global i64 0
@.str.2 = [2 x i8] c"w\00"
@stdin = global i32 0
@.str.3 = [5 x i8] c"%99s\00"
@stdout = global i32* null
@.str.4 = [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 [100 x i8]
%7 = alloca i8
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %8
br label %14
14: ; preds = %31, %2
%15 = load i32, i32* %4
%16 = load i8**, i8*** %5
%17 = call signext i8 @getopt(i32 %15, i8** %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8 %17, i8* %7
%18 = sext i8 %17 to i32
%19 = load i8, i8* @EOF
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %18, %20
br i1 %21, label %22, label %32
22: ; preds = %14
%23 = load i8, i8* %7
%24 = sext i8 %23 to i32
switch i32 %24, label %26 [
i32 97, label %25
]
25: ; preds = %22
store i32 1, i32* %8
br label %31
26: ; preds = %22
%27 = load i32, i32* @stderr
%28 = sext i32 %27 to i64
%29 = inttoptr i64 %28 to i32*
%30 = call i32 (i32*, i8*, ...) @fprintf(i32* %29, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %122
31: ; preds = %25
br label %14
32: ; preds = %14
%33 = load i64, i64* @optind
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 %33
store i8** %35, i8*** %5
%36 = load i64, i64* @optind
%37 = load i32, i32* %4
%38 = sext i32 %37 to i64
%39 = sub nsw i64 %38, %36
%40 = trunc i64 %39 to i32
store i32 %40, i32* %4
%41 = load i32, i32* %4
%42 = sub nsw i32 %41, 1
%43 = zext i32 %42 to i64
%44 = call i8* @llvm.stacksave()
store i8* %44, i8** %9
%45 = alloca i32*, i64 %43
store i64 %43, i64* %10
store i32 0, i32* %11
br label %46
46: ; preds = %78, %32
%47 = load i32, i32* %11
%48 = load i32, i32* %4
%49 = icmp slt i32 %47, %48
br i1 %49, label %50, label %81
50: ; preds = %46
%51 = load i32, i32* %8
%52 = icmp eq i32 %51, 0
br i1 %52, label %53, label %63
53: ; preds = %50
%54 = load i8**, i8*** %5
%55 = load i32, i32* %11
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i8*, i8** %54, i64 %56
%58 = load i8*, i8** %57
%59 = call i32* @fopen(i8* %58, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%60 = load i32, i32* %11
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i32*, i32** %45, i64 %61
store i32* %59, i32** %62
br label %77
63: ; preds = %50
%64 = load i32, i32* %8
%65 = icmp eq i32 %64, 1
br i1 %65, label %66, label %76
66: ; preds = %63
%67 = load i8**, i8*** %5
%68 = load i32, i32* %11
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds i8*, i8** %67, i64 %69
%71 = load i8*, i8** %70
%72 = call i32* @fopen(i8* %71, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%73 = load i32, i32* %11
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds i32*, i32** %45, i64 %74
store i32* %72, i32** %75
br label %76
76: ; preds = %66, %63
br label %77
77: ; preds = %76, %53
br label %78
78: ; preds = %77
%79 = load i32, i32* %11
%80 = add nsw i32 %79, 1
store i32 %80, i32* %11
br label %46
81: ; preds = %46
br label %82
82: ; preds = %105, %81
%83 = load i32, i32* @stdin
%84 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%85 = call i32 @fscanf(i32 %83, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %84)
%86 = icmp eq i32 %85, 1
br i1 %86, label %87, label %106
87: ; preds = %82
store i32 0, i32* %12
br label %88
88: ; preds = %102, %87
%89 = load i32, i32* %12
%90 = load i32, i32* %4
%91 = icmp slt i32 %89, %90
br i1 %91, label %92, label %105
92: ; preds = %88
%93 = load i32*, i32** @stdout
%94 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%95 = call i32 (i32*, i8*, ...) @fprintf(i32* %93, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %94)
%96 = load i32, i32* %12
%97 = sext i32 %96 to i64
%98 = getelementptr inbounds i32*, i32** %45, i64 %97
%99 = load i32*, i32** %98
%100 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%101 = call i32 (i32*, i8*, ...) @fprintf(i32* %99, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %100)
br label %102
102: ; preds = %92
%103 = load i32, i32* %12
%104 = add nsw i32 %103, 1
store i32 %104, i32* %12
br label %88
105: ; preds = %88
br label %82
106: ; preds = %82
store i32 0, i32* %13
br label %107
107: ; preds = %117, %106
%108 = load i32, i32* %13
%109 = load i32, i32* %4
%110 = icmp slt i32 %108, %109
br i1 %110, label %111, label %120
111: ; preds = %107
%112 = load i32, i32* %13
%113 = sext i32 %112 to i64
%114 = getelementptr inbounds i32*, i32** %45, i64 %113
%115 = load i32*, i32** %114
%116 = call i32 @fclose(i32* %115)
br label %117
117: ; preds = %111
%118 = load i32, i32* %13
%119 = add nsw i32 %118, 1
store i32 %119, i32* %13
br label %107
120: ; preds = %107
store i32 0, i32* %3
%121 = load i8*, i8** %9
br label %122
122: ; preds = %120, %26
%123 = load i32, i32* %3
ret i32 %123
}

LLVM IR (-O2):
@.str = [2 x i8] c"a\00"
@EOF = global i8 0
@stderr = global i32 0
@.str.1 = [15 x i8] c"Unknown option\00"
@optind = global i64 0
@.str.2 = [2 x i8] c"w\00"
@stdin = global i32 0
@.str.3 = [5 x i8] c"%99s\00"
@stdout = global i32* null
@.str.4 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [100 x i8]
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%5 = tail call signext i8 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = load i8, i8* @EOF
%7 = icmp eq i8 %5, %6
br i1 %7, label %20, label %12
8: ; preds = %12
%9 = tail call signext i8 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = load i8, i8* @EOF
%11 = icmp eq i8 %9, %10
br i1 %11, label %20, label %12
12: ; preds = %2, %8
%13 = phi i8 [ %9, %8 ], [ %5, %2 ]
%14 = icmp eq i8 %13, 97
br i1 %14, label %8, label %15
15: ; preds = %12
%16 = load i32, i32* @stderr
%17 = sext i32 %16 to i64
%18 = inttoptr i64 %17 to i32*
%19 = tail call i64 @fwrite(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i64 14, i64 1, i32* %18)
br label %72
20: ; preds = %8, %2
%21 = load i64, i64* @optind
%22 = getelementptr inbounds i8*, i8** %1, i64 %21
%23 = trunc i64 %21 to i32
%24 = sub i32 %0, %23
%25 = add nsw i32 %24, -1
%26 = zext i32 %25 to i64
%27 = tail call i8* @llvm.stacksave()
%28 = alloca i32*, i64 %26
%29 = icmp sgt i32 %24, 0
br i1 %29, label %30, label %33
30: ; preds = %20
%31 = zext i32 %24 to i64
%32 = select i1 %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0)
br label %39
33: ; preds = %39, %20
%34 = load i32, i32* @stdin
%35 = call i32 @fscanf(i32 %34, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %4)
%36 = icmp eq i32 %35, 1
br i1 %36, label %37, label %52
37: ; preds = %33
%38 = zext i32 %24 to i64
br label %51
39: ; preds = %30, %39
%40 = phi i64 [ 0, %30 ], [ %45, %39 ]
%41 = getelementptr inbounds i8*, i8** %22, i64 %40
%42 = load i8*, i8** %41
%43 = tail call i32* @fopen(i8* %42, i8* %32)
%44 = getelementptr inbounds i32*, i32** %28, i64 %40
store i32* %43, i32** %44
%45 = add nuw nsw i64 %40, 1
%46 = icmp eq i64 %45, %31
br i1 %46, label %33, label %39
47: ; preds = %55, %51
%48 = load i32, i32* @stdin
%49 = call i32 @fscanf(i32 %48, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %4)
%50 = icmp eq i32 %49, 1
br i1 %50, label %51, label %52
51: ; preds = %37, %47
br i1 %29, label %55, label %47
52: ; preds = %47, %33
br i1 %29, label %53, label %64
53: ; preds = %52
%54 = zext i32 %24 to i64
br label %65
55: ; preds = %51, %55
%56 = phi i64 [ %62, %55 ], [ 0, %51 ]
%57 = load i32*, i32** @stdout
%58 = call i32 (i32*, i8*, ...) @fprintf(i32* %57, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %4)
%59 = getelementptr inbounds i32*, i32** %28, i64 %56
%60 = load i32*, i32** %59
%61 = call i32 (i32*, i8*, ...) @fprintf(i32* %60, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %4)
%62 = add nuw nsw i64 %56, 1
%63 = icmp eq i64 %62, %38
br i1 %63, label %47, label %55
64: ; preds = %65, %52
br label %72
65: ; preds = %53, %65
%66 = phi i64 [ 0, %53 ], [ %70, %65 ]
%67 = getelementptr inbounds i32*, i32** %28, i64 %66
%68 = load i32*, i32** %67
%69 = call i32 @fclose(i32* %68)
%70 = add nuw nsw i64 %66, 1
%71 = icmp eq i64 %70, %54
br i1 %71, label %64, label %65
72: ; preds = %64, %15
%73 = phi i32 [ 1, %15 ], [ 0, %64 ]
ret i32 %73
}