#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int getFileSize(char *);
char getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putchar(char);
int main(int argc, char **argv) {
  FILE *fp;
  char c;
  int size;
  fp = fopen(argv[1], "r");
  if (fp) {
    while ((c = getc(fp)) != EOF)
      putchar(c);
    printf("\n");
    size = getFileSize(argv[1]);
    printf("%20s has %d bytes.\n", argv[1], size);
  } else
    printf("Please, provide a valid file name.\n");
  fclose(fp);
}


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)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe7b(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1209 <main+0xa9>
jmp    119e <main+0x3e>
mov    -0x18(%rbp),%rdi
call   1080 <getc@plt>
mov    %al,-0x19(%rbp)
movsbl %al,%eax
mov    0x2e34(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11cd <main+0x6d>
movsbl -0x19(%rbp),%edi
call   1030 <putchar@plt>
jmp    119e <main+0x3e>
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <getFileSize@plt>
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x20(%rbp),%edx
lea    0xe05(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1217 <main+0xb7>
lea    0xe06(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    0x8(%rsi),%rdi
lea    0xe7d(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11ee <main+0x7e>
mov    %rbx,%rdi
call   1090 <getc@plt>
mov    0x2e49(%rip),%r15
cmp    (%r15),%al
je     11c5 <main+0x55>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl %al,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
call   1090 <getc@plt>
cmp    (%r15),%al
jne    11b0 <main+0x40>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x8(%r14),%rdi
call   1070 <getFileSize@plt>
mov    0x8(%r14),%rsi
lea    0xe1f(%rip),%rdi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <printf@plt>
jmp    11fa <main+0x8a>
lea    0xe21(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@EOF = global i8 0
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [20 x i8] c"%20s has %d bytes.\0A\00"
@.str.3 = [36 x i8] c"Please, provide a valid file name.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i8
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 1
%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))
store i32* %12, i32** %6
%13 = load i32*, i32** %6
%14 = icmp ne i32* %13, null
br i1 %14, label %15, label %37
15: ; preds = %2
br label %16
16: ; preds = %23, %15
%17 = load i32*, i32** %6
%18 = call signext i8 @getc(i32* %17)
store i8 %18, i8* %7
%19 = sext i8 %18 to i32
%20 = load i8, i8* @EOF
%21 = sext i8 %20 to i32
%22 = icmp ne i32 %19, %21
br i1 %22, label %23, label %26
23: ; preds = %16
%24 = load i8, i8* %7
%25 = call i32 @putchar(i8 signext %24)
br label %16
26: ; preds = %16
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 1
%30 = load i8*, i8** %29
%31 = call i32 @getFileSize(i8* %30)
store i32 %31, i32* %8
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 1
%34 = load i8*, i8** %33
%35 = load i32, i32* %8
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %34, i32 %35)
br label %39
37: ; preds = %2
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0))
br label %39
39: ; preds = %37, %26
%40 = load i32*, i32** %6
%41 = call i32 @fclose(i32* %40)
%42 = load i32, i32* %3
ret i32 %42
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@EOF = global i8 0
@.str.2 = [20 x i8] c"%20s has %d bytes.\0A\00"
@str = [35 x i8] c"Please, provide a valid file name.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = tail call i32* @fopen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %23, label %7
7: ; preds = %2
%8 = tail call signext i8 @getc(i32* %5)
%9 = load i8, i8* @EOF
%10 = icmp eq i8 %8, %9
br i1 %10, label %17, label %11
11: ; preds = %7, %11
%12 = phi i8 [ %14, %11 ], [ %8, %7 ]
%13 = tail call i32 @putchar(i8 signext %12)
%14 = tail call signext i8 @getc(i32* %5)
%15 = load i8, i8* @EOF
%16 = icmp eq i8 %14, %15
br i1 %16, label %17, label %11
17: ; preds = %11, %7
%18 = tail call i32 bitcast (i32 (i8)* @putchar to i32 (i32)*)(i32 10)
%19 = load i8*, i8** %3
%20 = tail call i32 @getFileSize(i8* %19)
%21 = load i8*, i8** %3
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %21, i32 %20)
br label %25
23: ; preds = %2
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
br label %25
25: ; preds = %23, %17
%26 = tail call i32 @fclose(i32* %5)
ret i32 0
}