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

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ err(int /*<<< orphan*/, char *);
int /*<<< orphan*/ errx(int /*<<< orphan*/, char *);
int open(char *, int /*<<< orphan*/);
int read(int, char *, int);
int main(void) {
  char c;
  int fd;
  fd = open("/proc/sys/fs/protected_hardlinks", O_RDONLY);
  if (fd == -1)
    err(EXIT_FAILURE, "[FAIL] open");
  if (read(fd, &c, sizeof(c)) != sizeof(c))
    err(EXIT_FAILURE, "[FAIL] read");
  close(fd);
  if (c != '0')
    errx(EXIT_FAILURE, "[FAIL] see requirements (README.md)");
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e82(%rip),%rax
mov    (%rax),%esi
lea    0xe91(%rip),%rdi
call   1070 <open@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jne    1196 <main+0x46>
mov    0x2e50(%rip),%rax
mov    (%rax),%edi
lea    0xe90(%rip),%rsi
call   1060 <err@plt>
mov    -0xc(%rbp),%edi
lea    -0x5(%rbp),%rsi
mov    $0x1,%edx
call   1050 <read@plt>
cltq
cmp    $0x1,%rax
je     11c8 <main+0x78>
mov    0x2e1e(%rip),%rax
mov    (%rax),%edi
lea    0xe6a(%rip),%rsi
call   1060 <err@plt>
mov    -0xc(%rbp),%edi
call   1040 <close@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x30,%eax
je     11f2 <main+0xa2>
mov    0x2df4(%rip),%rax
mov    (%rax),%edi
lea    0xe4c(%rip),%rsi
call   1030 <errx@plt>
mov    0x2dd7(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
mov    0x2e8c(%rip),%rax
mov    (%rax),%esi
lea    0xe9b(%rip),%rdi
call   1070 <open@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
jne    1186 <main+0x36>
mov    0x2e60(%rip),%rax
mov    (%rax),%edi
lea    0xea0(%rip),%rsi
call   1060 <err@plt>
lea    0xf(%rsp),%rsi
mov    %ebx,%edi
mov    $0x1,%edx
call   1050 <read@plt>
cmp    $0x1,%eax
je     11b1 <main+0x61>
mov    0x2e35(%rip),%rax
mov    (%rax),%edi
lea    0xe81(%rip),%rsi
call   1060 <err@plt>
mov    %ebx,%edi
call   1040 <close@plt>
cmpb   $0x30,0xf(%rsp)
je     11d4 <main+0x84>
mov    0x2e12(%rip),%rax
mov    (%rax),%edi
lea    0xe6a(%rip),%rsi
call   1030 <errx@plt>
mov    0x2df5(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [33 x i8] c"/proc/sys/fs/protected_hardlinks\00"
@O_RDONLY = global i32 0
@EXIT_FAILURE = global i32 0
@.str.1 = [12 x i8] c"[FAIL] open\00"
@.str.2 = [12 x i8] c"[FAIL] read\00"
@.str.3 = [36 x i8] c"[FAIL] see requirements (README.md)\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i32
store i32 0, i32* %1
%4 = load i32, i32* @O_RDONLY
%5 = call i32 @open(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 %4)
store i32 %5, i32* %3
%6 = load i32, i32* %3
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %11
8: ; preds = %0
%9 = load i32, i32* @EXIT_FAILURE
%10 = call i32 @err(i32 %9, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %11
11: ; preds = %8, %0
%12 = load i32, i32* %3
%13 = call i32 @read(i32 %12, i8* %2, i32 1)
%14 = sext i32 %13 to i64
%15 = icmp ne i64 %14, 1
br i1 %15, label %16, label %19
16: ; preds = %11
%17 = load i32, i32* @EXIT_FAILURE
%18 = call i32 @err(i32 %17, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
br label %19
19: ; preds = %16, %11
%20 = load i32, i32* %3
%21 = call i32 @close(i32 %20)
%22 = load i8, i8* %2
%23 = sext i8 %22 to i32
%24 = icmp ne i32 %23, 48
br i1 %24, label %25, label %28
25: ; preds = %19
%26 = load i32, i32* @EXIT_FAILURE
%27 = call i32 @errx(i32 %26, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0))
br label %28
28: ; preds = %25, %19
%29 = load i32, i32* @EXIT_SUCCESS
ret i32 %29
}

LLVM IR (-O2):
@.str = [33 x i8] c"/proc/sys/fs/protected_hardlinks\00"
@O_RDONLY = global i32 0
@EXIT_FAILURE = global i32 0
@.str.1 = [12 x i8] c"[FAIL] open\00"
@.str.2 = [12 x i8] c"[FAIL] read\00"
@.str.3 = [36 x i8] c"[FAIL] see requirements (README.md)\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i8
%2 = load i32, i32* @O_RDONLY
%3 = tail call i32 @open(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 %2)
%4 = icmp eq i32 %3, -1
br i1 %4, label %5, label %8
5: ; preds = %0
%6 = load i32, i32* @EXIT_FAILURE
%7 = tail call i32 @err(i32 %6, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %8
8: ; preds = %5, %0
%9 = call i32 @read(i32 %3, i8* %1, i32 1)
%10 = icmp eq i32 %9, 1
br i1 %10, label %14, label %11
11: ; preds = %8
%12 = load i32, i32* @EXIT_FAILURE
%13 = tail call i32 @err(i32 %12, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
br label %14
14: ; preds = %11, %8
%15 = tail call i32 @close(i32 %3)
%16 = load i8, i8* %1
%17 = icmp eq i8 %16, 48
br i1 %17, label %21, label %18
18: ; preds = %14
%19 = load i32, i32* @EXIT_FAILURE
%20 = tail call i32 @errx(i32 %19, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0))
br label %21
21: ; preds = %18, %14
%22 = load i32, i32* @EXIT_SUCCESS
ret i32 %22
}