#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 */

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
int open(char *, int /*<<< orphan*/, int /*<<< orphan*/);
int read(int, char *, int);
int /*<<< orphan*/ write(int /*<<< orphan*/, char *, int);
int main(int argc, char *argv[]) {
  int fd, n, i;
  char buf[1000];
  if (argc >= 1) {
    for (i = 1; i < argc; ++i) {
      fd = open(argv[i], O_RDONLY, 0);
      while ((n = read(fd, buf, 1000)) > 0)
        write(0, buf, n);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jl     11d3 <main+0xa3>
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11ce <main+0x9e>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    0x2e6f(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1050 <open@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x410(%rbp),%rsi
mov    $0x3e8,%edx
call   1040 <read@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jle    11bb <main+0x8b>
lea    -0x410(%rbp),%rsi
mov    -0x18(%rbp),%edx
xor    %edi,%edi
call   1030 <write@plt>
jmp    1185 <main+0x55>
jmp    11c0 <main+0x90>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    115a <main+0x2a>
jmp    11d3 <main+0xa3>
xor    %eax,%eax
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x3e8,%rsp
cmp    $0x2,%edi
jl     11a1 <main+0x71>
mov    %rsi,%r14
mov    %edi,%r15d
mov    $0x1,%r12d
mov    0x2e8f(%rip),%r13
mov    %rsp,%rbx
jmp    1169 <main+0x39>
xchg   %ax,%ax
add    $0x1,%r12
cmp    %r15,%r12
je     11a1 <main+0x71>
mov    (%r14,%r12,8),%rdi
mov    0x0(%r13),%esi
xor    %edx,%edx
call   1050 <open@plt>
mov    %eax,%ebp
mov    %eax,%edi
nopl   0x0(%rax)
mov    %rbx,%rsi
mov    $0x3e8,%edx
call   1040 <read@plt>
test   %eax,%eax
jle    1160 <main+0x30>
xor    %edi,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    %ebp,%edi
jmp    1180 <main+0x50>
xor    %eax,%eax
add    $0x3e8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@O_RDONLY = 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
%9 = alloca [1000 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp sge i32 %10, 1
br i1 %11, label %12, label %39
12: ; preds = %2
store i32 1, i32* %8
br label %13
13: ; preds = %35, %12
%14 = load i32, i32* %8
%15 = load i32, i32* %4
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %38
17: ; preds = %13
%18 = load i8**, i8*** %5
%19 = load i32, i32* %8
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8*, i8** %18, i64 %20
%22 = load i8*, i8** %21
%23 = load i32, i32* @O_RDONLY
%24 = call i32 @open(i8* %22, i32 %23, i32 0)
store i32 %24, i32* %6
br label %25
25: ; preds = %30, %17
%26 = load i32, i32* %6
%27 = getelementptr inbounds [1000 x i8], [1000 x i8]* %9, i64 0, i64 0
%28 = call i32 @read(i32 %26, i8* %27, i32 1000)
store i32 %28, i32* %7
%29 = icmp sgt i32 %28, 0
br i1 %29, label %30, label %34
30: ; preds = %25
%31 = getelementptr inbounds [1000 x i8], [1000 x i8]* %9, i64 0, i64 0
%32 = load i32, i32* %7
%33 = call i32 @write(i32 0, i8* %31, i32 %32)
br label %25
34: ; preds = %25
br label %35
35: ; preds = %34
%36 = load i32, i32* %8
%37 = add nsw i32 %36, 1
store i32 %37, i32* %8
br label %13
38: ; preds = %13
br label %39
39: ; preds = %38, %2
ret i32 0
}

LLVM IR (-O2):
@O_RDONLY = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1000 x i8]
%4 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%5 = icmp sgt i32 %0, 1
br i1 %5, label %6, label %24
6: ; preds = %2
%7 = zext i32 %0 to i64
br label %8
8: ; preds = %6, %21
%9 = phi i64 [ 1, %6 ], [ %22, %21 ]
%10 = getelementptr inbounds i8*, i8** %1, i64 %9
%11 = load i8*, i8** %10
%12 = load i32, i32* @O_RDONLY
%13 = tail call i32 @open(i8* %11, i32 %12, i32 0)
%14 = call i32 @read(i32 %13, i8* %4, i32 1000)
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %21
16: ; preds = %8, %16
%17 = phi i32 [ %19, %16 ], [ %14, %8 ]
%18 = call i32 @write(i32 0, i8* %4, i32 %17)
%19 = call i32 @read(i32 %13, i8* %4, i32 1000)
%20 = icmp sgt i32 %19, 0
br i1 %20, label %16, label %21
21: ; preds = %16, %8
%22 = add nuw nsw i64 %9, 1
%23 = icmp eq i64 %22, %7
br i1 %23, label %24, label %8
24: ; preds = %21, %2
ret i32 0
}