#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*/ dv_error(char *);
scalar_t__ errno;
scalar_t__ fseek(int /*<<< orphan*/ *, long, int);
void dv_fseek(FILE *stream, long offset, int whence) {
  if (errno) {
    dv_error("");
  }
  if (fseek(stream, offset, whence) < 0) {
    dv_error("Failed to seek file.");
  }
}


x86 assembly (clang, -O0):
<dv_fseek>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    0x2ea6(%rip),%rax
cmpq   $0x0,(%rax)
je     1150 <dv_fseek+0x30>
lea    0xec9(%rip),%rdi
call   1040 <dv_error@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <fseek@plt>
cmp    $0x0,%rax
jge    1176 <dv_fseek+0x56>
lea    0xe8f(%rip),%rdi
call   1040 <dv_error@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dv_fseek>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %rsi,%rbx
mov    %rdi,%rbp
mov    0x2eac(%rip),%rax
cmpq   $0x0,(%rax)
je     1146 <dv_fseek+0x26>
lea    0xed3(%rip),%rdi
call   1040 <dv_error@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r14d,%edx
call   1030 <fseek@plt>
test   %rax,%rax
js     115e <dv_fseek+0x3e>
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xe9b(%rip),%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <dv_error@plt>

LLVM IR (-O0):
@errno = global i64 0
@.str = [1 x i8] zeroinitializer
@.str.1 = [21 x i8] c"Failed to seek file.\00"
define void @dv_fseek(i32* %0, i64 %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i64
%6 = alloca i32
store i32* %0, i32** %4
store i64 %1, i64* %5
store i32 %2, i32* %6
%7 = load i64, i64* @errno
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %3
%10 = call i32 @dv_error(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %9, %3
%12 = load i32*, i32** %4
%13 = load i64, i64* %5
%14 = load i32, i32* %6
%15 = call i64 @fseek(i32* %12, i64 %13, i32 %14)
%16 = icmp slt i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %11
%18 = call i32 @dv_error(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
br label %19
19: ; preds = %17, %11
ret void
}

LLVM IR (-O2):
@errno = global i64 0
@.str = [1 x i8] zeroinitializer
@.str.1 = [21 x i8] c"Failed to seek file.\00"
define void @dv_fseek(i32* nocapture %0, i64 %1, i32 %2) {
%4 = load i64, i64* @errno
%5 = icmp eq i64 %4, 0
br i1 %5, label %8, label %6
6: ; preds = %3
%7 = tail call i32 @dv_error(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %6, %3
%9 = tail call i64 @fseek(i32* %0, i64 %1, i32 %2)
%10 = icmp slt i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = tail call i32 @dv_error(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
br label %13
13: ; preds = %11, %8
ret void
}