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

/* Variables and functions */
int /*<<< orphan*/ SEEK_CUR;
scalar_t__ fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
void fskip(int size, FILE *fd, int seekable) {
  if (seekable)
    fseek(fd, size, SEEK_CUR);
  else {
    char tmp[1024];
    while (size >= (int)sizeof(tmp)) {
      size -= fread(tmp, 1, sizeof(tmp), fd);
    }
    while (size > 0)
      size -= fread(tmp, 1, size, fd);
  }
}


x86 assembly (clang, -O0):
<fskip>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     1159 <fskip+0x39>
mov    -0x10(%rbp),%rdi
mov    -0x4(%rbp),%esi
mov    0x2e9b(%rip),%rax
mov    (%rax),%edx
call   1040 <fseek@plt>
jmp    11d5 <fskip+0xb5>
jmp    115e <fskip+0x3e>
cmpl   $0x400,-0x4(%rbp)
jl     1197 <fskip+0x77>
lea    -0x420(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
mov    $0x400,%edx
call   1030 <fread@plt>
mov    %rax,%rcx
movslq -0x4(%rbp),%rax
sub    %rcx,%rax
mov    %eax,-0x4(%rbp)
jmp    115e <fskip+0x3e>
jmp    119c <fskip+0x7c>
cmpl   $0x0,-0x4(%rbp)
jle    11d0 <fskip+0xb0>
lea    -0x420(%rbp),%rdi
mov    -0x4(%rbp),%edx
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
call   1030 <fread@plt>
mov    %rax,%rcx
movslq -0x4(%rbp),%rax
sub    %rcx,%rax
mov    %eax,-0x4(%rbp)
jmp    119c <fskip+0x7c>
jmp    11d5 <fskip+0xb5>
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fskip>:
push   %rbp
push   %r14
push   %rbx
sub    $0x400,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
test   %edx,%edx
je     1152 <fskip+0x32>
mov    0x2ead(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    %ebp,%esi
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <fseek@plt>
cmp    $0x400,%ebp
jl     117f <fskip+0x5f>
mov    %rsp,%r14
nopl   (%rax)
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x400,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
sub    %eax,%ebp
cmp    $0x3ff,%ebp
jg     1160 <fskip+0x40>
test   %ebp,%ebp
jle    11a8 <fskip+0x88>
mov    %rsp,%r14
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    $0x1,%esi
mov    %ebp,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
sub    %eax,%ebp
test   %ebp,%ebp
jg     1190 <fskip+0x70>
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@SEEK_CUR = global i32 0
define void @fskip(i32 %0, i32* nocapture %1, i32 %2) {
%4 = alloca [1024 x i8]
%5 = icmp eq i32 %2, 0
br i1 %5, label %9, label %6
6: ; preds = %3
%7 = load i32, i32* @SEEK_CUR
%8 = tail call i32 @fseek(i32* %1, i32 %0, i32 %7)
br label %28
9: ; preds = %3
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%11 = icmp sgt i32 %0, 1023
br i1 %11, label %15, label %12
12: ; preds = %15, %9
%13 = phi i32 [ %0, %9 ], [ %19, %15 ]
%14 = icmp sgt i32 %13, 0
br i1 %14, label %21, label %27
15: ; preds = %9, %15
%16 = phi i32 [ %19, %15 ], [ %0, %9 ]
%17 = call i64 @fread(i8* %10, i32 1, i32 1024, i32* %1)
%18 = trunc i64 %17 to i32
%19 = sub i32 %16, %18
%20 = icmp sgt i32 %19, 1023
br i1 %20, label %15, label %12
21: ; preds = %12, %21
%22 = phi i32 [ %25, %21 ], [ %13, %12 ]
%23 = call i64 @fread(i8* %10, i32 1, i32 %22, i32* %1)
%24 = trunc i64 %23 to i32
%25 = sub i32 %22, %24
%26 = icmp sgt i32 %25, 0
br i1 %26, label %21, label %27
27: ; preds = %21, %12
br label %28
28: ; preds = %27, %6
ret void
}