#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 detectPresence(char *);
int /*<<< orphan*/ getenv(char *);
scalar_t__ graphicMode();
int osascriptPresent() {
  static int lOsascriptPresent = -1;
  if (lOsascriptPresent < 0) {
    lOsascriptPresent = detectPresence("osascript");
  }
  return lOsascriptPresent && graphicMode() && !getenv("SSH_TTY");
}


x86 assembly (clang, -O0):
<osascriptPresent>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
cmpl   $0x0,0x2ef9(%rip)
jge    1157 <osascriptPresent+0x27>
lea    0xeb4(%rip),%rdi
call   1050 <detectPresence@plt>
mov    %eax,0x2ee1(%rip)
xor    %eax,%eax
cmpl   $0x0,0x2ed8(%rip)
mov    %al,-0x1(%rbp)
je     1199 <osascriptPresent+0x69>
mov    $0x0,%al
call   1040 <graphicMode@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x1(%rbp)
je     1199 <osascriptPresent+0x69>
lea    0xe81(%rip),%rdi
call   1030 <getenv@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
mov    %al,-0x1(%rbp)
mov    -0x1(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<osascriptPresent>:
push   %rbx
mov    0x2f01(%rip),%eax
test   %eax,%eax
jns    114d <osascriptPresent+0x1d>
lea    0xebe(%rip),%rdi
call   1050 <detectPresence@plt>
mov    %eax,0x2eeb(%rip)
xor    %ebx,%ebx
test   %eax,%eax
je     1172 <osascriptPresent+0x42>
xor    %eax,%eax
call   1040 <graphicMode@plt>
test   %rax,%rax
je     1172 <osascriptPresent+0x42>
lea    0xea4(%rip),%rdi
call   1030 <getenv@plt>
xor    %ebx,%ebx
test   %eax,%eax
sete   %bl
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@osascriptPresent.lOsascriptPresent = internal global i32 -1
@.str = [10 x i8] c"osascript\00"
@.str.1 = [8 x i8] c"SSH_TTY\00"
define i32 @osascriptPresent() {
%1 = load i32, i32* @osascriptPresent.lOsascriptPresent
%2 = icmp slt i32 %1, 0
br i1 %2, label %3, label %5
3: ; preds = %0
%4 = call i32 @detectPresence(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
store i32 %4, i32* @osascriptPresent.lOsascriptPresent
br label %5
5: ; preds = %3, %0
%6 = load i32, i32* @osascriptPresent.lOsascriptPresent
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %15
8: ; preds = %5
%9 = call i64 (...) @graphicMode()
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %8
%12 = call i32 @getenv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp ne i32 %12, 0
%14 = xor i1 %13, true
br label %15
15: ; preds = %11, %8, %5
%16 = phi i1 [ false, %8 ], [ false, %5 ], [ %14, %11 ]
%17 = zext i1 %16 to i32
ret i32 %17
}

LLVM IR (-O2):
@osascriptPresent.lOsascriptPresent = internal unnamed_addr global i32 -1
@.str = [10 x i8] c"osascript\00"
@.str.1 = [8 x i8] c"SSH_TTY\00"
define i32 @osascriptPresent() {
%1 = load i32, i32* @osascriptPresent.lOsascriptPresent
%2 = icmp slt i32 %1, 0
br i1 %2, label %3, label %5
3: ; preds = %0
%4 = tail call i32 @detectPresence(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
store i32 %4, i32* @osascriptPresent.lOsascriptPresent
br label %5
5: ; preds = %3, %0
%6 = phi i32 [ %4, %3 ], [ %1, %0 ]
%7 = icmp eq i32 %6, 0
br i1 %7, label %15, label %8
8: ; preds = %5
%9 = tail call i64 (...) @graphicMode()
%10 = icmp eq i64 %9, 0
br i1 %10, label %15, label %11
11: ; preds = %8
%12 = tail call i32 @getenv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i32 %12, 0
%14 = zext i1 %13 to i32
br label %15
15: ; preds = %11, %8, %5
%16 = phi i32 [ 0, %8 ], [ 0, %5 ], [ %14, %11 ]
ret i32 %16
}