#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*/ filecopy(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ *stdin;
int /*<<< orphan*/ stdout;
int main(int argc, char *argv[]) {
  FILE *fp;
  char *prog = argv[0];
  if (argc == 1)
    filecopy(stdin, stdout);
  else
    while (--argc > 0)
      if ((fp = fopen(*++argv, "r")) == NULL) {
        fprintf(stderr, "%s: can't open %s\n", prog, *argv);
        exit(-1);
      } else {
        filecopy(fp, stdout);
        fclose(fp);
      }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    1198 <main+0x48>
mov    0x2e66(%rip),%rax
mov    (%rax),%rdi
mov    0x2e44(%rip),%rax
mov    (%rax),%esi
call   1050 <filecopy@plt>
jmp    122b <main+0xdb>
jmp    119d <main+0x4d>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jle    1226 <main+0xd6>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    0x8(%rax),%rdi
lea    0xe37(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1206 <main+0xb6>
mov    0x2df5(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
lea    0xe0b(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>
mov    -0x18(%rbp),%rdi
mov    0x2dbf(%rip),%rax
mov    (%rax),%esi
call   1050 <filecopy@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
jmp    119d <main+0x4d>
jmp    122b <main+0xdb>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x1,%edi
jne    117a <main+0x2a>
mov    0x2e81(%rip),%rax
mov    (%rax),%rdi
mov    0x2e5f(%rip),%rax
mov    (%rax),%esi
call   1050 <filecopy@plt>
jmp    11d4 <main+0x84>
jle    11d4 <main+0x84>
mov    %rsi,%r12
mov    %edi,%ebp
mov    (%rsi),%r14
add    $0x1,%ebp
add    $0x8,%r12
lea    0xe6e(%rip),%r15
mov    0x2e37(%rip),%r13
nopl   0x0(%rax)
mov    (%r12),%rdi
mov    %r15,%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     11e5 <main+0x95>
mov    %rax,%rbx
mov    0x0(%r13),%esi
mov    %rax,%rdi
call   1050 <filecopy@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
add    $0xffffffff,%ebp
add    $0x8,%r12
cmp    $0x2,%ebp
jg     11a0 <main+0x50>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2dec(%rip),%rax
mov    (%rax),%edi
mov    (%r12),%rcx
lea    0xe09(%rip),%rsi
mov    %r14,%rdx
call   1040 <fprintf@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@stdin = global i32* null
@stdout = global i32 0
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [19 x i8] c"%s: can't open %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i8**, i8*** %5
%9 = getelementptr inbounds i8*, i8** %8, i64 0
%10 = load i8*, i8** %9
store i8* %10, i8** %7
%11 = load i32, i32* %4
%12 = icmp eq i32 %11, 1
br i1 %12, label %13, label %17
13: ; preds = %2
%14 = load i32*, i32** @stdin
%15 = load i32, i32* @stdout
%16 = call i32 @filecopy(i32* %14, i32 %15)
br label %43
17: ; preds = %2
br label %18
18: ; preds = %41, %17
%19 = load i32, i32* %4
%20 = add nsw i32 %19, -1
store i32 %20, i32* %4
%21 = icmp sgt i32 %20, 0
br i1 %21, label %22, label %42
22: ; preds = %18
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i32 1
store i8** %24, i8*** %5
%25 = load i8*, i8** %24
%26 = call i32* @fopen(i8* %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %26, i32** %6
%27 = icmp eq i32* %26, null
br i1 %27, label %28, label %35
28: ; preds = %22
%29 = load i32, i32* @stderr
%30 = load i8*, i8** %7
%31 = load i8**, i8*** %5
%32 = load i8*, i8** %31
%33 = call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %30, i8* %32)
%34 = call i32 @exit(i32 -1)
unreachable
35: ; preds = %22
%36 = load i32*, i32** %6
%37 = load i32, i32* @stdout
%38 = call i32 @filecopy(i32* %36, i32 %37)
%39 = load i32*, i32** %6
%40 = call i32 @fclose(i32* %39)
br label %41
41: ; preds = %35
br label %18
42: ; preds = %18
br label %43
43: ; preds = %42, %13
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32* null
@stdout = global i32 0
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [19 x i8] c"%s: can't open %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = load i8*, i8** %1
%4 = icmp eq i32 %0, 1
br i1 %4, label %7, label %5
5: ; preds = %2
%6 = icmp sgt i32 %0, 1
br i1 %6, label %11, label %29
7: ; preds = %2
%8 = load i32*, i32** @stdin
%9 = load i32, i32* @stdout
%10 = tail call i32 @filecopy(i32* %8, i32 %9)
br label %29
11: ; preds = %5, %23
%12 = phi i32 [ %24, %23 ], [ %0, %5 ]
%13 = phi i8** [ %14, %23 ], [ %1, %5 ]
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = tail call i32* @fopen(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%17 = icmp eq i32* %16, null
br i1 %17, label %18, label %23
18: ; preds = %11
%19 = load i32, i32* @stderr
%20 = load i8*, i8** %14
%21 = tail call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %3, i8* %20)
%22 = tail call i32 @exit(i32 -1)
unreachable
23: ; preds = %11
%24 = add nsw i32 %12, -1
%25 = load i32, i32* @stdout
%26 = tail call i32 @filecopy(i32* %16, i32 %25)
%27 = tail call i32 @fclose(i32* %16)
%28 = icmp sgt i32 %12, 2
br i1 %28, label %11, label %29
29: ; preds = %23, %5, %7
ret i32 0
}