#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*/ SEEK_END;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
long ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *, double);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  long int size;
  FILE *fin;
  if (argc != 2) {
    fprintf(stderr, "Usage: %s <filename>\n", argv[0]);
    exit(1);
  }
  fin = fopen(argv[1], "r");
  if (!fin) {
    perror("filesize:");
    exit(-1);
  }
  fseek(fin, 0, SEEK_END);
  size = ftell(fin);
  printf("Size of the file %s = %lf MB\n", argv[1],
         (double)size / (1024 * 1024));
  exit(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)
cmpl   $0x2,-0x8(%rbp)
je     11b6 <main+0x46>
mov    0x2e41(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe61(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe59(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11ef <main+0x7f>
lea    0xe40(%rip),%rdi
call   1080 <perror@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>
mov    -0x20(%rbp),%rdi
mov    0x2dee(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1060 <fseek@plt>
mov    -0x20(%rbp),%rdi
call   1050 <ftell@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
cvtsi2sdq -0x18(%rbp),%xmm0
movsd  0xdda(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xdf9(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1090 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x2,%edi
jne    11a7 <main+0x37>
mov    0x8(%rbx),%rdi
lea    0xe97(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
jne    11c9 <main+0x59>
lea    0xe88(%rip),%rdi
call   1080 <perror@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>
mov    0x2e2a(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe4e(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    %rax,%r14
mov    0x2e15(%rip),%rax
mov    (%rax),%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1060 <fseek@plt>
mov    %r14,%rdi
call   1050 <ftell@plt>
mov    0x8(%rbx),%rsi
cvtsi2sd %rax,%xmm0
mulsd  0xe08(%rip),%xmm0
lea    0xe2b(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [22 x i8] c"Usage: %s <filename>\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [10 x i8] c"filesize:\00"
@SEEK_END = global i32 0
@.str.3 = [30 x i8] c"Size of the file %s = %lf MB\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 2
br i1 %9, label %10, label %17
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32* @fopen(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %21, i32** %7
%22 = load i32*, i32** %7
%23 = icmp ne i32* %22, null
br i1 %23, label %27, label %24
24: ; preds = %17
%25 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%26 = call i32 @exit(i32 -1)
unreachable
27: ; preds = %17
%28 = load i32*, i32** %7
%29 = load i32, i32* @SEEK_END
%30 = call i32 @fseek(i32* %28, i32 0, i32 %29)
%31 = load i32*, i32** %7
%32 = call i64 @ftell(i32* %31)
store i64 %32, i64* %6
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 1
%35 = load i8*, i8** %34
%36 = load i64, i64* %6
%37 = sitofp i64 %36 to double
%38 = fdiv double %37, 0x4130000000000000
%39 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i8* %35, double %38)
%40 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [22 x i8] c"Usage: %s <filename>\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [10 x i8] c"filesize:\00"
@SEEK_END = global i32 0
@.str.3 = [30 x i8] c"Size of the file %s = %lf MB\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %9, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %17
14: ; preds = %9
%15 = tail call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%16 = tail call i32 @exit(i32 -1)
unreachable
17: ; preds = %9
%18 = load i32, i32* @SEEK_END
%19 = tail call i32 @fseek(i32* %12, i32 0, i32 %18)
%20 = tail call i64 @ftell(i32* %12)
%21 = load i8*, i8** %10
%22 = sitofp i64 %20 to double
%23 = fmul double %22, 0x3EB0000000000000
%24 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i8* %21, double %23)
%25 = tail call i32 @exit(i32 0)
unreachable
}