#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 */
char *getenv(char *);
scalar_t__ strcmp(char *, char const *);
int /*<<< orphan*/ *strstr(char const *, char *);
int isfakechroot() {
  const char *fakechroot, *ldpreload;
  return ((fakechroot = getenv("FAKECHROOT")) &&
          (strcmp("true", fakechroot) == 0) &&
          (NULL != getenv("FAKECHROOT_BASE")) &&
          (ldpreload = getenv("LD_PRELOAD")) &&
          (NULL != strstr(ldpreload, "libfakechroot.so")));
}


x86 assembly (clang, -O0):
<isfakechroot>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xec1(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rcx
mov    %rcx,-0x8(%rbp)
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x11(%rbp)
je     11db <isfakechroot+0xab>
mov    -0x8(%rbp),%rsi
lea    0xea6(%rip),%rdi
call   1040 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x11(%rbp)
jne    11db <isfakechroot+0xab>
lea    0xe8d(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rdx
xor    %eax,%eax
xor    %ecx,%ecx
cmp    %rdx,%rcx
mov    %al,-0x11(%rbp)
je     11db <isfakechroot+0xab>
lea    0xe7e(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rcx
mov    %rcx,-0x10(%rbp)
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x11(%rbp)
je     11db <isfakechroot+0xab>
mov    -0x10(%rbp),%rdi
lea    0xe63(%rip),%rsi
call   1050 <strstr@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isfakechroot>:
push   %rbx
lea    0xec8(%rip),%rdi
call   1030 <getenv@plt>
xor    %ebx,%ebx
test   %rax,%rax
je     1191 <isfakechroot+0x61>
lea    0xec0(%rip),%rdi
mov    %rax,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    1191 <isfakechroot+0x61>
lea    0xeb1(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     1191 <isfakechroot+0x61>
lea    0xeb0(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     1191 <isfakechroot+0x61>
lea    0xeaa(%rip),%rsi
mov    %rax,%rdi
call   1050 <strstr@plt>
xor    %ebx,%ebx
test   %rax,%rax
setne  %bl
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [11 x i8] c"FAKECHROOT\00"
@.str.1 = [5 x i8] c"true\00"
@.str.2 = [16 x i8] c"FAKECHROOT_BASE\00"
@.str.3 = [11 x i8] c"LD_PRELOAD\00"
@.str.4 = [17 x i8] c"libfakechroot.so\00"
define i32 @isfakechroot() {
%1 = alloca i8*
%2 = alloca i8*
%3 = call i8* @getenv(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
store i8* %3, i8** %1
%4 = icmp ne i8* %3, null
br i1 %4, label %5, label %19
5: ; preds = %0
%6 = load i8*, i8** %1
%7 = call i64 @strcmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %19
9: ; preds = %5
%10 = call i8* @getenv(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%11 = icmp ne i8* null, %10
br i1 %11, label %12, label %19
12: ; preds = %9
%13 = call i8* @getenv(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
store i8* %13, i8** %2
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %19
15: ; preds = %12
%16 = load i8*, i8** %2
%17 = call i32* @strstr(i8* %16, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
%18 = icmp ne i32* null, %17
br label %19
19: ; preds = %15, %12, %9, %5, %0
%20 = phi i1 [ false, %12 ], [ false, %9 ], [ false, %5 ], [ false, %0 ], [ %18, %15 ]
%21 = zext i1 %20 to i32
ret i32 %21
}

LLVM IR (-O2):
@.str = [11 x i8] c"FAKECHROOT\00"
@.str.1 = [5 x i8] c"true\00"
@.str.2 = [16 x i8] c"FAKECHROOT_BASE\00"
@.str.3 = [11 x i8] c"LD_PRELOAD\00"
@.str.4 = [17 x i8] c"libfakechroot.so\00"
define i32 @isfakechroot() {
%1 = tail call i8* @getenv(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%2 = icmp eq i8* %1, null
br i1 %2, label %16, label %3
3: ; preds = %0
%4 = tail call i64 @strcmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %16
6: ; preds = %3
%7 = tail call i8* @getenv(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%8 = icmp eq i8* %7, null
br i1 %8, label %16, label %9
9: ; preds = %6
%10 = tail call i8* @getenv(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%11 = icmp eq i8* %10, null
br i1 %11, label %16, label %12
12: ; preds = %9
%13 = tail call i32* @strstr(i8* %10, i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
%14 = icmp ne i32* %13, null
%15 = zext i1 %14 to i32
br label %16
16: ; preds = %12, %9, %6, %3, %0
%17 = phi i32 [ 0, %9 ], [ 0, %6 ], [ 0, %3 ], [ 0, %0 ], [ %15, %12 ]
ret i32 %17
}