#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*/ *fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int main(int argc, char *argv[]) {
  FILE *fp[argc - 1];
  if (argc < 2) {
    printf("You should specify at least one file.\n");
  }
  for (int i = 1; i < argc; i++) {
    fp[i] = fopen(argv[i], "w");
  }
  char input[80];
  while (fgets(input, 80, stdin) != NULL) {
    for (int i = 1; i < argc; i++) {
      fprintf(fp[i], "%s", input);
    }
    printf("%s", input);
  }
  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)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x90(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    119e <main+0x5e>
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11e9 <main+0xa9>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe63(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%rdx
mov    -0x90(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11a5 <main+0x65>
jmp    11ee <main+0xae>
lea    -0x80(%rbp),%rdi
mov    0x2def(%rip),%rax
mov    (%rax),%edx
mov    $0x50,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     1275 <main+0x135>
movl   $0x1,-0x84(%rbp)
mov    -0x84(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    125e <main+0x11e>
mov    -0x90(%rbp),%rax
movslq -0x84(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x80(%rbp),%rdx
lea    0xde4(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
jmp    1219 <main+0xd9>
lea    -0x80(%rbp),%rsi
lea    0xdc0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ee <main+0xae>
movl   $0x0,-0x4(%rbp)
mov    -0x18(%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    $0x58,%rsp
lea    -0x1(%rdi),%eax
mov    %rsp,%r13
lea    0xf(,%rax,8),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r13
mov    %r13,%rsp
mov    %edi,%r14d
mov    %rdi,-0x30(%rbp)
cmp    $0x1,%edi
jg     1193 <main+0x43>
lea    0xe79(%rip),%rdi
call   1030 <puts@plt>
jmp    11ca <main+0x7a>
mov    %rsi,%r12
mov    $0x1,%r15d
lea    0xe5d(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%r12,%r15,8),%rdi
mov    %rbx,%rsi
call   1070 <fopen@plt>
mov    %rax,0x0(%r13,%r15,8)
add    $0x1,%r15
cmp    %r15,%r14
jne    11b0 <main+0x60>
mov    0x2e17(%rip),%rax
mov    (%rax),%edx
lea    -0x80(%rbp),%rdi
mov    $0x50,%esi
call   1060 <fgets@plt>
test   %rax,%rax
je     1258 <main+0x108>
lea    0xe15(%rip),%r15
lea    -0x80(%rbp),%r12
jmp    1228 <main+0xd8>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2dd4(%rip),%rax
mov    (%rax),%edx
mov    %r12,%rdi
mov    $0x50,%esi
call   1060 <fgets@plt>
test   %rax,%rax
je     1258 <main+0x108>
cmpl   $0x2,-0x30(%rbp)
jl     1200 <main+0xb0>
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x0(%r13,%rbx,8),%rsi
mov    %r12,%rdi
call   1050 <fputs@plt>
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1240 <main+0xf0>
jmp    1200 <main+0xb0>
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [39 x i8] c"You should specify at least one file.\0A\00"
@.str.1 = [2 x i8] c"w\00"
@stdin = global i32 0
@.str.2 = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i32
%9 = alloca [80 x i8]
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = sub nsw i32 %11, 1
%13 = zext i32 %12 to i64
%14 = call i8* @llvm.stacksave()
store i8* %14, i8** %6
%15 = alloca i32*, i64 %13
store i64 %13, i64* %7
%16 = load i32, i32* %4
%17 = icmp slt i32 %16, 2
br i1 %17, label %18, label %20
18: ; preds = %2
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
br label %20
20: ; preds = %18, %2
store i32 1, i32* %8
br label %21
21: ; preds = %35, %20
%22 = load i32, i32* %8
%23 = load i32, i32* %4
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %38
25: ; preds = %21
%26 = load i8**, i8*** %5
%27 = load i32, i32* %8
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8*, i8** %26, i64 %28
%30 = load i8*, i8** %29
%31 = call i32* @fopen(i8* %30, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%32 = load i32, i32* %8
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i32*, i32** %15, i64 %33
store i32* %31, i32** %34
br label %35
35: ; preds = %25
%36 = load i32, i32* %8
%37 = add nsw i32 %36, 1
store i32 %37, i32* %8
br label %21
38: ; preds = %21
br label %39
39: ; preds = %59, %38
%40 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%41 = load i32, i32* @stdin
%42 = call i32* @fgets(i8* %40, i32 80, i32 %41)
%43 = icmp ne i32* %42, null
br i1 %43, label %44, label %62
44: ; preds = %39
store i32 1, i32* %10
br label %45
45: ; preds = %56, %44
%46 = load i32, i32* %10
%47 = load i32, i32* %4
%48 = icmp slt i32 %46, %47
br i1 %48, label %49, label %59
49: ; preds = %45
%50 = load i32, i32* %10
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i32*, i32** %15, i64 %51
%53 = load i32*, i32** %52
%54 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%55 = call i32 @fprintf(i32* %53, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %54)
br label %56
56: ; preds = %49
%57 = load i32, i32* %10
%58 = add nsw i32 %57, 1
store i32 %58, i32* %10
br label %45
59: ; preds = %45
%60 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %60)
br label %39
62: ; preds = %39
store i32 0, i32* %3
%63 = load i8*, i8** %6
%64 = load i32, i32* %3
ret i32 %64
}

LLVM IR (-O2):
@.str.1 = [2 x i8] c"w\00"
@stdin = global i32 0
@.str.2 = [3 x i8] c"%s\00"
@str = [38 x i8] c"You should specify at least one file.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [80 x i8]
%4 = add nsw i32 %0, -1
%5 = zext i32 %4 to i64
%6 = alloca i32*, i64 %5
%7 = icmp slt i32 %0, 2
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str, i64 0, i64 0))
br label %12
10: ; preds = %2
%11 = zext i32 %0 to i64
br label %19
12: ; preds = %19, %8
%13 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%14 = load i32, i32* @stdin
%15 = call i32* @fgets(i8* %13, i32 80, i32 %14)
%16 = icmp eq i32* %15, null
br i1 %16, label %40, label %17
17: ; preds = %12
%18 = zext i32 %0 to i64
br label %27
19: ; preds = %10, %19
%20 = phi i64 [ 1, %10 ], [ %25, %19 ]
%21 = getelementptr inbounds i8*, i8** %1, i64 %20
%22 = load i8*, i8** %21
%23 = tail call i32* @fopen(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%24 = getelementptr inbounds i32*, i32** %6, i64 %20
store i32* %23, i32** %24
%25 = add nuw nsw i64 %20, 1
%26 = icmp eq i64 %25, %11
br i1 %26, label %12, label %19
27: ; preds = %17, %28
br i1 %7, label %28, label %33
28: ; preds = %33, %27
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %13)
%30 = load i32, i32* @stdin
%31 = call i32* @fgets(i8* %13, i32 80, i32 %30)
%32 = icmp eq i32* %31, null
br i1 %32, label %40, label %27
33: ; preds = %27, %33
%34 = phi i64 [ %38, %33 ], [ 1, %27 ]
%35 = getelementptr inbounds i32*, i32** %6, i64 %34
%36 = load i32*, i32** %35
%37 = call i32 @fputs(i8* %13, i32* %36)
%38 = add nuw nsw i64 %34, 1
%39 = icmp eq i64 %38, %18
br i1 %39, label %28, label %33
40: ; preds = %28, %12
ret i32 0
}