#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*/ *);
char *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int, char *);
int /*<<< orphan*/ stdout;
int main(int argc, char *argv[]) {
  FILE *fp;
  char *filename, *line;
  char content[1000];
  int i, count;
  i = 1;
  count = 0;
  while (i < argc) {
    filename = argv[i];
    if ((fp = fopen(filename, "r")) != NULL) {
      ++count;
      printf("page %d: filename: %s\n", count, filename);
      while ((line = fgets(content, 1000, fp)) != NULL) {
        fputs(line, stdout);
      }
    }
    ++i;
  }
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x414(%rbp)
movl   $0x0,-0x418(%rbp)
mov    -0x414(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1235 <main+0xe5>
mov    -0x10(%rbp),%rax
movslq -0x414(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe56(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     1221 <main+0xd1>
mov    -0x418(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x418(%rbp)
mov    -0x418(%rbp),%esi
mov    -0x20(%rbp),%rdx
lea    0xe25(%rip),%rdi
call   1040 <printf@plt>
lea    -0x410(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x3e8,%esi
call   1060 <fgets@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
je     121c <main+0xcc>
mov    -0x28(%rbp),%rdi
mov    0x2dd0(%rip),%rax
mov    (%rax),%esi
call   1050 <fputs@plt>
jmp    11e2 <main+0x92>
jmp    1221 <main+0xd1>
mov    -0x414(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x414(%rbp)
jmp    117d <main+0x2d>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x3f8,%rsp
mov    %rsi,0x8(%rsp)
mov    %edi,%eax
mov    %rax,(%rsp)
xor    %r13d,%r13d
mov    $0x1,%r12d
lea    0x10(%rsp),%rbx
mov    0x2e5f(%rip),%r14
jmp    119a <main+0x4a>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%r12
cmp    (%rsp),%r12
je     11f2 <main+0xa2>
mov    0x8(%rsp),%rax
mov    (%rax,%r12,8),%r15
mov    %r15,%rdi
lea    0xe53(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbp
test   %rax,%rax
je     1190 <main+0x40>
add    $0x1,%r13d
lea    0xe3d(%rip),%rdi
mov    %r13d,%esi
mov    %r15,%rdx
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x3e8,%esi
mov    %rbp,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     1190 <main+0x40>
mov    (%r14),%esi
mov    %rax,%rdi
call   1050 <fputs@plt>
jmp    11d0 <main+0x80>
mov    %rbp,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x3f8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [23 x i8] c"page %d: filename: %s\0A\00"
@stdout = 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
%6 = zext i32 %0 to i64
br label %7
7: ; preds = %2, %25
%8 = phi i64 [ 1, %2 ], [ %27, %25 ]
%9 = phi i32 [ 0, %2 ], [ %26, %25 ]
%10 = getelementptr inbounds i8*, i8** %1, i64 %8
%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 %25, label %14
14: ; preds = %7
%15 = add nsw i32 %9, 1
%16 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %15, i8* %11)
%17 = call i8* @fgets(i8* %4, i32 1000, i32* %12)
%18 = icmp eq i8* %17, null
br i1 %18, label %25, label %19
19: ; preds = %14, %19
%20 = phi i8* [ %23, %19 ], [ %17, %14 ]
%21 = load i32, i32* @stdout
%22 = call i32 @fputs(i8* %20, i32 %21)
%23 = call i8* @fgets(i8* %4, i32 1000, i32* %12)
%24 = icmp eq i8* %23, null
br i1 %24, label %25, label %19
25: ; preds = %19, %14, %7
%26 = phi i32 [ %9, %7 ], [ %15, %14 ], [ %15, %19 ]
%27 = add nuw nsw i64 %8, 1
%28 = icmp eq i64 %27, %6
br i1 %28, label %29, label %7
29: ; preds = %25
%30 = call i32 @fclose(i32* %12)
ret i32 0
}