#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*/ filecpy(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) {
    filecpy(stdin, stdout);
  } else {
    while (--argc > 0) {
      if ((fp = fopen(*++argv, "r")) == NULL) {
        fprintf(stderr, "%s: can't open %s\n", prog, *argv);
        return 1;
      } else {
        filecpy(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    1188 <main+0x48>
mov    0x2e76(%rip),%rax
mov    (%rax),%rdi
mov    0x2e54(%rip),%rax
mov    (%rax),%esi
call   1030 <filecpy@plt>
jmp    121d <main+0xdd>
jmp    118d <main+0x4d>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jle    1218 <main+0xd8>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    0x8(%rax),%rdi
lea    0xe47(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11f8 <main+0xb8>
mov    0x2e05(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
lea    0xe1b(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1224 <main+0xe4>
mov    -0x18(%rbp),%rdi
mov    0x2dcd(%rip),%rax
mov    (%rax),%esi
call   1030 <filecpy@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
jmp    118d <main+0x4d>
jmp    121d <main+0xdd>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%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    1170 <main+0x30>
mov    0x2e91(%rip),%rax
mov    (%rax),%rdi
mov    0x2e6f(%rip),%rax
mov    (%rax),%esi
call   1030 <filecpy@plt>
xor    %r14d,%r14d
jmp    11f8 <main+0xb8>
mov    %edi,%ebp
xor    %r14d,%r14d
cmp    $0x2,%edi
jl     11f8 <main+0xb8>
mov    %rsi,%r13
mov    (%rsi),%rax
mov    %rax,(%rsp)
add    $0x1,%ebp
add    $0x8,%r13
lea    0xe6a(%rip),%r12
mov    0x2e33(%rip),%r15
nopl   (%rax)
mov    0x0(%r13),%rdi
mov    %r12,%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     11d5 <main+0x95>
mov    %rax,%rbx
mov    (%r15),%esi
mov    %rax,%rdi
call   1030 <filecpy@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
add    $0xffffffff,%ebp
add    $0x8,%r13
cmp    $0x2,%ebp
jg     11a0 <main+0x60>
jmp    11f8 <main+0xb8>
mov    0x2dfc(%rip),%rax
mov    (%rax),%edi
mov    0x0(%r13),%rcx
lea    0xe19(%rip),%rsi
mov    (%rsp),%rdx
call   1050 <fprintf@plt>
mov    $0x1,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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 @filecpy(i32* %14, i32 %15)
br label %42
17: ; preds = %2
br label %18
18: ; preds = %40, %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 %41
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 %34
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)
store i32 1, i32* %3
br label %43
34: ; preds = %22
%35 = load i32*, i32** %6
%36 = load i32, i32* @stdout
%37 = call i32 @filecpy(i32* %35, i32 %36)
%38 = load i32*, i32** %6
%39 = call i32 @fclose(i32* %38)
br label %40
40: ; preds = %34
br label %18
41: ; preds = %18
br label %42
42: ; preds = %41, %13
store i32 0, i32* %3
br label %43
43: ; preds = %42, %28
%44 = load i32, i32* %3
ret i32 %44
}

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 %28
7: ; preds = %2
%8 = load i32*, i32** @stdin
%9 = load i32, i32* @stdout
%10 = tail call i32 @filecpy(i32* %8, i32 %9)
br label %28
11: ; preds = %5, %22
%12 = phi i32 [ %23, %22 ], [ %0, %5 ]
%13 = phi i8** [ %14, %22 ], [ %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 %22
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)
br label %28
22: ; preds = %11
%23 = add nsw i32 %12, -1
%24 = load i32, i32* @stdout
%25 = tail call i32 @filecpy(i32* %16, i32 %24)
%26 = tail call i32 @fclose(i32* %16)
%27 = icmp sgt i32 %12, 2
br i1 %27, label %11, label %28
28: ; preds = %22, %5, %7, %18
%29 = phi i32 [ 1, %18 ], [ 0, %7 ], [ 0, %5 ], [ 0, %22 ]
ret i32 %29
}