#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*/ FILE;

/* Variables and functions */
scalar_t__ psi_read(int /*<<< orphan*/ *, unsigned char *, unsigned long);
int psi_skip(FILE *fp, unsigned long cnt) {
  unsigned long n;
  unsigned char buf[256];
  while (cnt > 0) {
    n = (cnt < 256) ? cnt : 256;
    if (psi_read(fp, buf, n)) {
      return (1);
    }
    cnt -= n;
  }
  return (0);
}


x86 assembly (clang, -O0):
<psi_skip>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jbe    11a6 <psi_skip+0x96>
cmpq   $0x100,-0x18(%rbp)
jae    114c <psi_skip+0x3c>
mov    -0x18(%rbp),%rax
mov    %rax,-0x128(%rbp)
jmp    115d <psi_skip+0x4d>
mov    $0x100,%eax
mov    %rax,-0x128(%rbp)
jmp    115d <psi_skip+0x4d>
mov    -0x128(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x120(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1030 <psi_read@plt>
cmp    $0x0,%rax
je     1192 <psi_skip+0x82>
movl   $0x1,-0x4(%rbp)
jmp    11ad <psi_skip+0x9d>
mov    -0x20(%rbp),%rcx
mov    -0x18(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x18(%rbp)
jmp    1123 <psi_skip+0x13>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<psi_skip>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x100,%rsp
xor    %r14d,%r14d
test   %rsi,%rsi
je     1160 <psi_skip+0x50>
mov    %rsi,%rbx
mov    %rdi,%r12
mov    %rsp,%r15
cmp    $0x100,%rbx
mov    $0x100,%ebp
cmovb  %rbx,%rbp
mov    %r12,%rdi
mov    %r15,%rsi
mov    %rbp,%rdx
call   1030 <psi_read@plt>
test   %rax,%rax
jne    115a <psi_skip+0x4a>
sub    %rbp,%rbx
jne    1130 <psi_skip+0x20>
jmp    1160 <psi_skip+0x50>
mov    $0x1,%r14d
mov    %r14d,%eax
add    $0x100,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @psi_skip(i32* %0, i64 %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i64
%6 = alloca i64
%7 = alloca [256 x i8]
store i32* %0, i32** %4
store i64 %1, i64* %5
br label %8
8: ; preds = %25, %2
%9 = load i64, i64* %5
%10 = icmp ugt i64 %9, 0
br i1 %10, label %11, label %29
11: ; preds = %8
%12 = load i64, i64* %5
%13 = icmp ult i64 %12, 256
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = load i64, i64* %5
br label %17
16: ; preds = %11
br label %17
17: ; preds = %16, %14
%18 = phi i64 [ %15, %14 ], [ 256, %16 ]
store i64 %18, i64* %6
%19 = load i32*, i32** %4
%20 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%21 = load i64, i64* %6
%22 = call i64 @psi_read(i32* %19, i8* %20, i64 %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %17
store i32 1, i32* %3
br label %30
25: ; preds = %17
%26 = load i64, i64* %6
%27 = load i64, i64* %5
%28 = sub i64 %27, %26
store i64 %28, i64* %5
br label %8
29: ; preds = %8
store i32 0, i32* %3
br label %30
30: ; preds = %29, %24
%31 = load i32, i32* %3
ret i32 %31
}

LLVM IR (-O2):
define i32 @psi_skip(i32* %0, i64 %1) {
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%5 = icmp eq i64 %1, 0
br i1 %5, label %15, label %8
6: ; preds = %8
%7 = icmp eq i64 %14, 0
br i1 %7, label %15, label %8
8: ; preds = %2, %6
%9 = phi i64 [ %14, %6 ], [ %1, %2 ]
%10 = icmp ult i64 %9, 256
%11 = select i1 %10, i64 %9, i64 256
%12 = call i64 @psi_read(i32* %0, i8* %4, i64 %11)
%13 = icmp eq i64 %12, 0
%14 = sub i64 %9, %11
br i1 %13, label %6, label %15
15: ; preds = %8, %6, %2
%16 = phi i32 [ 0, %2 ], [ 0, %6 ], [ 1, %8 ]
ret i32 %16
}