#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*/ 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*/ stdin;
int /*<<< orphan*/ *stdout;
int main(int argc, char *argv[]) {
  char ch;
  int append = 0;
  while ((ch = getopt(argc, argv, "a")) != -1) {
    switch (ch) {
    case 'a':
      append = 1;
      break;
    default:
      return 1;
    }
  }
  argc -= optind;
  argv += optind;
  int i = 0;
  FILE *files[argc];
  char word[100];
  for (i = 0; i < argc; i++) {
    files[i] = fopen(argv[i], (append ? "a" : "w"));
  }
  while (fscanf(stdin, "%s", word) == 1) {
    for (i = -1; i < argc; i++) {
      if (i == -1) {
        fprintf(stdout, "%s ", word);
      } else {
        fprintf(files[i], "%s ", word);
      }
    }
  }
  fprintf(stdout, "\n");
  for (i = 0; i < argc; i++) {
    fprintf(files[i], "\n");
    fclose(files[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,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe82(%rip),%rdx
call   1070 <getopt@plt>
mov    %al,-0x11(%rbp)
movsbl %al,%eax
cmp    $0xffffffff,%eax
je     11bf <main+0x6f>
mov    -0x11(%rbp),%al
sub    $0x61,%al
jne    11ae <main+0x5e>
jmp    11a2 <main+0x52>
movl   $0x1,-0x18(%rbp)
jmp    11ba <main+0x6a>
movl   $0x1,-0x4(%rbp)
jmp    138b <main+0x23b>
jmp    1170 <main+0x20>
mov    0x2e1a(%rip),%rax
mov    (%rax),%edx
mov    -0x8(%rbp),%ecx
sub    %edx,%ecx
mov    %ecx,-0x8(%rbp)
mov    (%rax),%rcx
mov    -0x10(%rbp),%rax
lea    (%rax,%rcx,8),%rax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0xa8(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    126c <main+0x11c>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x18(%rbp),%ecx
lea    0xdc9(%rip),%rsi
lea    0xdc0(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
call   1060 <fopen@plt>
mov    %rax,%rdx
mov    -0xa8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1217 <main+0xc7>
jmp    1271 <main+0x121>
mov    0x2d70(%rip),%rax
mov    (%rax),%edi
lea    -0xa0(%rbp),%rdx
lea    0xd7c(%rip),%rsi
call   1040 <fscanf@plt>
cmp    $0x1,%eax
jne    1313 <main+0x1c3>
movl   $0xffffffff,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    130e <main+0x1be>
cmpl   $0xffffffff,-0x1c(%rbp)
jne    12d7 <main+0x187>
mov    0x2d16(%rip),%rax
mov    (%rax),%rdi
lea    -0xa0(%rbp),%rdx
lea    0xd3c(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    12fb <main+0x1ab>
mov    -0xa8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0xa0(%rbp),%rdx
lea    0xd13(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    1300 <main+0x1b0>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    129d <main+0x14d>
jmp    1271 <main+0x121>
mov    0x2cb6(%rip),%rax
mov    (%rax),%rdi
lea    0xce7(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    137d <main+0x22d>
mov    -0xa8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xcb7(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0xa8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <fclose@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1332 <main+0x1e2>
movl   $0x0,-0x4(%rbp)
mov    -0x28(%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
mov    %rsi,%r15
mov    %edi,%r13d
lea    0xe84(%rip),%rcx
lea    0xe7b(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rcx,%r14
mov    %r13d,%edi
mov    %r15,%rsi
mov    %r12,%rdx
call   1080 <getopt@plt>
mov    %r12,%rcx
cmp    $0x61,%al
je     1190 <main+0x30>
cmp    $0xff,%al
jne    129c <main+0x13c>
mov    %rsp,-0x30(%rbp)
mov    0x2e25(%rip),%rax
mov    (%rax),%rax
sub    %eax,%r13d
lea    0xf(,%r13,8),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%r12
sub    %rcx,%r12
mov    %r12,%rsp
test   %r13d,%r13d
jle    1209 <main+0xa9>
lea    (%r15,%rax,8),%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%r15,%rbx,8),%rdi
mov    %r14,%rsi
call   1070 <fopen@plt>
mov    %rax,(%r12,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r13
jne    11f0 <main+0x90>
mov    0x2dd8(%rip),%rax
mov    (%rax),%edi
lea    0xdeb(%rip),%rsi
lea    -0xa0(%rbp),%rdx
call   1040 <fscanf@plt>
cmp    $0x1,%eax
jne    12a3 <main+0x143>
lea    0xdd6(%rip),%r14
lea    -0xa0(%rbp),%r15
jmp    125d <main+0xfd>
nopw   0x0(%rax,%rax,1)
mov    0x2da1(%rip),%rax
mov    (%rax),%edi
lea    0xdb4(%rip),%rsi
mov    %r15,%rdx
call   1040 <fscanf@plt>
cmp    $0x1,%eax
jne    12a3 <main+0x143>
test   %r13d,%r13d
js     1240 <main+0xe0>
mov    0x2d67(%rip),%rax
mov    (%rax),%rdi
mov    %r14,%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
test   %r13d,%r13d
je     1240 <main+0xe0>
xor    %ebx,%ebx
mov    (%r12,%rbx,8),%rdi
mov    %r14,%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1280 <main+0x120>
jmp    1240 <main+0xe0>
mov    $0x1,%eax
jmp    12e8 <main+0x188>
mov    0x2d26(%rip),%rax
mov    (%rax),%rsi
mov    $0xa,%edi
call   1050 <fputc@plt>
test   %r13d,%r13d
jle    12e2 <main+0x182>
xor    %ebx,%ebx
xchg   %ax,%ax
mov    (%r12,%rbx,8),%r14
mov    $0xa,%edi
mov    %r14,%rsi
call   1050 <fputc@plt>
mov    %r14,%rdi
call   1030 <fclose@plt>
add    $0x1,%rbx
cmp    %rbx,%r13
jne    12c0 <main+0x160>
mov    -0x30(%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 = [2 x i8] c"a\00"
@optind = global i64 0
@.str.1 = [2 x i8] c"w\00"
@stdin = global i32 0
@.str.2 = [3 x i8] c"%s\00"
@stdout = global i32* null
@.str.3 = [4 x i8] c"%s \00"
@.str.4 = [2 x i8] c"\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 i8*
%10 = alloca i64
%11 = alloca [100 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
br label %12
12: ; preds = %23, %2
%13 = load i32, i32* %4
%14 = load i8**, i8*** %5
%15 = call signext i8 @getopt(i32 %13, i8** %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8 %15, i8* %6
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, -1
br i1 %17, label %18, label %24
18: ; preds = %12
%19 = load i8, i8* %6
%20 = sext i8 %19 to i32
switch i32 %20, label %22 [
i32 97, label %21
]
21: ; preds = %18
store i32 1, i32* %7
br label %23
22: ; preds = %18
store i32 1, i32* %3
br label %111
23: ; preds = %21
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 = zext i32 %33 to i64
%35 = call i8* @llvm.stacksave()
store i8* %35, i8** %9
%36 = alloca i32*, i64 %34
store i64 %34, i64* %10
store i32 0, i32* %8
br label %37
37: ; preds = %55, %24
%38 = load i32, i32* %8
%39 = load i32, i32* %4
%40 = icmp slt i32 %38, %39
br i1 %40, label %41, label %58
41: ; preds = %37
%42 = load i8**, i8*** %5
%43 = load i32, i32* %8
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8*, i8** %42, i64 %44
%46 = load i8*, i8** %45
%47 = load i32, i32* %7
%48 = icmp ne i32 %47, 0
%49 = zext i1 %48 to i64
%50 = select i1 %48, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0)
%51 = call i32* @fopen(i8* %46, i8* %50)
%52 = load i32, i32* %8
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i32*, i32** %36, i64 %53
store i32* %51, i32** %54
br label %55
55: ; preds = %41
%56 = load i32, i32* %8
%57 = add nsw i32 %56, 1
store i32 %57, i32* %8
br label %37
58: ; preds = %37
br label %59
59: ; preds = %87, %58
%60 = load i32, i32* @stdin
%61 = getelementptr inbounds [100 x i8], [100 x i8]* %11, i64 0, i64 0
%62 = call i32 @fscanf(i32 %60, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %61)
%63 = icmp eq i32 %62, 1
br i1 %63, label %64, label %88
64: ; preds = %59
store i32 -1, i32* %8
br label %65
65: ; preds = %84, %64
%66 = load i32, i32* %8
%67 = load i32, i32* %4
%68 = icmp slt i32 %66, %67
br i1 %68, label %69, label %87
69: ; preds = %65
%70 = load i32, i32* %8
%71 = icmp eq i32 %70, -1
br i1 %71, label %72, label %76
72: ; preds = %69
%73 = load i32*, i32** @stdout
%74 = getelementptr inbounds [100 x i8], [100 x i8]* %11, i64 0, i64 0
%75 = call i32 (i32*, i8*, ...) @fprintf(i32* %73, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %74)
br label %83
76: ; preds = %69
%77 = load i32, i32* %8
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds i32*, i32** %36, i64 %78
%80 = load i32*, i32** %79
%81 = getelementptr inbounds [100 x i8], [100 x i8]* %11, i64 0, i64 0
%82 = call i32 (i32*, i8*, ...) @fprintf(i32* %80, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %81)
br label %83
83: ; preds = %76, %72
br label %84
84: ; preds = %83
%85 = load i32, i32* %8
%86 = add nsw i32 %85, 1
store i32 %86, i32* %8
br label %65
87: ; preds = %65
br label %59
88: ; preds = %59
%89 = load i32*, i32** @stdout
%90 = call i32 (i32*, i8*, ...) @fprintf(i32* %89, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %8
br label %91
91: ; preds = %106, %88
%92 = load i32, i32* %8
%93 = load i32, i32* %4
%94 = icmp slt i32 %92, %93
br i1 %94, label %95, label %109
95: ; preds = %91
%96 = load i32, i32* %8
%97 = sext i32 %96 to i64
%98 = getelementptr inbounds i32*, i32** %36, i64 %97
%99 = load i32*, i32** %98
%100 = call i32 (i32*, i8*, ...) @fprintf(i32* %99, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%101 = load i32, i32* %8
%102 = sext i32 %101 to i64
%103 = getelementptr inbounds i32*, i32** %36, i64 %102
%104 = load i32*, i32** %103
%105 = call i32 @fclose(i32* %104)
br label %106
106: ; preds = %95
%107 = load i32, i32* %8
%108 = add nsw i32 %107, 1
store i32 %108, i32* %8
br label %91
109: ; preds = %91
store i32 0, i32* %3
%110 = load i8*, i8** %9
br label %111
111: ; preds = %109, %22
%112 = load i32, i32* %3
ret i32 %112
}

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