#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 long off_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int SEEK_CUR;
int fseek(int /*<<< orphan*/ *, long, int);
int fseeko(FILE *stream, off_t offset, int whence) {
  while (offset != (long)offset) {
    long pos = (offset < 0) ? (-1 - ((long)((unsigned long)~0 >> 1)))
                            : ((long)((unsigned long)~0 >> 1));
    if (fseek(stream, pos, whence) != 0)
      return -1;
    offset -= pos;
    whence = SEEK_CUR;
  }
  return fseek(stream, (long)offset, whence);
}


x86 assembly (clang, -O0):
<fseeko>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x18(%rbp),%rax
je     119a <fseeko+0x8a>
mov    -0x18(%rbp),%rdx
movabs $0x7fffffffffffffff,%rax
ff ff 7f
movabs $0x8000000000000000,%rcx
cmp    $0x0,%rdx
cmovl  %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1030 <fseek@plt>
cmp    $0x0,%eax
je     117a <fseeko+0x6a>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ad <fseeko+0x9d>
mov    -0x28(%rbp),%rcx
mov    -0x18(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    0x2e58(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
jmp    1123 <fseeko+0x13>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1030 <fseek@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fseeko>:
jmp    1030 <fseek@plt>

LLVM IR (-O0):
@SEEK_CUR = global i32 0
define i32 @fseeko(i32* %0, i64 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i64
%7 = alloca i32
%8 = alloca i64
store i32* %0, i32** %5
store i64 %1, i64* %6
store i32 %2, i32* %7
br label %9
9: ; preds = %24, %3
%10 = load i64, i64* %6
%11 = load i64, i64* %6
%12 = icmp ne i64 %10, %11
br i1 %12, label %13, label %29
13: ; preds = %9
%14 = load i64, i64* %6
%15 = icmp slt i64 %14, 0
%16 = zext i1 %15 to i64
%17 = select i1 %15, i64 -9223372036854775808, i64 9223372036854775807
store i64 %17, i64* %8
%18 = load i32*, i32** %5
%19 = load i64, i64* %8
%20 = load i32, i32* %7
%21 = call i32 @fseek(i32* %18, i64 %19, i32 %20)
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %13
store i32 -1, i32* %4
br label %34
24: ; preds = %13
%25 = load i64, i64* %8
%26 = load i64, i64* %6
%27 = sub nsw i64 %26, %25
store i64 %27, i64* %6
%28 = load i32, i32* @SEEK_CUR
store i32 %28, i32* %7
br label %9
29: ; preds = %9
%30 = load i32*, i32** %5
%31 = load i64, i64* %6
%32 = load i32, i32* %7
%33 = call i32 @fseek(i32* %30, i64 %31, i32 %32)
store i32 %33, i32* %4
br label %34
34: ; preds = %29, %23
%35 = load i32, i32* %4
ret i32 %35
}

LLVM IR (-O2):
@SEEK_CUR = global i32 0
define i32 @fseeko(i32* nocapture %0, i64 %1, i32 %2) {
%4 = tail call i32 @fseek(i32* %0, i64 %1, i32 %2)
ret i32 %4
}