#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;

/* Variables and functions */
scalar_t__ EINTR;
scalar_t__ errno;
int read(int, char *, int);
int heat_the_cache(int fd) {
  char buf[1024];
  int rv;
  do {
  retry_read:
    rv = read(fd, buf, sizeof(buf));
    if (-1 == rv && EINTR == errno) {
      goto retry_read;
    }
  } while (0 < rv);
  return rv != 0;
}


x86 assembly (clang, -O0):
<heat_the_cache>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %edi,-0x4(%rbp)
jmp    1123 <heat_the_cache+0x13>
mov    -0x4(%rbp),%edi
lea    -0x410(%rbp),%rsi
mov    $0x400,%edx
call   1030 <read@plt>
mov    %eax,-0x414(%rbp)
mov    $0xffffffff,%eax
cmp    -0x414(%rbp),%eax
jne    116d <heat_the_cache+0x5d>
mov    0x2e83(%rip),%rax
mov    (%rax),%rax
mov    0x2e81(%rip),%rcx
cmp    (%rcx),%rax
jne    116d <heat_the_cache+0x5d>
jmp    1123 <heat_the_cache+0x13>
jmp    1172 <heat_the_cache+0x62>
xor    %eax,%eax
cmp    -0x414(%rbp),%eax
jl     111e <heat_the_cache+0xe>
cmpl   $0x0,-0x414(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<heat_the_cache>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x408,%rsp
mov    %edi,%ebx
mov    %rsp,%r14
mov    0x2eae(%rip),%r15
mov    0x2eaf(%rip),%r12
jmp    1149 <heat_the_cache+0x39>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%r15),%rax
cmp    (%r12),%rax
jne    1169 <heat_the_cache+0x59>
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x400,%edx
call   1030 <read@plt>
cmp    $0xffffffff,%eax
je     1140 <heat_the_cache+0x30>
test   %eax,%eax
jg     1149 <heat_the_cache+0x39>
setne  %al
movzbl %al,%eax
jmp    116e <heat_the_cache+0x5e>
mov    $0x1,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@EINTR = global i64 0
@errno = global i64 0
define i32 @heat_the_cache(i32 %0) {
%2 = alloca i32
%3 = alloca [1024 x i8]
%4 = alloca i32
store i32 %0, i32* %2
br label %5
5: ; preds = %18, %1
br label %6
6: ; preds = %16, %5
%7 = load i32, i32* %2
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%9 = call i32 @read(i32 %7, i8* %8, i32 1024)
store i32 %9, i32* %4
%10 = load i32, i32* %4
%11 = icmp eq i32 -1, %10
br i1 %11, label %12, label %17
12: ; preds = %6
%13 = load i64, i64* @EINTR
%14 = load i64, i64* @errno
%15 = icmp eq i64 %13, %14
br i1 %15, label %16, label %17
16: ; preds = %12
br label %6
17: ; preds = %12, %6
br label %18
18: ; preds = %17
%19 = load i32, i32* %4
%20 = icmp slt i32 0, %19
br i1 %20, label %5, label %21
21: ; preds = %18
%22 = load i32, i32* %4
%23 = icmp ne i32 %22, 0
%24 = zext i1 %23 to i32
ret i32 %24
}

LLVM IR (-O2):
@EINTR = global i64 0
@errno = global i64 0
define i32 @heat_the_cache(i32 %0) {
%2 = alloca [1024 x i8]
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
br label %4
4: ; preds = %11, %1
%5 = call i32 @read(i32 %0, i8* %3, i32 1024)
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %12
7: ; preds = %4
%8 = load i64, i64* @EINTR
%9 = load i64, i64* @errno
%10 = icmp eq i64 %8, %9
br i1 %10, label %11, label %17
11: ; preds = %7, %12
br label %4
12: ; preds = %4
%13 = icmp sgt i32 %5, 0
br i1 %13, label %11, label %14
14: ; preds = %12
%15 = icmp ne i32 %5, 0
%16 = zext i1 %15 to i32
br label %17
17: ; preds = %7, %14
%18 = phi i32 [ %16, %14 ], [ 1, %7 ]
ret i32 %18
}