#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 */
scalar_t__ detectPresence(char *);
scalar_t__ isDarwin();
scalar_t__ isTerminalRunning();
scalar_t__ strcpy(char *, char *);
scalar_t__ strlen(char *);
scalar_t__ terminalName();
char const *dialogName() {
  static char lDialogName[64] = "*";
  if (lDialogName[0] == '*') {
    if (isDarwin() && strcpy(lDialogName, "/opt/local/bin/dialog") &&
        detectPresence(lDialogName)) {
    } else if (strcpy(lDialogName, "dialog") && detectPresence(lDialogName)) {
    } else {
      strcpy(lDialogName, "");
    }
  }
  if (strlen(lDialogName) && (isTerminalRunning() || terminalName())) {
    return lDialogName;
  } else {
    return NULL;
  }
}


x86 assembly (clang, -O0):
<dialogName>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movsbl 0x2ef1(%rip),%eax
cmp    $0x2a,%eax
jne    1216 <dialogName+0xb6>
mov    $0x0,%al
call   1060 <isDarwin@plt>
cmp    $0x0,%rax
je     11c1 <dialogName+0x61>
lea    0x2ed0(%rip),%rdi
lea    0xe69(%rip),%rsi
call   1030 <strcpy@plt>
cmp    $0x0,%rax
je     11c1 <dialogName+0x61>
lea    0x2eb3(%rip),%rdi
call   1070 <detectPresence@plt>
cmp    $0x0,%rax
je     11c1 <dialogName+0x61>
jmp    1211 <dialogName+0xb1>
lea    0x2e98(%rip),%rdi
lea    0xe40(%rip),%rsi
call   1030 <strcpy@plt>
cmp    $0x0,%rax
je     11f9 <dialogName+0x99>
lea    0x2e7b(%rip),%rdi
call   1070 <detectPresence@plt>
cmp    $0x0,%rax
je     11f9 <dialogName+0x99>
jmp    120c <dialogName+0xac>
lea    0x2e60(%rip),%rdi
lea    0xe0e(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1211 <dialogName+0xb1>
jmp    1216 <dialogName+0xb6>
lea    0x2e43(%rip),%rdi
call   1050 <strlen@plt>
cmp    $0x0,%rax
je     125e <dialogName+0xfe>
mov    $0x0,%al
call   1040 <isTerminalRunning@plt>
cmp    $0x0,%rax
jne    124e <dialogName+0xee>
mov    $0x0,%al
call   1080 <terminalName@plt>
cmp    $0x0,%rax
je     125e <dialogName+0xfe>
lea    0x2e0b(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1266 <dialogName+0x106>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dialogName>:
push   %rbx
mov    0x2ef9(%rip),%al
cmp    $0x2a,%al
jne    11d2 <dialogName+0x82>
xor    %eax,%eax
call   1050 <isDarwin@plt>
test   %rax,%rax
je     1190 <dialogName+0x40>
lea    0x2ee2(%rip),%rdi
lea    0xe8b(%rip),%rsi
call   1030 <strcpy@plt>
test   %rax,%rax
je     1190 <dialogName+0x40>
lea    0x2eca(%rip),%rdi
call   1060 <detectPresence@plt>
test   %rax,%rax
jne    11cc <dialogName+0x7c>
lea    0x2eb9(%rip),%rdi
lea    0xe71(%rip),%rsi
call   1030 <strcpy@plt>
test   %rax,%rax
je     11b9 <dialogName+0x69>
lea    0x2ea1(%rip),%rdi
call   1060 <detectPresence@plt>
test   %rax,%rax
jne    11cc <dialogName+0x7c>
lea    0x2e90(%rip),%rdi
lea    0xe4e(%rip),%rsi
call   1030 <strcpy@plt>
mov    0x2e7e(%rip),%al
test   %al,%al
je     11f5 <dialogName+0xa5>
xor    %eax,%eax
call   1040 <isTerminalRunning@plt>
lea    0x2e6c(%rip),%rbx
test   %rax,%rax
jne    11f7 <dialogName+0xa7>
xor    %eax,%eax
call   1070 <terminalName@plt>
test   %rax,%rax
jne    11f7 <dialogName+0xa7>
xor    %ebx,%ebx
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@dialogName.lDialogName = internal global [64 x i8] c"*\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [22 x i8] c"/opt/local/bin/dialog\00"
@.str.1 = [7 x i8] c"dialog\00"
@.str.2 = [1 x i8] zeroinitializer
define i8* @dialogName() {
%1 = alloca i8*
%2 = load i8, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @dialogName.lDialogName, i64 0, i64 0)
%3 = sext i8 %2 to i32
%4 = icmp eq i32 %3, 42
br i1 %4, label %5, label %26
5: ; preds = %0
%6 = call i64 (...) @isDarwin()
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %15
8: ; preds = %5
%9 = call i64 @strcpy(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @dialogName.lDialogName, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %8
%12 = call i64 @detectPresence(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @dialogName.lDialogName, i64 0, i64 0))
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %11
br label %25
15: ; preds = %11, %8, %5
%16 = call i64 @strcpy(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @dialogName.lDialogName, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %22
18: ; preds = %15
%19 = call i64 @detectPresence(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @dialogName.lDialogName, i64 0, i64 0))
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %18
br label %24
22: ; preds = %18, %15
%23 = call i64 @strcpy(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @dialogName.lDialogName, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
br label %24
24: ; preds = %22, %21
br label %25
25: ; preds = %24, %14
br label %26
26: ; preds = %25, %0
%27 = call i64 @strlen(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @dialogName.lDialogName, i64 0, i64 0))
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %36
29: ; preds = %26
%30 = call i64 (...) @isTerminalRunning()
%31 = icmp ne i64 %30, 0
br i1 %31, label %35, label %32
32: ; preds = %29
%33 = call i64 (...) @terminalName()
%34 = icmp ne i64 %33, 0
br i1 %34, label %35, label %36
35: ; preds = %32, %29
store i8* getelementptr inbounds ([64 x i8], [64 x i8]* @dialogName.lDialogName, i64 0, i64 0), i8** %1
br label %37
36: ; preds = %32, %26
store i8* null, i8** %1
br label %37
37: ; preds = %36, %35
%38 = load i8*, i8** %1
ret i8* %38
}

LLVM IR (-O2):
@dialogName.lDialogName = internal global [64 x i8] c"*\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [22 x i8] c"/opt/local/bin/dialog\00"
@.str.1 = [7 x i8] c"dialog\00"
@.str.2 = [1 x i8] zeroinitializer
define i8* @dialogName() {
%1 = load i8, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @dialogName.lDialogName, i64 0, i64 0)
%2 = icmp eq i8 %1, 42
br i1 %2, label %3, label %22
3: ; preds = %0
%4 = tail call i64 (...) @isDarwin()
%5 = icmp eq i64 %4, 0
br i1 %5, label %12, label %6
6: ; preds = %3
%7 = tail call i64 @strcpy(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @dialogName.lDialogName, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %6
%10 = tail call i64 @detectPresence(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @dialogName.lDialogName, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %20
12: ; preds = %9, %6, %3
%13 = tail call i64 @strcpy(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @dialogName.lDialogName, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %18, label %15
15: ; preds = %12
%16 = tail call i64 @detectPresence(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @dialogName.lDialogName, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %15, %12
%19 = tail call i64 @strcpy(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @dialogName.lDialogName, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
br label %20
20: ; preds = %18, %15, %9
%21 = load i8, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @dialogName.lDialogName, i64 0, i64 0)
br label %22
22: ; preds = %20, %0
%23 = phi i8 [ %21, %20 ], [ %1, %0 ]
%24 = icmp eq i8 %23, 0
br i1 %24, label %31, label %25
25: ; preds = %22
%26 = tail call i64 (...) @isTerminalRunning()
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %32
28: ; preds = %25
%29 = tail call i64 (...) @terminalName()
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %28, %22
br label %32
32: ; preds = %25, %28, %31
%33 = phi i8* [ null, %31 ], [ getelementptr inbounds ([64 x i8], [64 x i8]* @dialogName.lDialogName, i64 0, i64 0), %28 ], [ getelementptr inbounds ([64 x i8], [64 x i8]* @dialogName.lDialogName, i64 0, i64 0), %25 ]
ret i8* %33
}