#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*/ *fopen(char *, char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
long ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *, long);
void printFileSize() {
  char *read_path = "./rm.exe";
  FILE *fp = fopen(read_path, "r");
  fseek(fp, 0, SEEK_END);
  long fileSize = ftell(fp);
  printf("%s file size = %d \n", read_path, fileSize);
}


x86 assembly (clang, -O0):
<printFileSize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xeb1(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xeab(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2e76(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1050 <fseek@plt>
mov    -0x10(%rbp),%rdi
call   1040 <ftell@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    0xe74(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printFileSize>:
push   %r14
push   %rbx
push   %rax
lea    0xeb5(%rip),%r14
lea    0xeb7(%rip),%rsi
mov    %r14,%rdi
call   1060 <fopen@plt>
mov    %rax,%rbx
mov    0x2e84(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1050 <fseek@plt>
mov    %rbx,%rdi
call   1040 <ftell@plt>
lea    0xe8c(%rip),%rdi
mov    %r14,%rsi
mov    %rax,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"./rm.exe\00"
@.str.1 = [2 x i8] c"r\00"
@SEEK_END = global i32 0
@.str.2 = [20 x i8] c"%s file size = %d \0A\00"
define void @printFileSize() {
%1 = alloca i8*
%2 = alloca i32*
%3 = alloca i64
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8** %1
%4 = load i8*, i8** %1
%5 = call i32* @fopen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %5, i32** %2
%6 = load i32*, i32** %2
%7 = load i32, i32* @SEEK_END
%8 = call i32 @fseek(i32* %6, i32 0, i32 %7)
%9 = load i32*, i32** %2
%10 = call i64 @ftell(i32* %9)
store i64 %10, i64* %3
%11 = load i8*, i8** %1
%12 = load i64, i64* %3
%13 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %11, i64 %12)
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"./rm.exe\00"
@.str.1 = [2 x i8] c"r\00"
@SEEK_END = global i32 0
@.str.2 = [20 x i8] c"%s file size = %d \0A\00"
define void @printFileSize() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%2 = load i32, i32* @SEEK_END
%3 = tail call i32 @fseek(i32* %1, i32 0, i32 %2)
%4 = tail call i64 @ftell(i32* %1)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i64 %4)
ret void
}