#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*/ yama_buf;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strcmp(char *, char *);
void check_yama(void) {
  FILE *yama_file = fopen("/proc/sys/kernel/yama/ptrace_scope", "r");
  if (yama_file == NULL) {
    return;
  }
  char yama_buf[8];
  memset(yama_buf, 0, sizeof(yama_buf));
  fread(yama_buf, 1, sizeof(yama_buf), yama_file);
  if (strcmp(yama_buf, "0\n") != 0) {
    printf("\nThe likely cause of this failure is that your system has "
           "kernel.yama.ptrace_scope = %s",
           yama_buf);
    printf("If you would like to disable Yama, you can run: "
           "sudo sysctl kernel.yama.ptrace_scope=0\n");
  }
  fclose(yama_file);
}


x86 assembly (clang, -O0):
<check_yama>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xe91(%rip),%rdi
lea    0xead(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    118f <check_yama+0x2f>
jmp    11f9 <check_yama+0x99>
lea    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1060 <memset@plt>
lea    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x1,%esi
mov    $0x8,%edx
call   1030 <fread@plt>
lea    -0x10(%rbp),%rdi
lea    0xf11(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
je     11f0 <check_yama+0x90>
lea    -0x10(%rbp),%rsi
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_yama>:
push   %r14
push   %rbx
push   %rax
lea    0xe85(%rip),%rdi
lea    0xea1(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     11ef <check_yama+0x7f>
mov    %rax,%rbx
mov    %rsp,%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1070 <memset@plt>
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x8,%edx
mov    %rbx,%rcx
call   1040 <fread@plt>
lea    0xe68(%rip),%rsi
mov    %r14,%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     11e7 <check_yama+0x77>
lea    0xe57(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe9e(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [35 x i8] c"/proc/sys/kernel/yama/ptrace_scope\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"0\0A\00"
@.str.3 = [88 x i8] c"\0AThe likely cause of this failure is that your system has kernel.yama.ptrace_scope = %s\00"
@.str.4 = [88 x i8] c"If you would like to disable Yama, you can run: sudo sysctl kernel.yama.ptrace_scope=0\0A\00"
define void @check_yama() {
%1 = alloca i32*
%2 = alloca [8 x i8]
%3 = call i32* @fopen(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %3, i32** %1
%4 = load i32*, i32** %1
%5 = icmp eq i32* %4, null
br i1 %5, label %6, label %7
6: ; preds = %0
br label %23
7: ; preds = %0
%8 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%9 = call i32 @memset(i8* %8, i32 0, i32 8)
%10 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%11 = load i32*, i32** %1
%12 = call i32 @fread(i8* %10, i32 1, i32 8, i32* %11)
%13 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%14 = call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %7
%17 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([88 x i8], [88 x i8]* @.str.3, i64 0, i64 0), i8* %17)
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([88 x i8], [88 x i8]* @.str.4, i64 0, i64 0))
br label %20
20: ; preds = %16, %7
%21 = load i32*, i32** %1
%22 = call i32 @fclose(i32* %21)
br label %23
23: ; preds = %20, %6
ret void
}

LLVM IR (-O2):
@.str = [35 x i8] c"/proc/sys/kernel/yama/ptrace_scope\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"0\0A\00"
@.str.3 = [88 x i8] c"\0AThe likely cause of this failure is that your system has kernel.yama.ptrace_scope = %s\00"
@str = [87 x i8] c"If you would like to disable Yama, you can run: sudo sysctl kernel.yama.ptrace_scope=0\00"
define void @check_yama() {
%1 = alloca [8 x i8]
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %15, label %4
4: ; preds = %0
%5 = getelementptr inbounds [8 x i8], [8 x i8]* %1, i64 0, i64 0
%6 = call i32 @memset(i8* %5, i32 0, i32 8)
%7 = call i32 @fread(i8* %5, i32 1, i32 8, i32* %2)
%8 = call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %4
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([88 x i8], [88 x i8]* @.str.3, i64 0, i64 0), i8* %5)
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([87 x i8], [87 x i8]* @str, i64 0, i64 0))
br label %13
13: ; preds = %10, %4
%14 = call i32 @fclose(i32* %2)
br label %15
15: ; preds = %0, %13
ret void
}