#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*/ SEEK_SET;
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, long, int /*<<< orphan*/);
long ftell(int /*<<< orphan*/ *);
long get_file_size(FILE *f) {
  long t1, t2;
  fseek(f, 0L, SEEK_SET);
  t1 = ftell(f);
  fseek(f, 0L, SEEK_END);
  t2 = ftell(f);
  fseek(f, 0L, SEEK_SET);
  return t2 - t1;
}


x86 assembly (clang, -O0):
<get_file_size>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2ea1(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   1040 <fseek@plt>
mov    -0x8(%rbp),%rdi
call   1030 <ftell@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2e8e(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   1040 <fseek@plt>
mov    -0x8(%rbp),%rdi
call   1030 <ftell@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2e5b(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   1040 <fseek@plt>
mov    -0x18(%rbp),%rax
sub    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_file_size>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r15
mov    0x2ea6(%rip),%r12
mov    (%r12),%edx
xor    %esi,%esi
call   1040 <fseek@plt>
mov    %r15,%rdi
call   1030 <ftell@plt>
mov    %rax,%r14
mov    0x2e99(%rip),%rax
mov    (%rax),%edx
mov    %r15,%rdi
xor    %esi,%esi
call   1040 <fseek@plt>
mov    %r15,%rdi
call   1030 <ftell@plt>
mov    %rax,%rbx
mov    (%r12),%edx
mov    %r15,%rdi
xor    %esi,%esi
call   1040 <fseek@plt>
sub    %r14,%rbx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@SEEK_SET = global i32 0
@SEEK_END = global i32 0
define i64 @get_file_size(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_SET
%7 = call i32 @fseek(i32* %5, i64 0, i32 %6)
%8 = load i32*, i32** %2
%9 = call i64 @ftell(i32* %8)
store i64 %9, i64* %3
%10 = load i32*, i32** %2
%11 = load i32, i32* @SEEK_END
%12 = call i32 @fseek(i32* %10, i64 0, i32 %11)
%13 = load i32*, i32** %2
%14 = call i64 @ftell(i32* %13)
store i64 %14, i64* %4
%15 = load i32*, i32** %2
%16 = load i32, i32* @SEEK_SET
%17 = call i32 @fseek(i32* %15, i64 0, i32 %16)
%18 = load i64, i64* %4
%19 = load i64, i64* %3
%20 = sub nsw i64 %18, %19
ret i64 %20
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
@SEEK_END = global i32 0
define i64 @get_file_size(i32* nocapture %0) {
%2 = load i32, i32* @SEEK_SET
%3 = tail call i32 @fseek(i32* %0, i64 0, i32 %2)
%4 = tail call i64 @ftell(i32* %0)
%5 = load i32, i32* @SEEK_END
%6 = tail call i32 @fseek(i32* %0, i64 0, i32 %5)
%7 = tail call i64 @ftell(i32* %0)
%8 = load i32, i32* @SEEK_SET
%9 = tail call i32 @fseek(i32* %0, i64 0, i32 %8)
%10 = sub nsw i64 %7, %4
ret i64 %10
}