#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*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ output_file(char *);
int /*<<< orphan*/ printf(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  char *prog = argv[0];
  char *cur_f;
  int i, page_count;
  if (argc < 1) {
    fprintf(stderr, "%s file1 file2 ...\n", prog);
    exit(1);
  }
  i = 1;
  page_count = 1;
  while (i < argc) {
    cur_f = argv[i++];
    printf("file:%s page:%d\n", cur_f, page_count++);
    output_file(cur_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)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x1,-0x8(%rbp)
jge    118e <main+0x4e>
mov    0x2e6e(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xe81(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
movl   $0x1,-0x24(%rbp)
movl   $0x1,-0x28(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11eb <main+0xab>
mov    -0x10(%rbp),%rax
mov    -0x24(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x24(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%edx
mov    %edx,%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
lea    0xe3c(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <output_file@plt>
jmp    119c <main+0x5c>
xor    %edi,%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r15
test   %edi,%edi
jg     1172 <main+0x32>
mov    (%r15),%rdx
mov    0x2e86(%rip),%rax
mov    (%rax),%edi
lea    0xe9d(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
cmp    $0x1,%edi
je     11b3 <main+0x73>
mov    %edi,%r12d
mov    $0x1,%edx
lea    0xe8e(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
lea    0x1(%rdx),%r13
mov    (%r15,%rdx,8),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <output_file@plt>
mov    %r13,%rdx
cmp    %r13,%r12
jne    1190 <main+0x50>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [20 x i8] c"%s file1 file2 ...\0A\00"
@.str.1 = [17 x i8] c"file:%s page:%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 0
%12 = load i8*, i8** %11
store i8* %12, i8** %6
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 1
br i1 %14, label %15, label %20
15: ; preds = %2
%16 = load i32, i32* @stderr
%17 = load i8*, i8** %6
%18 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %2
store i32 1, i32* %8
store i32 1, i32* %9
br label %21
21: ; preds = %25, %20
%22 = load i32, i32* %8
%23 = load i32, i32* %4
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %38
25: ; preds = %21
%26 = load i8**, i8*** %5
%27 = load i32, i32* %8
%28 = add nsw i32 %27, 1
store i32 %28, i32* %8
%29 = sext i32 %27 to i64
%30 = getelementptr inbounds i8*, i8** %26, i64 %29
%31 = load i8*, i8** %30
store i8* %31, i8** %7
%32 = load i8*, i8** %7
%33 = load i32, i32* %9
%34 = add nsw i32 %33, 1
store i32 %34, i32* %9
%35 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %32, i32 %33)
%36 = load i8*, i8** %7
%37 = call i32 @output_file(i8* %36)
br label %21
38: ; preds = %21
%39 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [20 x i8] c"%s file1 file2 ...\0A\00"
@.str.1 = [17 x i8] c"file:%s page:%d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 1
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = icmp eq i32 %0, 1
br i1 %5, label %22, label %6
6: ; preds = %4
%7 = zext i32 %0 to i64
br label %13
8: ; preds = %2
%9 = load i8*, i8** %1
%10 = load i32, i32* @stderr
%11 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %9)
%12 = tail call i32 @exit(i32 1)
unreachable
13: ; preds = %6, %13
%14 = phi i64 [ 1, %6 ], [ %16, %13 ]
%15 = trunc i64 %14 to i32
%16 = add nuw nsw i64 %14, 1
%17 = getelementptr inbounds i8*, i8** %1, i64 %14
%18 = load i8*, i8** %17
%19 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %18, i32 %15)
%20 = tail call i32 @output_file(i8* %18)
%21 = icmp eq i64 %16, %7
br i1 %21, label %22, label %13
22: ; preds = %13, %4
%23 = tail call i32 @exit(i32 0)
unreachable
}