#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*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ ferror(int /*<<< orphan*/);
int /*<<< orphan*/ filecopy(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ printf(char *, char *, unsigned int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int main(int argc, char *argv[]) {
  if (argc == 1) {
    fprintf(stdout, "Usage: ./prog.out file_1, file_2, ...\n");
    return 0;
  }
  char *prog = argv[0];
  FILE *fp;
  unsigned page = 1;
  char *title =
      "\f#################################################\n\tFile: %s Page: "
      "%u\t\t\n#################################################\n\n";
  while (--argc > 0) {
    if ((fp = fopen(*++argv, "r")) == NULL) {
      fprintf(stderr, "can't open %s\n", *argv);
      exit(1);
    } else {
      printf(title, *argv, page);
      filecopy(fp, stdout);
      fclose(fp);
      ++page;
    }
  }
  if (ferror(stdout)) {
    fprintf(stderr, "%s: error writing stdout\n", prog);
    exit(2);
  }
  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)
cmpl   $0x1,-0x8(%rbp)
jne    11af <main+0x3f>
mov    0x2e41(%rip),%rax
mov    (%rax),%edi
lea    0xe60(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
movl   $0x1,-0x24(%rbp)
lea    0xe5f(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jle    126f <main+0xff>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    0x8(%rax),%rdi
lea    0xeab(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    1233 <main+0xc3>
mov    0x2dce(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe83(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
mov    -0x24(%rbp),%edx
call   1050 <printf@plt>
mov    -0x20(%rbp),%rdi
mov    0x2d87(%rip),%rax
mov    (%rax),%esi
call   1070 <filecopy@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11cc <main+0x5c>
mov    0x2d62(%rip),%rax
mov    (%rax),%edi
call   1030 <ferror@plt>
cmp    $0x0,%rax
je     12ac <main+0x13c>
mov    0x2d52(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xe19(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x2,%edi
call   1090 <exit@plt>
xor    %edi,%edi
call   1090 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x1,%edi
jne    11a8 <main+0x38>
mov    0x2e51(%rip),%rax
mov    (%rax),%edi
lea    0xe70(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rsi,%r15
mov    (%rsi),%rax
mov    %rax,(%rsp)
jle    1213 <main+0xa3>
mov    %edi,%r14d
mov    $0x1,%ebx
lea    0xe64(%rip),%r13
mov    0x2e0e(%rip),%r12
nopw   0x0(%rax,%rax,1)
mov    (%r15,%rbx,8),%rdi
lea    0xec8(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     1252 <main+0xe2>
mov    %rax,%rbp
mov    (%r15,%rbx,8),%rsi
mov    %r13,%rdi
mov    %ebx,%edx
call   1050 <printf@plt>
mov    (%r12),%esi
mov    %rbp,%rdi
call   1070 <filecopy@plt>
mov    %rbp,%rdi
call   1040 <fclose@plt>
add    $0x1,%rbx
cmp    %ebx,%r14d
jne    11d0 <main+0x60>
mov    0x2dbe(%rip),%rax
mov    (%rax),%edi
call   1030 <ferror@plt>
test   %rax,%rax
jne    122d <main+0xbd>
xor    %edi,%edi
call   1090 <exit@plt>
mov    0x2dac(%rip),%rax
mov    (%rax),%edi
lea    0xe77(%rip),%rsi
mov    (%rsp),%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x2,%edi
call   1090 <exit@plt>
mov    0x2d87(%rip),%rax
mov    (%rax),%edi
mov    (%r15,%rbx,8),%rdx
lea    0xe3f(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@stdout = global i32 0
@.str = [39 x i8] c"Usage: ./prog.out file_1, file_2, ...\0A\00"
@.str.1 = [124 x i8] c"\0C#################################################\0A\09File: %s Page: %u\09\09\0A#################################################\0A\0A\00"
@.str.2 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.3 = [15 x i8] c"can't open %s\0A\00"
@.str.4 = [26 x i8] c"%s: error writing stdout\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = load i32, i32* @stdout
%14 = call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
ret i32 0
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 0
%18 = load i8*, i8** %17
store i8* %18, i8** %6
store i32 1, i32* %8
store i8* getelementptr inbounds ([124 x i8], [124 x i8]* @.str.1, i64 0, i64 0), i8** %9
br label %19
19: ; preds = %48, %15
%20 = load i32, i32* %4
%21 = add nsw i32 %20, -1
store i32 %21, i32* %4
%22 = icmp sgt i32 %21, 0
br i1 %22, label %23, label %49
23: ; preds = %19
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i32 1
store i8** %25, i8*** %5
%26 = load i8*, i8** %25
%27 = call i32* @fopen(i8* %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %27, i32** %7
%28 = icmp eq i32* %27, null
br i1 %28, label %29, label %35
29: ; preds = %23
%30 = load i32, i32* @stderr
%31 = load i8**, i8*** %5
%32 = load i8*, i8** %31
%33 = call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i8* %32)
%34 = call i32 @exit(i32 1)
unreachable
35: ; preds = %23
%36 = load i8*, i8** %9
%37 = load i8**, i8*** %5
%38 = load i8*, i8** %37
%39 = load i32, i32* %8
%40 = call i32 @printf(i8* %36, i8* %38, i32 %39)
%41 = load i32*, i32** %7
%42 = load i32, i32* @stdout
%43 = call i32 @filecopy(i32* %41, i32 %42)
%44 = load i32*, i32** %7
%45 = call i32 @fclose(i32* %44)
%46 = load i32, i32* %8
%47 = add i32 %46, 1
store i32 %47, i32* %8
br label %48
48: ; preds = %35
br label %19
49: ; preds = %19
%50 = load i32, i32* @stdout
%51 = call i64 @ferror(i32 %50)
%52 = icmp ne i64 %51, 0
br i1 %52, label %53, label %58
53: ; preds = %49
%54 = load i32, i32* @stderr
%55 = load i8*, i8** %6
%56 = call i32 (i32, i8*, ...) @fprintf(i32 %54, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i8* %55)
%57 = call i32 @exit(i32 2)
unreachable
58: ; preds = %49
%59 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [39 x i8] c"Usage: ./prog.out file_1, file_2, ...\0A\00"
@.str.1 = [124 x i8] c"\0C#################################################\0A\09File: %s Page: %u\09\09\0A#################################################\0A\0A\00"
@.str.2 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.3 = [15 x i8] c"can't open %s\0A\00"
@.str.4 = [26 x i8] c"%s: error writing stdout\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 1
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = load i32, i32* @stdout
%6 = tail call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
ret i32 0
7: ; preds = %2
%8 = load i8*, i8** %1
%9 = icmp sgt i32 %0, 1
br i1 %9, label %10, label %30
10: ; preds = %7, %22
%11 = phi i32 [ %28, %22 ], [ 1, %7 ]
%12 = phi i8** [ %13, %22 ], [ %1, %7 ]
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = tail call i32* @fopen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %22
17: ; preds = %10
%18 = load i32, i32* @stderr
%19 = load i8*, i8** %13
%20 = tail call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i8* %19)
%21 = tail call i32 @exit(i32 1)
unreachable
22: ; preds = %10
%23 = load i8*, i8** %13
%24 = tail call i32 @printf(i8* getelementptr inbounds ([124 x i8], [124 x i8]* @.str.1, i64 0, i64 0), i8* %23, i32 %11)
%25 = load i32, i32* @stdout
%26 = tail call i32 @filecopy(i32* %15, i32 %25)
%27 = tail call i32 @fclose(i32* %15)
%28 = add nuw nsw i32 %11, 1
%29 = icmp eq i32 %28, %0
br i1 %29, label %30, label %10
30: ; preds = %22, %7
%31 = load i32, i32* @stdout
%32 = tail call i64 @ferror(i32 %31)
%33 = icmp eq i64 %32, 0
br i1 %33, label %38, label %34
34: ; preds = %30
%35 = load i32, i32* @stderr
%36 = tail call i32 (i32, i8*, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i8* %8)
%37 = tail call i32 @exit(i32 2)
unreachable
38: ; preds = %30
%39 = tail call i32 @exit(i32 0)
unreachable
}