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

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ strstr(char *, char *);
int pid_hidepid(void) {
  FILE *fp = fopen("/proc/mounts", "r");
  if (!fp)
    return 1;
  char buf[4096];
  while (fgets(buf, 4096, fp)) {
    if (strstr(buf, "proc /proc proc")) {
      fclose(fp);
      if (strstr(buf, "hidepid=2") || strstr(buf, "hidepid=1"))
        return 1;
      return 0;
    }
  }
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<pid_hidepid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1010,%rsp
lea    0xeae(%rip),%rdi
lea    0xeb4(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1179 <pid_hidepid+0x39>
movl   $0x1,-0x4(%rbp)
jmp    122a <pid_hidepid+0xea>
jmp    117e <pid_hidepid+0x3e>
lea    -0x1010(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x1000,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     121a <pid_hidepid+0xda>
lea    -0x1010(%rbp),%rdi
lea    0xe64(%rip),%rsi
call   1060 <strstr@plt>
cmp    $0x0,%rax
je     1215 <pid_hidepid+0xd5>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
lea    -0x1010(%rbp),%rdi
lea    0xe4e(%rip),%rsi
call   1060 <strstr@plt>
cmp    $0x0,%rax
jne    11fd <pid_hidepid+0xbd>
lea    -0x1010(%rbp),%rdi
lea    0xe3b(%rip),%rsi
call   1060 <strstr@plt>
cmp    $0x0,%rax
je     1209 <pid_hidepid+0xc9>
movl   $0x1,-0x4(%rbp)
jmp    122a <pid_hidepid+0xea>
movl   $0x0,-0x4(%rbp)
jmp    122a <pid_hidepid+0xea>
jmp    117e <pid_hidepid+0x3e>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1010,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pid_hidepid>:
push   %r15
push   %r14
push   %rbx
sub    $0x1000,%rsp
lea    0xead(%rip),%rdi
lea    0xeb3(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     11e5 <pid_hidepid+0xa5>
mov    %rax,%rbx
mov    %rsp,%r14
lea    0xe9a(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
mov    $0x1000,%esi
mov    %rbx,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     11ec <pid_hidepid+0xac>
mov    %r14,%rdi
mov    %r15,%rsi
call   1060 <strstr@plt>
test   %rax,%rax
je     1180 <pid_hidepid+0x40>
mov    %rbx,%rdi
call   1030 <fclose@plt>
lea    0xe6b(%rip),%rsi
mov    %rsp,%rdi
call   1060 <strstr@plt>
mov    %rax,%rcx
mov    $0x1,%eax
test   %rcx,%rcx
jne    11f6 <pid_hidepid+0xb6>
lea    0xe59(%rip),%rsi
mov    %rsp,%rdi
call   1060 <strstr@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
setne  %al
jmp    11f6 <pid_hidepid+0xb6>
mov    $0x1,%eax
jmp    11f6 <pid_hidepid+0xb6>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x1000,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [13 x i8] c"/proc/mounts\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [16 x i8] c"proc /proc proc\00"
@.str.3 = [10 x i8] c"hidepid=2\00"
@.str.4 = [10 x i8] c"hidepid=1\00"
define i32 @pid_hidepid() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca [4096 x i8]
%4 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %4, i32** %2
%5 = load i32*, i32** %2
%6 = icmp ne i32* %5, null
br i1 %6, label %8, label %7
7: ; preds = %0
store i32 1, i32* %1
br label %34
8: ; preds = %0
br label %9
9: ; preds = %30, %8
%10 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%11 = load i32*, i32** %2
%12 = call i64 @fgets(i8* %10, i32 4096, i32* %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %31
14: ; preds = %9
%15 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%16 = call i64 @strstr(i8* %15, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %30
18: ; preds = %14
%19 = load i32*, i32** %2
%20 = call i32 @fclose(i32* %19)
%21 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%22 = call i64 @strstr(i8* %21, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%23 = icmp ne i64 %22, 0
br i1 %23, label %28, label %24
24: ; preds = %18
%25 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%26 = call i64 @strstr(i8* %25, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %24, %18
store i32 1, i32* %1
br label %34
29: ; preds = %24
store i32 0, i32* %1
br label %34
30: ; preds = %14
br label %9
31: ; preds = %9
%32 = load i32*, i32** %2
%33 = call i32 @fclose(i32* %32)
store i32 0, i32* %1
br label %34
34: ; preds = %31, %29, %28, %7
%35 = load i32, i32* %1
ret i32 %35
}

LLVM IR (-O2):
@.str = [13 x i8] c"/proc/mounts\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [16 x i8] c"proc /proc proc\00"
@.str.3 = [10 x i8] c"hidepid=2\00"
@.str.4 = [10 x i8] c"hidepid=1\00"
define i32 @pid_hidepid() {
%1 = alloca [4096 x i8]
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 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 %24, label %4
4: ; preds = %0
%5 = getelementptr inbounds [4096 x i8], [4096 x i8]* %1, i64 0, i64 0
br label %6
6: ; preds = %9, %4
%7 = call i64 @fgets(i8* %5, i32 4096, i32* %2)
%8 = icmp eq i64 %7, 0
br i1 %8, label %20, label %9
9: ; preds = %6
%10 = call i64 @strstr(i8* %5, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %6, label %12
12: ; preds = %9
%13 = call i32 @fclose(i32* %2)
%14 = call i64 @strstr(i8* %5, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %22
16: ; preds = %12
%17 = call i64 @strstr(i8* %5, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%18 = icmp ne i64 %17, 0
%19 = zext i1 %18 to i32
br label %22
20: ; preds = %6
%21 = call i32 @fclose(i32* %2)
br label %22
22: ; preds = %16, %12, %20
%23 = phi i32 [ 0, %20 ], [ 1, %12 ], [ %19, %16 ]
br label %24
24: ; preds = %0, %22
%25 = phi i32 [ %23, %22 ], [ 1, %0 ]
ret i32 %25
}