#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__ voidpf;
typedef int /*<<< orphan*/ uLong;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/, int);
long fseek_file_func(voidpf opaque, voidpf stream, uLong offset, int origin) {
  int fseek_origin = 0;
  long ret;
  switch (origin) {
  case (1):
    fseek_origin = 1;
    break;
  case (2):
    fseek_origin = 2;
    break;
  case (0):
    fseek_origin = 0;
    break;
  default:
    return -1;
  }
  ret = 0;
  fseek((FILE *)stream, offset, fseek_origin);
  return ret;
}


x86 assembly (clang, -O0):
<fseek_file_func>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x34(%rbp)
test   %eax,%eax
je     117a <fseek_file_func+0x6a>
jmp    1140 <fseek_file_func+0x30>
mov    -0x34(%rbp),%eax
sub    $0x1,%eax
je     1162 <fseek_file_func+0x52>
jmp    1151 <fseek_file_func+0x41>
mov    -0x34(%rbp),%eax
sub    $0x2,%eax
je     116e <fseek_file_func+0x5e>
jmp    1186 <fseek_file_func+0x76>
movl   $0x1,-0x24(%rbp)
jmp    1193 <fseek_file_func+0x83>
movl   $0x2,-0x24(%rbp)
jmp    1193 <fseek_file_func+0x83>
movl   $0x0,-0x24(%rbp)
jmp    1193 <fseek_file_func+0x83>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    11b2 <fseek_file_func+0xa2>
movq   $0x0,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x24(%rbp),%edx
call   1030 <fseek@plt>
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fseek_file_func>:
mov    $0xffffffffffffffff,%rax
cmp    $0x2,%ecx
ja     112f <fseek_file_func+0x1f>
push   %rax
mov    %rsi,%rdi
mov    %edx,%esi
mov    %ecx,%edx
call   1030 <fseek@plt>
xor    %eax,%eax
add    $0x8,%rsp
ret

LLVM IR (-O0):
define i64 @fseek_file_func(i64 %0, i64 %1, i32 %2, i32 %3) {
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i64
store i64 %0, i64* %6
store i64 %1, i64* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 0, i32* %10
%12 = load i32, i32* %9
switch i32 %12, label %16 [
i32 1, label %13
i32 2, label %14
i32 0, label %15
]
13: ; preds = %4
store i32 1, i32* %10
br label %17
14: ; preds = %4
store i32 2, i32* %10
br label %17
15: ; preds = %4
store i32 0, i32* %10
br label %17
16: ; preds = %4
store i64 -1, i64* %5
br label %24
17: ; preds = %15, %14, %13
store i64 0, i64* %11
%18 = load i64, i64* %7
%19 = inttoptr i64 %18 to i32*
%20 = load i32, i32* %8
%21 = load i32, i32* %10
%22 = call i32 @fseek(i32* %19, i32 %20, i32 %21)
%23 = load i64, i64* %11
store i64 %23, i64* %5
br label %24
24: ; preds = %17, %16
%25 = load i64, i64* %5
ret i64 %25
}

LLVM IR (-O2):
define i64 @fseek_file_func(i64 %0, i64 %1, i32 %2, i32 %3) {
%5 = icmp ult i32 %3, 3
br i1 %5, label %6, label %9
6: ; preds = %4
%7 = inttoptr i64 %1 to i32*
%8 = tail call i32 @fseek(i32* %7, i32 %2, i32 %3)
br label %9
9: ; preds = %4, %6
%10 = phi i64 [ 0, %6 ], [ -1, %4 ]
ret i64 %10
}