#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*/ *);
void file_center(FILE *file) {
  long start;
  fseek(file, 0, SEEK_SET);
  start = ftell(file);
  long end;
  fseek(file, 0, SEEK_END);
  end = ftell(file);
  fseek(file, (start + end) / 2, SEEK_SET);
}


x86 assembly (clang, -O0):
<file_center>:
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    -0x10(%rbp),%rax
add    -0x18(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
mov    %rax,%rsi
mov    0x2e46(%rip),%rax
mov    (%rax),%edx
call   1040 <fseek@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<file_center>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
mov    0x2ea9(%rip),%r15
mov    (%r15),%edx
xor    %esi,%esi
call   1040 <fseek@plt>
mov    %r14,%rdi
call   1030 <ftell@plt>
mov    %rax,%rbx
mov    0x2e9d(%rip),%rax
mov    (%rax),%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1040 <fseek@plt>
mov    %r14,%rdi
call   1030 <ftell@plt>
add    %rax,%rbx
mov    %rbx,%rsi
shr    $0x3f,%rsi
add    %rbx,%rsi
sar    %rsi
mov    (%r15),%edx
mov    %r14,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <fseek@plt>

LLVM IR (-O0):
@SEEK_SET = global i32 0
@SEEK_END = global i32 0
define void @file_center(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 i64, i64* %3
%17 = load i64, i64* %4
%18 = add nsw i64 %16, %17
%19 = sdiv i64 %18, 2
%20 = load i32, i32* @SEEK_SET
%21 = call i32 @fseek(i32* %15, i64 %19, i32 %20)
ret void
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
@SEEK_END = global i32 0
define void @file_center(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 = add nsw i64 %7, %4
%9 = sdiv i64 %8, 2
%10 = load i32, i32* @SEEK_SET
%11 = tail call i32 @fseek(i32* %0, i64 %9, i32 %10)
ret void
}