#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*/ buf;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
size_t fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fwrite(char *, int, size_t, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stdout;
int main(int argc, char **argv) {
  int i;
  FILE *fp;
  char buf[1024];
  size_t r;
  for (i = 1; i < argc; ++i) {
    fp = fopen(argv[i], "r");
    if (!fp) {
      perror(argv[i]);
      continue;
    }
    while ((r = fread(buf, 1, sizeof(buf), fp)))
      fwrite(buf, 1, r, stdout);
    fclose(fp);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1226 <main+0xd6>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe71(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11b9 <main+0x69>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1060 <perror@plt>
jmp    1218 <main+0xc8>
jmp    11be <main+0x6e>
lea    -0x420(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0x1,%esi
mov    $0x400,%edx
call   1030 <fread@plt>
mov    %rax,-0x428(%rbp)
cmp    $0x0,%rax
je     120f <main+0xbf>
lea    -0x420(%rbp),%rdi
mov    -0x428(%rbp),%rdx
mov    0x2de2(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
call   1070 <fwrite@plt>
jmp    11be <main+0x6e>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1170 <main+0x20>
xor    %eax,%eax
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x408,%rsp
cmp    $0x2,%edi
jl     11ee <main+0x9e>
mov    %rsi,%r15
mov    %edi,%r13d
mov    $0x1,%ebp
mov    %rsp,%r12
mov    0x2e61(%rip),%r14
nop
mov    (%r15,%rbp,8),%rdi
lea    0xe75(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     11e3 <main+0x93>
mov    %rax,%rbx
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x400,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
test   %rax,%rax
je     11d0 <main+0x80>
mov    (%r14),%ecx
mov    %r12,%rdi
mov    $0x1,%esi
mov    %rax,%rdx
call   1070 <fwrite@plt>
jmp    11a0 <main+0x50>
nop
mov    %rbx,%rdi
call   1040 <fclose@plt>
add    $0x1,%rbp
cmp    %r13,%rbp
jne    1180 <main+0x30>
jmp    11ee <main+0x9e>
mov    (%r15,%rbp,8),%rdi
call   1060 <perror@plt>
jmp    11d8 <main+0x88>
xor    %eax,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32*
%8 = alloca [1024 x i8]
%9 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %6
br label %10
10: ; preds = %44, %2
%11 = load i32, i32* %6
%12 = load i32, i32* %4
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %47
14: ; preds = %10
%15 = load i8**, i8*** %5
%16 = load i32, i32* %6
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8*, i8** %15, i64 %17
%19 = load i8*, i8** %18
%20 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %20, i32** %7
%21 = load i32*, i32** %7
%22 = icmp ne i32* %21, null
br i1 %22, label %30, label %23
23: ; preds = %14
%24 = load i8**, i8*** %5
%25 = load i32, i32* %6
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8*, i8** %24, i64 %26
%28 = load i8*, i8** %27
%29 = call i32 @perror(i8* %28)
br label %44
30: ; preds = %14
br label %31
31: ; preds = %36, %30
%32 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%33 = load i32*, i32** %7
%34 = call i64 @fread(i8* %32, i32 1, i32 1024, i32* %33)
store i64 %34, i64* %9
%35 = icmp ne i64 %34, 0
br i1 %35, label %36, label %41
36: ; preds = %31
%37 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%38 = load i64, i64* %9
%39 = load i32, i32* @stdout
%40 = call i32 @fwrite(i8* %37, i32 1, i64 %38, i32 %39)
br label %31
41: ; preds = %31
%42 = load i32*, i32** %7
%43 = call i32 @fclose(i32* %42)
br label %44
44: ; preds = %41, %23
%45 = load i32, i32* %6
%46 = add nsw i32 %45, 1
store i32 %46, i32* %6
br label %10
47: ; preds = %10
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = icmp sgt i32 %0, 1
br i1 %5, label %6, label %31
6: ; preds = %2
%7 = zext i32 %0 to i64
br label %8
8: ; preds = %6, %28
%9 = phi i64 [ 1, %6 ], [ %29, %28 ]
%10 = getelementptr inbounds i8*, i8** %1, i64 %9
%11 = load i8*, i8** %10
%12 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%13 = icmp eq i32* %12, null
br i1 %13, label %17, label %14
14: ; preds = %8
%15 = call i64 @fread(i8* %4, i32 1, i32 1024, i32* %12)
%16 = icmp eq i64 %15, 0
br i1 %16, label %26, label %20
17: ; preds = %8
%18 = load i8*, i8** %10
%19 = call i32 @perror(i8* %18)
br label %28
20: ; preds = %14, %20
%21 = phi i64 [ %24, %20 ], [ %15, %14 ]
%22 = load i32, i32* @stdout
%23 = call i32 @fwrite(i8* %4, i32 1, i64 %21, i32 %22)
%24 = call i64 @fread(i8* %4, i32 1, i32 1024, i32* %12)
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %20
26: ; preds = %20, %14
%27 = call i32 @fclose(i32* %12)
br label %28
28: ; preds = %26, %17
%29 = add nuw nsw i64 %9, 1
%30 = icmp eq i64 %29, %7
br i1 %30, label %31, label %8
31: ; preds = %28, %2
ret i32 0
}