#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_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
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(EXIT_FAILURE);
      } 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    0x2e3c(%rip),%rax
mov    (%rax),%esi
call   1050 <filecopy@plt>
jmp    122f <main+0xdf>
jmp    119d <main+0x4d>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jle    122a <main+0xda>
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    120a <main+0xba>
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    0x2dcd(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x18(%rbp),%rdi
mov    0x2db3(%rip),%rax
mov    (%rax),%esi
call   1050 <filecopy@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
jmp    119d <main+0x4d>
jmp    122f <main+0xdf>
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    0x2e57(%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    0x2e2f(%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    0x2dc8(%rip),%rax
mov    (%rax),%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"
@EXIT_FAILURE = global i32 0
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 %44
17: ; preds = %2
br label %18
18: ; preds = %42, %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 %43
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 %36
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 = load i32, i32* @EXIT_FAILURE
%35 = call i32 @exit(i32 %34)
unreachable
36: ; preds = %22
%37 = load i32*, i32** %6
%38 = load i32, i32* @stdout
%39 = call i32 @filecopy(i32* %37, i32 %38)
%40 = load i32*, i32** %6
%41 = call i32 @fclose(i32* %40)
br label %42
42: ; preds = %36
br label %18
43: ; preds = %18
br label %44
44: ; preds = %43, %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"
@EXIT_FAILURE = global i32 0
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 %30
7: ; preds = %2
%8 = load i32*, i32** @stdin
%9 = load i32, i32* @stdout
%10 = tail call i32 @filecopy(i32* %8, i32 %9)
br label %30
11: ; preds = %5, %24
%12 = phi i32 [ %25, %24 ], [ %0, %5 ]
%13 = phi i8** [ %14, %24 ], [ %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 %24
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 = load i32, i32* @EXIT_FAILURE
%23 = tail call i32 @exit(i32 %22)
unreachable
24: ; preds = %11
%25 = add nsw i32 %12, -1
%26 = load i32, i32* @stdout
%27 = tail call i32 @filecopy(i32* %16, i32 %26)
%28 = tail call i32 @fclose(i32* %16)
%29 = icmp sgt i32 %12, 2
br i1 %29, label %11, label %30
30: ; preds = %24, %5, %7
ret i32 0
}