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

/* Variables and functions */
int O_NONBLOCK;
int O_RDONLY;
int /*<<< orphan*/ close(int);
int open(char *, int);
int /*<<< orphan*/ perror(char *);
int read(int, char *, int);
int prereq(void) {
  char allowed;
  int fd;
  fd = open("/proc/sys/vm/compact_unevictable_allowed", O_RDONLY | O_NONBLOCK);
  if (fd < 0) {
    perror("Failed to open\n"
           "/proc/sys/vm/compact_unevictable_allowed\n");
    return -1;
  }
  if (read(fd, &allowed, sizeof(char)) != sizeof(char)) {
    perror("Failed to read from\n"
           "/proc/sys/vm/compact_unevictable_allowed\n");
    close(fd);
    return -1;
  }
  close(fd);
  if (allowed == '1')
    return 0;
  return -1;
}


x86 assembly (clang, -O0):
<prereq>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2e91(%rip),%rax
mov    (%rax),%esi
mov    0x2e90(%rip),%rax
or     (%rax),%esi
lea    0xe9f(%rip),%rdi
call   1050 <open@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    118b <prereq+0x4b>
lea    0xeaf(%rip),%rdi
call   1060 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11f0 <prereq+0xb0>
mov    -0xc(%rbp),%edi
lea    -0x5(%rbp),%rsi
mov    $0x1,%edx
call   1040 <read@plt>
cltq
cmp    $0x1,%rax
je     11c8 <prereq+0x88>
lea    0xeb3(%rip),%rdi
call   1060 <perror@plt>
mov    -0xc(%rbp),%edi
call   1030 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11f0 <prereq+0xb0>
mov    -0xc(%rbp),%edi
call   1030 <close@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x31,%eax
jne    11e9 <prereq+0xa9>
movl   $0x0,-0x4(%rbp)
jmp    11f0 <prereq+0xb0>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prereq>:
push   %rbx
sub    $0x10,%rsp
mov    0x2e94(%rip),%rax
mov    0x2e95(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
lea    0xea2(%rip),%rdi
call   1050 <open@plt>
test   %eax,%eax
js     1198 <prereq+0x58>
mov    %eax,%ebx
lea    0xf(%rsp),%rsi
mov    %eax,%edi
mov    $0x1,%edx
call   1040 <read@plt>
cmp    $0x1,%eax
jne    11ab <prereq+0x6b>
mov    %ebx,%edi
call   1030 <close@plt>
xor    %eax,%eax
cmpb   $0x31,0xf(%rsp)
setne  %al
neg    %eax
add    $0x10,%rsp
pop    %rbx
ret
lea    0xe8a(%rip),%rdi
call   1060 <perror@plt>
mov    $0xffffffff,%eax
jmp    1192 <prereq+0x52>
lea    0xeb0(%rip),%rdi
call   1060 <perror@plt>
mov    %ebx,%edi
call   1030 <close@plt>
mov    $0xffffffff,%eax
jmp    1192 <prereq+0x52>

LLVM IR (-O0):
@.str = [41 x i8] c"/proc/sys/vm/compact_unevictable_allowed\00"
@O_RDONLY = global i32 0
@O_NONBLOCK = global i32 0
@.str.1 = [57 x i8] c"Failed to open\0A/proc/sys/vm/compact_unevictable_allowed\0A\00"
@.str.2 = [62 x i8] c"Failed to read from\0A/proc/sys/vm/compact_unevictable_allowed\0A\00"
define i32 @prereq() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i32
%4 = load i32, i32* @O_RDONLY
%5 = load i32, i32* @O_NONBLOCK
%6 = or i32 %4, %5
%7 = call i32 @open(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 %6)
store i32 %7, i32* %3
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %0
%11 = call i32 @perror(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %1
br label %29
12: ; preds = %0
%13 = load i32, i32* %3
%14 = call i32 @read(i32 %13, i8* %2, i32 1)
%15 = sext i32 %14 to i64
%16 = icmp ne i64 %15, 1
br i1 %16, label %17, label %21
17: ; preds = %12
%18 = call i32 @perror(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.2, i64 0, i64 0))
%19 = load i32, i32* %3
%20 = call i32 @close(i32 %19)
store i32 -1, i32* %1
br label %29
21: ; preds = %12
%22 = load i32, i32* %3
%23 = call i32 @close(i32 %22)
%24 = load i8, i8* %2
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 49
br i1 %26, label %27, label %28
27: ; preds = %21
store i32 0, i32* %1
br label %29
28: ; preds = %21
store i32 -1, i32* %1
br label %29
29: ; preds = %28, %27, %17, %10
%30 = load i32, i32* %1
ret i32 %30
}

LLVM IR (-O2):
@.str = [41 x i8] c"/proc/sys/vm/compact_unevictable_allowed\00"
@O_RDONLY = global i32 0
@O_NONBLOCK = global i32 0
@.str.1 = [57 x i8] c"Failed to open\0A/proc/sys/vm/compact_unevictable_allowed\0A\00"
@.str.2 = [62 x i8] c"Failed to read from\0A/proc/sys/vm/compact_unevictable_allowed\0A\00"
define i32 @prereq() {
%1 = alloca i8
%2 = load i32, i32* @O_RDONLY
%3 = load i32, i32* @O_NONBLOCK
%4 = or i32 %3, %2
%5 = tail call i32 @open(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = icmp slt i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = tail call i32 @perror(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.1, i64 0, i64 0))
br label %20
9: ; preds = %0
%10 = call i32 @read(i32 %5, i8* %1, i32 1)
%11 = icmp eq i32 %10, 1
br i1 %11, label %15, label %12
12: ; preds = %9
%13 = tail call i32 @perror(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.2, i64 0, i64 0))
%14 = tail call i32 @close(i32 %5)
br label %20
15: ; preds = %9
%16 = tail call i32 @close(i32 %5)
%17 = load i8, i8* %1
%18 = icmp ne i8 %17, 49
%19 = sext i1 %18 to i32
br label %20
20: ; preds = %15, %12, %7
%21 = phi i32 [ -1, %7 ], [ -1, %12 ], [ %19, %15 ]
ret i32 %21
}