#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 EOF;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ perror(char *);
scalar_t__ putchar(int);
int main(int argc, char *argv[]) {
  int i;
  for (i = 1; i < argc; i++) {
    FILE *f;
    int c;
    f = fopen(argv[i], "r");
    if (!f) {
      perror(argv[i]);
      exit(1);
    }
    while ((c = fgetc(f)) != EOF) {
      if (putchar(c) < 0) {
        exit(1);
      }
    }
    fclose(f);
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%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    1223 <main+0xc3>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe64(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11cb <main+0x6b>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1070 <perror@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
jmp    11d0 <main+0x70>
mov    -0x20(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %eax,-0x24(%rbp)
mov    0x2e05(%rip),%rcx
cmp    (%rcx),%eax
je     120c <main+0xac>
mov    -0x24(%rbp),%edi
call   1030 <putchar@plt>
cmp    $0x0,%rax
jge    1207 <main+0xa7>
mov    $0x1,%edi
call   1080 <exit@plt>
jmp    11d0 <main+0x70>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    117d <main+0x1d>
xor    %edi,%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%edi
jl     11e3 <main+0x83>
mov    %rsi,%r15
mov    %edi,%r13d
mov    $0x1,%r12d
lea    0xe7d(%rip),%r14
mov    0x2e5e(%rip),%rbp
jmp    11a1 <main+0x41>
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1040 <fclose@plt>
add    $0x1,%r12
cmp    %r13,%r12
je     11e3 <main+0x83>
mov    (%r15,%r12,8),%rdi
mov    %r14,%rsi
call   1060 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11ea <main+0x8a>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
call   1050 <fgetc@plt>
cmp    0x0(%rbp),%eax
je     1190 <main+0x30>
mov    %eax,%edi
call   1030 <putchar@plt>
test   %rax,%rax
jns    11c0 <main+0x60>
mov    $0x1,%edi
call   1080 <exit@plt>
xor    %edi,%edi
call   1080 <exit@plt>
mov    %r12d,%eax
mov    (%r15,%rax,8),%rdi
call   1070 <perror@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@EOF = 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 i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %6
br label %9
9: ; preds = %46, %2
%10 = load i32, i32* %6
%11 = load i32, i32* %4
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %49
13: ; preds = %9
%14 = load i8**, i8*** %5
%15 = load i32, i32* %6
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8*, i8** %14, i64 %16
%18 = load i8*, i8** %17
%19 = call i32* @fopen(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %19, i32** %7
%20 = load i32*, i32** %7
%21 = icmp ne i32* %20, null
br i1 %21, label %30, label %22
22: ; preds = %13
%23 = load i8**, i8*** %5
%24 = load i32, i32* %6
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8*, i8** %23, i64 %25
%27 = load i8*, i8** %26
%28 = call i32 @perror(i8* %27)
%29 = call i32 @exit(i32 1)
unreachable
30: ; preds = %13
br label %31
31: ; preds = %42, %30
%32 = load i32*, i32** %7
%33 = call i32 @fgetc(i32* %32)
store i32 %33, i32* %8
%34 = load i32, i32* @EOF
%35 = icmp ne i32 %33, %34
br i1 %35, label %36, label %43
36: ; preds = %31
%37 = load i32, i32* %8
%38 = call i64 @putchar(i32 %37)
%39 = icmp slt i64 %38, 0
br i1 %39, label %40, label %42
40: ; preds = %36
%41 = call i32 @exit(i32 1)
unreachable
42: ; preds = %36
br label %31
43: ; preds = %31
%44 = load i32*, i32** %7
%45 = call i32 @fclose(i32* %44)
br label %46
46: ; preds = %43
%47 = load i32, i32* %6
%48 = add nsw i32 %47, 1
store i32 %48, i32* %6
br label %9
49: ; preds = %9
%50 = call i32 @exit(i32 0)
unreachable
}

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