#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 */

/* Variables and functions */
int /*<<< orphan*/ SEEK_CUR;
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
long lseek(int, long, int /*<<< orphan*/);
long int getFileSize(int fp) {
  long int save_pos, size_of_file;
  save_pos = lseek(fp, 0, SEEK_CUR);
  lseek(fp, 0L, SEEK_SET);
  size_of_file = lseek(fp, 0L, SEEK_END);
  lseek(fp, save_pos, SEEK_SET);
  return (size_of_file);
}


x86 assembly (clang, -O0):
<getFileSize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2ebb(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   1030 <lseek@plt>
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e92(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   1030 <lseek@plt>
mov    -0x4(%rbp),%edi
mov    0x2e95(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   1030 <lseek@plt>
mov    %rax,-0x18(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    0x2e60(%rip),%rax
mov    (%rax),%edx
call   1030 <lseek@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getFileSize>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %edi,%ebx
mov    0x2ebf(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1030 <lseek@plt>
mov    %rax,%r14
mov    0x2e9c(%rip),%r12
mov    (%r12),%edx
mov    %ebx,%edi
xor    %esi,%esi
call   1030 <lseek@plt>
mov    0x2ea0(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
xor    %esi,%esi
call   1030 <lseek@plt>
mov    %rax,%r15
mov    (%r12),%edx
mov    %ebx,%edi
mov    %r14,%rsi
call   1030 <lseek@plt>
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@SEEK_CUR = global i32 0
@SEEK_SET = global i32 0
@SEEK_END = global i32 0
define i64 @getFileSize(i32 %0) {
%2 = alloca i32
%3 = alloca i64
%4 = alloca i64
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = load i32, i32* @SEEK_CUR
%7 = call i64 @lseek(i32 %5, i64 0, i32 %6)
store i64 %7, i64* %3
%8 = load i32, i32* %2
%9 = load i32, i32* @SEEK_SET
%10 = call i64 @lseek(i32 %8, i64 0, i32 %9)
%11 = load i32, i32* %2
%12 = load i32, i32* @SEEK_END
%13 = call i64 @lseek(i32 %11, i64 0, i32 %12)
store i64 %13, i64* %4
%14 = load i32, i32* %2
%15 = load i64, i64* %3
%16 = load i32, i32* @SEEK_SET
%17 = call i64 @lseek(i32 %14, i64 %15, i32 %16)
%18 = load i64, i64* %4
ret i64 %18
}

LLVM IR (-O2):
@SEEK_CUR = global i32 0
@SEEK_SET = global i32 0
@SEEK_END = global i32 0
define i64 @getFileSize(i32 %0) {
%2 = load i32, i32* @SEEK_CUR
%3 = tail call i64 @lseek(i32 %0, i64 0, i32 %2)
%4 = load i32, i32* @SEEK_SET
%5 = tail call i64 @lseek(i32 %0, i64 0, i32 %4)
%6 = load i32, i32* @SEEK_END
%7 = tail call i64 @lseek(i32 %0, i64 0, i32 %6)
%8 = load i32, i32* @SEEK_SET
%9 = tail call i64 @lseek(i32 %0, i64 %3, i32 %8)
ret i64 %7
}