#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*/);
int ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
int _get_file_size2(FILE *file) {
  fseek(file, 0L, SEEK_END);
  int size = ftell(file);
  if (size < 0) {
    perror("file error.");
  }
  fseek(file, 0L, SEEK_SET);
  return size;
}


x86 assembly (clang, -O0):
<_get_file_size2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%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    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    1174 <_get_file_size2+0x44>
lea    0xe91(%rip),%rdi
call   1050 <perror@plt>
mov    -0x8(%rbp),%rdi
mov    0x2e59(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   1040 <fseek@plt>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_get_file_size2>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    0x2eab(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1040 <fseek@plt>
mov    %rbx,%rdi
call   1030 <ftell@plt>
mov    %eax,%ebp
test   %eax,%eax
js     1170 <_get_file_size2+0x40>
mov    0x2e7d(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <fseek@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xe89(%rip),%rdi
call   1050 <perror@plt>
jmp    1154 <_get_file_size2+0x24>

LLVM IR (-O0):
@SEEK_END = global i32 0
@.str = [12 x i8] c"file error.\00"
@SEEK_SET = global i32 0
define i32 @_get_file_size2(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
store i32* %0, i32** %2
%4 = load i32*, i32** %2
%5 = load i32, i32* @SEEK_END
%6 = call i32 @fseek(i32* %4, i64 0, i32 %5)
%7 = load i32*, i32** %2
%8 = call i32 @ftell(i32* %7)
store i32 %8, i32* %3
%9 = load i32, i32* %3
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %1
%12 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %11, %1
%14 = load i32*, i32** %2
%15 = load i32, i32* @SEEK_SET
%16 = call i32 @fseek(i32* %14, i64 0, i32 %15)
%17 = load i32, i32* %3
ret i32 %17
}

LLVM IR (-O2):
@SEEK_END = global i32 0
@.str = [12 x i8] c"file error.\00"
@SEEK_SET = global i32 0
define i32 @_get_file_size2(i32* nocapture %0) {
%2 = load i32, i32* @SEEK_END
%3 = tail call i32 @fseek(i32* %0, i64 0, i32 %2)
%4 = tail call i32 @ftell(i32* %0)
%5 = icmp slt i32 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = tail call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %6, %1
%9 = load i32, i32* @SEEK_SET
%10 = tail call i32 @fseek(i32* %0, i64 0, i32 %9)
ret i32 %4
}