#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_bytes_total_from_file(FILE *fp) {
  long t = 0;
  if (fp == NULL) {
    return 0;
  }
  fseek(fp, 0L, SEEK_END);
  t = ftell(fp);
  fseek(fp, 0L, SEEK_SET);
  return t;
}


x86 assembly (clang, -O0):
<get_bytes_total_from_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    114c <get_bytes_total_from_file+0x2c>
movq   $0x0,-0x8(%rbp)
jmp    118d <get_bytes_total_from_file+0x6d>
mov    -0x10(%rbp),%rdi
mov    0x2e91(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   1040 <fseek@plt>
mov    -0x10(%rbp),%rdi
call   1030 <ftell@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2e5e(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   1040 <fseek@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_bytes_total_from_file>:
test   %rdi,%rdi
je     1165 <get_bytes_total_from_file+0x45>
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    0x2eb5(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1040 <fseek@plt>
mov    %rbx,%rdi
call   1030 <ftell@plt>
mov    %rax,%r14
mov    0x2e8a(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <fseek@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
xor    %eax,%eax
ret

LLVM IR (-O0):
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
define i64 @get_bytes_total_from_file(i32* %0) {
%2 = alloca i64
%3 = alloca i32*
%4 = alloca i64
store i32* %0, i32** %3
store i64 0, i64* %4
%5 = load i32*, i32** %3
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %8
7: ; preds = %1
store i64 0, i64* %2
br label %18
8: ; preds = %1
%9 = load i32*, i32** %3
%10 = load i32, i32* @SEEK_END
%11 = call i32 @fseek(i32* %9, i64 0, i32 %10)
%12 = load i32*, i32** %3
%13 = call i64 @ftell(i32* %12)
store i64 %13, i64* %4
%14 = load i32*, i32** %3
%15 = load i32, i32* @SEEK_SET
%16 = call i32 @fseek(i32* %14, i64 0, i32 %15)
%17 = load i64, i64* %4
store i64 %17, i64* %2
br label %18
18: ; preds = %8, %7
%19 = load i64, i64* %2
ret i64 %19
}

LLVM IR (-O2):
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
define i64 @get_bytes_total_from_file(i32* %0) {
%2 = icmp eq i32* %0, null
br i1 %2, label %9, label %3
3: ; preds = %1
%4 = load i32, i32* @SEEK_END
%5 = tail call i32 @fseek(i32* %0, i64 0, i32 %4)
%6 = tail call i64 @ftell(i32* %0)
%7 = load i32, i32* @SEEK_SET
%8 = tail call i32 @fseek(i32* %0, i64 0, i32 %7)
br label %9
9: ; preds = %1, %3
%10 = phi i64 [ %6, %3 ], [ 0, %1 ]
ret i64 %10
}