#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*/ *fopen(char *, char *);
int fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fwrite(char *, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stdout;
int main(int argc, char *argv[], char *envp[]) {
  FILE *fp;
  int arg, i, fd;
  char buf[512];
  for (arg = 1; arg < argc; arg++) {
    fp = fopen(argv[arg], "r");
    if (fp) {
      i = 1;
      while (i > 0) {
        i = fread(buf, 512, 1, fp);
        fwrite(buf, i, 1, stdout);
      }
    } else {
      printf("could not open \"%s\"\n", argv[arg]);
      break;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x230,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    121c <main+0xdc>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe7d(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11ec <main+0xac>
movl   $0x1,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jle    11e7 <main+0xa7>
lea    -0x230(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0x200,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
mov    %eax,-0x28(%rbp)
lea    -0x230(%rbp),%rdi
mov    -0x28(%rbp),%esi
mov    0x2e0a(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%edx
call   1060 <fwrite@plt>
jmp    119e <main+0x5e>
jmp    1209 <main+0xc9>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe03(%rip),%rdi
call   1040 <printf@plt>
jmp    121c <main+0xdc>
jmp    120e <main+0xce>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1164 <main+0x24>
xor    %eax,%eax
add    $0x230,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x218,%rsp
mov    %rsi,0x8(%rsp)
cmp    $0x2,%edi
jl     11f0 <main+0xb0>
mov    %edi,%r14d
mov    $0x1,%r13d
lea    0x10(%rsp),%r12
mov    0x2e6c(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x8(%rsp),%rax
mov    (%rax,%r13,8),%rdi
lea    0xe70(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     11d8 <main+0x98>
mov    %rax,%rbx
nopl   (%rax)
mov    %r12,%rdi
mov    $0x200,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
mov    %eax,%ebp
mov    (%r15),%ecx
mov    %r12,%rdi
mov    %eax,%esi
mov    $0x1,%edx
call   1060 <fwrite@plt>
test   %ebp,%ebp
jg     11a0 <main+0x60>
add    $0x1,%r13
cmp    %r14,%r13
jne    1180 <main+0x40>
jmp    11f0 <main+0xb0>
mov    %r13d,%eax
mov    0x8(%rsp),%rcx
mov    (%rcx,%rax,8),%rsi
lea    0xe17(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x218,%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
@.str.1 = [21 x i8] c"could not open \22%s\22\0A\00"
define i32 @main(i32 %0, i8** %1, i8** %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca [512 x i8]
store i32 0, i32* %4
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
store i32 1, i32* %9
br label %13
13: ; preds = %47, %3
%14 = load i32, i32* %9
%15 = load i32, i32* %5
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %50
17: ; preds = %13
%18 = load i8**, i8*** %6
%19 = load i32, i32* %9
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8*, i8** %18, i64 %20
%22 = load i8*, i8** %21
%23 = call i32* @fopen(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %23, i32** %8
%24 = load i32*, i32** %8
%25 = icmp ne i32* %24, null
br i1 %25, label %26, label %39
26: ; preds = %17
store i32 1, i32* %10
br label %27
27: ; preds = %30, %26
%28 = load i32, i32* %10
%29 = icmp sgt i32 %28, 0
br i1 %29, label %30, label %38
30: ; preds = %27
%31 = getelementptr inbounds [512 x i8], [512 x i8]* %12, i64 0, i64 0
%32 = load i32*, i32** %8
%33 = call i32 @fread(i8* %31, i32 512, i32 1, i32* %32)
store i32 %33, i32* %10
%34 = getelementptr inbounds [512 x i8], [512 x i8]* %12, i64 0, i64 0
%35 = load i32, i32* %10
%36 = load i32, i32* @stdout
%37 = call i32 @fwrite(i8* %34, i32 %35, i32 1, i32 %36)
br label %27
38: ; preds = %27
br label %46
39: ; preds = %17
%40 = load i8**, i8*** %6
%41 = load i32, i32* %9
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8*, i8** %40, i64 %42
%44 = load i8*, i8** %43
%45 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %44)
br label %50
46: ; preds = %38
br label %47
47: ; preds = %46
%48 = load i32, i32* %9
%49 = add nsw i32 %48, 1
store i32 %49, i32* %9
br label %13
50: ; preds = %39, %13
ret i32 0
}

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