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

/* Variables and functions */
int /*<<< orphan*/ POSIX_FADV_DONTNEED;
int posix_fadvise(int, int /*<<< orphan*/, int /*<<< orphan*/,
                  int /*<<< orphan*/);
int fadv_dontneed(int fd, off_t offset, off_t len, int n) {
  int i, ret;
  for (i = 0, ret = 0; i < n && ret == 0; i++)
    ret = posix_fadvise(fd, offset, len, POSIX_FADV_DONTNEED);
  return ret;
}


x86 assembly (clang, -O0):
<fadv_dontneed>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x14(%rbp),%ecx
xor    %eax,%eax
cmp    -0x10(%rbp),%ecx
mov    %al,-0x19(%rbp)
jge    114d <fadv_dontneed+0x3d>
cmpl   $0x0,-0x18(%rbp)
sete   %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    115d <fadv_dontneed+0x4d>
jmp    1185 <fadv_dontneed+0x75>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    0x2e83(%rip),%rax
mov    (%rax),%ecx
call   1030 <posix_fadvise@plt>
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1132 <fadv_dontneed+0x22>
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fadv_dontneed>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %ecx,%ecx
jle    115f <fadv_dontneed+0x4f>
mov    %ecx,%r12d
mov    %edx,%r14d
mov    %esi,%r15d
mov    %edi,%ebp
mov    $0x1,%ebx
mov    0x2eba(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
mov    0x0(%r13),%ecx
mov    %ebp,%edi
mov    %r15d,%esi
mov    %r14d,%edx
call   1030 <posix_fadvise@plt>
cmp    %r12d,%ebx
jge    1161 <fadv_dontneed+0x51>
add    $0x1,%ebx
test   %eax,%eax
je     1140 <fadv_dontneed+0x30>
jmp    1161 <fadv_dontneed+0x51>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@POSIX_FADV_DONTNEED = global i32 0
define i32 @fadv_dontneed(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
store i32 0, i32* %9
store i32 0, i32* %10
br label %11
11: ; preds = %26, %4
%12 = load i32, i32* %9
%13 = load i32, i32* %8
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %18
15: ; preds = %11
%16 = load i32, i32* %10
%17 = icmp eq i32 %16, 0
br label %18
18: ; preds = %15, %11
%19 = phi i1 [ false, %11 ], [ %17, %15 ]
br i1 %19, label %20, label %29
20: ; preds = %18
%21 = load i32, i32* %5
%22 = load i32, i32* %6
%23 = load i32, i32* %7
%24 = load i32, i32* @POSIX_FADV_DONTNEED
%25 = call i32 @posix_fadvise(i32 %21, i32 %22, i32 %23, i32 %24)
store i32 %25, i32* %10
br label %26
26: ; preds = %20
%27 = load i32, i32* %9
%28 = add nsw i32 %27, 1
store i32 %28, i32* %9
br label %11
29: ; preds = %18
%30 = load i32, i32* %10
ret i32 %30
}

LLVM IR (-O2):
@POSIX_FADV_DONTNEED = global i32 0
define i32 @fadv_dontneed(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = icmp sgt i32 %3, 0
br i1 %5, label %6, label %14
6: ; preds = %4, %6
%7 = phi i32 [ %10, %6 ], [ 0, %4 ]
%8 = load i32, i32* @POSIX_FADV_DONTNEED
%9 = tail call i32 @posix_fadvise(i32 %0, i32 %1, i32 %2, i32 %8)
%10 = add nuw nsw i32 %7, 1
%11 = icmp slt i32 %10, %3
%12 = icmp eq i32 %9, 0
%13 = select i1 %11, i1 %12, i1 false
br i1 %13, label %6, label %14
14: ; preds = %6, %4
%15 = phi i32 [ 0, %4 ], [ %9, %6 ]
ret i32 %15
}