#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 */
struct file {
  int dummy;
};

/* Variables and functions */
scalar_t__ argfd(int /*<<< orphan*/, int *, struct file **);
scalar_t__ argint(int, int *);
int /*<<< orphan*/ cprintf(char *);
int fileseek(struct file *, int);
int sys_fseek(void) {
  struct file *f;
  int pos, fd;
  if (argint(0, &fd) < 0 || argint(1, &pos) < 0 || argfd(0, &fd, &f) < 0) {
    cprintf("Incorrect call to fseek\n");
    return -1;
  }
  return fileseek(f, pos);
}


x86 assembly (clang, -O0):
<sys_fseek>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
xor    %edi,%edi
lea    -0x18(%rbp),%rsi
call   1050 <argint@plt>
cmp    $0x0,%rax
jl     118e <sys_fseek+0x4e>
mov    $0x1,%edi
lea    -0x14(%rbp),%rsi
call   1050 <argint@plt>
cmp    $0x0,%rax
jl     118e <sys_fseek+0x4e>
xor    %edi,%edi
lea    -0x18(%rbp),%rsi
lea    -0x10(%rbp),%rdx
call   1060 <argfd@plt>
cmp    $0x0,%rax
jge    11a6 <sys_fseek+0x66>
lea    0xe6b(%rip),%rdi
call   1040 <cprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b5 <sys_fseek+0x75>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <fileseek@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sys_fseek>:
sub    $0x18,%rsp
lea    0x8(%rsp),%rsi
xor    %edi,%edi
call   1050 <argint@plt>
test   %rax,%rax
js     1192 <sys_fseek+0x52>
lea    0xc(%rsp),%rsi
mov    $0x1,%edi
call   1050 <argint@plt>
test   %rax,%rax
js     1192 <sys_fseek+0x52>
lea    0x8(%rsp),%rsi
lea    0x10(%rsp),%rdx
xor    %edi,%edi
call   1060 <argfd@plt>
test   %rax,%rax
js     1192 <sys_fseek+0x52>
mov    0x10(%rsp),%rdi
mov    0xc(%rsp),%esi
call   1030 <fileseek@plt>
add    $0x18,%rsp
ret
lea    0xe67(%rip),%rdi
call   1040 <cprintf@plt>
mov    $0xffffffff,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
%struct.file = type { i32 }
@.str = [25 x i8] c"Incorrect call to fseek\0A\00"
define i32 @sys_fseek() {
%1 = alloca i32
%2 = alloca %struct.file*
%3 = alloca i32
%4 = alloca i32
%5 = call i64 @argint(i32 0, i32* %4)
%6 = icmp slt i64 %5, 0
br i1 %6, label %13, label %7
7: ; preds = %0
%8 = call i64 @argint(i32 1, i32* %3)
%9 = icmp slt i64 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %7
%11 = call i64 @argfd(i32 0, i32* %4, %struct.file** %2)
%12 = icmp slt i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %10, %7, %0
%14 = call i32 @cprintf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %1
br label %19
15: ; preds = %10
%16 = load %struct.file*, %struct.file** %2
%17 = load i32, i32* %3
%18 = call i32 @fileseek(%struct.file* %16, i32 %17)
store i32 %18, i32* %1
br label %19
19: ; preds = %15, %13
%20 = load i32, i32* %1
ret i32 %20
}

LLVM IR (-O2):
%struct.file = type { i32 }
@.str = [25 x i8] c"Incorrect call to fseek\0A\00"
define i32 @sys_fseek() {
%1 = alloca %struct.file*
%2 = alloca i32
%3 = alloca i32
%4 = bitcast %struct.file** %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = call i64 @argint(i32 0, i32* %3)
%8 = icmp slt i64 %7, 0
br i1 %8, label %15, label %9
9: ; preds = %0
%10 = call i64 @argint(i32 1, i32* %2)
%11 = icmp slt i64 %10, 0
br i1 %11, label %15, label %12
12: ; preds = %9
%13 = call i64 @argfd(i32 0, i32* %3, %struct.file** %1)
%14 = icmp slt i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %12, %9, %0
%16 = call i32 @cprintf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
br label %21
17: ; preds = %12
%18 = load %struct.file*, %struct.file** %1
%19 = load i32, i32* %2
%20 = call i32 @fileseek(%struct.file* %18, i32 %19)
br label %21
21: ; preds = %17, %15
%22 = phi i32 [ -1, %15 ], [ %20, %17 ]
ret i32 %22
}