#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 /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ strncmp(char *, char *, int /*<<< orphan*/);
int is_protected(char *dir) {
  size_t i;
  char *protected_mnts[] = {"/sys",
                            "/proc",
                            "/.dev",
                            "/dev",
                            "/dev/pts",
                            "/dev/shm",
                            "dev/.static/dev",
                            "/dev/vcs",
                            "/run",
                            "/var/run",
                            "/",
                            NULL};
  char *any[] = {"/proc/", "/sys/", "/run/", NULL};
  for (i = 0; protected_mnts[i]; i++) {
    if (!strcmp(dir, protected_mnts[i]))
      return 1;
  }
  for (i = 0; any[i]; i++) {
    if (!strncmp(dir, any[i], strlen(any[i])))
      return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<is_protected>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x80(%rbp),%rdi
lea    0x2c46(%rip),%rsi
mov    $0x60,%edx
call   1060 <memcpy@plt>
mov    0x2c95(%rip),%rax
mov    %rax,-0xa0(%rbp)
mov    0x2c8f(%rip),%rax
mov    %rax,-0x98(%rbp)
mov    0x2c89(%rip),%rax
mov    %rax,-0x90(%rbp)
mov    0x2c83(%rip),%rax
mov    %rax,-0x88(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpq   $0x0,-0x80(%rbp,%rax,8)
je     11f1 <is_protected+0xb1>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    -0x80(%rbp,%rax,8),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    11db <is_protected+0x9b>
movl   $0x1,-0x4(%rbp)
jmp    1282 <is_protected+0x142>
jmp    11e0 <is_protected+0xa0>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    11a4 <is_protected+0x64>
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpq   $0x0,-0xa0(%rbp,%rax,8)
je     127b <is_protected+0x13b>
mov    -0x10(%rbp),%rax
mov    %rax,-0xb0(%rbp)
mov    -0x18(%rbp),%rax
mov    -0xa0(%rbp,%rax,8),%rax
ff
mov    %rax,-0xa8(%rbp)
mov    -0x18(%rbp),%rax
mov    -0xa0(%rbp,%rax,8),%rdi
ff
call   1040 <strlen@plt>
mov    -0xb0(%rbp),%rdi
mov    -0xa8(%rbp),%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1265 <is_protected+0x125>
movl   $0x1,-0x4(%rbp)
jmp    1282 <is_protected+0x142>
jmp    126a <is_protected+0x12a>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    11f9 <is_protected+0xb9>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_protected>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
lea    0xec2(%rip),%rsi
call   1050 <strcmp@plt>
mov    $0x1,%ebp
test   %eax,%eax
je     1292 <is_protected+0x162>
lea    0xeae(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     1292 <is_protected+0x162>
lea    0xe9d(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     1292 <is_protected+0x162>
lea    0xea9(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     1292 <is_protected+0x162>
lea    0xe75(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     1292 <is_protected+0x162>
lea    0xe67(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     1292 <is_protected+0x162>
lea    0xe59(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     1292 <is_protected+0x162>
lea    0xe52(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     1292 <is_protected+0x162>
lea    0xe48(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     1292 <is_protected+0x162>
lea    0xe2d(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     1292 <is_protected+0x162>
lea    0xe28(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     1292 <is_protected+0x162>
lea    0xe10(%rip),%r14
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     1292 <is_protected+0x162>
lea    0xdf7(%rip),%r14
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     1292 <is_protected+0x162>
lea    0xddd(%rip),%rbp
mov    %rbp,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
xor    %ebp,%ebp
test   %eax,%eax
sete   %bpl
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"/sys\00"
@.str.1 = [6 x i8] c"/proc\00"
@.str.2 = [6 x i8] c"/.dev\00"
@.str.3 = [5 x i8] c"/dev\00"
@.str.4 = [9 x i8] c"/dev/pts\00"
@.str.5 = [9 x i8] c"/dev/shm\00"
@.str.6 = [16 x i8] c"dev/.static/dev\00"
@.str.7 = [9 x i8] c"/dev/vcs\00"
@.str.8 = [5 x i8] c"/run\00"
@.str.9 = [9 x i8] c"/var/run\00"
@.str.10 = [2 x i8] c"/\00"
@__const.is_protected.protected_mnts = [12 x i8*] [i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i32 0, i32 0), i8* null]
@.str.11 = [7 x i8] c"/proc/\00"
@.str.12 = [6 x i8] c"/sys/\00"
@.str.13 = [6 x i8] c"/run/\00"
@__const.is_protected.any = [4 x i8*] [i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.13, i32 0, i32 0), i8* null]
define i32 @is_protected(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i64
%5 = alloca [12 x i8*]
%6 = alloca [4 x i8*]
store i8* %0, i8** %3
%7 = bitcast [12 x i8*]* %5 to i8*
%8 = bitcast [4 x i8*]* %6 to i8*
store i64 0, i64* %4
br label %9
9: ; preds = %23, %1
%10 = load i64, i64* %4
%11 = getelementptr inbounds [12 x i8*], [12 x i8*]* %5, i64 0, i64 %10
%12 = load i8*, i8** %11
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %26
14: ; preds = %9
%15 = load i8*, i8** %3
%16 = load i64, i64* %4
%17 = getelementptr inbounds [12 x i8*], [12 x i8*]* %5, i64 0, i64 %16
%18 = load i8*, i8** %17
%19 = call i32 @strcmp(i8* %15, i8* %18)
%20 = icmp ne i32 %19, 0
br i1 %20, label %22, label %21
21: ; preds = %14
store i32 1, i32* %2
br label %49
22: ; preds = %14
br label %23
23: ; preds = %22
%24 = load i64, i64* %4
%25 = add i64 %24, 1
store i64 %25, i64* %4
br label %9
26: ; preds = %9
store i64 0, i64* %4
br label %27
27: ; preds = %45, %26
%28 = load i64, i64* %4
%29 = getelementptr inbounds [4 x i8*], [4 x i8*]* %6, i64 0, i64 %28
%30 = load i8*, i8** %29
%31 = icmp ne i8* %30, null
br i1 %31, label %32, label %48
32: ; preds = %27
%33 = load i8*, i8** %3
%34 = load i64, i64* %4
%35 = getelementptr inbounds [4 x i8*], [4 x i8*]* %6, i64 0, i64 %34
%36 = load i8*, i8** %35
%37 = load i64, i64* %4
%38 = getelementptr inbounds [4 x i8*], [4 x i8*]* %6, i64 0, i64 %37
%39 = load i8*, i8** %38
%40 = call i32 @strlen(i8* %39)
%41 = call i32 @strncmp(i8* %33, i8* %36, i32 %40)
%42 = icmp ne i32 %41, 0
br i1 %42, label %44, label %43
43: ; preds = %32
store i32 1, i32* %2
br label %49
44: ; preds = %32
br label %45
45: ; preds = %44
%46 = load i64, i64* %4
%47 = add i64 %46, 1
store i64 %47, i64* %4
br label %27
48: ; preds = %27
store i32 0, i32* %2
br label %49
49: ; preds = %48, %43, %21
%50 = load i32, i32* %2
ret i32 %50
}

LLVM IR (-O2):
@.str = [5 x i8] c"/sys\00"
@.str.1 = [6 x i8] c"/proc\00"
@.str.2 = [6 x i8] c"/.dev\00"
@.str.3 = [5 x i8] c"/dev\00"
@.str.4 = [9 x i8] c"/dev/pts\00"
@.str.5 = [9 x i8] c"/dev/shm\00"
@.str.6 = [16 x i8] c"dev/.static/dev\00"
@.str.7 = [9 x i8] c"/dev/vcs\00"
@.str.8 = [5 x i8] c"/run\00"
@.str.9 = [9 x i8] c"/var/run\00"
@.str.10 = [2 x i8] c"/\00"
@.str.11 = [7 x i8] c"/proc/\00"
@.str.12 = [6 x i8] c"/sys/\00"
@.str.13 = [6 x i8] c"/run/\00"
define i32 @is_protected(i8* %0) {
%2 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32 %2, 0
br i1 %3, label %47, label %4
4: ; preds = %1
%5 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i32 %5, 0
br i1 %6, label %47, label %7
7: ; preds = %4
%8 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%9 = icmp eq i32 %8, 0
br i1 %9, label %47, label %10
10: ; preds = %7
%11 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%12 = icmp eq i32 %11, 0
br i1 %12, label %47, label %13
13: ; preds = %10
%14 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(9) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%15 = icmp eq i32 %14, 0
br i1 %15, label %47, label %16
16: ; preds = %13
%17 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(9) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%18 = icmp eq i32 %17, 0
br i1 %18, label %47, label %19
19: ; preds = %16
%20 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(16) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0))
%21 = icmp eq i32 %20, 0
br i1 %21, label %47, label %22
22: ; preds = %19
%23 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(9) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%24 = icmp eq i32 %23, 0
br i1 %24, label %47, label %25
25: ; preds = %22
%26 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%27 = icmp eq i32 %26, 0
br i1 %27, label %47, label %28
28: ; preds = %25
%29 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(9) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0))
%30 = icmp eq i32 %29, 0
br i1 %30, label %47, label %31
31: ; preds = %28
%32 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
%33 = icmp eq i32 %32, 0
br i1 %33, label %47, label %34
34: ; preds = %31
%35 = tail call i32 @strlen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0))
%36 = tail call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0), i32 %35)
%37 = icmp eq i32 %36, 0
br i1 %37, label %47, label %38
38: ; preds = %34
%39 = tail call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0))
%40 = tail call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0), i32 %39)
%41 = icmp eq i32 %40, 0
br i1 %41, label %47, label %42
42: ; preds = %38
%43 = tail call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.13, i64 0, i64 0))
%44 = tail call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.13, i64 0, i64 0), i32 %43)
%45 = icmp eq i32 %44, 0
%46 = zext i1 %45 to i32
br label %47
47: ; preds = %42, %1, %4, %7, %10, %13, %16, %19, %22, %25, %28, %31, %34, %38
%48 = phi i32 [ 1, %34 ], [ 1, %38 ], [ 1, %31 ], [ 1, %28 ], [ 1, %25 ], [ 1, %22 ], [ 1, %19 ], [ 1, %16 ], [ 1, %13 ], [ 1, %10 ], [ 1, %7 ], [ 1, %4 ], [ 1, %1 ], [ %46, %42 ]
ret i32 %48
}