#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 EOF;
int /*<<< orphan*/ argOk(char const **);
char fgetc(int /*<<< orphan*/ *);
int fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fsize(char *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ strcpy(char *, char const *);
int main(int argc, char const *argv[]) {
  argOk(argv);
  char *file_name;
  char file_char;
  int size;
  char all[1000];
  FILE *fPointer;
  fPointer = fopen(file_name, "r");
  strcpy(file_name, argv[1]);
  int file_size = fsize(file_name);
  while (file_char != EOF) {
    printf("size: %d\n", fgets(all, 100, fPointer));
    file_char = fgetc(fPointer);
  }
  printf("%d", file_size);
  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)
mov    -0x10(%rbp),%rdi
call   1030 <argOk@plt>
mov    -0x18(%rbp),%rdi
lea    0xe63(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x418(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1040 <strcpy@plt>
mov    -0x18(%rbp),%rdi
call   1080 <fsize@plt>
mov    %eax,-0x41c(%rbp)
movsbl -0x19(%rbp),%eax
mov    0x2e14(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1219 <main+0xa9>
lea    -0x410(%rbp),%rdi
mov    -0x418(%rbp),%rdx
mov    $0x64,%esi
call   1070 <fgets@plt>
mov    %eax,%esi
lea    0xe02(%rip),%rdi
call   1050 <printf@plt>
mov    -0x418(%rbp),%rdi
call   1060 <fgetc@plt>
mov    %al,-0x19(%rbp)
jmp    11c9 <main+0x59>
mov    -0x41c(%rbp),%esi
lea    0xde6(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x3f0,%rsp
mov    %rsi,%rbp
mov    %rsi,%rdi
call   1030 <argOk@plt>
lea    0xe6f(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%rbx
mov    0x8(%rbp),%rsi
call   1040 <strcpy@plt>
call   1080 <fsize@plt>
mov    %eax,%r14d
mov    %rsp,%r15
lea    0xe4e(%rip),%r12
mov    0x2e2d(%rip),%rbp
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    $0x64,%esi
mov    %rbx,%rdx
call   1070 <fgets@plt>
mov    %r12,%rdi
mov    %eax,%esi
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1060 <fgetc@plt>
cmp    0x0(%rbp),%al
jne    11c0 <main+0x50>
lea    0xe1e(%rip),%rdi
mov    %r14d,%esi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x3f0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@EOF = global i8 0
@.str.1 = [10 x i8] c"size: %d\0A\00"
@.str.2 = [3 x i8] c"%d\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 [1000 x i8]
%10 = alloca i32*
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i8**, i8*** %5
%13 = call i32 @argOk(i8** %12)
%14 = load i8*, i8** %6
%15 = call i32* @fopen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %15, i32** %10
%16 = load i8*, i8** %6
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i32 @strcpy(i8* %16, i8* %19)
%21 = load i8*, i8** %6
%22 = call i32 @fsize(i8* %21)
store i32 %22, i32* %11
br label %23
23: ; preds = %29, %2
%24 = load i8, i8* %7
%25 = sext i8 %24 to i32
%26 = load i8, i8* @EOF
%27 = sext i8 %26 to i32
%28 = icmp ne i32 %25, %27
br i1 %28, label %29, label %36
29: ; preds = %23
%30 = getelementptr inbounds [1000 x i8], [1000 x i8]* %9, i64 0, i64 0
%31 = load i32*, i32** %10
%32 = call i32 @fgets(i8* %30, i32 100, i32* %31)
%33 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %32)
%34 = load i32*, i32** %10
%35 = call signext i8 @fgetc(i32* %34)
store i8 %35, i8* %7
br label %23
36: ; preds = %23
%37 = load i32, i32* %11
%38 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %37)
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@EOF = global i8 0
@.str.1 = [10 x i8] c"size: %d\0A\00"
@.str.2 = [3 x i8] c"%d\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [1000 x i8]
%4 = tail call i32 @argOk(i8** %1)
%5 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%6 = tail call i32* @fopen(i8* undef, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @strcpy(i8* undef, i8* %8)
%10 = tail call i32 @fsize(i8* undef)
br label %11
11: ; preds = %2, %11
%12 = call i32 @fgets(i8* %5, i32 100, i32* %6)
%13 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = call signext i8 @fgetc(i32* %6)
%15 = load i8, i8* @EOF
%16 = icmp eq i8 %14, %15
br i1 %16, label %17, label %11
17: ; preds = %11
%18 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %10)
ret i32 0
}