#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);
  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   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     125c <detectPresence+0xec>
lea    -0x410(%rbp),%rdi
mov    $0x3a,%esi
call   1040 <strchr@plt>
cmp    $0x0,%eax
jne    125c <detectPresence+0xec>
lea    -0x410(%rbp),%rdi
lea    0xdd2(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     125c <detectPresence+0xec>
mov    -0x818(%rbp),%rdi
call   1050 <pclose@plt>
movl   $0x1,-0x4(%rbp)
jmp    126f <detectPresence+0xff>
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   1080 <popen@plt>
mov    %rax,%rbx
lea    0x400(%rsp),%rdi
mov    $0x400,%esi
mov    %rax,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     120c <detectPresence+0x9c>
lea    0x400(%rsp),%rdi
mov    $0x3a,%esi
call   1040 <strchr@plt>
test   %eax,%eax
jne    120c <detectPresence+0x9c>
lea    0xe12(%rip),%rsi
lea    0x400(%rsp),%rdi
mov    $0x3,%edx
call   1030 <strncmp@plt>
mov    $0x1,%ebp
test   %rax,%rax
jne    120e <detectPresence+0x9e>
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 = [2 x i8] c"r\00"
@.str.1 = [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* @popen(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %19, i32** %6
%20 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%21 = load i32*, i32** %6
%22 = call i32* @fgets(i8* %20, i32 1024, i32* %21)
%23 = icmp ne i32* %22, null
br i1 %23, label %24, label %35
24: ; preds = %1
%25 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%26 = call i32 @strchr(i8* %25, i8 signext 58)
%27 = icmp ne i32 %26, 0
br i1 %27, label %35, label %28
28: ; preds = %24
%29 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%30 = call i64 @strncmp(i8* %29, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 3)
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %28
%33 = load i32*, i32** %6
%34 = call i32 @pclose(i32* %33)
store i32 1, i32* %2
br label %38
35: ; preds = %28, %24, %1
%36 = load i32*, i32** %6
%37 = call i32 @pclose(i32* %36)
store i32 0, i32* %2
br label %38
38: ; preds = %35, %32
%39 = load i32, i32* %2
ret i32 %39
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [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* @popen(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%13 = call i32* @fgets(i8* %4, i32 1024, i32* %12)
%14 = icmp eq i32* %13, null
br i1 %14, label %21, label %15
15: ; preds = %1
%16 = call i32 @strchr(i8* %4, i8 signext 58)
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %15
%19 = call i64 @strncmp(i8* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 3)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %18, %15, %1
br label %22
22: ; preds = %18, %21
%23 = phi i32 [ 0, %21 ], [ 1, %18 ]
%24 = call i32 @pclose(i32* %12)
ret i32 %23
}