#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 scalar_t__ off_t;

/* Variables and functions */
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ error_reason(int /*<<< orphan*/);
int /*<<< orphan*/ error_text(char *);
scalar_t__ lseek(int, scalar_t__, int /*<<< orphan*/);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
int misc_seek(int fd, off_t off) {
  if (lseek(fd, off, SEEK_SET) == off)
    return 0;
  error_reason(strerror(errno));
  error_text("Could not seek on device");
  return -1;
}


x86 assembly (clang, -O0):
<misc_seek>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    0x2e7b(%rip),%rax
mov    (%rax),%edx
call   1040 <lseek@plt>
cmp    -0x10(%rbp),%rax
jne    117a <misc_seek+0x3a>
movl   $0x0,-0x4(%rbp)
jmp    11a2 <misc_seek+0x62>
mov    0x2e5f(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    %eax,%edi
call   1030 <error_reason@plt>
lea    0xe6a(%rip),%rdi
call   1050 <error_text@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<misc_seek>:
push   %rbx
mov    %rsi,%rbx
mov    0x2e8d(%rip),%rax
mov    (%rax),%edx
call   1040 <lseek@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rbx,%rcx
je     1182 <misc_seek+0x42>
mov    0x2e7d(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    %eax,%edi
call   1030 <error_reason@plt>
lea    0xe88(%rip),%rdi
call   1050 <error_text@plt>
mov    $0xffffffff,%eax
pop    %rbx
ret

LLVM IR (-O0):
@SEEK_SET = global i32 0
@errno = global i32 0
@.str = [25 x i8] c"Could not seek on device\00"
define i32 @misc_seek(i32 %0, i64 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i64
store i32 %0, i32* %4
store i64 %1, i64* %5
%6 = load i32, i32* %4
%7 = load i64, i64* %5
%8 = load i32, i32* @SEEK_SET
%9 = call i64 @lseek(i32 %6, i64 %7, i32 %8)
%10 = load i64, i64* %5
%11 = icmp eq i64 %9, %10
br i1 %11, label %12, label %13
12: ; preds = %2
store i32 0, i32* %3
br label %18
13: ; preds = %2
%14 = load i32, i32* @errno
%15 = call i32 @strerror(i32 %14)
%16 = call i32 @error_reason(i32 %15)
%17 = call i32 @error_text(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %18
18: ; preds = %13, %12
%19 = load i32, i32* %3
ret i32 %19
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
@errno = global i32 0
@.str = [25 x i8] c"Could not seek on device\00"
define i32 @misc_seek(i32 %0, i64 %1) {
%3 = load i32, i32* @SEEK_SET
%4 = tail call i64 @lseek(i32 %0, i64 %1, i32 %3)
%5 = icmp eq i64 %4, %1
br i1 %5, label %11, label %6
6: ; preds = %2
%7 = load i32, i32* @errno
%8 = tail call i32 @strerror(i32 %7)
%9 = tail call i32 @error_reason(i32 %8)
%10 = tail call i32 @error_text(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %2, %6
%12 = phi i32 [ -1, %6 ], [ 0, %2 ]
ret i32 %12
}