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

/* Variables and functions */
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ pclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *popen(char *, char *);
int /*<<< orphan*/ strcat(char *, char const *const);
int /*<<< orphan*/ strchr(char *, char);
scalar_t__ strncmp(char *, char *, int);
int detectPresence(char const *const aExecutable) {
  char lBuff[1024];
  char lTestedString[1024] = "which ";
  FILE *lIn;
  strcat(lTestedString, aExecutable);
  strcat(lTestedString, " 2>/dev/null ");
  lIn = popen(lTestedString, "r");
  if ((fgets(lBuff, sizeof(lBuff), lIn) != NULL) && (!strchr(lBuff, ':')) &&
      (strncmp(lBuff, "no ", 3))) {
    pclose(lIn);
    return 1;
  } else {
    pclose(lIn);
    return 0;
  }
}


x86 assembly (clang, -O0):
<detectPresence>:
push   %rbp
mov    %rsp,%rbp
sub    $0x820,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x810(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1060 <memset@plt>
movb   $0x77,-0x810(%rbp)
movb   $0x68,-0x80f(%rbp)
movb   $0x69,-0x80e(%rbp)
movb   $0x63,-0x80d(%rbp)
movb   $0x68,-0x80c(%rbp)
movb   $0x20,-0x80b(%rbp)
lea    -0x810(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1090 <strcat@plt>
lea    -0x810(%rbp),%rdi
lea    0xe26(%rip),%rsi
call   1090 <strcat@plt>
lea    -0x810(%rbp),%rdi
lea    0xe21(%rip),%rsi
call   1080 <popen@plt>
mov    %rax,-0x818(%rbp)
lea    -0x410(%rbp),%rdi
mov    -0x818(%rbp),%rdx
mov    $0x400,%esi
call   1070 <fgets@plt>
cmp    $0x0,%rax
je     126f <detectPresence+0xff>
lea    -0x410(%rbp),%rdi
mov    $0x3a,%esi
call   1040 <strchr@plt>
cmp    $0x0,%eax
jne    126f <detectPresence+0xff>
lea    -0x410(%rbp),%rdi
lea    0xdcd(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     126f <detectPresence+0xff>
mov    -0x818(%rbp),%rdi
call   1050 <pclose@plt>
movl   $0x1,-0x4(%rbp)
jmp    1282 <detectPresence+0x112>
mov    -0x818(%rbp),%rdi
call   1050 <pclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x820,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<detectPresence>:
push   %rbp
push   %rbx
sub    $0x808,%rsp
mov    %rdi,%rbx
mov    %rsp,%rbp
mov    $0x400,%edx
mov    %rbp,%rdi
xor    %esi,%esi
call   1060 <memset@plt>
movl   $0x63696877,(%rsp)
movw   $0x2068,0x4(%rsp)
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1090 <strcat@plt>
lea    0xe52(%rip),%rsi
mov    %rbp,%rdi
call   1090 <strcat@plt>
lea    0xe51(%rip),%rsi
mov    %rbp,%rdi
call   1080 <popen@plt>
mov    %rax,%rbx
lea    0x400(%rsp),%rdi
mov    $0x400,%esi
mov    %rax,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     121b <detectPresence+0xab>
lea    0x400(%rsp),%rdi
mov    $0x3a,%esi
call   1040 <strchr@plt>
test   %eax,%eax
jne    121b <detectPresence+0xab>
lea    0xe11(%rip),%rsi
lea    0x400(%rsp),%rdi
mov    $0x3,%edx
call   1030 <strncmp@plt>
mov    $0x1,%ebp
test   %rax,%rax
jne    121d <detectPresence+0xad>
xor    %ebp,%ebp
mov    %rbx,%rdi
call   1050 <pclose@plt>
mov    %ebp,%eax
add    $0x808,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [14 x i8] c" 2>/dev/null \00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [4 x i8] c"no \00"
define i32 @detectPresence(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [1024 x i8]
%5 = alloca [1024 x i8]
%6 = alloca i32*
store i8* %0, i8** %3
%7 = bitcast [1024 x i8]* %5 to i8*
%8 = bitcast i8* %7 to [1024 x i8]*
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i32 0, i32 0
store i8 119, i8* %9
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i32 0, i32 1
store i8 104, i8* %10
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i32 0, i32 2
store i8 105, i8* %11
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i32 0, i32 3
store i8 99, i8* %12
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i32 0, i32 4
store i8 104, i8* %13
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i32 0, i32 5
store i8 32, i8* %14
%15 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%16 = load i8*, i8** %3
%17 = call i32 @strcat(i8* %15, i8* %16)
%18 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%19 = call i32 @strcat(i8* %18, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%20 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%21 = call i32* @popen(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %21, i32** %6
%22 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%23 = load i32*, i32** %6
%24 = call i32* @fgets(i8* %22, i32 1024, i32* %23)
%25 = icmp ne i32* %24, null
br i1 %25, label %26, label %37
26: ; preds = %1
%27 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%28 = call i32 @strchr(i8* %27, i8 signext 58)
%29 = icmp ne i32 %28, 0
br i1 %29, label %37, label %30
30: ; preds = %26
%31 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%32 = call i64 @strncmp(i8* %31, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 3)
%33 = icmp ne i64 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %30
%35 = load i32*, i32** %6
%36 = call i32 @pclose(i32* %35)
store i32 1, i32* %2
br label %40
37: ; preds = %30, %26, %1
%38 = load i32*, i32** %6
%39 = call i32 @pclose(i32* %38)
store i32 0, i32* %2
br label %40
40: ; preds = %37, %34
%41 = load i32, i32* %2
ret i32 %41
}

LLVM IR (-O2):
@.str = [14 x i8] c" 2>/dev/null \00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [4 x i8] c"no \00"
define i32 @detectPresence(i8* %0) {
%2 = alloca [1024 x i8]
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
store i8 119, i8* %5
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 1
store i8 104, i8* %6
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 2
store i8 105, i8* %7
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 3
store i8 99, i8* %8
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 4
store i8 104, i8* %9
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 5
store i8 32, i8* %10
%11 = call i32 @strcat(i8* %5, i8* %0)
%12 = call i32 @strcat(i8* %5, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%13 = call i32* @popen(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32* @fgets(i8* %4, i32 1024, i32* %13)
%15 = icmp eq i32* %14, null
br i1 %15, label %22, label %16
16: ; preds = %1
%17 = call i32 @strchr(i8* %4, i8 signext 58)
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %16
%20 = call i64 @strncmp(i8* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 3)
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %19, %16, %1
br label %23
23: ; preds = %19, %22
%24 = phi i32 [ 0, %22 ], [ 1, %19 ]
%25 = call i32 @pclose(i32* %13)
ret i32 %24
}