#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 */
char *OptionScanFileArg(int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int main(int argc, char *argv[]) {
  FILE *fp;
  char *text = NULL;
  fp = fopen(argv[argc - 1], "r");
  if (fp == NULL) {
    fprintf(stderr, "File not found.\n");
    exit(-1);
  }
  while ((text = OptionScanFileArg(fp)) != NULL) {
    fprintf(stdout, "%s\n", text);
    free(text);
  }
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe6a(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11cb <main+0x6b>
mov    0x2e2f(%rip),%rax
mov    (%rax),%edi
lea    0xe48(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
jmp    11d0 <main+0x70>
mov    -0x18(%rbp),%rdi
call   1030 <OptionScanFileArg@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     1210 <main+0xb0>
mov    0x2dea(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xe18(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   1040 <free@plt>
jmp    11d0 <main+0x70>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
movslq %edi,%rax
mov    -0x8(%rsi,%rax,8),%rdi
lea    0xe89(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     11ef <main+0x8f>
mov    %rax,%r15
mov    %rax,%rdi
call   1030 <OptionScanFileArg@plt>
test   %rax,%rax
je     11d9 <main+0x79>
mov    %rax,%rbx
mov    0x2e3d(%rip),%r12
lea    0xe71(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%r12),%edi
mov    %r14,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %rbx,%rdi
call   1040 <free@plt>
mov    %r15,%rdi
call   1030 <OptionScanFileArg@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    11b0 <main+0x50>
mov    %r15,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    0x2dea(%rip),%rax
mov    (%rax),%edi
lea    0xe03(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [17 x i8] c"File not found.\0A\00"
@stdout = global i32 0
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %7
%8 = load i8**, i8*** %5
%9 = load i32, i32* %4
%10 = sub nsw i32 %9, 1
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8*, i8** %8, i64 %11
%13 = load i8*, i8** %12
%14 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %14, i32** %6
%15 = load i32*, i32** %6
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %21
17: ; preds = %2
%18 = load i32, i32* @stderr
%19 = call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%20 = call i32 @exit(i32 -1)
unreachable
21: ; preds = %2
br label %22
22: ; preds = %26, %21
%23 = load i32*, i32** %6
%24 = call i8* @OptionScanFileArg(i32* %23)
store i8* %24, i8** %7
%25 = icmp ne i8* %24, null
br i1 %25, label %26, label %32
26: ; preds = %22
%27 = load i32, i32* @stdout
%28 = load i8*, i8** %7
%29 = call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %28)
%30 = load i8*, i8** %7
%31 = call i32 @free(i8* %30)
br label %22
32: ; preds = %22
%33 = load i32*, i32** %6
%34 = call i32 @fclose(i32* %33)
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [17 x i8] c"File not found.\0A\00"
@stdout = global i32 0
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = add nsw i32 %0, -1
%4 = sext i32 %3 to i64
%5 = getelementptr inbounds i8*, i8** %1, i64 %4
%6 = load i8*, i8** %5
%7 = tail call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %12, label %9
9: ; preds = %2
%10 = tail call i8* @OptionScanFileArg(i32* %7)
%11 = icmp eq i8* %10, null
br i1 %11, label %23, label %16
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = tail call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%15 = tail call i32 @exit(i32 -1)
unreachable
16: ; preds = %9, %16
%17 = phi i8* [ %21, %16 ], [ %10, %9 ]
%18 = load i32, i32* @stdout
%19 = tail call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %17)
%20 = tail call i32 @free(i8* %17)
%21 = tail call i8* @OptionScanFileArg(i32* %7)
%22 = icmp eq i8* %21, null
br i1 %22, label %23, label %16
23: ; preds = %16, %9
%24 = tail call i32 @fclose(i32* %7)
ret i32 0
}