#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 */
int /*<<< orphan*/ die_file_eof(int /*<<< orphan*/ *);
int fread(char *, size_t, int, int /*<<< orphan*/ *);
void skip_nbyte(FILE *fp, size_t len) {
  size_t d;
  char dmy[1024];
  while (len) {
    d = len > 1024 ? 1024 : len;
    if (fread(dmy, d, 1, fp) != 1)
      die_file_eof(fp);
    len -= d;
  }
}


x86 assembly (clang, -O0):
<skip_nbyte>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11b2 <skip_nbyte+0x92>
cmpq   $0x400,-0x10(%rbp)
jbe    115d <skip_nbyte+0x3d>
mov    $0x400,%eax
mov    %rax,-0x428(%rbp)
jmp    1168 <skip_nbyte+0x48>
mov    -0x10(%rbp),%rax
mov    %rax,-0x428(%rbp)
mov    -0x428(%rbp),%rax
mov    %rax,-0x18(%rbp)
lea    -0x420(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x8(%rbp),%rcx
mov    $0x1,%edx
call   1030 <fread@plt>
cmp    $0x1,%eax
je     119e <skip_nbyte+0x7e>
mov    -0x8(%rbp),%rdi
call   1040 <die_file_eof@plt>
mov    -0x18(%rbp),%rcx
mov    -0x10(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x10(%rbp)
jmp    1133 <skip_nbyte+0x13>
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<skip_nbyte>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x408,%rsp
test   %rsi,%rsi
je     1178 <skip_nbyte+0x58>
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsp,%r15
jmp    1145 <skip_nbyte+0x25>
xchg   %ax,%ax
sub    %r12,%rbx
je     1178 <skip_nbyte+0x58>
cmp    $0x400,%rbx
mov    $0x400,%r12d
cmovb  %rbx,%r12
mov    %r15,%rdi
mov    %r12,%rsi
mov    $0x1,%edx
mov    %r14,%rcx
call   1030 <fread@plt>
cmp    $0x1,%eax
je     1140 <skip_nbyte+0x20>
mov    %r14,%rdi
call   1040 <die_file_eof@plt>
jmp    1140 <skip_nbyte+0x20>
add    $0x408,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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