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

/* Variables and functions */
int /*<<< orphan*/ SEEK_CUR;
int fread(char *, int, int, int /*<<< orphan*/ *);
scalar_t__ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int fp_move_forward(FILE *fp, int hop) {
  char buf[256];
  if (!fp || hop < 0)
    return 0;
  if (!hop)
    return 1;
  if (hop <= sizeof(buf)) {
    if (fread(buf, 1, hop, fp) != hop)
      return 0;
  } else {
    if (fseek(fp, hop, SEEK_CUR) != 0)
      return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<fp_move_forward>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1147 <fp_move_forward+0x27>
cmpl   $0x0,-0x14(%rbp)
jge    1153 <fp_move_forward+0x33>
movl   $0x0,-0x4(%rbp)
jmp    11e2 <fp_move_forward+0xc2>
cmpl   $0x0,-0x14(%rbp)
jne    1169 <fp_move_forward+0x49>
movl   $0x1,-0x4(%rbp)
jmp    11e2 <fp_move_forward+0xc2>
movslq -0x14(%rbp),%rax
cmp    $0x100,%rax
ja     11ab <fp_move_forward+0x8b>
lea    -0x120(%rbp),%rdi
mov    -0x14(%rbp),%edx
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
call   1030 <fread@plt>
cmp    -0x14(%rbp),%eax
je     11a6 <fp_move_forward+0x86>
movl   $0x0,-0x4(%rbp)
jmp    11e2 <fp_move_forward+0xc2>
jmp    11db <fp_move_forward+0xbb>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    0x2e2f(%rip),%rax
mov    (%rax),%edx
call   1040 <fseek@plt>
cmp    $0x0,%rax
je     11d6 <fp_move_forward+0xb6>
movl   $0x0,-0x4(%rbp)
jmp    11e2 <fp_move_forward+0xc2>
jmp    11db <fp_move_forward+0xbb>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fp_move_forward>:
push   %rbp
push   %rbx
sub    $0x108,%rsp
xor    %ebx,%ebx
test   %rdi,%rdi
je     115b <fp_move_forward+0x3b>
mov    %esi,%ebp
test   %esi,%esi
js     115b <fp_move_forward+0x3b>
je     1156 <fp_move_forward+0x36>
mov    %rdi,%rcx
cmp    $0x100,%ebp
ja     1167 <fp_move_forward+0x47>
mov    %rsp,%rdi
mov    $0x1,%esi
mov    %ebp,%edx
call   1030 <fread@plt>
cmp    %ebp,%eax
jne    115b <fp_move_forward+0x3b>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x108,%rsp
pop    %rbx
pop    %rbp
ret
mov    0x2e7a(%rip),%rax
mov    (%rax),%edx
mov    %rcx,%rdi
mov    %ebp,%esi
call   1040 <fseek@plt>
test   %rax,%rax
jne    115b <fp_move_forward+0x3b>
jmp    1156 <fp_move_forward+0x36>

LLVM IR (-O0):
@SEEK_CUR = global i32 0
define i32 @fp_move_forward(i32* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
%6 = alloca [256 x i8]
store i32* %0, i32** %4
store i32 %1, i32* %5
%7 = load i32*, i32** %4
%8 = icmp ne i32* %7, null
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load i32, i32* %5
%11 = icmp slt i32 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %9, %2
store i32 0, i32* %3
br label %39
13: ; preds = %9
%14 = load i32, i32* %5
%15 = icmp ne i32 %14, 0
br i1 %15, label %17, label %16
16: ; preds = %13
store i32 1, i32* %3
br label %39
17: ; preds = %13
%18 = load i32, i32* %5
%19 = sext i32 %18 to i64
%20 = icmp ule i64 %19, 256
br i1 %20, label %21, label %30
21: ; preds = %17
%22 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%23 = load i32, i32* %5
%24 = load i32*, i32** %4
%25 = call i32 @fread(i8* %22, i32 1, i32 %23, i32* %24)
%26 = load i32, i32* %5
%27 = icmp ne i32 %25, %26
br i1 %27, label %28, label %29
28: ; preds = %21
store i32 0, i32* %3
br label %39
29: ; preds = %21
br label %38
30: ; preds = %17
%31 = load i32*, i32** %4
%32 = load i32, i32* %5
%33 = load i32, i32* @SEEK_CUR
%34 = call i64 @fseek(i32* %31, i32 %32, i32 %33)
%35 = icmp ne i64 %34, 0
br i1 %35, label %36, label %37
36: ; preds = %30
store i32 0, i32* %3
br label %39
37: ; preds = %30
br label %38
38: ; preds = %37, %29
store i32 1, i32* %3
br label %39
39: ; preds = %38, %36, %28, %16, %12
%40 = load i32, i32* %3
ret i32 %40
}

LLVM IR (-O2):
@SEEK_CUR = global i32 0
define i32 @fp_move_forward(i32* %0, i32 %1) {
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%5 = icmp eq i32* %0, null
%6 = icmp slt i32 %1, 0
%7 = or i1 %5, %6
br i1 %7, label %20, label %8
8: ; preds = %2
%9 = icmp eq i32 %1, 0
br i1 %9, label %20, label %10
10: ; preds = %8
%11 = icmp ult i32 %1, 257
br i1 %11, label %12, label %15
12: ; preds = %10
%13 = call i32 @fread(i8* %4, i32 1, i32 %1, i32* %0)
%14 = icmp eq i32 %13, %1
br i1 %14, label %19, label %20
15: ; preds = %10
%16 = load i32, i32* @SEEK_CUR
%17 = tail call i64 @fseek(i32* %0, i32 %1, i32 %16)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %15, %12
br label %20
20: ; preds = %15, %12, %8, %2, %19
%21 = phi i32 [ 1, %19 ], [ 0, %2 ], [ 1, %8 ], [ 0, %12 ], [ 0, %15 ]
ret i32 %21
}